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-195 Enable Manual tests and Selenium tests where possible #176

Merged
merged 14 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -80,8 +80,12 @@ void testLoginAndCreateSandboxStart() {
"Adoption", // Takes 0:39 minutes
"Booking", // Takes 10:52 minutes
"CS", // 10:37 minutes
// "Ebl", // x:x minutes (DT-1681, issue with Ebl v3.0.0, suite: Conformance TD-only, Carrier & Shipper)
"eBL Issuance", // 5:34 minutes
// "eBL Surrender", // Same issue as in ManualScenarioTest
"JIT", // 1:12 minutes
"OVS", // 3:28 minutes
// "PINT", // Waits until DT-1796 is fixed
"TnT" // 6:6 minutes
})
void testStandardWithAllVersions(String standardName) {
Expand All @@ -96,30 +100,22 @@ void testStandardWithAllVersions(String standardName) {
requestedStandard
.versions()
.forEach(
version -> version
.roles()
.forEach(
role -> createSandboxesAndRunGroups(requestedStandard, version, "Conformance", role)));
version ->
version.suites().stream()
.filter(suite -> suite.startsWith("Conformance"))
.forEach(
suite ->
version
.roles()
.forEach(
role ->
createSandboxesAndRunGroups(
requestedStandard, version.number(), suite, role))));
log.info("Finished with standard: {}, time taken: {}", standardName, stopWatch);
}

// Note: this method can be deleted when 'Conformance TD-only' is working. Standard can be added to method above.
// Takes 20 minutes
@ParameterizedTest
@ValueSource(strings = {"Carrier", "Shipper"})
void testEBLSIOnly(String testedParty) {
getAllSandboxes();
List<Standard> availableStandards = getAvailableStandards();
Standard requestedStandard =
availableStandards.stream()
.filter(standard -> standard.name().equals("Ebl"))
.findFirst()
.orElseThrow();
StandardVersion version = requestedStandard.versions().getFirst();
createSandboxesAndRunGroups(requestedStandard, version, "Conformance SI-only", testedParty);
}

