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

STNG-165 Run one scenario in AWS dev fully end-to-end #182

Merged
merged 15 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
11 changes: 8 additions & 3 deletions .github/workflows/deploy-to-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.AWS_ENVIRONMENT }}
# Enforces only AWS env name matching branches are checkout and deployed.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a pain.. I was making experimental changes in the pom.xml file for the new situation, but they were not applied, because I changed the checkout here to force it to dev HEAD instead.
The enforcing of the right environment is also already guaranteed by line 5 and line 10 of this file.


- name: Print commit sha
shell: bash
Expand Down Expand Up @@ -72,3 +69,11 @@ jobs:
run: |
cd cdk/
cdk deploy ${{ env.AWS_ENVIRONMENT }}ConformanceStack

- name: Verify a scenario in AWS Dev environment
env:
TEST_LOGIN_EMAIL: ${{ secrets.AWS_DEV_LOGIN_EMAIL }} # User account details to log in the Web UI.
TEST_LOGIN_PASSWORD: ${{ secrets.AWS_DEV_LOGIN_PASSWORD }}
TEST_BASE_URL: ${{ secrets.AWS_DEV_WEB_URL }}
run: |
mvn -B test -Pintegration
2 changes: 1 addition & 1 deletion .github/workflows/webui-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Test Conformance-Gateway
run: |
mvn test -B -Djunit.includedTags=WebUI
mvn test -B -Pwebui

- name: Stop Web UI
run: |
Expand Down
33 changes: 29 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
<junit.version>5.11.1</junit.version>
<lombok.version>1.18.34</lombok.version>

<junit.includedTags>!WebUI</junit.includedTags>

<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>dcsaorg</sonar.organization>
<sonar.projectKey>Conformance-Gateway</sonar.projectKey>
Expand Down Expand Up @@ -150,10 +148,36 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
</dependencyManagement>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<junit.includedTags/>
<junit.excludedTags>WebUI,Integration</junit.excludedTags>
</properties>
</profile>
<profile>
<id>webui</id>
<properties>
<junit.includedTags>WebUI</junit.includedTags>
<junit.excludedTags>Integration</junit.excludedTags>
</properties>
</profile>
<profile>
<id>integration</id>
<properties>
<junit.includedTags>Integration</junit.includedTags>
<junit.excludedTags>WebUI</junit.excludedTags>
</properties>
</profile>
</profiles>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduced profiles to make it more clear and easy to use and select which profile you'd like to use. By default, the first profile is used.


<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -229,9 +253,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
<configuration>
<groups>${junit.includedTags}</groups>
<excludedGroups>${junit.excludedTags}</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.dcsa.conformance.frontend;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Slf4j
@Tag("Integration")
class AWSEnvironmentTest extends SeleniumTestBase {
private static final String ENV_BASE_URL = "TEST_BASE_URL";
private static final String ENV_LOGIN_EMAIL = "TEST_LOGIN_EMAIL";
private static final String ENV_LOGIN_PASSWORD = "TEST_LOGIN_PASSWORD";

@Override
@BeforeEach
public void setUp() {
// Browsing in AWS is slow, so we need to increase the timeouts
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(WAIT_BEFORE_TIMEOUT_IN_MILLIS * 6));
wait.withTimeout(Duration.ofSeconds(20L));
stopAfterFirstScenarioGroup = true;
lambdaDelay = 2_000L; // Not adding delays, but accept to wait longer sometimes.
}

@Test
void testStandardOnDevEnvironment() {
baseUrl = getRequiredProperty(ENV_BASE_URL);
loginEmail = getRequiredProperty(ENV_LOGIN_EMAIL);
loginPassword = getRequiredProperty(ENV_LOGIN_PASSWORD);

StopWatch stopWatch = StopWatch.createStarted();
String standardName = "Ebl";
createSandboxesAndRunGroups(
new Standard(standardName, null), "3.0.0", "Conformance TD-only", "Carrier");
log.info("Finished AWS testing on standard: {}, time taken: {}", standardName, stopWatch);
}

// Prevent sandbox names from clashing with existing sandboxes in AWS, by adding a date-timestamp
@Override
protected String getSandboxName(
String standardName, String version, String suiteName, String roleName, int sandboxType) {
String dateTimeFormatted =
LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss ")); // Keep space at end
return dateTimeFormatted
+ super.getSandboxName(standardName, version, suiteName, roleName, sandboxType);
}

private String getRequiredProperty(String environmentProperty) {
String value =
System.getenv().getOrDefault(environmentProperty, null); // Try system property first
if (value == null) {
// When it fails, also check the passed -Dkey=value properties
value = System.getProperty(environmentProperty, null);
}

if (StringUtils.isBlank(value)) {
throw new IllegalArgumentException(
"Variable '%s' must be set, as an environment variable or supplied with -Dkey=value parameter."
.formatted(environmentProperty));
}
return value;
}
}
Loading