From 23a5f85ee9fb2f95fb6550760ff4e336a543f236 Mon Sep 17 00:00:00 2001 From: Michael Dombrowski Date: Tue, 26 Mar 2024 13:54:05 -0400 Subject: [PATCH] fix(idt): remove cmd and bash requirements --- .../testing/features/DeploymentSteps.java | 14 +++++++----- .../testing/features/GreengrassCliSteps.java | 22 ++++++------------- .../hello_world_recipe_multiplatform.yaml | 12 +--------- .../local_hello_world_multiplatform.yaml | 12 +--------- 4 files changed, 18 insertions(+), 42 deletions(-) diff --git a/aws-greengrass-testing-features/aws-greengrass-testing-features-api/src/main/java/com/aws/greengrass/testing/features/DeploymentSteps.java b/aws-greengrass-testing-features/aws-greengrass-testing-features-api/src/main/java/com/aws/greengrass/testing/features/DeploymentSteps.java index 1fc76331..25eeafbe 100644 --- a/aws-greengrass-testing-features/aws-greengrass-testing-features-api/src/main/java/com/aws/greengrass/testing/features/DeploymentSteps.java +++ b/aws-greengrass-testing-features/aws-greengrass-testing-features-api/src/main/java/com/aws/greengrass/testing/features/DeploymentSteps.java @@ -77,9 +77,9 @@ public class DeploymentSteps { GreengrassDeploymentSpec deployment; - private Platform platform; - private Path artifactPath; - private Path recipePath; + private final Platform platform; + private final Path artifactPath; + private final Path recipePath; @Inject @SuppressWarnings("MissingJavadocMethod") @@ -276,11 +276,12 @@ private String executeCommandWithConfigs(CommandInput commandInput) { * @throws InterruptedException Task interrupted */ @When("I create a local deployment with components") - public void createLocalDeployment(List> componentNames) throws InterruptedException { + public void createLocalDeployment(List> componentNames) throws InterruptedException, IOException { createLocalDeployment(componentNames, 0); } - private void createLocalDeployment(List> componentNames, int retryCount) throws InterruptedException { + private void createLocalDeployment(List> componentNames, int retryCount) + throws InterruptedException, IOException { // find the component artifacts and copy into a local store final Map components = parseComponentNamesAndPrepare(componentNames); @@ -291,6 +292,9 @@ private void createLocalDeployment(List> componentNames, int retryC "--artifactDir " + artifactPath.toString(), "--recipeDir " + recipePath.toString())); + Files.createDirectories(artifactPath); + Files.createDirectories(recipePath); + for (Map.Entry entry : components.entrySet()) { commandArgs.add(" --merge "); commandArgs.add(entry.getKey() + "=" + entry.getValue().componentVersion()); diff --git a/aws-greengrass-testing-features/aws-greengrass-testing-features-api/src/main/java/com/aws/greengrass/testing/features/GreengrassCliSteps.java b/aws-greengrass-testing-features/aws-greengrass-testing-features-api/src/main/java/com/aws/greengrass/testing/features/GreengrassCliSteps.java index a08d1b60..345c57a1 100644 --- a/aws-greengrass-testing-features/aws-greengrass-testing-features-api/src/main/java/com/aws/greengrass/testing/features/GreengrassCliSteps.java +++ b/aws-greengrass-testing-features/aws-greengrass-testing-features-api/src/main/java/com/aws/greengrass/testing/features/GreengrassCliSteps.java @@ -25,24 +25,18 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; -import static com.aws.greengrass.testing.component.LocalComponentPreparationService.ARTIFACTS_DIR; -import static com.aws.greengrass.testing.component.LocalComponentPreparationService.LOCAL_STORE; -import static com.aws.greengrass.testing.component.LocalComponentPreparationService.RECIPE_DIR; - @ScenarioScoped public class GreengrassCliSteps { public static final String LOCAL_DEPLOYMENT_ID = "localDeploymentId"; - private Platform platform; - private Path artifactPath; - private Path recipePath; - private TestContext testContext; - private ScenarioContext scenarioContext; - private ComponentPreparationService componentPreparation; - private WaitSteps waitSteps; + private final Platform platform; + private final TestContext testContext; + private final ScenarioContext scenarioContext; + private final ComponentPreparationService componentPreparation; + private final WaitSteps waitSteps; - private static Logger LOGGER = LogManager.getLogger(GreengrassCliSteps.class); + private static final Logger LOGGER = LogManager.getLogger(GreengrassCliSteps.class); @Inject @SuppressWarnings("MissingJavadocMethod") @@ -54,8 +48,6 @@ public GreengrassCliSteps(Platform platform, TestContext testContext, this.componentPreparation = componentPreparation; this.scenarioContext = scenarioContext; this.waitSteps = waitSteps; - this.artifactPath = testContext.testDirectory().resolve(LOCAL_STORE).resolve(ARTIFACTS_DIR);; - this.recipePath = testContext.testDirectory().resolve(LOCAL_STORE).resolve(RECIPE_DIR); } /** @@ -99,7 +91,7 @@ public void verifyLocalDeployment(String status, int value, String unit) throws terminalStatuses.add("SUCCEEDED"); terminalStatuses.add("FAILED"); TimeUnit timeUnit = TimeUnit.valueOf(unit.toUpperCase()); - waitSteps.untilTerminal(() -> this.getLocalDeploymentStatus(), status::equals, + waitSteps.untilTerminal(this::getLocalDeploymentStatus, status::equals, terminalStatuses::contains, value, timeUnit); } diff --git a/aws-greengrass-testing-features/aws-greengrass-testing-features-cloudcomponent/src/main/resources/greengrass/components/recipes/hello_world_recipe_multiplatform.yaml b/aws-greengrass-testing-features/aws-greengrass-testing-features-cloudcomponent/src/main/resources/greengrass/components/recipes/hello_world_recipe_multiplatform.yaml index dce23e37..7a170dee 100644 --- a/aws-greengrass-testing-features/aws-greengrass-testing-features-cloudcomponent/src/main/resources/greengrass/components/recipes/hello_world_recipe_multiplatform.yaml +++ b/aws-greengrass-testing-features/aws-greengrass-testing-features-cloudcomponent/src/main/resources/greengrass/components/recipes/hello_world_recipe_multiplatform.yaml @@ -12,21 +12,11 @@ ComponentPublisher: Amazon Manifests: - Platform: os: windows - Artifacts: - - URI: "file:C:/Windows/System32/cmd.exe" - Permission: - Read: ALL - Execute: ALL Lifecycle: run: | cmd /c echo "Hello World!" - Platform: os: linux - Artifacts: - - URI: file:/bin/bash - Permission: - Read: ALL - Execute: ALL Lifecycle: run: | - bash -c "echo -ne \"Hello World!\n\"" + echo "Hello World!" diff --git a/aws-greengrass-testing-features/aws-greengrass-testing-features-localdeployment/src/main/resources/greengrass/components/recipes/local_hello_world_multiplatform.yaml b/aws-greengrass-testing-features/aws-greengrass-testing-features-localdeployment/src/main/resources/greengrass/components/recipes/local_hello_world_multiplatform.yaml index b6f1647a..87889071 100644 --- a/aws-greengrass-testing-features/aws-greengrass-testing-features-localdeployment/src/main/resources/greengrass/components/recipes/local_hello_world_multiplatform.yaml +++ b/aws-greengrass-testing-features/aws-greengrass-testing-features-localdeployment/src/main/resources/greengrass/components/recipes/local_hello_world_multiplatform.yaml @@ -12,21 +12,11 @@ ComponentPublisher: Amazon Manifests: - Platform: os: windows - Artifacts: - - URI: "file:C:/Windows/System32/cmd.exe" - Permission: - Read: ALL - Execute: ALL Lifecycle: run: | cmd /c echo "Hello World!" - Platform: os: linux - Artifacts: - - URI: file:/bin/bash - Permission: - Read: ALL - Execute: ALL Lifecycle: run: | - bash -c "echo -ne \"Hello World!\n\"" + echo "Hello World!"