Skip to content

Commit

Permalink
Add integration tests for Tomcat clusterbench#435
Browse files Browse the repository at this point in the history
  • Loading branch information
rhusar committed Mar 12, 2024
1 parent 0468c23 commit f9e7a67
Show file tree
Hide file tree
Showing 7 changed files with 357 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clusterbench-ee10-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
<goal>war</goal>
</goals>
<configuration>
<!-- This makes classes testable and can be depended upon -->
<attachClasses>true</attachClasses>
<webResources>
<resource>
<filtering>true</filtering>
Expand Down
38 changes: 38 additions & 0 deletions integration-tests/pom.xml
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>
202 changes: 202 additions & 0 deletions integration-tests/tomcat-10.1/pom.xml
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>
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 integration-tests/tomcat-10.1/src/test/resources/arquillian.xml
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>
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>
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@
<module>clusterbench-ee10-ejb</module>
<module>clusterbench-ee10-web</module>
<module>clusterbench-ee10-ear</module>
<module>integration-tests</module>
</modules>

<properties>
<linkXRef>false</linkXRef>
<version.org.wildfly>31.0.1.Final</version.org.wildfly>
<version.org.wildfly.cloud-feature-pack>6.0.0.Final</version.org.wildfly.cloud-feature-pack>
<version.org.wildfly.maven.plugin>4.2.2.Final</version.org.wildfly.maven.plugin>

<!-- Test dependencies -->
<version.org.apache.tomcat>10.1.15</version.org.apache.tomcat>
<version.org.junit.jupiter>5.10.0</version.org.junit.jupiter>
<version.org.jboss.arquillian>1.8.0.Final</version.org.jboss.arquillian>

<wildfly.skip>true</wildfly.skip>
</properties>

Expand Down

0 comments on commit f9e7a67

Please sign in to comment.