use of com.aws.greengrass.lifecyclemanager.Kernel in project aws-greengrass-nucleus by aws-greengrass.
the class GenericExternalServiceIntegTest method beforeEach.
@BeforeEach
void beforeEach() {
kernel = new Kernel();
NoOpPathOwnershipHandler.register(kernel);
}
use of com.aws.greengrass.lifecyclemanager.Kernel in project aws-greengrass-nucleus by aws-greengrass.
the class KernelRestartTest method GIVEN_kernel_shuts_down_WHEN_kernel_restarts_with_a_new_config_THEN_it_should_start_with_the_new_config.
@Test
void GIVEN_kernel_shuts_down_WHEN_kernel_restarts_with_a_new_config_THEN_it_should_start_with_the_new_config() throws Exception {
// GIVEN
kernel = new Kernel();
ConfigPlatformResolver.initKernelWithMultiPlatformConfig(kernel, this.getClass().getResource("kernel_restart_initial_config.yaml"));
kernel.launch();
assertThat(kernel.getMain()::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_1")::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_2")::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_2").getConfig().find("setenv", "key1").getOnce(), is(equalTo("value1")));
kernel.shutdown();
// WHEN
// start Nucleus with parseArgs input so previous config tlog will be ignored.
kernel = new Kernel();
kernel.parseArgs("-i", this.getClass().getResource("kernel_restart_new_config.yaml").toString());
kernel.launch();
// THEN
assertThat(kernel.getMain()::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
// service 3 is added
assertThat(kernel.locate("service_3")::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
// service 2's setenv is updated
assertThat(kernel.locate("service_2")::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_2").getConfig().find("setenv", "key1").getOnce(), is(equalTo("new_value1")));
// service 1 is removed
assertThrows(ServiceLoadException.class, () -> kernel.locate("service_1"), "actual kernel config: " + kernel.getConfig().toPOJO());
}
use of com.aws.greengrass.lifecyclemanager.Kernel in project aws-greengrass-nucleus by aws-greengrass.
the class KernelRestartTest method GIVEN_kernel_shuts_down_WHEN_kernel_restarts_with_same_root_dir_THEN_it_should_get_back_to_prev_state.
@Test
void GIVEN_kernel_shuts_down_WHEN_kernel_restarts_with_same_root_dir_THEN_it_should_get_back_to_prev_state() throws Exception {
// GIVEN
kernel = new Kernel();
ConfigPlatformResolver.initKernelWithMultiPlatformConfig(kernel, this.getClass().getResource("kernel_restart_initial_config.yaml"));
kernel.launch();
assertThat(kernel.getMain()::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_1")::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_2")::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_2").getConfig().find("setenv", "key1").getOnce(), is(equalTo("value1")));
kernel.shutdown();
// WHEN
kernel = new Kernel();
kernel.parseArgs().launch();
// THEN
assertThat(kernel.getMain()::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_1")::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_2")::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
assertThat(kernel.locate("service_2").getConfig().find("setenv", "key1").getOnce(), is(equalTo("value1")));
}
use of com.aws.greengrass.lifecyclemanager.Kernel in project aws-greengrass-nucleus by aws-greengrass.
the class KernelRestartTest method GIVEN_kernel_launch_cleanly_and_shutdown_WHEN_kernel_restarts_with_same_root_dir_THEN_it_is_successful.
@Test
void GIVEN_kernel_launch_cleanly_and_shutdown_WHEN_kernel_restarts_with_same_root_dir_THEN_it_is_successful() {
// note that this test is mainly to verify system plugins restart fine with tlog
// GIVEN
kernel = new Kernel();
kernel.parseArgs();
kernel.launch();
assertThat(kernel.getMain()::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
kernel.shutdown();
// WHEN
kernel = new Kernel();
kernel.parseArgs().launch();
// THEN
assertThat(kernel.getMain()::getState, eventuallyEval(is(State.FINISHED), TIMEOUT));
}
use of com.aws.greengrass.lifecyclemanager.Kernel in project aws-greengrass-nucleus by aws-greengrass.
the class KernelShutdownTest method beforeEach.
@BeforeEach
void beforeEach() throws Exception {
kernel = new Kernel();
ConfigPlatformResolver.initKernelWithMultiPlatformConfig(kernel, getClass().getResource("long_running_services.yaml"));
kernel.launch();
}
Aggregations