Skip to content

Commit

Permalink
fix(idt): remove cmd and bash requirements (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDombo authored Mar 26, 2024
1 parent 45934c8 commit c6a7f7f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public class DeploymentSteps {


private Platform platform;
private Path artifactPath;
private Path recipePath;
private final Path artifactPath;
private final Path recipePath;

@Inject
@SuppressWarnings("MissingJavadocMethod")
Expand Down Expand Up @@ -274,13 +274,15 @@ private String executeCommandWithConfigs(CommandInput commandInput) {
* Create a local deployment using greengrass cli.
* @param componentNames map of component name to source of the component
* @throws InterruptedException Task interrupted
* @throws IOException if required directories cannot be made
*/
@When("I create a local deployment with components")
public void createLocalDeployment(List<List<String>> componentNames) throws InterruptedException {
public void createLocalDeployment(List<List<String>> componentNames) throws InterruptedException, IOException {
createLocalDeployment(componentNames, 0);
}

private void createLocalDeployment(List<List<String>> componentNames, int retryCount) throws InterruptedException {
private void createLocalDeployment(List<List<String>> componentNames, int retryCount)
throws InterruptedException, IOException {
// find the component artifacts and copy into a local store
final Map<String, ComponentDeploymentSpecification> components = parseComponentNamesAndPrepare(componentNames);

Expand All @@ -291,6 +293,9 @@ private void createLocalDeployment(List<List<String>> componentNames, int retryC
"--artifactDir " + artifactPath.toString(),
"--recipeDir " + recipePath.toString()));

Files.createDirectories(artifactPath);
Files.createDirectories(recipePath);

for (Map.Entry<String, ComponentDeploymentSpecification> entry : components.entrySet()) {
commandArgs.add(" --merge ");
commandArgs.add(entry.getKey() + "=" + entry.getValue().componentVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Original file line number Diff line number Diff line change
Expand Up @@ -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!"

0 comments on commit c6a7f7f

Please sign in to comment.