private TestCluster buildWithPrivateContext(final Scope scope, final long seed) throws Exception { return RandomizedContext.current().runWithPrivateRandomness(seed, new Callable<TestCluster>() { @Override public TestCluster call() throws Exception { return buildTestCluster(scope, seed); } }); }
/** * Pushes the given randomness to the top of the stack, runs the {@link Callable} and disposes * the randomness before the this method returns. * <p> * This utility method can be used to initialize resources in a reproducible way since all calls to utility methods * like {@link com.carrotsearch.randomizedtesting.RandomizedTest#randomInt()} et.al. are forwarded to the current * RandomContext which uses the provided randomness from the top of the stack. * </p> * * @param seed The initial seed for the new, private randomness * @param callable the callable to execute * @param <T> the return type of the callable * @return the result of the call to {@link java.util.concurrent.Callable#call()} * @throws Exception if {@link java.util.concurrent.Callable#call()} throws an exception */ public <T> T runWithPrivateRandomness(long seed, Callable<T> callable) throws Exception { Randomness randomness = getRandomness(); Randomness prv = new Randomness(seed, randomness.getRandomSupplier(), randomness.getDecorators()); return runWithPrivateRandomness(prv, callable); }
/** * Pushes the given randomness to the top of the stack, runs the {@link Callable} and disposes * the randomness before the this method returns. * <p> * This utility method can be used to initialize resources in a reproducible way since all calls to utility methods * like {@link com.carrotsearch.randomizedtesting.RandomizedTest#randomInt()} et.al. are forwarded to the current * RandomContext which uses the provided randomness from the top of the stack. * </p> * * @param seed The initial seed for the new, private randomness * @param callable the callable to execute * @param <T> the return type of the callable * @return the result of the call to {@link java.util.concurrent.Callable#call()} * @throws Exception if {@link java.util.concurrent.Callable#call()} throws an exception */ public <T> T runWithPrivateRandomness(long seed, Callable<T> callable) throws Exception { Randomness randomness = getRandomness(); Randomness prv = new Randomness(seed, randomness.getRandomSupplier(), randomness.getDecorators()); return runWithPrivateRandomness(prv, callable); }
protected void startNode(long seed) throws Exception { ElassandraDaemon.instance.node(RandomizedContext.current().runWithPrivateRandomness(seed, this::newNode)); // we must wait for the node to actually be up and running. otherwise the node might have started, // elected itself master but might not yet have removed the // SERVICE_UNAVAILABLE/1/state not recovered / initialized block ClusterAdminClient clusterAdminClient = client().admin().cluster(); ClusterHealthRequestBuilder builder = clusterAdminClient.prepareHealth(); ClusterHealthResponse clusterHealthResponse = builder.setWaitForGreenStatus().get(); assertFalse(clusterHealthResponse.isTimedOut()); }