Skip to content

Commit

Permalink
Merge pull request #183 from laDok8/simultaneous_exec
Browse files Browse the repository at this point in the history
make default test parameters unique
  • Loading branch information
istraka authored Aug 1, 2023
2 parents f70a0d3 + 9b83d05 commit ab3420f
Show file tree
Hide file tree
Showing 50 changed files with 363 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@


public class AwsTestConstants {
public static final String TAG = "sunstoneKeyTag";
public static final String NAME_1 = "sunstoneKeyName1";
public static final String NAME_2 = "sunstoneKeyName2";
public static final String instanceName = "${non.existing:eapSunstoneInjectInstance}";
// must be same as in MP Config
public static final String region = "${ec2.region:us-east-1}";
public static final String instanceName = "${sunstone.test.instance.name}";
public static final String region = "${sunstone.aws.region}";
public static final String mgmtUser = "${non.existing:admin}";
public static final String mgmtPassword = "${non.existing:pass.1234}";
public static final String mgmtPort = "${non.existing:9990}";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aws.cloudformation.archiveDeploy.ec2;


import aws.cloudformation.AwsTestConstants;
import aws.cloudformation.archiveDeploy.ec2.suitetests.AwsEc2DeployFirstTest;
import aws.cloudformation.archiveDeploy.ec2.suitetests.AwsEc2UndeployedSecondTest;
import org.junit.platform.suite.api.SelectClasses;
Expand All @@ -14,4 +15,5 @@
@Suite
@SelectClasses({AwsEc2DeployFirstTest.class, AwsEc2UndeployedSecondTest.class})
public class Ec2DeploySuiteTests {
public static final String suiteInstanceName = "ec2-deploy-" + AwsTestConstants.instanceName;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package aws.cloudformation.archiveDeploy.ec2.suitetests;


import aws.cloudformation.AwsTestConstants;
import aws.cloudformation.archiveDeploy.ec2.Ec2DeploySuiteTests;
import sunstone.aws.annotation.AwsEc2Instance;
import okhttp3.OkHttpClient;
import okhttp3.Request;
Expand All @@ -21,15 +21,15 @@
import static aws.cloudformation.AwsTestConstants.region;

@WithAwsCfTemplate(parameters = {
@Parameter(k = "instanceName", v = AwsTestConstants.instanceName)
@Parameter(k = "instanceName", v = Ec2DeploySuiteTests.suiteInstanceName)
},
template = "sunstone/aws/cloudformation/eap.yaml", region = region, perSuite = true)
public class AwsEc2DeployFirstTest {
@AwsEc2Instance(nameTag = AwsTestConstants.instanceName, region = region)
@AwsEc2Instance(nameTag = Ec2DeploySuiteTests.suiteInstanceName, region = region)
Hostname hostname;

@Deployment(name = "testapp.war")
@AwsEc2Instance(nameTag = AwsTestConstants.instanceName, region = region)
@AwsEc2Instance(nameTag = Ec2DeploySuiteTests.suiteInstanceName, region = region)
static WebArchive deploy() {
return ShrinkWrap.create(WebArchive.class)
.addAsWebResource(new StringAsset("Hello World"), "index.jsp");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package aws.cloudformation.archiveDeploy.ec2.suitetests;


import aws.cloudformation.AwsTestConstants;
import aws.cloudformation.archiveDeploy.ec2.Ec2DeploySuiteTests;
import sunstone.aws.annotation.AwsEc2Instance;
import okhttp3.OkHttpClient;
import okhttp3.Request;
Expand All @@ -17,11 +17,11 @@
import static aws.cloudformation.AwsTestConstants.region;

@WithAwsCfTemplate(parameters = {
@Parameter(k = "instanceName", v = AwsTestConstants.instanceName)
@Parameter(k = "instanceName", v = Ec2DeploySuiteTests.suiteInstanceName)
},
template = "sunstone/aws/cloudformation/eap.yaml", region = region, perSuite = true)
public class AwsEc2UndeployedSecondTest {
@AwsEc2Instance(nameTag = AwsTestConstants.instanceName, region = region)
@AwsEc2Instance(nameTag = Ec2DeploySuiteTests.suiteInstanceName, region = region)
Hostname hostname;

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aws.cloudformation.archiveDeploy.ec2Domain;


import aws.cloudformation.AwsTestConstants;
import aws.cloudformation.archiveDeploy.ec2Domain.suitetests.AwsDomainEc2DeployFirstTest;
import aws.cloudformation.archiveDeploy.ec2Domain.suitetests.AwsDomainEc2UndeployedSecondTest;
import org.junit.platform.suite.api.SelectClasses;
Expand All @@ -14,4 +15,5 @@
@Suite
@SelectClasses({AwsDomainEc2DeployFirstTest.class, AwsDomainEc2UndeployedSecondTest.class})
public class DomainEc2DeploySuiteTests {
public static final String suiteInstanceName = "domain-ec2-deploy-" + AwsTestConstants.instanceName;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package aws.cloudformation.archiveDeploy.ec2Domain.suitetests;


import aws.cloudformation.AwsTestConstants;
import aws.cloudformation.archiveDeploy.ec2Domain.DomainEc2DeploySuiteTests;
import sunstone.annotation.OperatingMode;
import sunstone.annotation.WildFly;
import sunstone.aws.annotation.AwsEc2Instance;
Expand All @@ -23,16 +23,16 @@
import static aws.cloudformation.AwsTestConstants.region;

@WithAwsCfTemplate(parameters = {
@Parameter(k = "instanceName", v = AwsTestConstants.instanceName)
@Parameter(k = "instanceName", v = DomainEc2DeploySuiteTests.suiteInstanceName)
},
template = "sunstone/aws/cloudformation/eapDomain.yaml", region = region, perSuite = true)
public class AwsDomainEc2DeployFirstTest {
@AwsEc2Instance(nameTag = AwsTestConstants.instanceName, region = region)
@AwsEc2Instance(nameTag = DomainEc2DeploySuiteTests.suiteInstanceName, region = region)
@WildFly(mode = OperatingMode.DOMAIN)
Hostname hostname;

@Deployment(name = "testapp.war")
@AwsEc2Instance(nameTag = AwsTestConstants.instanceName, region = region)
@AwsEc2Instance(nameTag = DomainEc2DeploySuiteTests.suiteInstanceName, region = region)
@WildFly(mode = OperatingMode.DOMAIN)
static WebArchive deploy() {
return ShrinkWrap.create(WebArchive.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package aws.cloudformation.archiveDeploy.ec2Domain.suitetests;


import aws.cloudformation.AwsTestConstants;
import aws.cloudformation.archiveDeploy.ec2Domain.DomainEc2DeploySuiteTests;
import sunstone.annotation.OperatingMode;
import sunstone.annotation.WildFly;
import sunstone.aws.annotation.AwsEc2Instance;
Expand All @@ -19,11 +19,11 @@
import static aws.cloudformation.AwsTestConstants.region;

@WithAwsCfTemplate(parameters = {
@Parameter(k = "instanceName", v = AwsTestConstants.instanceName)
@Parameter(k = "instanceName", v = DomainEc2DeploySuiteTests.suiteInstanceName)
},
template = "sunstone/aws/cloudformation/eapDomain.yaml", region = region, perSuite = true)
public class AwsDomainEc2UndeployedSecondTest {
@AwsEc2Instance(nameTag = AwsTestConstants.instanceName, region = region)
@AwsEc2Instance(nameTag = DomainEc2DeploySuiteTests.suiteInstanceName, region = region)
@WildFly(mode = OperatingMode.DOMAIN)
Hostname hostname;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@
* So the idea is to have only one testcase due to performance.
*/
@WithAwsCfTemplate(parameters = {
@Parameter(k = "instanceName", v = instanceName)
@Parameter(k = "instanceName", v = AwsDomainManagementClientTests.classInstanceName)
},
template = "sunstone/aws/cloudformation/eapDomain.yaml", region = region)

public class AwsDomainManagementClientTests {
protected static final String classInstanceName = "AwsDomainManagementClientTests-" + instanceName;

@AwsEc2Instance(nameTag = instanceName)
@AwsEc2Instance(nameTag = classInstanceName)
@WildFly(mode = OperatingMode.DOMAIN)
static OnlineManagementClient staticMgmtClient;

@AwsEc2Instance(nameTag = instanceName, region = region)
@AwsEc2Instance(nameTag = classInstanceName, region = region)
@WildFly(
mode = OperatingMode.DOMAIN,
domain = @DomainMode(
Expand All @@ -44,7 +45,7 @@ public class AwsDomainManagementClientTests {
)
static OnlineManagementClient staticMgmtClientSpecified;

@AwsEc2Instance(nameTag = instanceName, region = region)
@AwsEc2Instance(nameTag = classInstanceName, region = region)
@WildFly(
mode = OperatingMode.DOMAIN,
domain = @DomainMode(
Expand All @@ -57,7 +58,7 @@ public class AwsDomainManagementClientTests {
)
OnlineManagementClient mgmtClientSpecified;

@AwsEc2Instance(nameTag = instanceName)
@AwsEc2Instance(nameTag = classInstanceName)
@WildFly(mode = OperatingMode.DOMAIN)
OnlineManagementClient mgmtClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@
* So the idea is to have only one testcase due to performance.
*/
@WithAwsCfTemplate(parameters = {
@Parameter(k = "instanceName", v = instanceName)
@Parameter(k = "instanceName", v = AwsStandaloneManagementClientTests.classInstanceName)
},
template = "sunstone/aws/cloudformation/eap.yaml", region = region)
public class AwsStandaloneManagementClientTests {
protected static final String classInstanceName = "AwsStandaloneManagementClientTests-" + instanceName;

@AwsEc2Instance(nameTag = instanceName)
@AwsEc2Instance(nameTag = classInstanceName)
static OnlineManagementClient staticMgmtClient;

@AwsEc2Instance(nameTag = instanceName, region = region)
@AwsEc2Instance(nameTag = classInstanceName, region = region)
@WildFly(mode = OperatingMode.STANDALONE, standalone = @StandaloneMode(user = mgmtUser, password = mgmtPassword, port = mgmtPort))
static OnlineManagementClient staticMgmtClientSpecified;

@AwsEc2Instance(nameTag = instanceName, region = region)
@AwsEc2Instance(nameTag = classInstanceName, region = region)
@WildFly(mode = OperatingMode.STANDALONE, standalone = @StandaloneMode(user = mgmtUser, password = mgmtPassword, port = mgmtPort))
OnlineManagementClient mgmtClientSpecified;

@AwsEc2Instance(nameTag = instanceName)
@AwsEc2Instance(nameTag = classInstanceName)
OnlineManagementClient mgmtClient;

@BeforeAll
Expand Down
3 changes: 3 additions & 0 deletions aws-wildfly/src/test/resources/sunstone.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ sunstone.wildfly.mgmt.password=pass.1234
sunstone.wildfly.mgmt.connection.timeout=120000
sunstone.wildfly.mgmt.host=master
sunstone.wildfly.mgmt.profile=default
sunstone.test.instance.name=eapSunstoneInjectInstance-${ts.test.run}

ts.test.run=defaultrun
14 changes: 8 additions & 6 deletions aws/src/test/java/aws/cloudformation/AwsTestConstants.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package aws.cloudformation;


import sunstone.aws.impl.AwsConfig;

public class AwsTestConstants {
public static final String TAG = "sunstoneKeyTag";
public static final String NAME_1 = "sunstoneKeyName1";
public static final String NAME_2 = "sunstoneKeyName2";
public static final String instanceName = "${non.existing:eapSunstoneInjectInstance}";
// must be same as in MP Config
public static final String region = "${ec2.region:us-east-1}";
public static final String TAG = "${sunstone.test.keypair.tag}";
public static final String NAME_1 = "${sunstone.test.keypair.name1}";
public static final String NAME_2 = "${sunstone.test.keypair.name2}";
public static final String instanceName = "${sunstone.test.instance.name}";
public static final String region = "${"+ AwsConfig.REGION + "}";
public static final String region2 = "${sunstone.aws.region2}";
public static final String mgmtUser = "${non.existing:admin}";
public static final String mgmtPassword = "${non.existing:pass.1234}";
public static final String mgmtPort = "${non.existing:9990}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import software.amazon.awssdk.services.ec2.Ec2Client;
import software.amazon.awssdk.services.ec2.model.KeyPairInfo;
import sunstone.annotation.Parameter;
import sunstone.annotation.SunstoneProperty;
import sunstone.aws.annotation.WithAwsCfTemplate;
import sunstone.aws.annotation.WithAwsCfTemplateRepeatable;

Expand All @@ -17,19 +18,28 @@
@WithAwsCfTemplate(parameters = {
@Parameter(k = "keyTag", v = AwsTestConstants.TAG),
@Parameter(k = "keyName", v = AwsTestConstants.NAME_1)},
template = "sunstone/aws/cloudformation/keyPair.yaml", region = "us-east-1"),
template = "sunstone/aws/cloudformation/keyPair.yaml"),

@WithAwsCfTemplate(parameters = {
@Parameter(k = "keyTag", v = AwsTestConstants.TAG),
@Parameter(k = "keyName", v = AwsTestConstants.NAME_2)},
template = "sunstone/aws/cloudformation/keyPair.yaml", region = "us-east-1")
template = "sunstone/aws/cloudformation/keyPair.yaml")
})
public class MultipleAwsCfTemplatesRepetableTest {
static Ec2Client client;

@SunstoneProperty(expression=AwsTestConstants.NAME_1)
static String keyName1;
@SunstoneProperty(expression=AwsTestConstants.NAME_2)
static String keyName2;
@SunstoneProperty(expression=AwsTestConstants.TAG)
static String keyTag;
@SunstoneProperty(expression = AwsTestConstants.region)
static String region;

@BeforeAll
public static void setup() {
client = AwsTestUtils.getEC2Client("us-east-1");
client = AwsTestUtils.getEC2Client(region);
}

@AfterAll
Expand All @@ -39,9 +49,9 @@ public static void close() {

@Test
public void resourcesCreated() {
List<KeyPairInfo> keys = AwsTestUtils.findEC2KeysByTag(client, "tag", AwsTestConstants.TAG);
List<KeyPairInfo> keys = AwsTestUtils.findEC2KeysByTag(client, "tag", keyTag);
assertThat(keys.size()).isEqualTo(2);
assertThat(keys).anyMatch(key -> key.keyName().equals(AwsTestConstants.NAME_1));
assertThat(keys).anyMatch(key -> key.keyName().equals(AwsTestConstants.NAME_2));
assertThat(keys).anyMatch(key -> key.keyName().equals(keyName1));
assertThat(keys).anyMatch(key -> key.keyName().equals(keyName2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import software.amazon.awssdk.services.ec2.Ec2Client;
import software.amazon.awssdk.services.ec2.model.KeyPairInfo;
import sunstone.annotation.Parameter;
import sunstone.annotation.SunstoneProperty;
import sunstone.aws.annotation.WithAwsCfTemplate;

import java.util.List;
Expand All @@ -17,19 +18,28 @@
@Parameter(k = "keyTag", v = AwsTestConstants.TAG),
@Parameter(k = "keyName", v = AwsTestConstants.NAME_1)
},
template = "sunstone/aws/cloudformation/keyPair.yaml", region = "us-east-1")
template = "sunstone/aws/cloudformation/keyPair.yaml")

@WithAwsCfTemplate(parameters = {
@Parameter(k = "keyTag", v = AwsTestConstants.TAG),
@Parameter(k = "keyName", v = AwsTestConstants.NAME_2)
},
template = "sunstone/aws/cloudformation/keyPair.yaml", region = "us-east-1")
template = "sunstone/aws/cloudformation/keyPair.yaml")
public class MultipleAwsCfTemplatesTest {
static Ec2Client client;

@SunstoneProperty(expression=AwsTestConstants.NAME_1)
static String keyName1;
@SunstoneProperty(expression=AwsTestConstants.NAME_2)
static String keyName2;
@SunstoneProperty(expression=AwsTestConstants.TAG)
static String keyTag;
@SunstoneProperty(expression = AwsTestConstants.region)
static String region;

@BeforeAll
public static void setup() {
client = AwsTestUtils.getEC2Client("us-east-1");
client = AwsTestUtils.getEC2Client(region);
}

@AfterAll
Expand All @@ -39,10 +49,10 @@ public static void close() {

@Test
public void resourcesCreated() {
List<KeyPairInfo> keys = AwsTestUtils.findEC2KeysByTag(client, "tag", AwsTestConstants.TAG);
List<KeyPairInfo> keys = AwsTestUtils.findEC2KeysByTag(client, "tag", keyTag);
assertThat(keys.size()).isEqualTo(2);
assertThat(keys).anyMatch(key -> key.keyName().equals(AwsTestConstants.NAME_1));
assertThat(keys).anyMatch(key -> key.keyName().equals(AwsTestConstants.NAME_2));
assertThat(keys).anyMatch(key -> key.keyName().equals(keyName1));
assertThat(keys).anyMatch(key -> key.keyName().equals(keyName2));
}
}

Loading

0 comments on commit ab3420f

Please sign in to comment.