Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: handle new local deployment status format #236

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ String getLocalDeploymentStatus() {
.build());
LOGGER.debug(String.format("deployment status response received for deployment ID %s is %s",
deploymentId, response));
String[] responseArray = response.split(":");
return responseArray[responseArray.length - 1].trim();
// compatible with CLI <2.11.0 where deployment status output is just one line
return Arrays.stream(response.split("\n"))
.filter(line -> line.contains(":"))
.findFirst() // status is the first line
.map(statusLine -> statusLine.split(": "))
.map(statusParts -> statusParts.length == 2 ? statusParts[1] : null)
.orElse("UNKNOWN");
} catch (CommandExecutionException e) {
LOGGER.info("Exception occurred while getting the deployment status. Will try again", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import com.aws.greengrass.testing.api.model.InitializationContext;
import com.aws.greengrass.testing.api.model.TestId;
import com.aws.greengrass.testing.api.model.TimeoutMultiplier;
import com.aws.greengrass.testing.features.GreengrassCliSteps;
import com.aws.greengrass.testing.features.WaitSteps;
import com.aws.greengrass.testing.model.ScenarioContext;
import com.aws.greengrass.testing.model.TestContext;
import com.aws.greengrass.testing.platform.Commands;
Expand Down Expand Up @@ -110,6 +108,11 @@ void GIVEN_a_valid_deployment_id_WHEN_get_local_deployment_status_THEN_it_return
.executeToString(expectedCommandInput);

assertEquals("SUCCEEDED", greengrassCliSteps.getLocalDeploymentStatus());

// simulate response for cli version >=2.11.0 that has multiple lines
Mockito.doReturn(String.format("%s: SUCCEEDED\nCreated on: 1/1/1 11:11 AM", MOCK_DEPLOYMENT_ID))
.when(mockedCommands).executeToString(expectedCommandInput);
assertEquals("SUCCEEDED", greengrassCliSteps.getLocalDeploymentStatus());
}

private TestContext initializeMockTestContext() {
Expand Down
Loading