Search in sources :

Example 1 with GreengrassLogMessage

use of com.aws.greengrass.logging.impl.GreengrassLogMessage 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);
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) Matchers.not(org.hamcrest.Matchers.not) GROUP_TO_ROOT_COMPONENTS_TOPICS(com.aws.greengrass.deployment.DeploymentService.GROUP_TO_ROOT_COMPONENTS_TOPICS) ComponentUpdatePolicyEvents(software.amazon.awssdk.aws.greengrass.model.ComponentUpdatePolicyEvents) SubscribeToComponentUpdatesResponse(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesResponse) AfterAll(org.junit.jupiter.api.AfterAll) IPCTestUtils(com.aws.greengrass.integrationtests.ipc.IPCTestUtils) Future(java.util.concurrent.Future) BeforeAll(org.junit.jupiter.api.BeforeAll) GenericExternalService(com.aws.greengrass.lifecyclemanager.GenericExternalService) Duration(java.time.Duration) Map(java.util.Map) Matchers.nullValue(org.hamcrest.Matchers.nullValue) LogManager(com.aws.greengrass.logging.impl.LogManager) StreamResponseHandler(software.amazon.awssdk.eventstreamrpc.StreamResponseHandler) Path(java.nio.file.Path) DependencyResolver(com.aws.greengrass.componentmanager.DependencyResolver) DeploymentResult(com.aws.greengrass.deployment.model.DeploymentResult) GreengrassCoreIPCClient(software.amazon.awssdk.aws.greengrass.GreengrassCoreIPCClient) Set(java.util.Set) Utils.copyFolderRecursively(com.aws.greengrass.util.Utils.copyFolderRecursively) ExceptionLogProtector.ignoreExceptionOfType(com.aws.greengrass.testcommons.testutilities.ExceptionLogProtector.ignoreExceptionOfType) DeferComponentUpdateRequest(software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateRequest) SdkClientException(software.amazon.awssdk.core.exception.SdkClientException) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) Kernel(com.aws.greengrass.lifecyclemanager.Kernel) CountDownLatch(java.util.concurrent.CountDownLatch) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.is(org.hamcrest.Matchers.is) DeploymentService(com.aws.greengrass.deployment.DeploymentService) Matchers.containsString(org.hamcrest.Matchers.containsString) ComponentIdentifier(com.aws.greengrass.componentmanager.models.ComponentIdentifier) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) PreloadComponentStoreHelper(com.aws.greengrass.helper.PreloadComponentStoreHelper) POSIX_USER_KEY(com.aws.greengrass.lifecyclemanager.GreengrassService.POSIX_USER_KEY) DeploymentDirectoryManager(com.aws.greengrass.deployment.DeploymentDirectoryManager) SYSTEM_RESOURCE_LIMITS_TOPICS(com.aws.greengrass.lifecyclemanager.GreengrassService.SYSTEM_RESOURCE_LIMITS_TOPICS) GROUP_TO_ROOT_COMPONENTS_VERSION_KEY(com.aws.greengrass.deployment.DeploymentService.GROUP_TO_ROOT_COMPONENTS_VERSION_KEY) FileMatchers.anExistingDirectory(org.hamcrest.io.FileMatchers.anExistingDirectory) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) Coerce(com.aws.greengrass.util.Coerce) WINDOWS_USER_KEY(com.aws.greengrass.lifecyclemanager.GreengrassService.WINDOWS_USER_KEY) ComponentManager(com.aws.greengrass.componentmanager.ComponentManager) SudoUtil.assumeCanSudoShell(com.aws.greengrass.testcommons.testutilities.SudoUtil.assumeCanSudoShell) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) REPLACE_EXISTING(java.nio.file.StandardCopyOption.REPLACE_EXISTING) ServiceLoadException(com.aws.greengrass.lifecyclemanager.exceptions.ServiceLoadException) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Files(java.nio.file.Files) IOException(java.io.IOException) File(java.io.File) AfterEach(org.junit.jupiter.api.AfterEach) Matchers.hasItem(org.hamcrest.Matchers.hasItem) Paths(java.nio.file.Paths) ServiceUpdateException(com.aws.greengrass.deployment.exceptions.ServiceUpdateException) KernelConfigResolver(com.aws.greengrass.componentmanager.KernelConfigResolver) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) IsMapWithSize(org.hamcrest.collection.IsMapWithSize) Logger(com.aws.greengrass.logging.api.Logger) PackageLoadingException(com.aws.greengrass.componentmanager.exceptions.PackageLoadingException) SocketOptions(software.amazon.awssdk.crt.io.SocketOptions) URISyntaxException(java.net.URISyntaxException) Deployment(com.aws.greengrass.deployment.model.Deployment) Order(org.junit.jupiter.api.Order) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) DEFAULT_NUCLEUS_COMPONENT_NAME(com.aws.greengrass.deployment.DeviceConfiguration.DEFAULT_NUCLEUS_COMPONENT_NAME) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) State(com.aws.greengrass.dependency.State) BaseITCase(com.aws.greengrass.integrationtests.BaseITCase) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DEFAULT(com.aws.greengrass.deployment.model.Deployment.DeploymentStage.DEFAULT) DeploymentDocument(com.aws.greengrass.deployment.model.DeploymentDocument) URI(java.net.URI) TestUtils(com.aws.greengrass.testcommons.testutilities.TestUtils) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Topics(com.aws.greengrass.config.Topics) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) DeploymentDocumentDownloader(com.aws.greengrass.deployment.DeploymentDocumentDownloader) Optional(java.util.Optional) ComponentStore(com.aws.greengrass.componentmanager.ComponentStore) DeploymentConfigMerger(com.aws.greengrass.deployment.DeploymentConfigMerger) ConfigPlatformResolver(com.aws.greengrass.integrationtests.util.ConfigPlatformResolver) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ThingGroupHelper(com.aws.greengrass.deployment.ThingGroupHelper) MapperFeature(com.fasterxml.jackson.databind.MapperFeature) GreengrassService(com.aws.greengrass.lifecyclemanager.GreengrassService) Semver(com.vdurmont.semver4j.Semver) PackageDownloadException(com.aws.greengrass.componentmanager.exceptions.PackageDownloadException) PlatformResolver(com.aws.greengrass.config.PlatformResolver) ExecutorService(java.util.concurrent.ExecutorService) RUN_WITH_NAMESPACE_TOPIC(com.aws.greengrass.lifecyclemanager.GreengrassService.RUN_WITH_NAMESPACE_TOPIC) ImmutableMap(software.amazon.awssdk.utils.ImmutableMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Matchers(org.hamcrest.Matchers) ExceptionLogProtector.ignoreExceptionUltimateCauseOfType(com.aws.greengrass.testcommons.testutilities.ExceptionLogProtector.ignoreExceptionUltimateCauseOfType) EventStreamRPCConnection(software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection) SubscribeToComponentUpdatesRequest(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesRequest) FileMatchers.anExistingFile(org.hamcrest.io.FileMatchers.anExistingFile) MethodOrderer(org.junit.jupiter.api.MethodOrderer) IsMapContaining(org.hamcrest.collection.IsMapContaining) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Slf4jLogAdapter(com.aws.greengrass.logging.impl.Slf4jLogAdapter) Utils(com.aws.greengrass.util.Utils) NoOpPathOwnershipHandler(com.aws.greengrass.testcommons.testutilities.NoOpPathOwnershipHandler) DefaultDeploymentTask(com.aws.greengrass.deployment.DefaultDeploymentTask) Collections(java.util.Collections) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) Matchers.containsString(org.hamcrest.Matchers.containsString) DeploymentResult(com.aws.greengrass.deployment.model.DeploymentResult) CountDownLatch(java.util.concurrent.CountDownLatch) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Test(org.junit.jupiter.api.Test)

