Skip to content

Commit

Permalink
Remove List tests asserting timeouts (#4051)
Browse files Browse the repository at this point in the history
As a client library, it should be enough to send the command arguments and get & parse the reply properly.
  • Loading branch information
sazzad16 authored Jan 14, 2025
1 parent a55da99 commit 180d9aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static redis.clients.jedis.util.AssertUtil.assertByteArrayListEquals;

Expand Down Expand Up @@ -495,17 +494,11 @@ public void blpopDouble() throws InterruptedException {
assertArrayEquals(bbar, bresult.getValue());
}

@Test
@Test(timeout = 5000L)
public void blpopDoubleWithSleep() {
long startMillis, totalMillis;

startMillis = System.currentTimeMillis();
KeyValue<String, String> result = jedis.blpop(0.04, "foo");
totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
assertNull(result);

startMillis = System.currentTimeMillis();
new Thread(() -> {
try {
Thread.sleep(30);
Expand All @@ -517,8 +510,6 @@ public void blpopDoubleWithSleep() {
}
}).start();
result = jedis.blpop(1.2, "foo");
totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);

assertNotNull(result);
assertEquals("foo", result.getKey());
Expand Down Expand Up @@ -617,17 +608,11 @@ public void brpopDouble() throws InterruptedException {
assertArrayEquals(bbar, bresult.getValue());
}

@Test
@Test(timeout = 5000L)
public void brpopDoubleWithSleep() {
long startMillis, totalMillis;

startMillis = System.currentTimeMillis();
KeyValue<String, String> result = jedis.brpop(0.04, "foo");
totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
assertNull(result);

startMillis = System.currentTimeMillis();
new Thread(() -> {
try {
Thread.sleep(30);
Expand All @@ -639,8 +624,6 @@ public void brpopDoubleWithSleep() {
}
}).start();
result = jedis.brpop(1.2, "foo");
totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);

assertNotNull(result);
assertEquals("foo", result.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static redis.clients.jedis.util.AssertUtil.assertByteArrayListEquals;

Expand Down Expand Up @@ -491,17 +490,11 @@ public void blpopDouble() throws InterruptedException {
assertArrayEquals(bbar, bresult.getValue());
}

@Test
@Test(timeout = 5000L)
public void blpopDoubleWithSleep() {
long startMillis, totalMillis;

startMillis = System.currentTimeMillis();
KeyValue<String, String> result = jedis.blpop(0.04, "foo");
totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
assertNull(result);

startMillis = System.currentTimeMillis();
new Thread(() -> {
try {
Thread.sleep(30);
Expand All @@ -511,8 +504,6 @@ public void blpopDoubleWithSleep() {
jedis.lpush("foo", "bar");
}).start();
result = jedis.blpop(1.2, "foo");
totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);

assertNotNull(result);
assertEquals("foo", result.getKey());
Expand Down Expand Up @@ -611,17 +602,11 @@ public void brpopDouble() throws InterruptedException {
assertArrayEquals(bbar, bresult.getValue());
}

@Test
@Test(timeout = 5000L)
public void brpopDoubleWithSleep() {
long startMillis, totalMillis;

startMillis = System.currentTimeMillis();
KeyValue<String, String> result = jedis.brpop(0.04, "foo");
totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
assertNull(result);

startMillis = System.currentTimeMillis();
new Thread(() -> {
try {
Thread.sleep(30);
Expand All @@ -631,8 +616,6 @@ public void brpopDoubleWithSleep() {
jedis.lpush("foo", "bar");
}).start();
result = jedis.brpop(1.2, "foo");
totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);

assertNotNull(result);
assertEquals("foo", result.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertTrue;

import java.util.List;

Expand All @@ -15,6 +14,7 @@
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import redis.clients.jedis.RedisProtocol;
import redis.clients.jedis.Response;
import redis.clients.jedis.args.ListDirection;
Expand Down Expand Up @@ -524,21 +524,13 @@ public void blpopDouble() {
assertThat(bresult3.get().getValue(), equalTo(bcar));
}

@Test
@Test(timeout = 5000L)
public void blpopDoubleWithSleep() {
long startMillis, totalMillis;

startMillis = System.currentTimeMillis();

Response<KeyValue<String, String>> result = pipe.blpop(0.04, "foo");
pipe.sync();

totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);

assertThat(result.get(), nullValue());

startMillis = System.currentTimeMillis();
new Thread(() -> {
try {
Thread.sleep(30);
Expand All @@ -551,9 +543,6 @@ public void blpopDoubleWithSleep() {
result = pipe.blpop(1.2, "foo");
pipe.sync();

totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);

assertThat(result.get().getKey(), equalTo("foo"));
assertThat(result.get().getValue(), equalTo("bar"));
}
Expand Down Expand Up @@ -646,21 +635,13 @@ public void brpopDouble() {
assertThat(bresult3.get().getValue(), equalTo(bcar));
}

@Test
@Test(timeout = 5000L)
public void brpopDoubleWithSleep() {
long startMillis, totalMillis;

startMillis = System.currentTimeMillis();

Response<KeyValue<String, String>> result = pipe.brpop(0.04, "foo");
pipe.sync();

totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);

assertThat(result.get(), nullValue());

startMillis = System.currentTimeMillis();
new Thread(() -> {
try {
Thread.sleep(30);
Expand All @@ -673,9 +654,6 @@ public void brpopDoubleWithSleep() {
result = pipe.brpop(1.2, "foo");
pipe.sync();

totalMillis = System.currentTimeMillis() - startMillis;
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);

assertThat(result.get().getKey(), equalTo("foo"));
assertThat(result.get().getValue(), equalTo("bar"));
}
Expand Down

0 comments on commit 180d9aa

Please sign in to comment.