private void createSandboxesAndRunGroups(Standard standard, StandardVersion version, String suiteName, String role) {
private void createSandboxesAndRunGroups(Standard standard, String version, String suiteName, String role) {
log.info("Starting standard: {}, version: {}, suite: {}, role: {}", standard.name(), version, suiteName, role);
switchToTab(0);
SandboxConfig sandBox1 = createSandBox(standard, version, suiteName, role, 0);
openNewTab();
Expand All @@ -128,7 +124,7 @@ private void createSandboxesAndRunGroups(Standard standard, StandardVersion vers
updateSandboxConfigBeforeStarting(sandBox1, sandBox2);

runScenarioGroups();
log.info("Finished with standard: {}, version: {}, role: {}", standard.name(), version.number(), role);
log.info("Finished with standard: {}, version: {}, suite: {}, role: {}", standard.name(), version, suiteName, role);

// Close tab and switch back to first tab.
driver.close();
Expand Down Expand Up @@ -270,8 +266,8 @@ private static void loginUser() {
alreadyLoggedIn = true;
}

SandboxConfig createSandBox(Standard standard, StandardVersion version, String suiteName, String roleName, int sandboxType) {
log.info("Creating Sandbox: {}, {}, {}, type: {}", standard.name(), version.number(), roleName, sandboxType);
SandboxConfig createSandBox(Standard standard, String version, String suiteName, String roleName, int sandboxType) {
log.info("Creating Sandbox: {}, {}, {}, {}, type: {}", standard.name(), version, suiteName, roleName, sandboxType);
driver.get(BASE_URL + "/create-sandbox");
if (driver.getCurrentUrl().endsWith("/login")) {
loginUser();
Expand All @@ -280,7 +276,7 @@ SandboxConfig createSandBox(Standard standard, StandardVersion version, String s
assertEquals(BASE_URL + "/create-sandbox", driver.getCurrentUrl());

selectAndPickOption("standardSelect", standard.name());
selectAndPickOption("versionSelect", version.number());
selectAndPickOption("versionSelect", version);
selectAndPickOption("suiteSelect", suiteName);
selectAndPickOption("roleSelect", roleName);

Expand All @@ -290,13 +286,7 @@ SandboxConfig createSandBox(Standard standard, StandardVersion version, String s
assertFalse(typeOptions.isEmpty());
typeOptions.get(sandboxType).click();

String sandboxName;
if (sandboxType == 0) {
sandboxName = "%s - %s testing: orchestrator".formatted(standard.name(), roleName);
} else {
sandboxName = "%s - %s testing: synthetic %s as tested party"
.formatted(standard.name(), roleName, roleName);
}
String sandboxName = getSandboxName(standard.name(), version, suiteName, roleName, sandboxType);
driver.findElement(By.id("mat-input-0")).sendKeys(sandboxName);
driver.findElement(By.id("createSandboxButton")).click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
@Slf4j
class ManualEBLTDOnlyTest extends ManualTestBase {

@Disabled("A required API exchange was not yet detected for action 'TD Change (Out of Band)'")
// Carrier issue: Carrier: URISyntaxException: Illegal character in path at index 127: http://localhost:8080/conformance/sandbox/8f925262-2ea6-4f82-ac20-da85801da3ce/party/Carrier1/api/v3/transport-documents/Insert TDR here
// Shipper issue: A required API exchange was not yet detected for action 'UC6'
@Disabled("See above")
@ParameterizedTest
@CsvSource({"Carrier", "Shipper"})
void testManualEblTD(String testedParty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
@Slf4j
class ManualScenarioTest extends ManualTestBase {

// PINT is postponed, until it has non-RI impls.
@SuppressWarnings("unused")
private static Stream<Arguments> testStandards() {
return Stream.of(
Expand All @@ -23,20 +22,28 @@ private static Stream<Arguments> testStandards() {
Arguments.of("Booking", true),
Arguments.of("CS", false),
Arguments.of("CS", true),

// DT-1681, issue with Ebl v3.0.0, suite: Conformance TD-only, Carrier & Shipper
// Arguments.of("Ebl", false),
// Arguments.of("Ebl", true),
Arguments.of("JIT", false),
Arguments.of("JIT", true),
Arguments.of("OVS", false),
Arguments.of("OVS", true),
// DT-1796, PINT issue: Unknown TD Reference: j5k./hY,wZNqNDSEmJ`
// Arguments.of("PINT", true),
// Arguments.of("PINT", false),
Arguments.of("TnT", false),
Arguments.of("TnT", true)
Arguments.of("TnT", true),
Arguments.of("eBL Issuance", false)

// eBL Issuance: 1) Carrier issue: Signature of the issuanceManifestSignedContent is valid.
// eBL Issuance: 2) Platform issue: STRAIGHT_EBL -> Response status '409' does not match the expected value '204'
// Arguments.of("eBL Issuance", false),
// 2nd run of eBL Issuance is not working, DT-1679: Scenario 'Supply carrier parameters - Supply scenario parameters
// [STRAIGHT_EBL] - Request(duplicate) - Response(ISSU)' is not conformant. Details: Supply carrier parameters -
// Supply scenario parameters [STRAIGHT_EBL] - Request(duplicate) - Response(ISSU): NON_CONFORMANT
// Arguments.of("eBL Issuance", true),

// eBL Surrender: 1) Carrier issue: A required API exchange was not yet detected for action 'Void&Reissue'.
// eBL Surrender: 2) Platform: same issue on 'SURR 409'
// eBL Surrender: 1) Carrier: DT-1680, NullPointerException: Cannot invoke "EblSurrenderState.ordinal()" because the return value of "java.util.Map.get(Object)" is null
// eBL Surrender: 2) Platform: DT-1680, UserFacingException: A required API exchange was not yet detected for action 'SURR 409'.
// Arguments.of("eBL Surrender", false),
// Arguments.of("eBL Surrender", true)
);
Expand All @@ -53,17 +60,25 @@ void testStandards(String standardName, boolean secondRun) {
.filter(standard -> standard.name().equals(standardName))
.findFirst()
.orElseThrow();

standard1
.versions()
.forEach(
version ->
version
.roles()
.forEach(role -> runManualTests(standard1.name(), version, role, secondRun)));
version.suites().stream()
.filter(suite -> suite.startsWith("Conformance"))
.forEach(
suite ->
version
.roles()
.forEach(
role ->
runManualTests(
standard1.name(), version, suite, role, secondRun))));
}

private void runManualTests(
String standardName, StandardVersion version, String roleName, boolean secondRun) {
String standardName, StandardVersion version, String suiteName, String roleName, boolean secondRun) {
SandboxConfig sandbox1;
SandboxConfig sandbox2;
if (!secondRun) {
Expand All @@ -72,29 +87,26 @@ private void runManualTests(
new Sandbox(
standardName,
version.number(),
"Conformance",
suiteName,
roleName,
true,
"%s - %s testing: orchestrator".formatted(standardName, roleName)));
getSandboxName(standardName, version.number(), suiteName, roleName, 0)));
sandbox2 =
createSandbox(
new Sandbox(
standardName,
version.number(),
"Conformance",
suiteName,
roleName,
false,
"%s - %s testing: synthetic %s as tested party"
.formatted(standardName, roleName, roleName)));
getSandboxName(standardName, version.number(), suiteName, roleName, 1)));
updateSandboxConfigBeforeStarting(sandbox1, sandbox2);
updateSandboxConfigBeforeStarting(sandbox2, sandbox1);
} else {
sandbox1 =
getSandboxByName("%s - %s testing: orchestrator".formatted(standardName, roleName));
getSandboxByName(getSandboxName(standardName, version.number(), suiteName, roleName, 0));
sandbox2 =
getSandboxByName(
"%s - %s testing: synthetic %s as tested party"
.formatted(standardName, roleName, roleName));
getSandboxByName(getSandboxName(standardName, version.number(), suiteName, roleName, 1));
log.info("Run for the 2nd time, and see that it still works");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ SandboxConfig createSandbox(Sandbox sandbox) {
JsonNode jsonNode = webuiHandler.handleRequest(USER_ID, node);
assertTrue(jsonNode.has("sandboxId"), "SandboxId not found, maybe not created? Response: " + jsonNode);
String sandboxId = jsonNode.get("sandboxId").asText();
log.info("Created sandbox: {}, v{}, suite: {}, role: {}, defaultType: {}", sandbox.standardName, sandbox.versionNumber, sandbox.scenarioSuite, sandbox.testedPartyRole, sandbox.isDefaultType);
log.info("Created sandbox: {} v{}, suite: {}, role: {}, defaultType: {}", sandbox.standardName, sandbox.versionNumber, sandbox.scenarioSuite, sandbox.testedPartyRole, sandbox.isDefaultType);

return getSandboxConfig(sandboxId);
}
Expand Down Expand Up @@ -278,6 +278,18 @@ List<ScenarioDigest> getScenarioDigests(String sandboxId) {
return mapper.convertValue(jsonNode, new TypeReference<>() {});
}

protected String getSandboxName(String standardName, String version, String suiteName, String roleName, int sandboxType) {
String sandboxName;
if (sandboxType == 0) {
sandboxName = "%s v%s, %s, %s - Testing: orchestrator".formatted(standardName, version, suiteName, roleName);
} else {
sandboxName = "%s v%s, %s, %s - Testing: synthetic %s as tested party"
.formatted(standardName, version, suiteName, roleName, roleName);
}
return sandboxName;
}


void runAllTests(
List<ScenarioDigest> sandbox1Digests, SandboxConfig sandbox1, SandboxConfig sandbox2) {
sandbox1Digests.forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ConformanceApplicationTest {
"eblsurrender-300-conformance-auto-all-in-one",
"jit-120-conformance-auto-all-in-one",
"ovs-300-conformance-auto-all-in-one",
"pint-300-reference-implementation-auto-all-in-one",
"pint-300-conformance-auto-all-in-one",
"tnt-220-conformance-auto-all-in-one"
})
void testEachSuite(final String sandboxId) throws InterruptedException {
Expand Down