Skip to content

Commit

Permalink
qa
Browse files Browse the repository at this point in the history
 - lowering retries
 - removed docker caching between steps (cache failed frequently with 429)
 - timeout added for another job step
 - Fixed test with multiple test creation
 - conflict fixes
 - docker steps minor fixes
 - disabled containers log on teardown
 - cleaning up job steps
 - replacing wait step with loop with timeout
 - clean up test code
 - increase log for debug purpose
 - adding wait loop when looking for device events
 - replacing wait step with loop with timeout

Signed-off-by: riccardomodanese <riccardo.modanese@eurotech.com>
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
riccardomodanese committed Oct 15, 2021
1 parent 730a6bf commit 9b457b1
Show file tree
Hide file tree
Showing 24 changed files with 1,170 additions and 1,533 deletions.
220 changes: 48 additions & 172 deletions .github/workflows/github-actions.yaml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,12 @@
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-junit</artifactId>
<version>${artemis.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,14 @@ public class DockerSteps {
DEFAULT_DEPLOYMENT_CONTAINERS_NAME.add(BasicSteps.TELEMETRY_CONSUMER_CONTAINER_NAME);
DEFAULT_DEPLOYMENT_CONTAINERS_NAME.add(BasicSteps.LIFECYCLE_CONSUMER_CONTAINER_NAME);
DEFAULT_DEPLOYMENT_CONTAINERS_NAME.add(BasicSteps.MESSAGE_BROKER_CONTAINER_NAME);
DEFAULT_DEPLOYMENT_CONTAINERS_NAME.add("/" + BasicSteps.TELEMETRY_CONSUMER_CONTAINER_NAME);
DEFAULT_DEPLOYMENT_CONTAINERS_NAME.add("/" + BasicSteps.LIFECYCLE_CONSUMER_CONTAINER_NAME);
DEFAULT_DEPLOYMENT_CONTAINERS_NAME.add("/" + BasicSteps.MESSAGE_BROKER_CONTAINER_NAME);
DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME = new ArrayList<>();
DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME.add(BasicSteps.JOB_ENGINE_CONTAINER_NAME);
DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME.add(BasicSteps.EVENTS_BROKER_CONTAINER_NAME);
DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME.add(BasicSteps.ES_CONTAINER_NAME);
DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME.add(BasicSteps.DB_CONTAINER_NAME);
DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME.add("/" + BasicSteps.JOB_ENGINE_CONTAINER_NAME);
DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME.add("/" + BasicSteps.EVENTS_BROKER_CONTAINER_NAME);
DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME.add("/" + BasicSteps.ES_CONTAINER_NAME);
DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME.add("/" + BasicSteps.DB_CONTAINER_NAME);
}

private boolean printContainerLogOnContainerExit = true;
private boolean printContainerLogOnContainerExit;
private NetworkConfig networkConfig;
private String networkId;
private boolean debug;
Expand Down Expand Up @@ -206,13 +199,13 @@ public void startFullDockerEnvironment() throws Exception {
stopFullDockerEnvironmentInternal();
startBaseDockerEnvironmentInternal();
try {
startMessageBrokerContainer("message-broker");
startMessageBrokerContainer(BasicSteps.MESSAGE_BROKER_CONTAINER_NAME);
synchronized (this) {
this.wait(WAIT_FOR_BROKER);
}

startLifecycleConsumerContainer("lifecycle-consumer");
startTelemetryConsumerContainer("telemetry-consumer");
startLifecycleConsumerContainer(BasicSteps.LIFECYCLE_CONSUMER_CONTAINER_NAME);
startTelemetryConsumerContainer(BasicSteps.TELEMETRY_CONSUMER_CONTAINER_NAME);
logger.info("Starting full docker environment... DONE (waiting for containers to be ready)");
//wait until consumers are ready
int loops = 0;
Expand Down Expand Up @@ -246,17 +239,17 @@ private void startBaseDockerEnvironmentInternal() throws Exception {
removeNetwork();
createNetwork();

startDBContainer("db");
startDBContainer(BasicSteps.DB_CONTAINER_NAME);
synchronized (this) {
this.wait(WAIT_FOR_DB);
}

startESContainer("es");
startESContainer(BasicSteps.ES_CONTAINER_NAME);
synchronized (this) {
this.wait(WAIT_FOR_ES);
}

startEventBrokerContainer("events-broker");
startEventBrokerContainer(BasicSteps.EVENTS_BROKER_CONTAINER_NAME);
synchronized (this) {
this.wait(WAIT_FOR_EVENTS_BROKER);
}
Expand Down Expand Up @@ -360,6 +353,7 @@ public void stopBaseDockerEnvironment() throws DockerException, InterruptedExcep

private void stopFullDockerEnvironmentInternal() throws SQLException, DockerException, InterruptedException {
database.dropAll();
listAllImages("Stop full docker environment");
printContainersNames("Print containers logs");
printContainersLog(DEFAULT_DEPLOYMENT_CONTAINERS_NAME);
printContainersLog(DEFAULT_BASE_DEPLOYMENT_CONTAINERS_NAME);
Expand All @@ -368,6 +362,7 @@ private void stopFullDockerEnvironmentInternal() throws SQLException, DockerExce
printContainersNames("Remove additional containers");
removeContainers(DEFAULT_DEPLOYMENT_CONTAINERS_NAME);
printContainersNames("Remove containers DONE");
listAllImages("Stop full docker environment");
}

@Given("Create network")
Expand Down Expand Up @@ -413,8 +408,37 @@ public void listImages(String imageName) throws DockerException, InterruptedExce
}
}

public void printContainersNames(String stepDescription) {
logger.info("Print containers - {}", stepDescription);
private void listAllImages(String description) throws DockerException, InterruptedException {
logger.info("Print images - {}", description);
List<Image> images = DockerUtil.getDockerClient().listImages(DockerClient.ListImagesParam.allImages());
int count = 0;
if ((images != null) && (images.size() > 0)) {
count = images.size();
logger.info("ids:");
for (Image image : images) {
if (filterImageToPrint(image)) {
StringBuilder builder = new StringBuilder();
builder.append(image.id());
image.repoTags().forEach(value -> builder.append("\t").append(value));
logger.info("{}", builder.toString());
}
}
}
logger.info("Print images ({}) DONE - {}", count, description);
}

private boolean filterImageToPrint(Image image) {
for (String tag : image.repoTags()) {
String tagToLowerCase = tag.toLowerCase();
if (tagToLowerCase.contains("kapua") || tagToLowerCase.contains("elasticsearch") || tagToLowerCase.contains("activemq") || tagToLowerCase.contains("artemis")) {
return true;
}
}
return false;
}

public void printContainersNames(String description) {
logger.info("Print containers - {}", description);
int count = 0;
try {
List<Container> containerList = DockerUtil.getDockerClient().listContainers(ListContainersParam.allContainers());
Expand All @@ -424,9 +448,9 @@ public void printContainersNames(String stepDescription) {
});
}
catch (DockerException | InterruptedException e) {
logger.warn("Cannot print container name for step '{}'", stepDescription, e);
logger.warn("Cannot print container name for step '{}'", description, e);
}
logger.info("Print containers ({}) DONE - {}", count, stepDescription);
logger.info("Print containers ({}) DONE - {}", count, description);
}

@And("Start DB container with name {string}")
Expand Down Expand Up @@ -532,14 +556,16 @@ public void stopContainer(List<String> names) throws DockerException, Interrupte
public void removeContainers(List<String> names) throws DockerException, InterruptedException {
for (String name : names) {
removeContainer(name);
//search for images with / at the beginning
removeContainer("/" + name);
}
}

private void removeContainer(String name) {
logger.info("Removing container {}...", name);
List<Container> containers = null;
try {
containers = DockerUtil.getDockerClient().listContainers(ListContainersParam.allContainers());
containers = DockerUtil.getDockerClient().listContainers(ListContainersParam.filter("name", name));
if (containers == null || containers.isEmpty()) {
logger.info("Cannot remove container '{}'. (Container not found!)", name);
} else {
Expand Down
15 changes: 10 additions & 5 deletions qa/integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
Expand Down Expand Up @@ -386,6 +381,16 @@
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>test</scope>
</dependency>

<!-- needed by Elasticsearch -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ Feature: Device Registry Integration
And A birth message from device "device_1"
When I search for the device "device_1" in account "AccountA"
Then I find 1 device
When I search for events from device "device_1" in account "AccountA"
Then I find 1 device event
When I search for events from device "device_1" in account "AccountA" I find 1 event within 30 seconds
And The type of the last event is "BIRTH"
And I logout

Expand Down Expand Up @@ -81,8 +80,7 @@ Feature: Device Registry Integration
| clientId | displayName | modelId | serialNumber |
| device_1 | testGateway | ReliaGate 10-20 | 12341234ABC |
And A birth message from device "device_1"
When I search for events from device "device_1" in account "AccountA"
Then I find 1 device event
When I search for events from device "device_1" in account "AccountA" I find 1 event within 30 seconds
And The type of the last event is "BIRTH"
And I logout

Expand Down Expand Up @@ -111,8 +109,7 @@ Feature: Device Registry Integration
| integer | maxNumberChildEntities | 10 |
And A birth message from device "device_1"
And A birth message from device "device_1"
When I search for events from device "device_1" in account "AccountA"
Then I find 2 device events
When I search for events from device "device_1" in account "AccountA" I find 2 events within 30 seconds
And The type of the last event is "BIRTH"
And I logout

Expand Down Expand Up @@ -170,8 +167,7 @@ Feature: Device Registry Integration
| integer | maxNumberChildEntities | 10 |
Given A birth message from device "device_1"
And A disconnect message from device "device_1"
When I search for events from device "device_1" in account "AccountA"
Then I find 2 device events
When I search for events from device "device_1" in account "AccountA" I find 2 events within 30 seconds
And The type of the last event is "DEATH"
And I logout

Expand Down Expand Up @@ -202,8 +198,7 @@ Feature: Device Registry Integration
| integer | maxNumberChildEntities | 10 |
Given A birth message from device "device_1"
And A missing message from device "device_1"
When I search for events from device "device_1" in account "AccountA"
Then I find 2 device events
When I search for events from device "device_1" in account "AccountA" I find 2 events within 30 seconds
And The type of the last event is "MISSING"
And I logout

Expand Down Expand Up @@ -234,8 +229,7 @@ Feature: Device Registry Integration
| integer | maxNumberChildEntities | 10 |
Given A birth message from device "device_1"
And An application message from device "device_1"
When I search for events from device "device_1" in account "AccountA"
Then I find 2 device events
When I search for events from device "device_1" in account "AccountA" I find 2 events within 30 seconds
And The type of the last event is "APPLICATION"
And I logout

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ Scenario: Job execution factory sanity checks

@teardown
Scenario: Stop test environment
Given Stop base docker environment
Given Stop full docker environment
And Reset Security Context
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,5 @@ Feature: Job service CRUD tests

@teardown
Scenario: Stop test environment
Given Stop base docker environment
Given Stop full docker environment
And Reset Security Context
Loading

0 comments on commit 9b457b1

Please sign in to comment.