-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix a flaky test It turns out that sometimes the slow log entry has a duration of zero, so cover for this case too. * Try to fix a flaky test * Streamline unit test execution in CI vs. locally The current way of running JUnit tests has some drawbacks. The CI executes tests by running multiple `mvn` commands. When running tests locally, it is tedious to run the same multiple commands, in order, for example, to get the same coverage as the CI gets. Ideally the tests are configured in the project itself, in the pom.xml file and by annotations on the tests, so that simply running `mvn test` will do everything needed. In order to achieve this, adapt the tests to be parameterized, so that JUnit takes care of running them with different RESP protocols. It is OK to use environment variables in general, for example for injecting connection details. But it is not OK to use environment variables for driving test execution, by injecting a RESP version and running the tests multiple times. If I have to run more than `mvn test`, it does not feel right. Some tests rely on static fields and @BeforeClass and @afterclass annotations. These do not work well with parameterized tests, so remove the static and switch to @before and @after annotations. The Makefile is a bit unpolished, i.e. the sequence of tasks is controlled manually when it could be controlled declaratively, and the `start` and `stop` tasks do not cover starting and stopping the Redis Stack docker. Take care of these aspects. All in all, now if I run `make test` I know I get the correct coverage in the JaCoCo report. And the CI can also just run `make test`, without additional work. * React to code review Add comments to clarify the intentions. Make more tests parameterized. Use a friendlier port number for Redis Stack. * Remove unnecessary Jedis object. Jedis object is now being created in every clearData() call. That removes the necessity of this object. * Comment of RedisJsonV1Test class protocol limit * Comment about default protocol * Polish a bit some documentation --------- Co-authored-by: Gabriel Erzse <[email protected]> Co-authored-by: M Sazzadul Hoque <[email protected]>
- Loading branch information
1 parent
f7699b1
commit 24653e0
Showing
96 changed files
with
906 additions
and
289 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
22 changes: 22 additions & 0 deletions
22
src/test/java/redis/clients/jedis/commands/CommandsTestsParameters.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package redis.clients.jedis.commands; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import redis.clients.jedis.RedisProtocol; | ||
|
||
public class CommandsTestsParameters { | ||
|
||
/** | ||
* RESP protocol versions we want our commands related tests to run against. | ||
* {@code null} means to use the default protocol which is assumed to be RESP2. | ||
*/ | ||
public static Collection<Object[]> respVersions() { | ||
return Arrays.asList( | ||
new Object[]{ null }, | ||
new Object[]{ RedisProtocol.RESP2 }, | ||
new Object[]{ RedisProtocol.RESP3 } | ||
); | ||
} | ||
|
||
} |
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
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
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
Oops, something went wrong.