dice icon indicating copy to clipboard operation
dice copied to clipboard

FIX: Inconsistent EXPIRE with conflicting options: LT GT

Open harshrai654 opened this issue 1 year ago • 4 comments

Fixes #506

Test run logs:

❯ TEST_FUNC=TestExpire make test-one
go test -v -count=1 --run TestExpire ./tests/...
2024/09/11 01:09:57 INFO DiceDB running on port 8739
Starting the test server on port 8739
=== RUN   TestExpire
=== RUN   TestExpire/Set_with_EXPIRE_command
=== RUN   TestExpire/Check_if_key_is_nil_after_expiration
=== RUN   TestExpire/EXPIRE_non-existent_key
=== RUN   TestExpire/EXPIRE_with_past_time
=== RUN   TestExpire/EXPIRE_with_invalid_syntax
=== RUN   TestExpire/Test(NX):_Set_the_expiration_only_if_the_key_has_no_expiration_time
=== RUN   TestExpire/Test(XX):_Set_the_expiration_only_if_the_key_already_has_an_expiration_time
=== RUN   TestExpire/TEST(GT):_Set_the_expiration_only_if_the_new_expiration_time_is_greater_than_the_current_one
=== RUN   TestExpire/TEST(LT):_Set_the_expiration_only_if_the_new_expiration_time_is_less_than_the_current_one
=== RUN   TestExpire/TEST(LT):_Set_the_expiration_only_if_the_new_expiration_time_is_less_than_the_current_one#01
=== RUN   TestExpire/TEST(NX_+_LT/GT)
=== RUN   TestExpire/TEST(XX_+_LT/GT)
=== RUN   TestExpire/Test_if_value_is_nil_after_expiration
=== RUN   TestExpire/Test_if_value_is_nil_after_expiration#01
=== RUN   TestExpire/Invalid_Command_Test
--- PASS: TestExpire (5.12s)

TCL tests log: tcl-output.log

harshrai654 avatar Sep 10 '24 19:09 harshrai654

Overall, the changes look good. However, the same helper function evaluateAndSetExpiry is also being used by the EXPIREAT command. Can you please update the test cases for that command as well?

jainam2907 avatar Sep 10 '24 23:09 jainam2907

Got it, will update the PR with changes.

harshrai654 avatar Sep 11 '24 04:09 harshrai654

@jainam2907 I have updated the test case of invalid commands for EXPIREAT command. Test run output:

❯ TEST_FUNC=TestExpireat make test-one
go test -v -count=1 --run TestExpireat ./tests/...
2024/09/11 15:41:15 INFO DiceDB running on port 8739
Starting the test server on port 8739
=== RUN   TestExpireat
=== RUN   TestExpireat/Set_with_EXPIREAT_command
=== RUN   TestExpireat/Check_if_key_is_nil_after_expiration
=== RUN   TestExpireat/EXPIREAT_non-existent_key
=== RUN   TestExpireat/EXPIREAT_with_past_time
=== RUN   TestExpireat/EXPIREAT_with_invalid_syntax
=== RUN   TestExpireat/Test(NX):_Set_the_expiration_only_if_the_key_has_no_expiration_time
=== RUN   TestExpireat/Test(XX):_Set_the_expiration_only_if_the_key_already_has_an_expiration_time
=== RUN   TestExpireat/TEST(GT):_Set_the_expiration_only_if_the_new_expiration_time_is_greater_than_the_current_one
=== RUN   TestExpireat/TEST(LT):_Set_the_expiration_only_if_the_new_expiration_time_is_less_than_the_current_one
=== RUN   TestExpireat/TEST(LT):_Set_the_expiration_only_if_the_new_expiration_time_is_less_than_the_current_one#01
=== RUN   TestExpireat/TEST(NX_+_LT/GT)
=== RUN   TestExpireat/TEST(XX_+_LT/GT)
=== RUN   TestExpireat/Test_if_value_is_nil_after_expiration
=== RUN   TestExpireat/Test_if_value_is_nil_after_expiration#01
=== RUN   TestExpireat/Invalid_Command_Test
--- PASS: TestExpireat (5.14s)
    --- PASS: TestExpireat/Set_with_EXPIREAT_command (0.00s)
    --- PASS: TestExpireat/Check_if_key_is_nil_after_expiration (1.10s)
    --- PASS: TestExpireat/EXPIREAT_non-existent_key (0.00s)
    --- PASS: TestExpireat/EXPIREAT_with_past_time (0.00s)
    --- PASS: TestExpireat/EXPIREAT_with_invalid_syntax (0.00s)
    --- PASS: TestExpireat/Test(NX):_Set_the_expiration_only_if_the_key_has_no_expiration_time (0.00s)
    --- PASS: TestExpireat/Test(XX):_Set_the_expiration_only_if_the_key_already_has_an_expiration_time (0.00s)
    --- PASS: TestExpireat/TEST(GT):_Set_the_expiration_only_if_the_new_expiration_time_is_greater_than_the_current_one (0.00s)
    --- PASS: TestExpireat/TEST(LT):_Set_the_expiration_only_if_the_new_expiration_time_is_less_than_the_current_one (0.00s)
    --- PASS: TestExpireat/TEST(LT):_Set_the_expiration_only_if_the_new_expiration_time_is_less_than_the_current_one#01 (0.00s)
    --- PASS: TestExpireat/TEST(NX_+_LT/GT) (0.00s)
    --- PASS: TestExpireat/TEST(XX_+_LT/GT) (0.00s)
    --- PASS: TestExpireat/Test_if_value_is_nil_after_expiration (2.01s)
    --- PASS: TestExpireat/Test_if_value_is_nil_after_expiration#01 (2.01s)
    --- PASS: TestExpireat/Invalid_Command_Test (0.01s)
PASS
2024/09/11 15:41:21 INFO Connection closed by client or reset fd=13
2024/09/11 15:41:21 INFO Received abort command, initiating graceful shutdown
2024/09/11 15:41:21 INFO Server socket closed successfully
2024/09/11 15:41:21 INFO cleaned up all client connections
2024/09/11 15:41:21 INFO Skipping AOF dump as test env enabled.
ok  	github.com/dicedb/dice/tests	9.386s

harshrai654 avatar Sep 11 '24 10:09 harshrai654

@harshrai654 thanks for contributing, changes look good to me. Can you please add TCL tests log also for reference. The steps to run the test cases are mentioned in the README of the dice-tests repository. Look out for the mentioned test case you've fixed it should be passing with [ok] prefix.

lucifercr07 avatar Sep 11 '24 13:09 lucifercr07

@lucifercr07 I have attached tcl test run log file:

tcl-output.log

The mentioned tcl test case is now passing:

[ok]: EXPIRE with LT and XX option on a key with ttl (0 ms)
2024/09/11 19:30:17 INFO Connection closed by client or reset fd=11
[ok]: EXPIRE with LT and XX option on a key without ttl (1 ms)
2024/09/11 19:30:17 INFO Connection closed by client or reset fd=11
[ok]: EXPIRE with conflicting options: LT GT (0 ms)

harshrai654 avatar Sep 11 '24 14:09 harshrai654