1010import org .junit .After ;
1111import org .junit .AfterClass ;
1212import org .junit .Before ;
13+ import org .junit .BeforeClass ;
1314import org .junit .Test ;
1415
1516import redis .clients .jedis .args .*;
2324import redis .clients .jedis .util .JedisClusterTestUtil ;
2425import redis .clients .jedis .util .SafeEncoder ;
2526
26- // SLOW
27- // TODO: make it fast
2827public class ClusterPipeliningTest {
2928
3029 private static final String LOCAL_IP = "127.0.0.1" ;
@@ -36,13 +35,13 @@ public class ClusterPipeliningTest {
3635 private static Jedis node2 ;
3736 private static Jedis node3 ;
3837
39- private HostAndPort nodeInfo1 = HostAndPorts .getClusterServers ().get (0 );
40- private HostAndPort nodeInfo2 = HostAndPorts .getClusterServers ().get (1 );
41- private HostAndPort nodeInfo3 = HostAndPorts .getClusterServers ().get (2 );
38+ private static HostAndPort nodeInfo1 = HostAndPorts .getClusterServers ().get (0 );
39+ private static HostAndPort nodeInfo2 = HostAndPorts .getClusterServers ().get (1 );
40+ private static HostAndPort nodeInfo3 = HostAndPorts .getClusterServers ().get (2 );
4241 private Set <HostAndPort > nodes = new HashSet <>(Arrays .asList (nodeInfo1 , nodeInfo2 , nodeInfo3 ));
4342
44- @ Before
45- public void setUp () throws InterruptedException {
43+ @ BeforeClass
44+ public static void setUp () throws InterruptedException {
4645 node1 = new Jedis (nodeInfo1 );
4746 node1 .auth ("cluster" );
4847 node1 .flushAll ();
@@ -81,8 +80,22 @@ public void setUp() throws InterruptedException {
8180 JedisClusterTestUtil .waitForClusterReady (node1 , node2 , node3 );
8281 }
8382
83+ @ Before
84+ public void prepare () {
85+ node1 .flushAll ();
86+ node2 .flushAll ();
87+ node3 .flushAll ();
88+ }
89+
90+ @ After
91+ public void cleanUp () {
92+ node1 .flushDB ();
93+ node2 .flushDB ();
94+ node3 .flushDB ();
95+ }
96+
8497 @ AfterClass
85- public static void cleanUp () {
98+ public static void tearDown () throws InterruptedException {
8699 node1 .flushDB ();
87100 node2 .flushDB ();
88101 node3 .flushDB ();
@@ -91,11 +104,6 @@ public static void cleanUp() {
91104 node3 .clusterReset (ClusterResetType .SOFT );
92105 }
93106
94- @ After
95- public void tearDown () throws InterruptedException {
96- cleanUp ();
97- }
98-
99107 @ Test
100108 public void constructorClientConfig () {
101109 try (ClusterPipeline pipe = new ClusterPipeline (nodes , DEFAULT_CLIENT_CONFIG )) {
0 commit comments