/** * Configures the test with custom options as would be provided via an {@code options.json} file. If this is not * invoked then the service defaults from {@code config.json} are used for the test. * * @param optionKeyVals an even number of strings which will be unpacked as (key, value, key, value, ...), where the * keys should be in {@code section1.section2.section3.name} form as an {@code options.json} file would have * @return {@code this} */ public ServiceTestRunner setOptions(String... optionKeyVals) { return setOptions(toMap(optionKeyVals)); }
@Test public void testRegionAwareness() throws Exception { ServiceTestResult result = getDefaultRunner() .setOptions("service.region", "Europe") .run(); Assert.assertEquals(result.getSchedulerEnvironment().get("SERVICE_REGION"), "Europe"); }
@Test public void testRegionAwareness() throws Exception { ServiceTestResult result = getDefaultRunner() .setOptions("service.region", "Europe") .run(); Assert.assertEquals(result.getSchedulerEnvironment().get("SERVICE_REGION"), "Europe"); }
@Test public void testSpecCustomUserAndSeeds() throws Exception { Map<String, String> nodeEnv = getDefaultNodeEnv(); nodeEnv.put("REMOTE_SEEDS", "baz"); ServiceTestResult result = new ServiceTestRunner() .setOptions("service.user", "foo") .setPodEnv("node", nodeEnv) .run(); Assert.assertEquals("foo", result.getServiceSpec().getUser()); Assert.assertEquals("foo", result.getServiceSpec().getPods().get(0).getUser().get()); Assert.assertTrue(result.getTaskConfig("node", "server", "cassandra").contains("- seeds: \"foo,bar,baz\"")); }
@Test public void testRegionAwareness() throws Exception { ServiceTestResult result = new ServiceTestRunner() .setOptions("service.region", "Europe") .setPodEnv("node", getDefaultNodeEnv()) .run(); Assert.assertEquals(result.getSchedulerEnvironment().get("SERVICE_REGION"), "Europe"); }
@Test public void testSpecSSL() throws Exception { ServiceTestResult result = new ServiceTestRunner() .setOptions("service.security.transport_encryption.enabled", "true") .setPodEnv("node", getDefaultNodeEnv()) .run(); Assert.assertTrue(result.getTaskConfig("node", "server", "cassandra").contains("internode_encryption: all")); Assert.assertTrue(result.getTaskConfig("node", "server", "cassandra").contains( "client_encryption_options:\n enabled: true\n optional: false")); }
.setOptions("hello.count", "0") .setState(result) .run(ticks);
.setOptions("service.sleep", newEnv) .setState(result) .run(ticks);
.setOptions("world.count", "0") .setState(result) .run(ticks);
.setPodEnv("data", "SERVICE_ZK_ROOT", "") .setPodEnv("name", "SERVICE_ZK_ROOT", "/path/to/zk") .setOptions( "service.security.transport_encryption.enabled", "true", "hdfs.name_node_https_port", "2000",
.setOptions("service.name", "/path/to/namespace") .run(getDefaultDeploymentTicks()); .setState(result) .enableMultiService("frameworkName") .setOptions("service.name", "test-namespace") .run(getDefaultDeploymentTicks());