Example 2 with GreengrassLogMessage

use of com.aws.greengrass.logging.impl.GreengrassLogMessage 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);
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) Matchers.not(org.hamcrest.Matchers.not) GROUP_TO_ROOT_COMPONENTS_TOPICS(com.aws.greengrass.deployment.DeploymentService.GROUP_TO_ROOT_COMPONENTS_TOPICS) ComponentUpdatePolicyEvents(software.amazon.awssdk.aws.greengrass.model.ComponentUpdatePolicyEvents) SubscribeToComponentUpdatesResponse(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesResponse) AfterAll(org.junit.jupiter.api.AfterAll) IPCTestUtils(com.aws.greengrass.integrationtests.ipc.IPCTestUtils) Future(java.util.concurrent.Future) BeforeAll(org.junit.jupiter.api.BeforeAll) GenericExternalService(com.aws.greengrass.lifecyclemanager.GenericExternalService) Duration(java.time.Duration) Map(java.util.Map) Matchers.nullValue(org.hamcrest.Matchers.nullValue) LogManager(com.aws.greengrass.logging.impl.LogManager) StreamResponseHandler(software.amazon.awssdk.eventstreamrpc.StreamResponseHandler) Path(java.nio.file.Path) DependencyResolver(com.aws.greengrass.componentmanager.DependencyResolver) DeploymentResult(com.aws.greengrass.deployment.model.DeploymentResult) GreengrassCoreIPCClient(software.amazon.awssdk.aws.greengrass.GreengrassCoreIPCClient) Set(java.util.Set) Utils.copyFolderRecursively(com.aws.greengrass.util.Utils.copyFolderRecursively) ExceptionLogProtector.ignoreExceptionOfType(com.aws.greengrass.testcommons.testutilities.ExceptionLogProtector.ignoreExceptionOfType) DeferComponentUpdateRequest(software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateRequest) SdkClientException(software.amazon.awssdk.core.exception.SdkClientException) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) Kernel(com.aws.greengrass.lifecyclemanager.Kernel) CountDownLatch(java.util.concurrent.CountDownLatch) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.is(org.hamcrest.Matchers.is) DeploymentService(com.aws.greengrass.deployment.DeploymentService) Matchers.containsString(org.hamcrest.Matchers.containsString) ComponentIdentifier(com.aws.greengrass.componentmanager.models.ComponentIdentifier) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) PreloadComponentStoreHelper(com.aws.greengrass.helper.PreloadComponentStoreHelper) POSIX_USER_KEY(com.aws.greengrass.lifecyclemanager.GreengrassService.POSIX_USER_KEY) DeploymentDirectoryManager(com.aws.greengrass.deployment.DeploymentDirectoryManager) SYSTEM_RESOURCE_LIMITS_TOPICS(com.aws.greengrass.lifecyclemanager.GreengrassService.SYSTEM_RESOURCE_LIMITS_TOPICS) GROUP_TO_ROOT_COMPONENTS_VERSION_KEY(com.aws.greengrass.deployment.DeploymentService.GROUP_TO_ROOT_COMPONENTS_VERSION_KEY) FileMatchers.anExistingDirectory(org.hamcrest.io.FileMatchers.anExistingDirectory) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) Coerce(com.aws.greengrass.util.Coerce) WINDOWS_USER_KEY(com.aws.greengrass.lifecyclemanager.GreengrassService.WINDOWS_USER_KEY) ComponentManager(com.aws.greengrass.componentmanager.ComponentManager) SudoUtil.assumeCanSudoShell(com.aws.greengrass.testcommons.testutilities.SudoUtil.assumeCanSudoShell) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) REPLACE_EXISTING(java.nio.file.StandardCopyOption.REPLACE_EXISTING) ServiceLoadException(com.aws.greengrass.lifecyclemanager.exceptions.ServiceLoadException) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Files(java.nio.file.Files) IOException(java.io.IOException) File(java.io.File) AfterEach(org.junit.jupiter.api.AfterEach) Matchers.hasItem(org.hamcrest.Matchers.hasItem) Paths(java.nio.file.Paths) ServiceUpdateException(com.aws.greengrass.deployment.exceptions.ServiceUpdateException) KernelConfigResolver(com.aws.greengrass.componentmanager.KernelConfigResolver) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) IsMapWithSize(org.hamcrest.collection.IsMapWithSize) Logger(com.aws.greengrass.logging.api.Logger) PackageLoadingException(com.aws.greengrass.componentmanager.exceptions.PackageLoadingException) SocketOptions(software.amazon.awssdk.crt.io.SocketOptions) URISyntaxException(java.net.URISyntaxException) Deployment(com.aws.greengrass.deployment.model.Deployment) Order(org.junit.jupiter.api.Order) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) DEFAULT_NUCLEUS_COMPONENT_NAME(com.aws.greengrass.deployment.DeviceConfiguration.DEFAULT_NUCLEUS_COMPONENT_NAME) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) State(com.aws.greengrass.dependency.State) BaseITCase(com.aws.greengrass.integrationtests.BaseITCase) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DEFAULT(com.aws.greengrass.deployment.model.Deployment.DeploymentStage.DEFAULT) DeploymentDocument(com.aws.greengrass.deployment.model.DeploymentDocument) URI(java.net.URI) TestUtils(com.aws.greengrass.testcommons.testutilities.TestUtils) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Topics(com.aws.greengrass.config.Topics) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) DeploymentDocumentDownloader(com.aws.greengrass.deployment.DeploymentDocumentDownloader) Optional(java.util.Optional) ComponentStore(com.aws.greengrass.componentmanager.ComponentStore) DeploymentConfigMerger(com.aws.greengrass.deployment.DeploymentConfigMerger) ConfigPlatformResolver(com.aws.greengrass.integrationtests.util.ConfigPlatformResolver) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ThingGroupHelper(com.aws.greengrass.deployment.ThingGroupHelper) MapperFeature(com.fasterxml.jackson.databind.MapperFeature) GreengrassService(com.aws.greengrass.lifecyclemanager.GreengrassService) Semver(com.vdurmont.semver4j.Semver) PackageDownloadException(com.aws.greengrass.componentmanager.exceptions.PackageDownloadException) PlatformResolver(com.aws.greengrass.config.PlatformResolver) ExecutorService(java.util.concurrent.ExecutorService) RUN_WITH_NAMESPACE_TOPIC(com.aws.greengrass.lifecyclemanager.GreengrassService.RUN_WITH_NAMESPACE_TOPIC) ImmutableMap(software.amazon.awssdk.utils.ImmutableMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Matchers(org.hamcrest.Matchers) ExceptionLogProtector.ignoreExceptionUltimateCauseOfType(com.aws.greengrass.testcommons.testutilities.ExceptionLogProtector.ignoreExceptionUltimateCauseOfType) EventStreamRPCConnection(software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection) SubscribeToComponentUpdatesRequest(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesRequest) FileMatchers.anExistingFile(org.hamcrest.io.FileMatchers.anExistingFile) MethodOrderer(org.junit.jupiter.api.MethodOrderer) IsMapContaining(org.hamcrest.collection.IsMapContaining) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Slf4jLogAdapter(com.aws.greengrass.logging.impl.Slf4jLogAdapter) Utils(com.aws.greengrass.util.Utils) NoOpPathOwnershipHandler(com.aws.greengrass.testcommons.testutilities.NoOpPathOwnershipHandler) DefaultDeploymentTask(com.aws.greengrass.deployment.DefaultDeploymentTask) Collections(java.util.Collections) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) Matchers.containsString(org.hamcrest.Matchers.containsString) DeploymentResult(com.aws.greengrass.deployment.model.DeploymentResult) CountDownLatch(java.util.concurrent.CountDownLatch) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Test(org.junit.jupiter.api.Test)

Example 3 with GreengrassLogMessage

use of com.aws.greengrass.logging.impl.GreengrassLogMessage in project aws-greengrass-nucleus by aws-greengrass.

the class DeploymentConfigMergingTest method GIVEN_kernel_running_single_service_WHEN_merge_changes_service_THEN_service_restarts_with_new_config.

@Test
void GIVEN_kernel_running_single_service_WHEN_merge_changes_service_THEN_service_restarts_with_new_config() throws Throwable {
    // GIVEN
    ConfigPlatformResolver.initKernelWithMultiPlatformConfig(kernel, getClass().getResource("single_service.yaml"));
    CountDownLatch mainRunning = new CountDownLatch(1);
    kernel.getContext().addGlobalStateChangeListener((service, oldState, newState) -> {
        if (service.getName().equals("main") && newState.equals(State.RUNNING)) {
            mainRunning.countDown();
        }
    });
    AtomicBoolean safeUpdateRegistered = new AtomicBoolean();
    Consumer<GreengrassLogMessage> listener = (m) -> {
        if ("register-service-update-action".equals(m.getEventType())) {
            safeUpdateRegistered.set(true);
        }
    };
    try (AutoCloseable l = createCloseableLogListener(listener)) {
        kernel.launch();
        assertTrue(mainRunning.await(5, TimeUnit.SECONDS));
        // WHEN
        CountDownLatch mainRestarted = new CountDownLatch(1);
        kernel.getContext().addGlobalStateChangeListener((service, oldState, newState) -> {
            if (service.getName().equals("main") && newState.equals(State.FINISHED) && oldState.equals(State.STARTING)) {
                mainRestarted.countDown();
            }
        });
        deploymentConfigMerger.mergeInNewConfig(testDeployment(), new HashMap<String, Object>() {

            {
                put(SERVICES_NAMESPACE_TOPIC, new HashMap<String, Object>() {

                    {
                        put("main", new HashMap<String, Object>() {

                            {
                                put(SETENV_CONFIG_NAMESPACE, new HashMap<String, Object>() {

                                    {
                                        put("HELLO", "redefined");
                                    }
                                });
                            }
                        });
                        put(DEFAULT_NUCLEUS_COMPONENT_NAME, getNucleusConfig());
                    }
                });
            }
        }).get(60, TimeUnit.SECONDS);
        // THEN
        assertTrue(mainRestarted.await(10, TimeUnit.SECONDS), "main restarted");
        assertEquals("redefined", kernel.findServiceTopic("main").find(SETENV_CONFIG_NAMESPACE, "HELLO").getOnce());
        assertTrue(safeUpdateRegistered.get(), "safe update registered");
    }
}
Also used : TestUtils.createCloseableLogListener(com.aws.greengrass.testcommons.testutilities.TestUtils.createCloseableLogListener) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) SocketOptions(software.amazon.awssdk.crt.io.SocketOptions) Deployment(com.aws.greengrass.deployment.model.Deployment) TimeoutException(java.util.concurrent.TimeoutException) Matchers.containsInRelativeOrder(org.hamcrest.Matchers.containsInRelativeOrder) ComponentUpdatePolicyEvents(software.amazon.awssdk.aws.greengrass.model.ComponentUpdatePolicyEvents) SubscribeToComponentUpdatesResponse(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesResponse) AfterAll(org.junit.jupiter.api.AfterAll) DEFAULT_NUCLEUS_COMPONENT_NAME(com.aws.greengrass.deployment.DeviceConfiguration.DEFAULT_NUCLEUS_COMPONENT_NAME) IPCTestUtils(com.aws.greengrass.integrationtests.ipc.IPCTestUtils) Future(java.util.concurrent.Future) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) State(com.aws.greengrass.dependency.State) BaseITCase(com.aws.greengrass.integrationtests.BaseITCase) BeforeAll(org.junit.jupiter.api.BeforeAll) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GenericExternalService(com.aws.greengrass.lifecyclemanager.GenericExternalService) FleetStatusService(com.aws.greengrass.status.FleetStatusService) DEFAULT(com.aws.greengrass.deployment.model.Deployment.DeploymentStage.DEFAULT) Duration(java.time.Duration) Map(java.util.Map) LogManager(com.aws.greengrass.logging.impl.LogManager) DeploymentDocument(com.aws.greengrass.deployment.model.DeploymentDocument) StreamResponseHandler(software.amazon.awssdk.eventstreamrpc.StreamResponseHandler) ComponentUpdatePolicy(com.aws.greengrass.deployment.model.ComponentUpdatePolicy) DeploymentResult(com.aws.greengrass.deployment.model.DeploymentResult) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GreengrassCoreIPCClient(software.amazon.awssdk.aws.greengrass.GreengrassCoreIPCClient) TestUtils(com.aws.greengrass.testcommons.testutilities.TestUtils) EventuallyLambdaMatcher.eventuallyEval(com.github.grantwest.eventually.EventuallyLambdaMatcher.eventuallyEval) Collectors(java.util.stream.Collectors) DeferComponentUpdateRequest(software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateRequest) TestUtils.createServiceStateChangeWaiter(com.aws.greengrass.testcommons.testutilities.TestUtils.createServiceStateChangeWaiter) Test(org.junit.jupiter.api.Test) Topics(com.aws.greengrass.config.Topics) Kernel(com.aws.greengrass.lifecyclemanager.Kernel) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) GlobalStateChangeListener(com.aws.greengrass.lifecyclemanager.GlobalStateChangeListener) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) LIFECYCLE_RUN_NAMESPACE_TOPIC(com.aws.greengrass.lifecyclemanager.GenericExternalService.LIFECYCLE_RUN_NAMESPACE_TOPIC) Matchers.is(org.hamcrest.Matchers.is) DeploymentConfigMerger(com.aws.greengrass.deployment.DeploymentConfigMerger) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ConfigPlatformResolver(com.aws.greengrass.integrationtests.util.ConfigPlatformResolver) DeploymentConfigurationValidationPolicy(software.amazon.awssdk.services.greengrassv2.model.DeploymentConfigurationValidationPolicy) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Coerce(com.aws.greengrass.util.Coerce) SKIP_NOTIFY_COMPONENTS(software.amazon.awssdk.services.greengrassv2.model.DeploymentComponentUpdatePolicyAction.SKIP_NOTIFY_COMPONENTS) ArrayList(java.util.ArrayList) GreengrassService(com.aws.greengrass.lifecyclemanager.GreengrassService) SudoUtil.assumeCanSudoShell(com.aws.greengrass.testcommons.testutilities.SudoUtil.assumeCanSudoShell) GGExtension(com.aws.greengrass.testcommons.testutilities.GGExtension) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PlatformResolver(com.aws.greengrass.config.PlatformResolver) ServiceLoadException(com.aws.greengrass.lifecyclemanager.exceptions.ServiceLoadException) SystemUtils(org.apache.commons.lang3.SystemUtils) Matchers(org.hamcrest.Matchers) EventStreamRPCConnection(software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection) IOException(java.io.IOException) NOTIFY_COMPONENTS(software.amazon.awssdk.services.greengrassv2.model.DeploymentComponentUpdatePolicyAction.NOTIFY_COMPONENTS) SubscribeToComponentUpdatesRequest(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesRequest) SUCCESSFUL(com.aws.greengrass.deployment.model.DeploymentResult.DeploymentStatus.SUCCESSFUL) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Topic(com.aws.greengrass.config.Topic) AfterEach(org.junit.jupiter.api.AfterEach) Matchers.hasItem(org.hamcrest.Matchers.hasItem) WhatHappened(com.aws.greengrass.config.WhatHappened) NoOpPathOwnershipHandler(com.aws.greengrass.testcommons.testutilities.NoOpPathOwnershipHandler) FailureHandlingPolicy(com.aws.greengrass.deployment.model.FailureHandlingPolicy) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) Logger(com.aws.greengrass.logging.api.Logger) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.jupiter.api.Test)

Example 4 with GreengrassLogMessage

use of com.aws.greengrass.logging.impl.GreengrassLogMessage in project aws-greengrass-nucleus by aws-greengrass.

the class DeploymentConfigMergingTest method GIVEN_kernel_running_single_service_WHEN_deployment_with_skip_safety_check_config_THEN_merge_without_checking_safety.

@Test
void GIVEN_kernel_running_single_service_WHEN_deployment_with_skip_safety_check_config_THEN_merge_without_checking_safety() throws Throwable {
    // GIVEN
    ConfigPlatformResolver.initKernelWithMultiPlatformConfig(kernel, getClass().getResource("single_service.yaml"));
    Runnable mainRunning = createServiceStateChangeWaiter(kernel, "main", 5, State.RUNNING);
    kernel.launch();
    mainRunning.run();
    // WHEN
    Runnable mainRestarted = createServiceStateChangeWaiter(kernel, "main", 10, State.FINISHED, State.STARTING);
    AtomicBoolean safeUpdateSkipped = new AtomicBoolean();
    Consumer<GreengrassLogMessage> listener = (m) -> {
        if ("Deployment is configured to skip update policy check, not waiting for disruptable time to update".equals(m.getMessage())) {
            safeUpdateSkipped.set(true);
        }
    };
    try (AutoCloseable l = createCloseableLogListener(listener)) {
        deploymentConfigMerger.mergeInNewConfig(testDeploymentWithSkipPolicyCheckConfig(), new HashMap<String, Object>() {

            {
                put(SERVICES_NAMESPACE_TOPIC, new HashMap<String, Object>() {

                    {
                        put("main", new HashMap<String, Object>() {

                            {
                                put(SETENV_CONFIG_NAMESPACE, new HashMap<String, Object>() {

                                    {
                                        put("HELLO", "redefined");
                                    }
                                });
                            }
                        });
                        put(DEFAULT_NUCLEUS_COMPONENT_NAME, getNucleusConfig());
                    }
                });
            }
        }).get(60, TimeUnit.SECONDS);
        // THEN
        mainRestarted.run();
        assertEquals("redefined", kernel.findServiceTopic("main").find(SETENV_CONFIG_NAMESPACE, "HELLO").getOnce());
        assertTrue(safeUpdateSkipped.get(), "safe updated skipped");
    }
}
Also used : TestUtils.createCloseableLogListener(com.aws.greengrass.testcommons.testutilities.TestUtils.createCloseableLogListener) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) SocketOptions(software.amazon.awssdk.crt.io.SocketOptions) Deployment(com.aws.greengrass.deployment.model.Deployment) TimeoutException(java.util.concurrent.TimeoutException) Matchers.containsInRelativeOrder(org.hamcrest.Matchers.containsInRelativeOrder) ComponentUpdatePolicyEvents(software.amazon.awssdk.aws.greengrass.model.ComponentUpdatePolicyEvents) SubscribeToComponentUpdatesResponse(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesResponse) AfterAll(org.junit.jupiter.api.AfterAll) DEFAULT_NUCLEUS_COMPONENT_NAME(com.aws.greengrass.deployment.DeviceConfiguration.DEFAULT_NUCLEUS_COMPONENT_NAME) IPCTestUtils(com.aws.greengrass.integrationtests.ipc.IPCTestUtils) Future(java.util.concurrent.Future) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) State(com.aws.greengrass.dependency.State) BaseITCase(com.aws.greengrass.integrationtests.BaseITCase) BeforeAll(org.junit.jupiter.api.BeforeAll) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GenericExternalService(com.aws.greengrass.lifecyclemanager.GenericExternalService) FleetStatusService(com.aws.greengrass.status.FleetStatusService) DEFAULT(com.aws.greengrass.deployment.model.Deployment.DeploymentStage.DEFAULT) Duration(java.time.Duration) Map(java.util.Map) LogManager(com.aws.greengrass.logging.impl.LogManager) DeploymentDocument(com.aws.greengrass.deployment.model.DeploymentDocument) StreamResponseHandler(software.amazon.awssdk.eventstreamrpc.StreamResponseHandler) ComponentUpdatePolicy(com.aws.greengrass.deployment.model.ComponentUpdatePolicy) DeploymentResult(com.aws.greengrass.deployment.model.DeploymentResult) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GreengrassCoreIPCClient(software.amazon.awssdk.aws.greengrass.GreengrassCoreIPCClient) TestUtils(com.aws.greengrass.testcommons.testutilities.TestUtils) EventuallyLambdaMatcher.eventuallyEval(com.github.grantwest.eventually.EventuallyLambdaMatcher.eventuallyEval) Collectors(java.util.stream.Collectors) DeferComponentUpdateRequest(software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateRequest) TestUtils.createServiceStateChangeWaiter(com.aws.greengrass.testcommons.testutilities.TestUtils.createServiceStateChangeWaiter) Test(org.junit.jupiter.api.Test) Topics(com.aws.greengrass.config.Topics) Kernel(com.aws.greengrass.lifecyclemanager.Kernel) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) GlobalStateChangeListener(com.aws.greengrass.lifecyclemanager.GlobalStateChangeListener) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) LIFECYCLE_RUN_NAMESPACE_TOPIC(com.aws.greengrass.lifecyclemanager.GenericExternalService.LIFECYCLE_RUN_NAMESPACE_TOPIC) Matchers.is(org.hamcrest.Matchers.is) DeploymentConfigMerger(com.aws.greengrass.deployment.DeploymentConfigMerger) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ConfigPlatformResolver(com.aws.greengrass.integrationtests.util.ConfigPlatformResolver) DeploymentConfigurationValidationPolicy(software.amazon.awssdk.services.greengrassv2.model.DeploymentConfigurationValidationPolicy) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Coerce(com.aws.greengrass.util.Coerce) SKIP_NOTIFY_COMPONENTS(software.amazon.awssdk.services.greengrassv2.model.DeploymentComponentUpdatePolicyAction.SKIP_NOTIFY_COMPONENTS) ArrayList(java.util.ArrayList) GreengrassService(com.aws.greengrass.lifecyclemanager.GreengrassService) SudoUtil.assumeCanSudoShell(com.aws.greengrass.testcommons.testutilities.SudoUtil.assumeCanSudoShell) GGExtension(com.aws.greengrass.testcommons.testutilities.GGExtension) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PlatformResolver(com.aws.greengrass.config.PlatformResolver) ServiceLoadException(com.aws.greengrass.lifecyclemanager.exceptions.ServiceLoadException) SystemUtils(org.apache.commons.lang3.SystemUtils) Matchers(org.hamcrest.Matchers) EventStreamRPCConnection(software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection) IOException(java.io.IOException) NOTIFY_COMPONENTS(software.amazon.awssdk.services.greengrassv2.model.DeploymentComponentUpdatePolicyAction.NOTIFY_COMPONENTS) SubscribeToComponentUpdatesRequest(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesRequest) SUCCESSFUL(com.aws.greengrass.deployment.model.DeploymentResult.DeploymentStatus.SUCCESSFUL) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Topic(com.aws.greengrass.config.Topic) AfterEach(org.junit.jupiter.api.AfterEach) Matchers.hasItem(org.hamcrest.Matchers.hasItem) WhatHappened(com.aws.greengrass.config.WhatHappened) NoOpPathOwnershipHandler(com.aws.greengrass.testcommons.testutilities.NoOpPathOwnershipHandler) FailureHandlingPolicy(com.aws.greengrass.deployment.model.FailureHandlingPolicy) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) Logger(com.aws.greengrass.logging.api.Logger) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.jupiter.api.Test)

