use of com.aws.greengrass.componentmanager.models.ComponentArtifact in project aws-greengrass-nucleus by aws-greengrass.
the class ComponentManagerTest method GIVEN_deployment_WHEN_dependency_closure_is_missing_download_prereq_component_THEN_fail.
@Test
void GIVEN_deployment_WHEN_dependency_closure_is_missing_download_prereq_component_THEN_fail() throws Exception {
ComponentIdentifier testComponent = new ComponentIdentifier("test.component", new Semver("1.0.0"));
ComponentRecipe mockRecipe = mock(ComponentRecipe.class);
Optional<ComponentRecipe> recipeResult = Optional.of(mockRecipe);
// Private ECR image
List<ComponentArtifact> artifacts = Collections.singletonList(ComponentArtifact.builder().artifactUri(new URI("s3://some/artifact")).build());
when(mockRecipe.getArtifacts()).thenReturn(artifacts);
when(componentStore.findPackageRecipe(any())).thenReturn(recipeResult);
doThrow(new MissingRequiredComponentsException("Missing required component for download")).when(artifactDownloaderFactory).checkDownloadPrerequisites(any(), any(), any());
List<ComponentIdentifier> dependencyClosure = Arrays.asList(testComponent);
assertThrows(MissingRequiredComponentsException.class, () -> componentManager.checkPreparePackagesPrerequisites(dependencyClosure));
}
use of com.aws.greengrass.componentmanager.models.ComponentArtifact in project aws-greengrass-nucleus by aws-greengrass.
the class ComponentManagerTest method GIVEN_deployment_WHEN_dependency_closure_has_download_prereq_component_THEN_succeed.
@Test
void GIVEN_deployment_WHEN_dependency_closure_has_download_prereq_component_THEN_succeed() throws Exception {
ComponentIdentifier testComponent = new ComponentIdentifier("test.component", new Semver("1.0.0"));
ComponentRecipe mockRecipe = mock(ComponentRecipe.class);
Optional<ComponentRecipe> recipeResult = Optional.of(mockRecipe);
// Private ECR image
List<ComponentArtifact> artifacts = Collections.singletonList(ComponentArtifact.builder().artifactUri(new URI("s3://some/artifact")).build());
when(mockRecipe.getArtifacts()).thenReturn(artifacts);
when(componentStore.findPackageRecipe(any())).thenReturn(recipeResult);
List<ComponentIdentifier> dependencyClosure = Arrays.asList(testComponent);
componentManager.checkPreparePackagesPrerequisites(dependencyClosure);
}
use of com.aws.greengrass.componentmanager.models.ComponentArtifact in project aws-greengrass-nucleus by aws-greengrass.
the class ArtifactDownloaderFactoryTest method GIVEN_deployment_has_component_requiring_download_plugins_WHEN_deployment_has_no_download_prereq_component_THEN_fail_1.
@Test
void GIVEN_deployment_has_component_requiring_download_plugins_WHEN_deployment_has_no_download_prereq_component_THEN_fail_1() throws Exception {
ComponentIdentifier testComponent = new ComponentIdentifier("test.component", new Semver("1.0.0"));
// Private ECR image
List<ComponentArtifact> artifacts = Collections.singletonList(ComponentArtifact.builder().artifactUri(new URI("docker:012345678910.dkr.ecr.us-east-1.amazonaws.com/test_image")).build());
List<ComponentIdentifier> dependencyClosure = Arrays.asList(testComponent);
Throwable err = assertThrows(MissingRequiredComponentsException.class, () -> artifactDownloaderFactory.checkDownloadPrerequisites(artifacts, testComponent, dependencyClosure));
assertThat(err.getMessage(), containsString(DOCKER_PLUGIN_REQUIRED_ERROR_MSG));
}
use of com.aws.greengrass.componentmanager.models.ComponentArtifact in project aws-greengrass-nucleus by aws-greengrass.
the class ArtifactDownloaderFactoryTest method GIVEN_artifact_from_gg_repo_WHEN_attempt_download_artifact_THEN_invoke_gg_downloader.
@Test
void GIVEN_artifact_from_gg_repo_WHEN_attempt_download_artifact_THEN_invoke_gg_downloader() throws Exception {
ComponentIdentifier pkgId = new ComponentIdentifier("CoolService", new Semver("1.0.0"));
ComponentArtifact artifact = ComponentArtifact.builder().artifactUri(new URI("greengrass:binary2")).build();
ArtifactDownloader artifactDownloader = artifactDownloaderFactory.getArtifactDownloader(pkgId, artifact, testDir);
assertThat(artifactDownloader, IsInstanceOf.instanceOf(GreengrassRepositoryDownloader.class));
}
use of com.aws.greengrass.componentmanager.models.ComponentArtifact in project aws-greengrass-nucleus by aws-greengrass.
the class ArtifactDownloaderFactoryTest method GIVEN_deployment_has_component_requiring_download_plugins_WHEN_deployment_has_no_download_prereq_component_THEN_fail_2.
@Test
void GIVEN_deployment_has_component_requiring_download_plugins_WHEN_deployment_has_no_download_prereq_component_THEN_fail_2() throws Exception {
ComponentIdentifier testComponent = new ComponentIdentifier("test.component", new Semver("1.0.0"));
// Private ECR image
List<ComponentArtifact> artifacts = Collections.singletonList(ComponentArtifact.builder().artifactUri(new URI("docker:012345678910.dkr.ecr.us-east-1.amazonaws.com/test_image")).build());
List<ComponentIdentifier> dependencyClosure = Arrays.asList(new ComponentIdentifier(DOCKER_MANAGER_PLUGIN_SERVICE_NAME, new Semver("2.0.0")), testComponent);
Throwable err = assertThrows(MissingRequiredComponentsException.class, () -> artifactDownloaderFactory.checkDownloadPrerequisites(artifacts, testComponent, dependencyClosure));
assertThat(err.getMessage(), containsString(TOKEN_EXCHANGE_SERVICE_REQUIRED_ERROR_MSG));
}
Aggregations