Skip to content

Commit

Permalink
make default test parameters unique
Browse files Browse the repository at this point in the history
  • Loading branch information
laDok8 committed May 31, 2023
1 parent ef2b35b commit a878b99
Show file tree
Hide file tree
Showing 42 changed files with 212 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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}";
public static final String instanceName = "${sunstone.test.instance.name}";
// must be same as in MP Config
public static final String region = "${ec2.region:us-east-1}";
public static final String mgmtUser = "${non.existing:admin}";
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
2 changes: 1 addition & 1 deletion aws/src/test/java/aws/cloudformation/AwsTestConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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}";
public static final String instanceName = "${sunstone.test.instance.name}";
// must be same as in MP Config
public static final String region = "${ec2.region:us-east-1}";
public static final String mgmtUser = "${non.existing:admin}";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package aws.cloudformation.di;


import aws.cloudformation.di.suitetests.AwsEC2InstanceTests;
import aws.cloudformation.di.suitetests.AwsHostnameTests;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;
import static aws.cloudformation.AwsTestConstants.instanceName;

@Suite
@SelectClasses({AwsHostnameTests.class})
@SelectClasses({AwsHostnameTests.class, AwsEC2InstanceTests.class})
public class SunstoneResourceAwsSuiteTests {
public static final String suiteInstanceName = "AwsEC2InstanceTests-" + instanceName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import sunstone.aws.annotation.AwsEc2Instance;
import sunstone.aws.annotation.WithAwsCfTemplate;

import static aws.cloudformation.AwsTestConstants.instanceName;
import static aws.cloudformation.AwsTestConstants.region;
import static aws.cloudformation.di.SunstoneResourceAwsSuiteTests.suiteInstanceName;
import static org.assertj.core.api.Assertions.assertThat;


Expand All @@ -20,21 +20,21 @@
* So the idea is to have only one testcase due to performance.
*/
@WithAwsCfTemplate(parameters = {
@Parameter(k = "instanceName", v = instanceName)
@Parameter(k = "instanceName", v = suiteInstanceName)
},
template = "sunstone/aws/cloudformation/eap.yaml", region = region, perSuite = true)
public class AwsEC2InstanceTests {

@AwsEc2Instance(nameTag = instanceName)
@AwsEc2Instance(nameTag = suiteInstanceName)
static Instance staticVm;

@AwsEc2Instance(nameTag = instanceName, region = region)
@AwsEc2Instance(nameTag = suiteInstanceName, region = region)
static Instance staticVmWithRegion;

@AwsEc2Instance(nameTag = instanceName)
@AwsEc2Instance(nameTag = suiteInstanceName)
Instance vm;

@AwsEc2Instance(nameTag = instanceName, region = region)
@AwsEc2Instance(nameTag = suiteInstanceName, region = region)
Instance vmWithRegion;

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import sunstone.aws.annotation.WithAwsCfTemplate;
import sunstone.inject.Hostname;

import static aws.cloudformation.AwsTestConstants.instanceName;
import static aws.cloudformation.AwsTestConstants.region;
import static aws.cloudformation.di.SunstoneResourceAwsSuiteTests.suiteInstanceName;
import static org.assertj.core.api.Assertions.assertThat;


Expand All @@ -20,21 +20,21 @@
* So the idea is to have only one testcase due to performance.
*/
@WithAwsCfTemplate(parameters = {
@Parameter(k = "instanceName", v = instanceName)
@Parameter(k = "instanceName", v = suiteInstanceName)
},
template = "sunstone/aws/cloudformation/eap.yaml", region = region, perSuite = true)
public class AwsHostnameTests {

@AwsEc2Instance(nameTag = instanceName)
@AwsEc2Instance(nameTag = suiteInstanceName)
static Hostname staticHostname;

@AwsEc2Instance(nameTag = instanceName, region = region)
@AwsEc2Instance(nameTag = suiteInstanceName, region = region)
static Hostname staticHostnameWithRegion;

@AwsEc2Instance(nameTag = instanceName)
@AwsEc2Instance(nameTag = suiteInstanceName)
Hostname hostname;

@AwsEc2Instance(nameTag = instanceName, region = region)
@AwsEc2Instance(nameTag = suiteInstanceName, region = region)
Hostname hostnameWithRegion;

@BeforeAll
Expand Down
5 changes: 4 additions & 1 deletion aws/src/test/resources/sunstone.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
sunstone.aws.accessKeyID=${aws.accessKeyID}
sunstone.aws.secretAccessKey=${aws.secretAccessKey}
sunstone.aws.region=${aws.region:us-east-1}
sunstone.aws.region=${aws.region:us-east-1}
sunstone.test.instance.name=eapSunstoneInjectInstance-${ts.test.run}

ts.test.run=defaultrun
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ public class AzureTestConstants {
public static final String VNET_NAME_2 = "sunstoneVnet2";

public static final String IMAGE_REF = "${image.ref:/subscriptions/7dee6f21-9f05-414e-99fa-08d3215fb420/resourceGroups/istraka-test/providers/Microsoft.Compute/images/eap-test-image}";
public static final String instanceName = "${non.existing:eapSunstoneInjectInstance}";
public static final String instanceName = "${sunstone.test.instance.name}";

public static final String deployGroup = "${sunstone.azure.group}";

public static final String mgmtUser = "${non.existing:admin}";
public static final String mgmtPassword = "${non.existing:pass.1234}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
@Suite
@SelectClasses({AzureVmDeployFirstTest.class, AzureVmUndeployedSecondTest.class})
public class VmDeploySuiteTests {
public static final String vmDeployGroup = "deploytestVM";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,22 @@

import java.io.IOException;

import static sunstone.azure.armTemplates.archiveDeploy.vm.VmDeploySuiteTests.vmDeployGroup;

@WithAzureArmTemplate(parameters = {
@Parameter(k = "virtualMachineName", v = AzureTestConstants.instanceName),
@Parameter(k = "imageRefId", v = AzureTestConstants.IMAGE_REF)
},
template = "sunstone/azure/armTemplates/eap.json", group = vmDeployGroup, perSuite = true)
template = "sunstone/azure/armTemplates/eap.json", group = AzureVmDeployFirstTest.groupName, perSuite = true)
public class AzureVmDeployFirstTest {
static final String groupName = "AzureVmDeployFirstTest-" + AzureTestConstants.deployGroup;

@Deployment(name = "testapp.war")
@AzureVirtualMachine(name = AzureTestConstants.instanceName, group = vmDeployGroup)
@AzureVirtualMachine(name = AzureTestConstants.instanceName, group = groupName)
static WebArchive deploy() {
return ShrinkWrap.create(WebArchive.class)
.addAsWebResource(new StringAsset("Hello World"), "index.jsp");
}

@AzureVirtualMachine(name = AzureTestConstants.instanceName, group = vmDeployGroup)
@AzureVirtualMachine(name = AzureTestConstants.instanceName, group = groupName)
Hostname hostname;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import sunstone.azure.armTemplates.AzureTestConstants;
import sunstone.azure.armTemplates.archiveDeploy.vm.VmDeploySuiteTests;
import sunstone.azure.annotation.AzureVirtualMachine;
import okhttp3.OkHttpClient;
import okhttp3.Request;
Expand All @@ -14,6 +13,7 @@
import sunstone.inject.Hostname;

import java.io.IOException;
import static sunstone.azure.armTemplates.AzureTestConstants.deployGroup;

/**
* The test is supposed to run after AzureWebAppDeployFirstTest and verifies undeploy operation
Expand All @@ -22,9 +22,10 @@
@Parameter(k = "virtualMachineName", v = AzureTestConstants.instanceName),
@Parameter(k = "imageRefId", v = AzureTestConstants.IMAGE_REF)
},
template = "sunstone/azure/armTemplates/eap.json", group = VmDeploySuiteTests.vmDeployGroup, perSuite = true)
template = "sunstone/azure/armTemplates/eap.json", group = AzureVmUndeployedSecondTest.groupName, perSuite = true)
public class AzureVmUndeployedSecondTest {
@AzureVirtualMachine(name = AzureTestConstants.instanceName, group = VmDeploySuiteTests.vmDeployGroup)
static final String groupName = "AzureVmUndeployedSecondTest-" + deployGroup;
@AzureVirtualMachine(name = AzureTestConstants.instanceName, group = groupName)
Hostname hostname;

@Test
Expand Down
Loading

0 comments on commit a878b99

Please sign in to comment.