forked from clusterbench/clusterbench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for Tomcat clusterbench#435
- Loading branch information
Showing
7 changed files
with
357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright The ClusterBench Authors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.jboss.test</groupId> | ||
<artifactId>clusterbench</artifactId> | ||
<version>9.0.0.Final-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>clusterbench-it-parent</artifactId> | ||
<packaging>pom</packaging> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.arquillian</groupId> | ||
<artifactId>arquillian-bom</artifactId> | ||
<version>${version.org.jboss.arquillian}</version> | ||
<scope>import</scope> | ||
<type>pom</type> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<modules> | ||
<!-- | ||
<module>wildfly</module> | ||
--> | ||
<module>tomcat-10.1</module> | ||
</modules> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright The ClusterBench Authors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.jboss.test</groupId> | ||
<artifactId>clusterbench-it-parent</artifactId> | ||
<version>9.0.0.Final-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>clusterbench-it-tomcat-10.1</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<catalina.home>${project.build.directory}/apache-tomcat-${version.org.apache.tomcat}</catalina.home> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.test</groupId> | ||
<artifactId>clusterbench-ee10-web</artifactId> | ||
<version>${project.version}</version> | ||
<classifier>classes</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.container</groupId> | ||
<artifactId>arquillian-tomcat-managed-8</artifactId> | ||
<version>1.1.0.Final</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.junit</groupId> | ||
<artifactId>arquillian-junit-container</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- Needed by ARQ --> | ||
<dependency> | ||
<groupId>jakarta.servlet</groupId> | ||
<artifactId>jakarta.servlet-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<testResources> | ||
<testResource> | ||
<directory>src/test/resources</directory> | ||
<includes> | ||
<include>arquillian.xml</include> | ||
</includes> | ||
<filtering>true</filtering> | ||
</testResource> | ||
<testResource> | ||
<directory>src/test/resources/tomcat</directory> | ||
<targetPath>${catalina.home}/conf</targetPath> | ||
<includes> | ||
<include>*</include> | ||
</includes> | ||
<filtering>true</filtering> | ||
</testResource> | ||
<testResource> | ||
<directory>src/test/java</directory> | ||
<includes> | ||
<include>**/*.properties</include> | ||
<include>**/*.xml</include> | ||
</includes> | ||
<filtering>true</filtering> | ||
</testResource> | ||
</testResources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-war</id> | ||
<phase>generate-test-resources</phase> | ||
<goals> | ||
<goal>copy</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>org.jboss.test</groupId> | ||
<artifactId>clusterbench-ee10-web</artifactId> | ||
<version>${project.version}</version> | ||
<type>war</type> | ||
<overWrite>true</overWrite> | ||
<classifier>tomcat</classifier> | ||
<outputDirectory>${project.build.directory}</outputDirectory> | ||
</artifactItem> | ||
</artifactItems> | ||
<stripVersion>true</stripVersion> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>unpack-tomcat</id> | ||
<phase>generate-test-resources</phase> | ||
<goals> | ||
<goal>unpack</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>org.apache.tomcat</groupId> | ||
<artifactId>tomcat</artifactId> | ||
<version>${version.org.apache.tomcat}</version> | ||
<type>zip</type> | ||
<overWrite>true</overWrite> | ||
<outputDirectory>${project.build.directory}</outputDirectory> | ||
<includes>**</includes> | ||
</artifactItem> | ||
</artifactItems> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>clean-tomcat-webapps</id> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>clean</goal> | ||
</goals> | ||
<configuration> | ||
<excludeDefaultDirectories>true</excludeDefaultDirectories> | ||
<filesets> | ||
<fileset> | ||
<directory>${catalina.home}/webapps</directory> | ||
<includes> | ||
<include>ROOT/**</include> | ||
<include>docs/**</include> | ||
<include>examples/**</include> | ||
</includes> | ||
</fileset> | ||
</filesets> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-tomcat-1</id> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.build.directory}/tomcat-1</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>${catalina.home}</directory> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>smoke-test</id> | ||
<phase>integration-test</phase> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
<configuration> | ||
<trimStackTrace>false</trimStackTrace> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
74 changes: 74 additions & 0 deletions
74
...-10.1/src/test/java/org/jboss/test/clusterbench/it/tomcat/HttpSessionServletTomcatIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright The ClusterBench Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.test.clusterbench.it.tomcat; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
import java.util.Arrays; | ||
import java.util.Optional; | ||
|
||
import org.apache.http.Header; | ||
import org.apache.http.client.methods.CloseableHttpResponse; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.client.CloseableHttpClient; | ||
import org.apache.http.impl.client.HttpClients; | ||
import org.apache.http.util.EntityUtils; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.importer.ZipImporter; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.jboss.test.clusterbench.web.session.HttpSessionServlet; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* @author Radoslav Husar | ||
*/ | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class HttpSessionServletTomcatIT { | ||
|
||
@Deployment(testable = false) | ||
public static Archive<?> deployment() { | ||
return ShrinkWrap | ||
.create(ZipImporter.class, "clusterbench.war") | ||
.importFrom(new File("target/clusterbench-ee10-web-tomcat.war")) | ||
.as(WebArchive.class); | ||
} | ||
|
||
@Test | ||
public void test(@ArquillianResource(HttpSessionServlet.class) URL baseURL) throws Exception { | ||
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { | ||
HttpGet httpGet = new HttpGet(baseURL.toURI() + "/session"); | ||
System.out.println(httpGet); | ||
|
||
try (CloseableHttpResponse response = httpClient.execute(httpGet)) { | ||
assertEquals(200, response.getStatusLine().getStatusCode()); | ||
|
||
String responseBody = EntityUtils.toString(response.getEntity()); | ||
assertEquals("0", responseBody); | ||
|
||
// Also ensure session is created | ||
Optional<Header> header = Arrays.stream(response.getAllHeaders()).filter(h -> Arrays.stream(h.getElements()).anyMatch(e -> e.getName().equals("JSESSIONID"))).findAny(); | ||
assertTrue(header.isPresent()); | ||
} | ||
|
||
try (CloseableHttpResponse response = httpClient.execute(httpGet)) { | ||
assertEquals(200, response.getStatusLine().getStatusCode()); | ||
|
||
String responseBody = EntityUtils.toString(response.getEntity()); | ||
assertEquals("1", responseBody); | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
integration-tests/tomcat-10.1/src/test/resources/arquillian.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<!-- | ||
~ Copyright The ClusterBench Authors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> | ||
<group qualifier="tomcat" default="true"> | ||
<container qualifier="tomcat-1"> | ||
<configuration> | ||
<property name="catalinaHome">${project.build.directory}/tomcat-1</property> | ||
<property name="jmxPort">8089</property> | ||
<property name="bindHttpPort">8080</property> | ||
<property name="javaVmArguments">--add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED</property> | ||
<property name="user">admin</property> | ||
<property name="pass">admin</property> | ||
</configuration> | ||
</container> | ||
</group> | ||
</arquillian> |
15 changes: 15 additions & 0 deletions
15
integration-tests/tomcat-10.1/src/test/resources/tomcat/tomcat-users.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright The ClusterBench Authors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> | ||
<role rolename="manager-gui"/> | ||
<role rolename="manager-script"/> | ||
<role rolename="manager-jmx"/> | ||
<role rolename="manager-status"/> | ||
<role rolename="admin-gui"/> | ||
<role rolename="admin-script"/> | ||
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/> | ||
</tomcat-users> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters