Search in sources :

Example 1 with DEPLOYMENT_FAILURE_CAUSE_KEY

use of com.aws.greengrass.deployment.DeploymentService.DEPLOYMENT_FAILURE_CAUSE_KEY in project aws-greengrass-nucleus by aws-greengrass.

the class DeploymentServiceIntegrationTest method GIVEN_cloud_deployment_has_required_capabilities_WHEN_receives_deployment_THEN_fail_with_proper_detailed_status.

@Test
void GIVEN_cloud_deployment_has_required_capabilities_WHEN_receives_deployment_THEN_fail_with_proper_detailed_status() 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();
            }
        }
    };
    CountDownLatch deploymentCDL = new CountDownLatch(1);
    DeploymentStatusKeeper deploymentStatusKeeper = kernel.getContext().get(DeploymentStatusKeeper.class);
    deploymentStatusKeeper.registerDeploymentStatusConsumer(DeploymentType.SHADOW, (status) -> {
        if (status.get(DEPLOYMENT_ID_KEY_NAME).equals("deployRedSignal") && status.get(DEPLOYMENT_STATUS_KEY_NAME).equals("FAILED")) {
            deploymentCDL.countDown();
            assertThat(((Map) status.get(DEPLOYMENT_STATUS_DETAILS_KEY_NAME)).get(DEPLOYMENT_FAILURE_CAUSE_KEY), equalTo("The current nucleus version doesn't support one or more capabilities that are required by " + "this deployment: ANOTHER_CAPABILITY"));
        }
        return true;
    }, "dummy");
    try (AutoCloseable l = TestUtils.createCloseableLogListener(listener)) {
        submitSampleJobDocument(DeploymentServiceIntegrationTest.class.getResource("FleetConfigWithRequiredCapability.json").toURI(), "deployRedSignal", DeploymentType.SHADOW);
        assertTrue(cdlDeployRedSignal.await(30, TimeUnit.SECONDS));
        assertTrue(deploymentCDL.await(10, 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) DeploymentStatusKeeper(com.aws.greengrass.deployment.DeploymentStatusKeeper) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.jupiter.api.Test)

Aggregations

Configuration (com.amazon.aws.iot.greengrass.configuration.common.Configuration)1 KernelConfigResolver (com.aws.greengrass.componentmanager.KernelConfigResolver)1 PackageDownloadException (com.aws.greengrass.componentmanager.exceptions.PackageDownloadException)1 State (com.aws.greengrass.dependency.State)1 DeploymentDocumentDownloader (com.aws.greengrass.deployment.DeploymentDocumentDownloader)1 DeploymentQueue (com.aws.greengrass.deployment.DeploymentQueue)1 DEPLOYMENT_FAILURE_CAUSE_KEY (com.aws.greengrass.deployment.DeploymentService.DEPLOYMENT_FAILURE_CAUSE_KEY)1 DEPLOYMENT_SERVICE_TOPICS (com.aws.greengrass.deployment.DeploymentService.DEPLOYMENT_SERVICE_TOPICS)1 DeploymentStatusKeeper (com.aws.greengrass.deployment.DeploymentStatusKeeper)1 DEPLOYMENT_ID_KEY_NAME (com.aws.greengrass.deployment.DeploymentStatusKeeper.DEPLOYMENT_ID_KEY_NAME)1 DEPLOYMENT_STATUS_DETAILS_KEY_NAME (com.aws.greengrass.deployment.DeploymentStatusKeeper.DEPLOYMENT_STATUS_DETAILS_KEY_NAME)1 DEPLOYMENT_STATUS_KEY_NAME (com.aws.greengrass.deployment.DeploymentStatusKeeper.DEPLOYMENT_STATUS_KEY_NAME)1 DeviceConfiguration (com.aws.greengrass.deployment.DeviceConfiguration)1 DeploymentDocumentConverter.convertFromDeploymentConfiguration (com.aws.greengrass.deployment.converter.DeploymentDocumentConverter.convertFromDeploymentConfiguration)1 Deployment (com.aws.greengrass.deployment.model.Deployment)1 DeploymentType (com.aws.greengrass.deployment.model.Deployment.DeploymentType)1 DeploymentDocument (com.aws.greengrass.deployment.model.DeploymentDocument)1 LocalOverrideRequest (com.aws.greengrass.deployment.model.LocalOverrideRequest)1 PreloadComponentStoreHelper (com.aws.greengrass.helper.PreloadComponentStoreHelper)1 BaseITCase (com.aws.greengrass.integrationtests.BaseITCase)1