Example 5 with GreengrassLogMessage

use of com.aws.greengrass.logging.impl.GreengrassLogMessage in project aws-greengrass-nucleus by aws-greengrass.

the class DeploymentServiceIntegrationTest method GIVEN_a_cloud_deployment_WHEN_receives_deployment_THEN_service_runs_and_deployment_succeeds.

@Test
void GIVEN_a_cloud_deployment_WHEN_receives_deployment_THEN_service_runs_and_deployment_succeeds() throws Exception {
    CountDownLatch cdlDeployRedSignal = new CountDownLatch(1);
    Consumer<GreengrassLogMessage> listener = m -> {
        if (m.getMessage() != null) {
            if (m.getMessage().contains("Current deployment finished") && m.getContexts().get("DeploymentId").equals("deployRedSignal")) {
                cdlDeployRedSignal.countDown();
            }
        }
    };
    try (AutoCloseable l = TestUtils.createCloseableLogListener(listener)) {
        CountDownLatch redSignalServiceLatch = new CountDownLatch(1);
        kernel.getContext().addGlobalStateChangeListener((service, oldState, newState) -> {
            if (service.getName().equals("RedSignal") && newState.equals(State.RUNNING)) {
                redSignalServiceLatch.countDown();
            }
        });
        submitSampleJobDocument(DeploymentServiceIntegrationTest.class.getResource("FleetConfigWithRedSignalService.json").toURI(), "deployRedSignal", // DeploymentType.SHADOW is used here and it
        DeploymentType.SHADOW);
        // is same for DeploymentType.IOT_JOBS
        assertTrue(redSignalServiceLatch.await(30, TimeUnit.SECONDS));
        assertTrue(cdlDeployRedSignal.await(30, TimeUnit.SECONDS));
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) Deployment(com.aws.greengrass.deployment.model.Deployment) TimeoutException(java.util.concurrent.TimeoutException) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) ComponentUpdatePolicyEvents(software.amazon.awssdk.aws.greengrass.model.ComponentUpdatePolicyEvents) IPCTestUtils(com.aws.greengrass.integrationtests.ipc.IPCTestUtils) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) State(com.aws.greengrass.dependency.State) BaseITCase(com.aws.greengrass.integrationtests.BaseITCase) FleetStatusService(com.aws.greengrass.status.FleetStatusService) Map(java.util.Map) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) DeploymentStatusKeeper(com.aws.greengrass.deployment.DeploymentStatusKeeper) LogManager(com.aws.greengrass.logging.impl.LogManager) DeploymentDocument(com.aws.greengrass.deployment.model.DeploymentDocument) URI(java.net.URI) StreamResponseHandler(software.amazon.awssdk.eventstreamrpc.StreamResponseHandler) Path(java.nio.file.Path) DEPLOYMENT_SERVICE_TOPICS(com.aws.greengrass.deployment.DeploymentService.DEPLOYMENT_SERVICE_TOPICS) FLEET_STATUS_SERVICE_TOPICS(com.aws.greengrass.status.FleetStatusService.FLEET_STATUS_SERVICE_TOPICS) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) LocalOverrideRequest(com.aws.greengrass.deployment.model.LocalOverrideRequest) GreengrassCoreIPCClient(software.amazon.awssdk.aws.greengrass.GreengrassCoreIPCClient) DEPLOYMENT_STATUS_KEY_NAME(com.aws.greengrass.deployment.DeploymentStatusKeeper.DEPLOYMENT_STATUS_KEY_NAME) Utils.copyFolderRecursively(com.aws.greengrass.util.Utils.copyFolderRecursively) TestUtils(com.aws.greengrass.testcommons.testutilities.TestUtils) DeploymentDocumentConverter.convertFromDeploymentConfiguration(com.aws.greengrass.deployment.converter.DeploymentDocumentConverter.convertFromDeploymentConfiguration) ExceptionLogProtector.ignoreExceptionOfType(com.aws.greengrass.testcommons.testutilities.ExceptionLogProtector.ignoreExceptionOfType) DeferComponentUpdateRequest(software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateRequest) SdkClientException(software.amazon.awssdk.core.exception.SdkClientException) Test(org.junit.jupiter.api.Test) Kernel(com.aws.greengrass.lifecyclemanager.Kernel) CountDownLatch(java.util.concurrent.CountDownLatch) DEFAULT_IPC_API_TIMEOUT_SECONDS(com.aws.greengrass.integrationtests.ipc.IPCTestUtils.DEFAULT_IPC_API_TIMEOUT_SECONDS) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) DeploymentDocumentDownloader(com.aws.greengrass.deployment.DeploymentDocumentDownloader) Optional(java.util.Optional) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) PreloadComponentStoreHelper(com.aws.greengrass.helper.PreloadComponentStoreHelper) SYSTEM_RESOURCE_LIMITS_TOPICS(com.aws.greengrass.lifecyclemanager.GreengrassService.SYSTEM_RESOURCE_LIMITS_TOPICS) Mock(org.mockito.Mock) DeploymentQueue(com.aws.greengrass.deployment.DeploymentQueue) ConfigPlatformResolver(com.aws.greengrass.integrationtests.util.ConfigPlatformResolver) HashMap(java.util.HashMap) DEPLOYMENT_STATUS_DETAILS_KEY_NAME(com.aws.greengrass.deployment.DeploymentStatusKeeper.DEPLOYMENT_STATUS_DETAILS_KEY_NAME) Configuration(com.amazon.aws.iot.greengrass.configuration.common.Configuration) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) DeviceConfiguration(com.aws.greengrass.deployment.DeviceConfiguration) Coerce(com.aws.greengrass.util.Coerce) PackageDownloadException(com.aws.greengrass.componentmanager.exceptions.PackageDownloadException) GGExtension(com.aws.greengrass.testcommons.testutilities.GGExtension) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) REPLACE_EXISTING(java.nio.file.StandardCopyOption.REPLACE_EXISTING) DeploymentType(com.aws.greengrass.deployment.model.Deployment.DeploymentType) RUN_WITH_NAMESPACE_TOPIC(com.aws.greengrass.lifecyclemanager.GreengrassService.RUN_WITH_NAMESPACE_TOPIC) OS(org.junit.jupiter.api.condition.OS) DEPLOYMENT_FAILURE_CAUSE_KEY(com.aws.greengrass.deployment.DeploymentService.DEPLOYMENT_FAILURE_CAUSE_KEY) DEPLOYMENT_ID_KEY_NAME(com.aws.greengrass.deployment.DeploymentStatusKeeper.DEPLOYMENT_ID_KEY_NAME) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EventStreamRPCConnection(software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection) SubscribeToComponentUpdatesRequest(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesRequest) Mockito.when(org.mockito.Mockito.when) File(java.io.File) IsMapContaining(org.hamcrest.collection.IsMapContaining) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) AfterEach(org.junit.jupiter.api.AfterEach) Paths(java.nio.file.Paths) NoOpPathOwnershipHandler(com.aws.greengrass.testcommons.testutilities.NoOpPathOwnershipHandler) KernelConfigResolver(com.aws.greengrass.componentmanager.KernelConfigResolver) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) Collections(java.util.Collections) Logger(com.aws.greengrass.logging.api.Logger) GreengrassLogMessage(com.aws.greengrass.logging.impl.GreengrassLogMessage) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.jupiter.api.Test)

Aggregations

GreengrassLogMessage (com.aws.greengrass.logging.impl.GreengrassLogMessage)30 Test (org.junit.jupiter.api.Test)27 CountDownLatch (java.util.concurrent.CountDownLatch)25 Map (java.util.Map)20 TimeUnit (java.util.concurrent.TimeUnit)20 Consumer (java.util.function.Consumer)20 AfterEach (org.junit.jupiter.api.AfterEach)20 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)20 BeforeEach (org.junit.jupiter.api.BeforeEach)20 State (com.aws.greengrass.dependency.State)19 HashMap (java.util.HashMap)19 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)19 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)19 TestUtils (com.aws.greengrass.testcommons.testutilities.TestUtils)17 Coerce (com.aws.greengrass.util.Coerce)17 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)17 GreengrassCoreIPCClient (software.amazon.awssdk.aws.greengrass.GreengrassCoreIPCClient)17 ComponentUpdatePolicyEvents (software.amazon.awssdk.aws.greengrass.model.ComponentUpdatePolicyEvents)17 DeferComponentUpdateRequest (software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateRequest)17 SubscribeToComponentUpdatesRequest (software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesRequest)17