Skip to content

Commit

Permalink
Integration tests for cluster deployment
Browse files Browse the repository at this point in the history
Covers also commit e5aec10
Signed-off-by:Ondro Mihalyi <mihalyi@omnifish.ee>
  • Loading branch information
OndroMih committed May 21, 2023
1 parent eae5330 commit c8fe818
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 5 deletions.
22 changes: 22 additions & 0 deletions appserver/tests/admin/tests/pom.xml
Expand Up @@ -141,6 +141,28 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>test-app-for-ClusterITest</id>
<phase>process-test-classes</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<primaryArtifact>false</primaryArtifact>
<classifier>clusterit</classifier>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingIncludes>index.html</packagingIncludes>
<warSourceDirectory>${basedir}/src/main/webapp/clusterit</warSourceDirectory>
<outputDirectory>${project.build.directory}/testapps</outputDirectory>
<webappDirectory>${project.build.directory}/testapps/${project.build.finalName}-clusterit</webappDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
26 changes: 26 additions & 0 deletions appserver/tests/admin/tests/src/main/webapp/clusterit/index.html
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<!--
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<html>
<head>
<title>Simple test app</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>Simple test app</div>
</body>
</html>
Expand Up @@ -58,6 +58,10 @@
@TestMethodOrder(OrderAnnotation.class)
public class ClusterITest {

// this name needs to match the filename generated by the Maven build
private static final String TEST_WAR_FILENAME = "admin-tests-clusterit.war";
private static final String TEST_WAR_LOCATION = "testapps";
private static final String TEST_APP_NAME = "testapp";
private static final String PORT1 = "55123";
private static final String PORT2 = "55124";
private static final String CLUSTER_NAME = "eec1";
Expand All @@ -67,6 +71,7 @@ public class ClusterITest {
private static final String URL2 = "http://localhost:" + PORT2;
private static final Asadmin ASADMIN = GlassFishTestEnvironment.getAsadmin();
private static final AtomicBoolean INSTANCES_REACHABLE = new AtomicBoolean();
private static final AtomicBoolean APP_DEPLOYED = new AtomicBoolean();


@AfterAll
Expand All @@ -83,6 +88,15 @@ public void createClusterTest() {

@Test
@Order(2)
public void deployAppToClusterTest() {
String warFile = GlassFishTestEnvironment.getTargetDirectory()
.toPath().resolve(TEST_WAR_LOCATION).resolve(TEST_WAR_FILENAME).toString();
assertThat(ASADMIN.exec("deploy", "--target", CLUSTER_NAME, "--name", TEST_APP_NAME, "--contextroot", TEST_APP_NAME,
warFile), asadminOK());
}

@Test
@Order(3)
public void createInstancesTest() {
assertThat(
ASADMIN.exec("create-local-instance", "--cluster", CLUSTER_NAME, "--systemproperties",
Expand Down Expand Up @@ -111,21 +125,32 @@ public void createInstancesTest() {


@Test
@Order(3)
@Order(4)
public void startInstancesTest() {
assertThat(ASADMIN.exec(60_000, "start-local-instance", INSTANCE_NAME_1), asadminOK());
assertThat(ASADMIN.exec(60_000, "start-local-instance", INSTANCE_NAME_2), asadminOK());
}

@Test
@Order(4)
@Order(5)
public void checkClusterTest() {
assertThat(ASADMIN.exec("list-instances"), asadminOK());
assertThat(getURL(URL1), stringContainsInOrder("GlassFish Server"));
assertThat(getURL(URL2), stringContainsInOrder("GlassFish Server"));
INSTANCES_REACHABLE.set(true);
}

@Test
@Order(6)
public void checkDeploymentTest() {
final AsadminResult result = ASADMIN.exec("list-applications", CLUSTER_NAME);
assertThat(result, asadminOK());
assertThat("list-applications output", result.getStdOut(), containsString(TEST_APP_NAME));
APP_DEPLOYED.set(true);
assertThat(getURL(URL1 + "/" + TEST_APP_NAME), stringContainsInOrder("Simple test app"));
assertThat(getURL(URL2 + "/" + TEST_APP_NAME), stringContainsInOrder("Simple test app"));
}

@Test
@Order(10)
public void retrieveCollectedLogFilesTest() throws IOException {
Expand Down Expand Up @@ -169,24 +194,30 @@ public void collectLogFilesFromInstanceTest() {

@Test
@Order(20)
public void undeployAppsTest() {
Assumptions.assumeTrue(APP_DEPLOYED.get());
assertThat(ASADMIN.exec("undeploy", "--target", CLUSTER_NAME, TEST_APP_NAME), asadminOK());
}

@Test
@Order(21)
public void stopInstancesTest() {
Assumptions.assumeTrue(INSTANCES_REACHABLE.get());
assertThat(ASADMIN.exec("stop-local-instance", "--kill", INSTANCE_NAME_1), asadminOK());
assertThat(ASADMIN.exec("stop-local-instance", "--kill", INSTANCE_NAME_2), asadminOK());
}

@Test
@Order(21)
@Order(22)
public void deleteInstancesTest() {
Assumptions.assumeTrue(INSTANCES_REACHABLE.get());
assertThat(ASADMIN.exec("delete-local-instance", INSTANCE_NAME_1), asadminOK());
assertThat(ASADMIN.exec("delete-local-instance", INSTANCE_NAME_2), asadminOK());
}

@Test
@Order(22)
@Order(23)
public void deleteClusterTest() {
Assumptions.assumeTrue(INSTANCES_REACHABLE.get());
assertThat(ASADMIN.exec("delete-cluster", CLUSTER_NAME), asadminOK());
}

Expand Down

0 comments on commit c8fe818

Please sign in to comment.