Skip to content

Commit

Permalink
Merge pull request #9806 from vbekiaris/fixes/3.8/bounce-test
Browse files Browse the repository at this point in the history
Bouncing member test fixes
  • Loading branch information
vbekiaris committed Feb 6, 2017
2 parents 204f4b9 + f765867 commit 4ed50df
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
Expand Up @@ -17,17 +17,16 @@
package com.hazelcast.client.map;

import com.hazelcast.map.QueryBounceTest;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.annotation.ParallelTest;
import com.hazelcast.test.HazelcastSerialClassRunner;
import com.hazelcast.test.annotation.SlowTest;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

/**
* Test querying a cluster from Hazelcast clients while members are shutting down and joining.
*/
@RunWith(HazelcastParallelClassRunner.class)
@Category({SlowTest.class, ParallelTest.class})
@RunWith(HazelcastSerialClassRunner.class)
@Category(SlowTest.class)
public class ClientQueryBounceTest extends QueryBounceTest {

}
11 changes: 7 additions & 4 deletions hazelcast/src/test/java/com/hazelcast/map/QueryBounceTest.java
Expand Up @@ -21,10 +21,10 @@
import com.hazelcast.core.IMap;
import com.hazelcast.query.SampleObjects;
import com.hazelcast.query.SqlPredicate;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.annotation.ParallelTest;
import com.hazelcast.test.HazelcastSerialClassRunner;
import com.hazelcast.test.annotation.SlowTest;
import com.hazelcast.test.bounce.BounceMemberRule;
import com.hazelcast.test.jitter.JitterRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -41,8 +41,8 @@
/**
* Query map while members of the cluster are being shutdown and started
*/
@RunWith(HazelcastParallelClassRunner.class)
@Category({SlowTest.class, ParallelTest.class})
@RunWith(HazelcastSerialClassRunner.class)
@Category(SlowTest.class)
public class QueryBounceTest {

private static final String TEST_MAP_NAME = "employees";
Expand All @@ -54,6 +54,9 @@ public class QueryBounceTest {
@Rule
public BounceMemberRule bounceMemberRule = BounceMemberRule.with(getConfig()).build();

@Rule
public JitterRule jitterRule = new JitterRule();

@Rule
public TestName testName = new TestName();

Expand Down
Expand Up @@ -236,10 +236,12 @@ private void testWithDuration(Runnable[] tasks, long durationSeconds) {
}
sleepSeconds(1);
}
testRunning.set(false);
waitForFutures(futures);
} else {
waitForFutures(futures);
testRunning.set(false);
}

testRunning.set(false);
waitForFutures(futures);
}

public static Builder with(Config memberConfig) {
Expand Down Expand Up @@ -469,15 +471,19 @@ protected class MemberUpDownMonkey implements Runnable {
public void run() {
int i = 0;
int nextInstance;
while (testRunning.get()) {
instances[i].shutdown();
nextInstance = (i + 1) % instances.length;
sleepSeconds(2);

instances[i] = factory.newHazelcastInstance();
sleepSeconds(2);
// move to next member
i = nextInstance;
try {
while (testRunning.get()) {
instances[i].shutdown();
nextInstance = (i + 1) % instances.length;
sleepSeconds(2);

instances[i] = factory.newHazelcastInstance();
sleepSeconds(2);
// move to next member
i = nextInstance;
}
} catch (Throwable t) {
t.printStackTrace();
}
}
}
Expand Down

0 comments on commit 4ed50df

Please sign in to comment.