-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CC-1299: Implement Transactions extension stages #154
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use MultiCommandTestCase for testTxIncr1, testTxIncr2, and testTxIncr3
This commit adds the testTxMulti function to the internal package. The function sets up a Redis executable and creates an instrumented RESP connection. It then runs a command test case using the MULTI command with no arguments, asserting that the response is "OK".
This commit adds the testTxEmpty function to the internal package. The function tests an empty transaction by running a Redis executable and executing various test cases. It includes assertions for error handling and ensures that the EXEC command without MULTI returns an error.
This commit adds the `testTxQueue` function to the internal package. The function sets up a Redis executable and creates two instrumented RESP connections. It then runs a transaction test case, followed by a command test case. This new function will be used for testing the transaction queue functionality.
This commit adds the `testTxExec` function to the internal package. The function sets up a Redis executable, creates an instrumented RESP connection, and runs a test case for the `EXEC` command.
…card - Added support for multiple clients in the functions `testTxErr`, `testTxSuccess`, and `testTxDiscard`. - Each client is created with a unique name using the format "client-{index+1}". - The clients are stored in an array for later use. - The clients are closed using the `Close` method before returning from the function.
This commit adds the `spawnClients` function. The `spawnClients` function is responsible for creating a specified number of client connections to a given address. It takes in the number of clients, address, stage harness, and logger as parameters. The function creates the clients and appends them to a slice before returning it. This new function is used in multiple places throughout the codebase to create client connections.
- Renamed the `spawnClients` function to `SpawnClients` - Added documentation for the `SpawnClients` function, explaining its purpose and usage - The `SpawnClients` function creates multiple clients connected to a given address using the `instrumented_resp_connection.NewFromAddr` function - Clients are expected to be closed after use
This commit adds new test cases for transaction functionality. The added test cases cover various stages of transactions, including INCR, MULTI, EXEC, and more. These tests ensure that the transaction functionality is working as expected. - Added new test cases for transaction functionality - Covered stages such as INCR-1, INCR-2, INCR-3, MULTI, EXEC, Empty Transaction, Queueing Commands - Ensured proper execution and handling of failed transactions
This commit renames several files in the internal directory for better clarity and organization. The changes include renaming `test_txn_9.go` to `test_txn_discard.go`, `test_txn_11.go` to `test_txn_multi_tx.go`, `test_txn_8.go` to `test_txn_tx.go`, and `test_txn_10.go` to `test_txn_tx_failure.go`. These file name updates improve the readability and maintainability of the codebase.
- Skip execution of transaction commands - Use `RunAll` instead of `RunMulti` and `RunQueueAll` - Update result array for each transaction command
This commit adds the "Transactions" extension to the Redis implementation. It includes the implementation of commands such as MULTI, EXEC, DISCARD, and handling failures within transactions. The extension also introduces stages for implementing the INCR command in multiple steps.
rohitpaulk
reviewed
Jun 13, 2024
rohitpaulk
reviewed
Jun 13, 2024
rohitpaulk
reviewed
Jun 13, 2024
rohitpaulk
reviewed
Jun 13, 2024
rohitpaulk
reviewed
Jun 13, 2024
rohitpaulk
reviewed
Jun 13, 2024
rohitpaulk
reviewed
Jun 13, 2024
rohitpaulk
approved these changes
Jun 13, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! Just needs randomization added in a few places
- Removed the ShouldSkipExec flag from the TransactionTestCase struct - Renamed the RunAll method to RunWithoutExec in the TransactionTestCase struct - Updated test_txn_discard.go, test_txn_multi.go, test_txn_multi_tx.go, and test_txn_queue.go to use the RunWithoutExec method instead of RunAll
This commit adds a new test case to the `testTxErr` function in `internal/test_txn_tx_failure.go`. The test case includes commands to set random values for two keys, and then increment those values within a transaction. The expected result is an error value indicating that the value is not an integer or out of range, followed by the incremented value. After running the transaction, there are assertions to check if the values were updated correctly. The purpose of this change is to ensure that transactions handle errors properly and provide accurate results when dealing with non-integer values.
This commit adds a new transaction test case to the `testTxSuccess` function in `internal/test_txn_tx.go`. The test case includes commands for setting random keys with random integer values, incrementing the values, and retrieving them. The expected results are updated accordingly. Additionally, a command test case is added to verify the final value of one of the keys.
This commit adds the functionality to generate random keys for test cases in `test_txn_incr1.go`, `test_txn_incr2.go`, and `test_txn_incr3.go`. The generated keys are used in the `SET` and `INCR` commands. This change improves the flexibility and randomness of the test cases.
This commit adds new test cases to the `testTxDiscard` function in `internal/test_txn_discard.go`. The changes include: - Importing the `fmt` package - Generating unique keys using the `random.RandomWords` function - Generating random integers using the `random.RandomInt` function - Modifying the command arguments to use the generated keys and random integers - Updating assertions to use the generated values These changes enhance the test coverage for transaction discards.
- In test_txn_discard, changed the number of uniqueKeys generated from 3 to 2. - In test_txn_multi_tx, updated the commands to set key2 with a random integer value and increment key1. - Also added a comment explaining the expected result in each transaction. - In test_txn_queue, updated the command to set a random key with a random integer value and increment it.
Updated all the tests, to use unique random keys and values. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes changes related to the implementation of transactions in a Redis testing framework. The changes introduced new test cases, assertions, and modifications to existing functions. The most significant changes include the addition of new test cases for transaction handling, the creation of new assertion types, and the modification of the
Value
struct to include abytes
field.New test cases and assertions:
internal/resp_assertions/error_assertion.go
: Introduced a newErrorAssertion
type to verify if the type of a value is an error and if it matches the expected value.internal/resp_assertions/ordered_array_assertion.go
: Introduced a newOrderedArrayAssertion
type to verify if a value is an array and if it matches the expected array in order.internal/test_cases/multi_command_test_case.go
: Introduced a newMultiCommandTestCase
type to run multiple commands and assertions.internal/test_cases/transaction_test_case.go
: Introduced a newTransactionTestCase
type to handle tests involving transactions.internal/test_txn_*.go
files. [1] [2] [3] [4] [5] [6] [7] [8] [9]Modifications to existing structures:
internal/resp/value/value.go
: Modified theValue
struct to include abytes
field and added a newError
method. This allows for the representation of integer and nil values as byte arrays and provides a method to retrieve the string representation of a value. [1] [2] [3]