use of com.aws.greengrass.deployment.model.Deployment.DeploymentStage.DEFAULT in project aws-greengrass-nucleus by aws-greengrass.
the class DeploymentTaskIntegrationTest method GIVEN_a_deployment_has_component_use_system_config_WHEN_submitted_THEN_system_configs_are_interpolated.
@Test
@Order(7)
void GIVEN_a_deployment_has_component_use_system_config_WHEN_submitted_THEN_system_configs_are_interpolated() throws Exception {
CountDownLatch stdoutLatch = new CountDownLatch(1);
// Set up stdout listener to capture stdout for verify #2 interpolation
List<String> stdouts = new CopyOnWriteArrayList<>();
Consumer<GreengrassLogMessage> listener = m -> {
String messageOnStdout = m.getMessage();
if (messageOnStdout != null && messageOnStdout.contains("aws.iot.gg.test.integ.SystemConfigTest output")) {
stdouts.add(messageOnStdout);
stdoutLatch.countDown();
}
};
Slf4jLogAdapter.addGlobalListener(listener);
try {
/*
* 1st deployment. Default Config.
*/
Future<DeploymentResult> resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("SystemConfigTest_DeployDocument.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
// The main comes from SystemConfigTest_DeployDocument.json
String mainComponentName = "aws.iot.gg.test.integ.SystemConfigTest";
String mainComponentNameVer = "0.0.1";
// The dependency is specified in aws.iot.gg.test.integ.SystemConfigTest-0.1.1
String otherComponentName = "GreenSignal";
String otherComponentVer = "1.0.0";
assertThat("has output", stdoutLatch.await(STDOUT_TIMEOUT, TimeUnit.SECONDS), is(true));
// verify interpolation result
assertThat(stdouts.get(0), containsString("I'm kernel's root path: " + rootDir.toAbsolutePath()));
assertThat(stdouts.get(0), containsString("I'm my own artifact path: " + rootDir.resolve("packages").resolve(ComponentStore.ARTIFACT_DIRECTORY).resolve(mainComponentName).resolve(mainComponentNameVer).toAbsolutePath()));
assertTrue(stdouts.get(0).contains("I'm my own artifact decompressed path: " + rootDir.resolve("packages").resolve(ComponentStore.ARTIFACTS_DECOMPRESSED_DIRECTORY).resolve(mainComponentName).resolve(mainComponentNameVer).toAbsolutePath()));
assertThat(stdouts.get(0), containsString("I'm GreenSignal's artifact path: " + rootDir.resolve("packages").resolve(ComponentStore.ARTIFACT_DIRECTORY).resolve(otherComponentName).resolve(otherComponentVer).toAbsolutePath()));
assertThat(stdouts.get(0), containsString("I'm GreenSignal's artifact decompressed path: " + rootDir.resolve("packages").resolve(ComponentStore.ARTIFACTS_DECOMPRESSED_DIRECTORY).resolve(otherComponentName).resolve(otherComponentVer).toAbsolutePath()));
} finally {
Slf4jLogAdapter.removeGlobalListener(listener);
}
}
use of com.aws.greengrass.deployment.model.Deployment.DeploymentStage.DEFAULT in project aws-greengrass-nucleus by aws-greengrass.
the class DeploymentTaskIntegrationTest method GIVEN_a_deployment_with_dependency_has_config_WHEN_submitted_THEN_dependency_configs_are_interpolated.
@Test
@Order(5)
void GIVEN_a_deployment_with_dependency_has_config_WHEN_submitted_THEN_dependency_configs_are_interpolated() throws Exception {
// Set up stdout listener to capture stdout for verify #2 interpolation
countDownLatch = new CountDownLatch(1);
List<String> stdouts = new CopyOnWriteArrayList<>();
Consumer<GreengrassLogMessage> listener = m -> {
String messageOnStdout = m.getMessage();
if (messageOnStdout != null && messageOnStdout.contains("aws.iot.gg.test.integ.ComponentConfigTestMain output")) {
countDownLatch.countDown();
stdouts.add(messageOnStdout);
}
};
Slf4jLogAdapter.addGlobalListener(listener);
try {
/*
* 1st deployment. Default Config.
*/
Future<DeploymentResult> resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("CrossComponentConfigTest_DeployDocument.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
// verify interpolation result
assertThat("The stdout should be captured within seconds.", countDownLatch.await(STDOUT_TIMEOUT, TimeUnit.SECONDS));
String stdout = stdouts.get(0);
assertThat(stdout, containsString("Value for /singleLevelKey: default value of singleLevelKey."));
assertThat(stdout, containsString("Value for /path/leafKey: default value of /path/leafKey."));
assertThat(stdout, containsString("Value for /listKey/0: item1."));
assertThat(stdout, containsString("Value for /emptyStringKey: ."));
} finally {
Slf4jLogAdapter.removeGlobalListener(listener);
}
}
use of com.aws.greengrass.deployment.model.Deployment.DeploymentStage.DEFAULT in project aws-greengrass-nucleus by aws-greengrass.
the class DeploymentTaskIntegrationTest method GIVEN_a_deployment_with_runwith_config_WHEN_submitted_THEN_runwith_updated.
/**
* Start a service running with a user, then deploy an update to change the user and ensure the correct user stops
* the process and starts the new one.
*/
@Test
// deploy before tests that break services
@Order(9)
void GIVEN_a_deployment_with_runwith_config_WHEN_submitted_THEN_runwith_updated() throws Exception {
((Map) kernel.getContext().getvIfExists(Kernel.SERVICE_TYPE_TO_CLASS_MAP_KEY).get()).put("plugin", GreengrassService.class.getName());
countDownLatch = new CountDownLatch(2);
// Set up stdout listener to capture stdout for verifying users
List<String> stdouts = new CopyOnWriteArrayList<>();
Consumer<GreengrassLogMessage> listener = m -> {
String messageOnStdout = m.getMessage();
if (messageOnStdout != null && messageOnStdout.contains("with user")) {
stdouts.add(messageOnStdout);
countDownLatch.countDown();
}
};
final boolean isWindows = PlatformResolver.isWindows;
final String currentUser = System.getProperty("user.name");
final String posixDefaultUser = "nobody";
final String posixPrivilegedUser = "root";
final String testServiceName = "CustomerAppStartupShutdown";
try (AutoCloseable ignored = TestUtils.createCloseableLogListener(listener)) {
/*
* 1st deployment. Default Config.
*/
Future<DeploymentResult> resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("SampleJobDocumentWithUser_1.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
// verify configs
String posixUser = Coerce.toString(kernel.findServiceTopic(testServiceName).find(RUN_WITH_NAMESPACE_TOPIC, POSIX_USER_KEY));
String windowsUser = Coerce.toString(kernel.findServiceTopic(testServiceName).find(RUN_WITH_NAMESPACE_TOPIC, WINDOWS_USER_KEY));
assertEquals("nobody", posixUser);
assertEquals(WINDOWS_TEST_UESRNAME, windowsUser);
long memory = Coerce.toLong(kernel.findServiceTopic(testServiceName).find(RUN_WITH_NAMESPACE_TOPIC, SYSTEM_RESOURCE_LIMITS_TOPICS, "memory"));
assertEquals(1024000, memory);
double cpus = Coerce.toDouble(kernel.findServiceTopic(testServiceName).find(RUN_WITH_NAMESPACE_TOPIC, SYSTEM_RESOURCE_LIMITS_TOPICS, "cpus"));
assertEquals(1.5, cpus);
// verify user
countDownLatch.await(10, TimeUnit.SECONDS);
// Install has RequiresPrivilege. On Windows, expect current user is the privileged user
if (isWindows) {
assertThat(stdouts, hasItem(containsString("installing app with user " + currentUser)));
assertThat(stdouts, hasItem(containsString("starting app with user " + WINDOWS_TEST_UESRNAME)));
} else {
assertThat(stdouts, hasItem(containsString("installing app with user " + posixPrivilegedUser)));
assertThat(stdouts, hasItem(containsString("starting app with user " + posixDefaultUser)));
}
stdouts.clear();
}
/*
* 2nd deployment. Change user
*/
countDownLatch = new CountDownLatch(3);
// update component to runas the user running the test
String doc = Utils.inputStreamToString(DeploymentTaskIntegrationTest.class.getResource("SampleJobDocumentWithUser_2.json").openStream());
// Set posixUser to currentUser. Set windowsUser to alternative test user
doc = String.format(doc, currentUser, WINDOWS_TEST_UESRNAME_2);
File f = File.createTempFile("user-deployment", ".json");
f.deleteOnExit();
Files.write(f.toPath(), doc.getBytes(StandardCharsets.UTF_8));
try (AutoCloseable ignored = TestUtils.createCloseableLogListener(listener)) {
Future<DeploymentResult> resultFuture = submitSampleJobDocument(f.toURI(), System.currentTimeMillis());
resultFuture.get(DEPLOYMENT_TIMEOUT, TimeUnit.SECONDS);
String posixUser = Coerce.toString(kernel.findServiceTopic(testServiceName).find(RUN_WITH_NAMESPACE_TOPIC, POSIX_USER_KEY));
String windowsUser = Coerce.toString(kernel.findServiceTopic(testServiceName).find(RUN_WITH_NAMESPACE_TOPIC, WINDOWS_USER_KEY));
assertEquals(currentUser, posixUser);
assertEquals(WINDOWS_TEST_UESRNAME_2, windowsUser);
countDownLatch.await(10, TimeUnit.SECONDS);
if (isWindows) {
assertThat(stdouts, hasItem(containsString("stopping app with user " + WINDOWS_TEST_UESRNAME)));
assertThat(stdouts, hasItem(containsString("installing app with user " + currentUser)));
assertThat(stdouts, hasItem(containsString("starting app with user " + WINDOWS_TEST_UESRNAME_2)));
} else {
assertThat(stdouts, hasItem(containsString("stopping app with user " + posixDefaultUser)));
assertThat(stdouts, hasItem(containsString("installing app with user " + posixPrivilegedUser)));
assertThat(stdouts, hasItem(containsString("starting app with user " + currentUser)));
}
stdouts.clear();
}
/*
* 3rd deployment. Set runWith user to null and use default
*/
countDownLatch = new CountDownLatch(3);
// update component to runas the user running the test
try (AutoCloseable ignored = TestUtils.createCloseableLogListener(listener)) {
Future<DeploymentResult> resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("SampleJobDocumentRemovingUser.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
String posixUser = Coerce.toString(kernel.findServiceTopic(testServiceName).find(RUN_WITH_NAMESPACE_TOPIC, POSIX_USER_KEY));
String windowsUser = Coerce.toString(kernel.findServiceTopic(testServiceName).find(RUN_WITH_NAMESPACE_TOPIC, WINDOWS_USER_KEY));
assertThat(posixUser, is(nullValue()));
assertThat(windowsUser, is(nullValue()));
// Assert fall back to runWithDefault
countDownLatch.await(10, TimeUnit.SECONDS);
if (isWindows) {
assertThat(stdouts, hasItem(containsString("stopping app with user " + WINDOWS_TEST_UESRNAME_2)));
assertThat(stdouts, hasItem(containsString("installing app with user " + currentUser)));
assertThat(stdouts, hasItem(containsString("starting app with user " + WINDOWS_TEST_UESRNAME)));
} else {
assertThat(stdouts, hasItem(containsString("stopping app with user " + currentUser)));
assertThat(stdouts, hasItem(containsString("installing app with user " + posixPrivilegedUser)));
assertThat(stdouts, hasItem(containsString("starting app with user " + posixDefaultUser)));
}
}
}
use of com.aws.greengrass.deployment.model.Deployment.DeploymentStage.DEFAULT in project aws-greengrass-nucleus by aws-greengrass.
the class DeploymentTaskIntegrationTest method GIVEN_initial_deployment_with_config_update_WHEN_submitted_to_deployment_task_THEN_configs_updates_on_default.
@Test
@Order(6)
void GIVEN_initial_deployment_with_config_update_WHEN_submitted_to_deployment_task_THEN_configs_updates_on_default() throws Exception {
// Two things are verified in this test
// 1. The component's configurations are updated correctly in the kernel's config store
// 2. The interpolation is correct by taking the newly updated configuration, that is consistent
// Set up stdout listener to capture stdout for verify #2 interpolation
List<String> stdouts = new CopyOnWriteArrayList<>();
Consumer<GreengrassLogMessage> listener = m -> {
String messageOnStdout = m.getMessage();
if (messageOnStdout != null && messageOnStdout.contains("aws.iot.gg.test.integ.ComponentConfigTestService output")) {
stdouts.add(messageOnStdout);
// countdown when received output to verify
countDownLatch.countDown();
}
};
Slf4jLogAdapter.addGlobalListener(listener);
try {
/*
* Initial deployment with configuration update
*/
countDownLatch = new CountDownLatch(1);
Future<DeploymentResult> resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("ComponentConfigTest_InitialDocumentWithUpdate.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
// verify config in config store and interpolation result
Map<String, Object> resultConfig = kernel.findServiceTopic("aws.iot.gg.test.integ.ComponentConfigTestService").findTopics(KernelConfigResolver.CONFIGURATION_CONFIG_KEY).toPOJO();
assertThat(resultConfig, IsMapWithSize.aMapWithSize(9));
// verify updated values, as specified from ComponentConfigTest_InitialDocumentWithUpdate.json
assertThat(resultConfig, IsMapContaining.hasEntry("singleLevelKey", "updated value of singleLevelKey"));
assertThat(resultConfig, IsMapContaining.hasEntry("newSingleLevelKey", "value of newSingleLevelKey"));
// verify default values from the aws.iot.gg.test.integ.ComponentConfigTestService-1.0.0.yaml recipe file
assertThat(resultConfig, IsMapContaining.hasEntry("listKey", Arrays.asList("item1", "item2")));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyStringKey", ""));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyListKey", Collections.emptyList()));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyObjectKey", Collections.emptyMap()));
assertThat(resultConfig, IsMapContaining.hasEntry("defaultIsNullKey", null));
assertThat(resultConfig, IsMapContaining.hasEntry("willBeNullKey", "I will be set to null soon"));
assertThat(resultConfig, IsMapContaining.hasKey("path"));
assertThat((Map<String, String>) resultConfig.get("path"), IsMapContaining.hasEntry("leafKey", "default value of /path/leafKey"));
// verify interpolation result
assertThat("The stdout should be captured within seconds.", countDownLatch.await(STDOUT_TIMEOUT, TimeUnit.SECONDS));
String stdout = stdouts.get(0);
// verify updated value, as specified from ComponentConfigTest_InitialDocumentWithUpdate.json
assertThat(stdout, containsString("Value for /singleLevelKey: updated value of singleLevelKey."));
assertThat(stdout, containsString("Value for /newSingleLevelKey: value of newSingleLevelKey."));
// verify default values from the aws.iot.gg.test.integ.ComponentConfigTestService-1.0.0.yaml recipe file
assertThat(stdout, containsString("Value for /path/leafKey: default value of /path/leafKey."));
assertThat(stdout, containsString("Value for /path: {\"leafKey\":\"default value of /path/leafKey\"}"));
assertThat(stdout, containsString("Value for /listKey/0: item1."));
assertThat(stdout, containsString("Value for /defaultIsNullKey: null"));
assertThat(stdout, containsString("Value for /emptyStringKey: ."));
stdouts.clear();
} finally {
Slf4jLogAdapter.removeGlobalListener(listener);
}
}
use of com.aws.greengrass.deployment.model.Deployment.DeploymentStage.DEFAULT in project aws-greengrass-nucleus by aws-greengrass.
the class DeploymentTaskIntegrationTest method GIVEN_multiple_deployments_with_config_update_WHEN_submitted_to_deployment_task_THEN_configs_are_updated.
@Test
@Order(4)
void GIVEN_multiple_deployments_with_config_update_WHEN_submitted_to_deployment_task_THEN_configs_are_updated() throws Exception {
// Two things are verified in this test
// 1. The component's configurations are updated correctly in the kernel's config store
// 2. The interpolation is correct by taking the newly updated configuration, that is consistent
// Set up stdout listener to capture stdout for verify #2 interpolation
List<String> stdouts = new CopyOnWriteArrayList<>();
Consumer<GreengrassLogMessage> listener = m -> {
String messageOnStdout = m.getMessage();
if (messageOnStdout != null && messageOnStdout.contains("aws.iot.gg.test.integ.ComponentConfigTestService output")) {
stdouts.add(messageOnStdout);
// countdown when received output to verify
countDownLatch.countDown();
}
};
Slf4jLogAdapter.addGlobalListener(listener);
try {
/*
* 1st deployment. Default Config.
*/
countDownLatch = new CountDownLatch(1);
Future<DeploymentResult> resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("ComponentConfigTest_DeployDocument_1.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
// verify config in config store and interpolation result
Map<String, Object> resultConfig = kernel.findServiceTopic("aws.iot.gg.test.integ.ComponentConfigTestService").findTopics(KernelConfigResolver.CONFIGURATION_CONFIG_KEY).toPOJO();
verifyDefaultValueIsApplied(stdouts, resultConfig);
/*
* 2nd deployment. MERGE existing keys.
*/
// reset countdown
countDownLatch = new CountDownLatch(1);
resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("ComponentConfigTest_DeployDocument_2.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
// verify config in config store
resultConfig = kernel.findServiceTopic("aws.iot.gg.test.integ.ComponentConfigTestService").findTopics(KernelConfigResolver.CONFIGURATION_CONFIG_KEY).toPOJO();
// Asserted values can be found in ComponentConfigTest_DeployDocument_2.json
assertThat(resultConfig, IsMapContaining.hasEntry("singleLevelKey", "updated value of singleLevelKey"));
assertThat(resultConfig, IsMapContaining.hasEntry("listKey", Collections.singletonList("item3")));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyStringKey", ""));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyListKey", Collections.emptyList()));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyObjectKey", Collections.emptyMap()));
assertThat(resultConfig, IsMapContaining.hasEntry("defaultIsNullKey", "updated value of defaultIsNullKey"));
assertThat(resultConfig, IsMapContaining.hasEntry("willBeNullKey", null));
assertThat(resultConfig, IsMapContaining.hasKey("path"));
// no more keys
assertThat(resultConfig, IsMapWithSize.aMapWithSize(8));
assertThat((Map<String, String>) resultConfig.get("path"), IsMapContaining.hasEntry("leafKey", "updated value of /path/leafKey"));
// no more keys
assertThat((Map<String, String>) resultConfig.get("path"), IsMapWithSize.aMapWithSize(1));
// verify interpolation result
assertThat("The stdout should be captured within seconds.", countDownLatch.await(STDOUT_TIMEOUT, TimeUnit.SECONDS));
String stdout = stdouts.get(0);
assertTrue(stdouts.get(0).contains("Value for /singleLevelKey: updated value of singleLevelKey."));
assertTrue(stdouts.get(0).contains("Value for /path/leafKey: updated value of /path/leafKey."));
assertTrue(stdouts.get(0).contains("Value for /listKey/0: item3."));
assertTrue(stdouts.get(0).contains("Value for /emptyStringKey: ."));
assertTrue(stdouts.get(0).contains("Value for /defaultIsNullKey: updated value of defaultIsNullKey."));
assertTrue(stdouts.get(0).contains("Value for /newSingleLevelKey: {configuration:/newSingleLevelKey}."));
stdouts.clear();
/*
* 3rd deployment MERGE not existed keys
*/
// reset countdown
countDownLatch = new CountDownLatch(1);
resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("ComponentConfigTest_DeployDocument_3.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
// verify config in config store
resultConfig = kernel.findServiceTopic("aws.iot.gg.test.integ.ComponentConfigTestService").findTopics(KernelConfigResolver.CONFIGURATION_CONFIG_KEY).toPOJO();
assertThat(resultConfig, IsMapContaining.hasEntry("singleLevelKey", "updated value of singleLevelKey"));
assertThat(resultConfig, IsMapContaining.hasEntry("listKey", Collections.singletonList("item3")));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyStringKey", ""));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyListKey", Collections.emptyList()));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyObjectKey", Collections.emptyMap()));
assertThat(resultConfig, IsMapContaining.hasEntry("defaultIsNullKey", "updated value of defaultIsNullKey"));
assertThat(resultConfig, IsMapContaining.hasEntry("willBeNullKey", null));
assertThat(resultConfig, IsMapContaining.hasKey("path"));
assertThat(resultConfig, IsMapContaining.hasEntry("newSingleLevelKey", "value of newSingleLevelKey"));
// no more keys
assertThat(resultConfig, IsMapWithSize.aMapWithSize(9));
assertThat((Map<String, String>) resultConfig.get("path"), IsMapContaining.hasEntry("leafKey", "updated value of /path/leafKey"));
assertThat((Map<String, String>) resultConfig.get("path"), IsMapContaining.hasEntry("newLeafKey", "value of /path/newLeafKey"));
// no more keys
assertThat((Map<String, String>) resultConfig.get("path"), IsMapWithSize.aMapWithSize(2));
// verify interpolation result
assertThat("The stdout should be captured within seconds.", countDownLatch.await(STDOUT_TIMEOUT, TimeUnit.SECONDS));
stdout = stdouts.get(0);
assertThat(stdout, containsString("Value for /singleLevelKey: updated value of singleLevelKey."));
assertThat(stdout, containsString("Value for /path/leafKey: updated value of /path/leafKey."));
assertThat(stdout, containsString("Value for /listKey/0: item3."));
assertThat(stdout, containsString("Value for /emptyStringKey: ."));
assertThat(stdout, containsString("Value for /defaultIsNullKey: updated value of defaultIsNullKey."));
assertThat(stdout, containsString("Value for /newSingleLevelKey: value of newSingleLevelKey."));
stdouts.clear();
/*
* 4th deployment. RESET.
*/
// reset countdown
countDownLatch = new CountDownLatch(1);
resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("ComponentConfigTest_DeployDocument_4.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
// verify config in config store
resultConfig = kernel.findServiceTopic("aws.iot.gg.test.integ.ComponentConfigTestService").findTopics(KernelConfigResolver.CONFIGURATION_CONFIG_KEY).toPOJO();
assertThat(resultConfig, IsMapContaining.hasEntry("singleLevelKey", "updated value of singleLevelKey"));
assertThat(resultConfig, IsMapContaining.hasEntry("listKey", Arrays.asList("item1", "item2")));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyStringKey", ""));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyListKey", Collections.emptyList()));
assertThat(resultConfig, IsMapContaining.hasEntry("emptyObjectKey", Collections.emptyMap()));
assertThat(resultConfig, IsMapContaining.hasEntry("defaultIsNullKey", "updated value of defaultIsNullKey"));
assertThat(resultConfig, IsMapContaining.hasEntry("willBeNullKey", null));
assertThat(resultConfig, IsMapContaining.hasKey("path"));
assertThat((Map<String, String>) resultConfig.get("path"), IsMapContaining.hasEntry("leafKey", "updated value of /path/leafKey"));
assertFalse(resultConfig.containsKey("newSingleLevelKey"), "newSingleLevelKey should be cleared after RESET because it doesn't have a default value");
// no more keys
assertThat(resultConfig, IsMapWithSize.aMapWithSize(8));
assertFalse(((Map<String, String>) resultConfig.get("path")).containsKey("newLeafKey"), "/path/newSingleLevelKey should be cleared after RESET because it doesn't have a default value");
// no more keys
assertThat((Map<String, String>) resultConfig.get("path"), IsMapWithSize.aMapWithSize(1));
// verify interpolation result
assertThat("The stdout should be captured within seconds.", countDownLatch.await(STDOUT_TIMEOUT, TimeUnit.SECONDS));
stdout = stdouts.get(0);
assertThat(stdout, containsString("Value for /singleLevelKey: updated value of singleLevelKey."));
assertThat(stdout, containsString("Value for /path/leafKey: updated value of /path/leafKey."));
assertThat(stdout, containsString("Value for /listKey/0: item1."));
assertThat(stdout, containsString("Value for /emptyStringKey: ."));
assertThat(stdout, containsString("Value for /defaultIsNullKey: updated value of defaultIsNullKey."));
assertThat(stdout, containsString("Value for /newSingleLevelKey: {configuration:/newSingleLevelKey}."));
stdouts.clear();
// 5th RESET entirely to default
// reset countdown
countDownLatch = new CountDownLatch(1);
resultFuture = submitSampleJobDocument(DeploymentTaskIntegrationTest.class.getResource("ComponentConfigTest_DeployDocument_5.json").toURI(), System.currentTimeMillis());
resultFuture.get(10, TimeUnit.SECONDS);
// verify config in config store and interpolation result
resultConfig = kernel.findServiceTopic("aws.iot.gg.test.integ.ComponentConfigTestService").findTopics(KernelConfigResolver.CONFIGURATION_CONFIG_KEY).toPOJO();
verifyDefaultValueIsApplied(stdouts, resultConfig);
} finally {
Slf4jLogAdapter.removeGlobalListener(listener);
}
}
Aggregations