Skip to content
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

Streamline test execution #3760

Merged
merged 8 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,10 @@ jobs:
mvn javadoc:jar
- name: Run tests
run: |
TEST="" make test
make test
env:
JVM_OPTS: -Xmx3200m
TERM: dumb
- name: sleep 10s
run: sleep 10s
- name: Make - start
run: |
make start
sleep 2s
- name: Docker - mod or stack
run: docker run -p 52567:6379 -d redis/redis-stack-server:edge
- name: Test commands - default protocol
run: mvn -Dtest="redis.clients.jedis.commands.**" test
- name: Test commands - RESP3 protocol
run: mvn -DjedisProtocol=3 -Dtest="redis.clients.jedis.commands.**" test
- name: Test module commands - default protocol
run: mvn -DmodulesDocker="localhost:52567" -Dtest="redis.clients.jedis.modules.**" test
- name: Test module commands - RESP3 protocol
run: mvn -DjedisProtocol=3 -DmodulesDocker="localhost:52567" -Dtest="redis.clients.jedis.modules.**" test
- name: Make - stop
run: make stop
- name: Codecov
run: |
bash <(curl -s https://codecov.io/bash)
27 changes: 16 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ ifndef STUNNEL_BIN
endif
export SKIP_SSL

start: stunnel cleanup
start: stunnel cleanup compile-module
echo "$$REDIS1_CONF" | redis-server -
echo "$$REDIS2_CONF" | redis-server -
echo "$$REDIS3_CONF" | redis-server -
Expand Down Expand Up @@ -446,6 +446,7 @@ start: stunnel cleanup
echo "$$REDIS_UDS" | redis-server -
echo "$$REDIS_UNAVAILABLE_CONF" | redis-server -
redis-cli -a cluster --cluster create 127.0.0.1:7479 127.0.0.1:7480 127.0.0.1:7481 --cluster-yes
docker run -p 6479:6379 --name jedis-stack -d redis/redis-stack-server:edge

cleanup:
- rm -vf /tmp/redis_cluster_node*.conf 2>/dev/null
Expand All @@ -455,6 +456,7 @@ stunnel:
@if [ -e "$$STUNNEL_BIN" ]; then\
echo "$$STUNNEL_CONF" | stunnel -fd 0;\
fi

stop:
kill `cat /tmp/redis1.pid`
kill `cat /tmp/redis2.pid`
Expand Down Expand Up @@ -496,29 +498,32 @@ stop:
rm -f /tmp/redis_stable_cluster_node1.conf
rm -f /tmp/redis_stable_cluster_node2.conf
rm -f /tmp/redis_stable_cluster_node3.conf
docker rm -f jedis-stack

test: | start mvn-test stop

test: compile-module start
sleep 2
mvn-test:
mvn -Dtest=${SKIP_SSL}${TEST} clean compile test
make stop

package: start
package: | start mvn-package stop

mvn-package:
mvn clean package
make stop

deploy: start
deploy: | start mvn-deploy stop

mvn-deploy:
mvn clean deploy
make stop

format:
mvn java-formatter:format

release:
make start
release: | start mvn-release stop

mvn-release:
mvn release:clean
mvn release:prepare
mvn release:perform -DskipTests
make stop

system-setup:
sudo apt install -y gcc g++
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/redis/clients/jedis/ACLJedisTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.net.URISyntaxException;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import redis.clients.jedis.commands.jedis.JedisCommandsTestBase;
import redis.clients.jedis.util.RedisVersionUtil;
Expand All @@ -15,6 +17,7 @@
* <p>
* This test is only executed when the server/cluster is Redis 6. or more.
*/
@RunWith(Parameterized.class)
public class ACLJedisTest extends JedisCommandsTestBase {

/**
Expand All @@ -27,6 +30,10 @@ public static void prepare() throws Exception {
RedisVersionUtil.checkRedisMajorVersionNumber(6));
}

public ACLJedisTest(RedisProtocol redisProtocol) {
super(redisProtocol);
}

@Test
public void useWithoutConnecting() {
try (Jedis j = new Jedis()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected String encode(byte[] raw) {
});
thread.start();

assertTrue(countDownLatch.await(10, TimeUnit.MILLISECONDS));
assertTrue(countDownLatch.await(20, TimeUnit.MILLISECONDS));

}
}
7 changes: 7 additions & 0 deletions src/test/java/redis/clients/jedis/JedisTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@
import java.util.Map;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import redis.clients.jedis.exceptions.InvalidURIException;
import redis.clients.jedis.exceptions.JedisConnectionException;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.jedis.commands.jedis.JedisCommandsTestBase;
import redis.clients.jedis.util.SafeEncoder;

@RunWith(Parameterized.class)
public class JedisTest extends JedisCommandsTestBase {

public JedisTest(RedisProtocol protocol) {
super(protocol);
}

@Test
public void useWithoutConnecting() {
try (Jedis j = new Jedis()) {
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/redis/clients/jedis/MigratePipeliningTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import redis.clients.jedis.commands.jedis.JedisCommandsTestBase;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.params.MigrateParams;

@RunWith(Parameterized.class)
public class MigratePipeliningTest extends JedisCommandsTestBase {

private static final byte[] bfoo = { 0x01, 0x02, 0x03 };
Expand All @@ -39,6 +43,10 @@ public class MigratePipeliningTest extends JedisCommandsTestBase {
private Jedis dest;
private Jedis destAuth;

public MigratePipeliningTest(RedisProtocol protocol) {
super(protocol);
}

@Before
@Override
public void setUp() throws Exception {
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/redis/clients/jedis/PipeliningTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,28 @@
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.commands.jedis.JedisCommandsTestBase;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.resps.Tuple;
import redis.clients.jedis.util.SafeEncoder;

@RunWith(Parameterized.class)
public class PipeliningTest extends JedisCommandsTestBase {

private static final byte[] bfoo = { 0x01, 0x02, 0x03, 0x04 };
private static final byte[] bfoo1 = { 0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14 };
private static final byte[] bbar = { 0x05, 0x06, 0x07, 0x08 };
private static final byte[] bbaz = { 0x09, 0x0A, 0x0B, 0x0C };

public PipeliningTest(RedisProtocol protocol) {
super(protocol);
}

@Test
public void pipeline() {
Pipeline p = jedis.pipelined();
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/redis/clients/jedis/TupleSortedSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import redis.clients.jedis.resps.Tuple;
import redis.clients.jedis.commands.jedis.JedisCommandsTestBase;

@RunWith(Parameterized.class)
public class TupleSortedSetTest extends JedisCommandsTestBase {
final byte[] bfoo = { 0x01, 0x02, 0x03, 0x04 };
final byte[] ba = { 0x0A };
Expand All @@ -18,6 +22,10 @@ public class TupleSortedSetTest extends JedisCommandsTestBase {
final byte[] be = { 0x0E };
final byte[] bf = { 0x0F };

public TupleSortedSetTest(RedisProtocol protocol) {
super(protocol);
}

@Test
public void testBinary() {
List<Tuple> array = new ArrayList<Tuple>();
Expand Down
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 }
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.RedisProtocol;
import redis.clients.jedis.Transaction;
import redis.clients.jedis.exceptions.JedisAccessControlException;
import redis.clients.jedis.exceptions.JedisDataException;
Expand All @@ -33,6 +36,7 @@
/**
* TODO: properly define and test exceptions
*/
@RunWith(Parameterized.class)
public class AccessControlListCommandsTest extends JedisCommandsTestBase {

public static final String USER_NAME = "newuser";
Expand All @@ -45,6 +49,10 @@ public static void prepare() throws Exception {
RedisVersionUtil.checkRedisMajorVersionNumber(6));
}

public AccessControlListCommandsTest(RedisProtocol protocol) {
super(protocol);
}

@After
@Override
public void tearDown() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.hamcrest.Matchers;
import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
Expand All @@ -35,8 +37,8 @@
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.util.AssertUtil;
import redis.clients.jedis.util.KeyValue;
import redis.clients.jedis.util.RedisProtocolUtil;

@RunWith(Parameterized.class)
public class AllKindOfValuesCommandsTest extends JedisCommandsTestBase {
final byte[] bfoo = { 0x01, 0x02, 0x03, 0x04 };
final byte[] bfoo1 = { 0x01, 0x02, 0x03, 0x04, 0x0A };
Expand All @@ -57,6 +59,10 @@ public class AllKindOfValuesCommandsTest extends JedisCommandsTestBase {

private static final HostAndPort lfuHnp = HostAndPorts.getRedisServers().get(7);

public AllKindOfValuesCommandsTest(RedisProtocol redisProtocol) {
super(redisProtocol);
}

@Test
public void ping() {
String status = jedis.ping();
Expand Down Expand Up @@ -984,7 +990,7 @@ public void encodeCompleteResponsePing() {

@Test
public void encodeCompleteResponseHgetall() {
Assume.assumeFalse(RedisProtocolUtil.getRedisProtocol() == RedisProtocol.RESP3);
Assume.assumeFalse(protocol == RedisProtocol.RESP3);

HashMap<String, String> entries = new HashMap<>();
entries.put("foo", "bar");
Expand All @@ -1002,7 +1008,7 @@ public void encodeCompleteResponseHgetall() {

@Test
public void encodeCompleteResponseHgetallResp3() {
Assume.assumeTrue(RedisProtocolUtil.getRedisProtocol() == RedisProtocol.RESP3);
Assume.assumeTrue(protocol == RedisProtocol.RESP3);

HashMap<String, String> entries = new HashMap<>();
entries.put("foo", "bar");
Expand All @@ -1019,7 +1025,7 @@ public void encodeCompleteResponseHgetallResp3() {

@Test
public void encodeCompleteResponseXinfoStream() {
Assume.assumeFalse(RedisProtocolUtil.getRedisProtocol() == RedisProtocol.RESP3);
Assume.assumeFalse(protocol == RedisProtocol.RESP3);

HashMap<String, String> entry = new HashMap<>();
entry.put("foo", "bar");
Expand All @@ -1046,7 +1052,7 @@ public void encodeCompleteResponseXinfoStream() {

@Test
public void encodeCompleteResponseXinfoStreamResp3() {
Assume.assumeTrue(RedisProtocolUtil.getRedisProtocol() == RedisProtocol.RESP3);
Assume.assumeTrue(protocol == RedisProtocol.RESP3);

HashMap<String, String> entry = new HashMap<>();
entry.put("foo", "bar");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import redis.clients.jedis.Protocol;
import redis.clients.jedis.RedisProtocol;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.util.SafeEncoder;

@RunWith(Parameterized.class)
public class BinaryValuesCommandsTest extends JedisCommandsTestBase {
byte[] bfoo = { 0x01, 0x02, 0x03, 0x04 };
byte[] bbar = { 0x05, 0x06, 0x07, 0x08 };
Expand All @@ -35,6 +39,10 @@ public class BinaryValuesCommandsTest extends JedisCommandsTestBase {
long expireMillis = expireSeconds * 1000;
byte[] binaryValue;

public BinaryValuesCommandsTest(RedisProtocol protocol) {
super(protocol);
}

@Before
public void startUp() {
StringBuilder sb = new StringBuilder();
Expand Down
Loading
Loading