Add RM_ReplyWithBigNumber module API#9639
Conversation
oranagra
left a comment
There was a problem hiding this comment.
@redis/core-team please approve
|
fyi, I was confused by how it compiled / ran as well, but I was just mirroring the existing test code. |
|
once I update PR, tests should be good to go, as had to fix a bunch of things to get them to work now which indicates that they are being used correctly. |
|
note that while the reply module tests are now running, I had to comment out 2 of them, to get them to work for now. I'll remove that to get this PR to fail after I see it passing |
|
On Mon, Oct 18, 2021, 8:40 PM Yossi Gottlieb ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/module.c
<#9639 (comment)>:
> + * It does not appear that any verification is done on this string to ensure
+ * it is a valid BigNumber. should it?
@sjpotter <https://github.com/sjpotter> This comment is used to
auto-generate API documentation, so it can't be left in this state.
The comment is for reviewers, for feedback in a possible issue. I'm not
sure it is, just wanted it to be pointed out clearly.
I could update it I guess to be fair for documentation and reviewers such
as "it's up to the caller to ensure that the string being passed in is a
valid BigNumber". Perhaps that ticks both boxes.
… |
the map test fails because it expects doubles (with the attribute test actually expects the error in RESP2, but it puts the please fix these. |
|
so the map test was easy to fix, having trouble with the attribute test. I've tried to simplify it to but it still fails on the catch in the proto == 2 run. when I comment out the proto == 2 run, it blocks forever. |
|
i don't understand what failure you're getting. the code looks correct. maybe post the exact error? i also don't understand why it blocks forever, IIUC you're running the resp3 branch of the test code with p.s. you can use |
|
ohh wait, i think your |
|
yes, already figured out the curley bracket thing. still hangs though. I was wondering if it was because of an odd number of elements in rw_attribute() (i.e. its a map in practice), the function didn't line up with the expected response as it is) so I fixed that, but still hangs. i.e. this I believe is wrong for multiple reasons, the not being a map and the OK return. However, fixing those things, doesn't cause it not to hang. but I am missing understanding of what attribute types are supposed to be. It seems to be addon data to normal requests, but that doesn't make sense as its own command/response then? |
|
current test tcl code is |
|
perhaps because of the redis support code |
|
yes, changing it to means no more hanging |
|
I have no idea why non module tests are failing. As there's no modificatoin to any code outside of module tcl tests and test module code. |
|
ok, figured it out my change for the attribute output, needs to go all rawread |
|
failing a defrag test, dont know why (perhaps only happened locally, and not in github checks) |
oranagra
left a comment
There was a problem hiding this comment.
LGTM, what's left is to handle the doc comments:
#9639 (comment)
oranagra
left a comment
There was a problem hiding this comment.
LGTM, with minor typos (assuming by English is any good)
Co-authored-by: Yossi Gottlieb <[email protected]>
but a problem that 2 of the unit tests are broken, and I haven't yet been able to figure out how to make them run
Co-authored-by: sundb <[email protected]>
fix map test fix attribute test (+ fix module code) fix attribute reading in redis tcl support code
I think this is what is wanted?
Co-authored-by: sundb <[email protected]>
The module test in reply.tcl was introduced by #8521 but didn't run until recently (see #9639) and then it started failing with valgrind. This is because valgrind uses 64 bit long double (unlike most other platforms that have at least 80 bits) But besides valgrind, the tests where also incompatible with ARM32, which also uses 64 bit long doubles. We now use appropriate value to avoid issues with either valgrind or ARM32 In all the double tests, i use 3.141, which is safe since since addReplyDouble uses `%.17Lg` which is able to represent this value without adding any digits due to precision loss. In the long double, since we use `%.17Lf` in ld2string, it preserves 17 significant digits, rather than 17 digit after the decimal point (like in `%.17Lg`). So to make these similar, i use value lower than 1 (no digits left of the period) Lastly, we have the same issue with TCL (no long doubles) so we read raw protocol in that test. Note that the only error before this fix (in both valgrind and ARM32 is this: ``` *** [err]: RM_ReplyWithLongDouble: a float reply in tests/unit/moduleapi/reply.tcl Expected '3.141' to be equal to '3.14100000000000001' (context: type eval line 2 cmd {assert_equal 3.141 [r rw.longdouble 3.141]} proc ::test) ``` so the changes to debug.c and scripting.tcl aren't really needed, but i consider them a cleanup (i.e. scripting.c validated a different constant than the one that's sent to it from debug.c). Another unrelated change is to add the RESP version to the repeated tests in reply.tcl
Let modules use additional type of RESP3 response (unused by redis so far)
Also fix tests that where introduced in #8521 but didn't actually run.