Search in sources :

Example 1 with ComponentArtifact

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));
}
Also used : MissingRequiredComponentsException(com.aws.greengrass.componentmanager.exceptions.MissingRequiredComponentsException) ComponentIdentifier(com.aws.greengrass.componentmanager.models.ComponentIdentifier) ComponentArtifact(com.aws.greengrass.componentmanager.models.ComponentArtifact) ComponentRecipe(com.aws.greengrass.componentmanager.models.ComponentRecipe) Semver(com.vdurmont.semver4j.Semver) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 2 with ComponentArtifact

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);
}
Also used : ComponentIdentifier(com.aws.greengrass.componentmanager.models.ComponentIdentifier) ComponentArtifact(com.aws.greengrass.componentmanager.models.ComponentArtifact) ComponentRecipe(com.aws.greengrass.componentmanager.models.ComponentRecipe) Semver(com.vdurmont.semver4j.Semver) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 3 with ComponentArtifact

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));
}
Also used : ComponentIdentifier(com.aws.greengrass.componentmanager.models.ComponentIdentifier) ComponentArtifact(com.aws.greengrass.componentmanager.models.ComponentArtifact) Semver(com.vdurmont.semver4j.Semver) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 4 with ComponentArtifact

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));
}
Also used : ComponentIdentifier(com.aws.greengrass.componentmanager.models.ComponentIdentifier) ComponentArtifact(com.aws.greengrass.componentmanager.models.ComponentArtifact) Semver(com.vdurmont.semver4j.Semver) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 5 with ComponentArtifact

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));
}
Also used : ComponentIdentifier(com.aws.greengrass.componentmanager.models.ComponentIdentifier) ComponentArtifact(com.aws.greengrass.componentmanager.models.ComponentArtifact) Semver(com.vdurmont.semver4j.Semver) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Aggregations

ComponentArtifact (com.aws.greengrass.componentmanager.models.ComponentArtifact)27 Test (org.junit.jupiter.api.Test)26 URI (java.net.URI)16 ComponentIdentifier (com.aws.greengrass.componentmanager.models.ComponentIdentifier)14 Semver (com.vdurmont.semver4j.Semver)14 Matchers.containsString (org.hamcrest.Matchers.containsString)10 File (java.io.File)7 ComponentRecipe (com.aws.greengrass.componentmanager.models.ComponentRecipe)4 ArtifactChecksumMismatchException (com.aws.greengrass.componentmanager.exceptions.ArtifactChecksumMismatchException)3 MissingRequiredComponentsException (com.aws.greengrass.componentmanager.exceptions.MissingRequiredComponentsException)3 PackageDownloadException (com.aws.greengrass.componentmanager.exceptions.PackageDownloadException)3 IOException (java.io.IOException)3 DependencyProperties (com.amazon.aws.iot.greengrass.component.common.DependencyProperties)2 PackageLoadingException (com.aws.greengrass.componentmanager.exceptions.PackageLoadingException)2 Path (java.nio.file.Path)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 EnabledOnOs (org.junit.jupiter.api.condition.EnabledOnOs)2 Unarchive (com.amazon.aws.iot.greengrass.component.common.Unarchive)1 ArtifactDownloader (com.aws.greengrass.componentmanager.builtins.ArtifactDownloader)1 SizeLimitException (com.aws.greengrass.componentmanager.exceptions.SizeLimitException)1