Skip to content

Commit c74d88f

Browse files
committed
Initial ARQ tests
1 parent 76b5701 commit c74d88f

19 files changed

+3415
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target
2+
.idea
3+
*.iml

tests/arq/pom.xml

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.jboss</groupId>
9+
<artifactId>jboss-parent</artifactId>
10+
<version>25</version>
11+
</parent>
12+
13+
<groupId>org.jboss.ce.testsuite</groupId>
14+
<artifactId>openjdk-arq-testsuite</artifactId>
15+
<packaging>jar</packaging>
16+
<name>OpenJDK 1.8 testsuite</name>
17+
<version>1.0-SNAPSHOT</version>
18+
<description>Arquillian OpenJDK 1.8 testsuite</description>
19+
20+
<properties>
21+
<version.arquillian>1.4.0.Final</version.arquillian>
22+
<version.arquillian.cube>1.16.0</version.arquillian.cube>
23+
<version.json-simple>1.1.1</version.json-simple>
24+
<version.junit>4.12</version.junit>
25+
<version.org.jboss.as.arquillian.container>7.2.0.Final</version.org.jboss.as.arquillian.container>
26+
<version.ce-arq>1.3.0.Final</version.ce-arq>
27+
28+
<image>registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift:1.4</image>
29+
<image.stream.version>1.4</image.stream.version>
30+
<image.stream.name>redhat-openjdk18-openshift</image.stream.name>
31+
</properties>
32+
33+
<dependencyManagement>
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.jboss.arquillian</groupId>
37+
<artifactId>arquillian-bom</artifactId>
38+
<version>${version.arquillian}</version>
39+
<type>pom</type>
40+
<scope>import</scope>
41+
</dependency>
42+
43+
<dependency>
44+
<groupId>org.arquillian.cube</groupId>
45+
<artifactId>arquillian-cube-bom</artifactId>
46+
<version>${version.arquillian.cube}</version>
47+
<scope>import</scope>
48+
<type>pom</type>
49+
</dependency>
50+
</dependencies>
51+
</dependencyManagement>
52+
53+
<dependencies>
54+
55+
<dependency>
56+
<groupId>com.googlecode.json-simple</groupId>
57+
<artifactId>json-simple</artifactId>
58+
<version>${version.json-simple}</version>
59+
</dependency>
60+
61+
<dependency>
62+
<groupId>org.jboss.arquillian.container</groupId>
63+
<artifactId>arquillian-ce-httpclient</artifactId>
64+
<version>${version.ce-arq}</version>
65+
</dependency>
66+
67+
<dependency>
68+
<groupId>org.jboss.arquillian.container</groupId>
69+
<artifactId>arquillian-ce-shrinkwrap</artifactId>
70+
<version>${version.ce-arq}</version>
71+
</dependency>
72+
73+
<dependency>
74+
<groupId>org.arquillian.cube</groupId>
75+
<artifactId>arquillian-cube-openshift</artifactId>
76+
<version>${version.arquillian.cube}</version>
77+
<scope>test</scope>
78+
</dependency>
79+
80+
<dependency>
81+
<groupId>org.jboss.arquillian.junit</groupId>
82+
<artifactId>arquillian-junit-container</artifactId>
83+
<version>${version.arquillian}</version>
84+
<scope>test</scope>
85+
</dependency>
86+
87+
<dependency>
88+
<groupId>org.jboss.arquillian.protocol</groupId>
89+
<artifactId>arquillian-protocol-jmx</artifactId>
90+
<version>${version.arquillian}</version>
91+
<scope>test</scope>
92+
</dependency>
93+
94+
<dependency>
95+
<groupId>org.jboss.as</groupId>
96+
<artifactId>jboss-as-arquillian-container-remote</artifactId>
97+
<version>${version.org.jboss.as.arquillian.container}</version>
98+
<scope>test</scope>
99+
</dependency>
100+
101+
<dependency>
102+
<groupId>junit</groupId>
103+
<artifactId>junit</artifactId>
104+
<version>${version.junit}</version>
105+
<scope>test</scope>
106+
</dependency>
107+
108+
</dependencies>
109+
110+
<build>
111+
<plugins>
112+
<plugin>
113+
<groupId>org.apache.maven.plugins</groupId>
114+
<artifactId>maven-dependency-plugin</artifactId>
115+
<executions>
116+
<execution>
117+
<id>unpack-dependencies</id>
118+
<phase>process-test-classes</phase>
119+
<goals>
120+
<goal>unpack-dependencies</goal>
121+
</goals>
122+
<configuration>
123+
<includeGroupIds>org.jboss</includeGroupIds>
124+
<includeTypes>test-jar</includeTypes>
125+
<includeScope>test</includeScope>
126+
<outputDirectory>${project.build.directory}/test-classes</outputDirectory>
127+
<overWriteReleases>false</overWriteReleases>
128+
<overWriteSnapshots>true</overWriteSnapshots>
129+
</configuration>
130+
</execution>
131+
</executions>
132+
</plugin>
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-surefire-plugin</artifactId>
136+
<configuration>
137+
<runOrder>alphabetical</runOrder>
138+
<redirectTestOutputToFile>true</redirectTestOutputToFile>
139+
<trimStackTrace>false</trimStackTrace>
140+
<forkCount>4</forkCount>
141+
<reuseForks>false</reuseForks>
142+
<includes>
143+
<include>org/jboss/**/*Test.java</include>
144+
</includes>
145+
<systemPropertyVariables>
146+
<!-- the property below ere needed to run the All in One tests, if it is not set then it
147+
will be default to cloudapps.example.com, then make sure your openshift instance can resolve this
148+
domain internally -->
149+
<route.suffix>cloudapps.example.com</route.suffix>
150+
<!-- end -->
151+
<sun.net.spi.nameservice.provider.1>dns,ArquillianCubeNameService</sun.net.spi.nameservice.provider.1>
152+
<sun.net.spi.nameservice.provider.2>default</sun.net.spi.nameservice.provider.2>
153+
<kubernetes.master>${kubernetes.master}</kubernetes.master>
154+
<kubernetes.auth.token>${kubernetes.auth.token}</kubernetes.auth.token>
155+
<arq.extension.openshift.routerHost>${router.hostIP}</arq.extension.openshift.routerHost>
156+
<image.stream.image>${image}</image.stream.image>
157+
<image.stream.name>${image.stream.name}</image.stream.name>
158+
<image.stream.version>${image.stream.version}</image.stream.version>
159+
<template.repository>jboss-openshift</template.repository>
160+
<template.branch>master</template.branch>
161+
<!-- URL to the OpenShift image streams that are officially added to OCP. These image streams are added to every test project run on OpenShift -->
162+
<openshift.imageStreams>https://raw.githubusercontent.com/openshift/origin/v3.9.0/examples/image-streams/image-streams-rhel7.json</openshift.imageStreams>
163+
</systemPropertyVariables>
164+
</configuration>
165+
</plugin>
166+
</plugins>
167+
</build>
168+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.jboss.test.arquillian.ce.openjdk;
2+
3+
import org.arquillian.cube.openshift.api.OpenShiftHandle;
4+
import org.arquillian.cube.openshift.impl.enricher.RouteURL;
5+
import org.jboss.arquillian.container.test.api.RunAsClient;
6+
import org.jboss.arquillian.test.api.ArquillianResource;
7+
import org.junit.Test;
8+
9+
import java.net.URL;
10+
import java.util.logging.Logger;
11+
12+
public class OpenJDKDatabaseTest extends OpenJDKTest {
13+
14+
private Logger log = Logger.getLogger(getClass().getName());
15+
16+
@ArquillianResource
17+
OpenShiftHandle adapter;
18+
19+
private final String NAME = "John";
20+
private final String NUMBER = "0123456789";
21+
private final String INSERT = "Stored " + NUMBER + " for " + NAME;
22+
private final String RETRIEVE = "Number for " + NAME + " is " + NUMBER;
23+
24+
protected boolean persistent;
25+
protected String driver;
26+
27+
@RouteURL("openjdk-app")
28+
private URL url;
29+
30+
@Test
31+
@RunAsClient
32+
public void testRoute() throws Exception {
33+
String insert = url.toString() + "/?name=" + NAME + "&number=" + NUMBER;
34+
checkResponse(insert, INSERT);
35+
if (persistent) {
36+
restartPod("openjdk-app-" + driver);
37+
}
38+
String retrieve = url.toString() + "/?name=" + NAME;
39+
checkResponse(retrieve, RETRIEVE);
40+
}
41+
42+
private void restartPod(String name) throws Exception {
43+
log.info("Scaling down " + name);
44+
adapter.scaleDeployment(name, 0);
45+
log.info("Scaling up " + name);
46+
adapter.scaleDeployment(name, 1);
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.jboss.test.arquillian.ce.openjdk;
2+
3+
import org.arquillian.cube.openshift.api.OpenShiftResource;
4+
import org.arquillian.cube.openshift.api.Template;
5+
import org.arquillian.cube.openshift.api.TemplateParameter;
6+
import org.jboss.arquillian.junit.Arquillian;
7+
import org.junit.runner.RunWith;
8+
9+
@RunWith(Arquillian.class)
10+
@Template(url = "file://${user.dir}/src/test/resources/openjdk18-mysql-persistent-s2i.json",
11+
parameters = {
12+
@TemplateParameter(name = "IMAGE_STREAM_NAMESPACE", value = "${kubernetes.namespace:openshift}")
13+
}
14+
)
15+
@OpenShiftResource("classpath:openjdk-app-secret.json")
16+
public class OpenJDKMysqlPersistentTest extends OpenJDKDatabaseTest {
17+
18+
public OpenJDKMysqlPersistentTest() {
19+
this.persistent = true;
20+
this.driver = "mysql";
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.jboss.test.arquillian.ce.openjdk;
2+
3+
import org.arquillian.cube.openshift.api.OpenShiftResource;
4+
import org.arquillian.cube.openshift.api.Template;
5+
import org.arquillian.cube.openshift.api.TemplateParameter;
6+
import org.jboss.arquillian.junit.Arquillian;
7+
import org.junit.runner.RunWith;
8+
9+
@RunWith(Arquillian.class)
10+
@Template(url = "file://${user.dir}/src/test/resources/openjdk18-mysql-s2i.json",
11+
parameters = {
12+
@TemplateParameter(name = "IMAGE_STREAM_NAMESPACE", value = "${kubernetes.namespace:openshift}")
13+
}
14+
)
15+
@OpenShiftResource("classpath:openjdk-app-secret.json")
16+
public class OpenJDKMysqlTest extends OpenJDKDatabaseTest {
17+
18+
public OpenJDKMysqlTest() {
19+
this.persistent = false;
20+
this.driver = "mysql";
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.jboss.test.arquillian.ce.openjdk;
2+
3+
import org.arquillian.cube.openshift.api.OpenShiftResource;
4+
import org.arquillian.cube.openshift.api.Template;
5+
import org.arquillian.cube.openshift.api.TemplateParameter;
6+
import org.jboss.arquillian.junit.Arquillian;
7+
import org.junit.runner.RunWith;
8+
9+
@RunWith(Arquillian.class)
10+
@Template(url = "file://${user.dir}/src/test/resources/openjdk18-postgresql-persistent-s2i.json",
11+
parameters = {
12+
@TemplateParameter(name = "IMAGE_STREAM_NAMESPACE", value = "${kubernetes.namespace:openshift}")
13+
}
14+
)
15+
@OpenShiftResource("classpath:openjdk-app-secret.json")
16+
public class OpenJDKPostgresqlPersistentTest extends OpenJDKDatabaseTest {
17+
18+
public OpenJDKPostgresqlPersistentTest() {
19+
this.persistent = true;
20+
this.driver = "postgresql";
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.jboss.test.arquillian.ce.openjdk;
2+
3+
import org.arquillian.cube.openshift.api.OpenShiftResource;
4+
import org.arquillian.cube.openshift.api.Template;
5+
import org.arquillian.cube.openshift.api.TemplateParameter;
6+
import org.jboss.arquillian.junit.Arquillian;
7+
import org.junit.runner.RunWith;
8+
9+
@RunWith(Arquillian.class)
10+
@Template(url = "file://${user.dir}/src/test/resources/openjdk18-postgresql-s2i.json",
11+
parameters = {
12+
@TemplateParameter(name = "IMAGE_STREAM_NAMESPACE", value = "${kubernetes.namespace:openshift}")
13+
}
14+
)
15+
@OpenShiftResource("classpath:openjdk-app-secret.json")
16+
public class OpenJDKPostgresqlTest extends OpenJDKDatabaseTest {
17+
18+
public OpenJDKPostgresqlTest() {
19+
this.persistent = false;
20+
this.driver = "postgresql";
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.jboss.test.arquillian.ce.openjdk;
2+
3+
import java.util.logging.Logger;
4+
5+
import org.arquillian.cube.openshift.api.OpenShiftDynamicImageStreamResource;
6+
import org.arquillian.cube.openshift.api.OpenShiftResource;
7+
import org.jboss.arquillian.ce.httpclient.HttpClientBuilder;
8+
import org.jboss.arquillian.ce.httpclient.HttpClientExecuteOptions;
9+
import org.jboss.arquillian.ce.httpclient.HttpRequest;
10+
import org.jboss.arquillian.ce.httpclient.HttpResponse;
11+
import org.jboss.arquillian.ce.shrinkwrap.Libraries;
12+
import org.jboss.arquillian.container.test.api.Deployment;
13+
import org.jboss.arquillian.junit.Arquillian;
14+
import org.jboss.logmanager.Level;
15+
import org.jboss.shrinkwrap.api.ShrinkWrap;
16+
import org.jboss.shrinkwrap.api.asset.StringAsset;
17+
import org.jboss.shrinkwrap.api.spec.WebArchive;
18+
import org.junit.Assert;
19+
import org.junit.runner.RunWith;
20+
21+
@RunWith(Arquillian.class)
22+
@OpenShiftResource("${openshift.imageStreams}")
23+
@OpenShiftDynamicImageStreamResource(name = "${image.stream.name}", image = "${image.stream.image}", version = "${image.stream.version}")
24+
public class OpenJDKTest {
25+
26+
private Logger log = Logger.getLogger(getClass().getName());
27+
private final HttpClientExecuteOptions execOptions = new HttpClientExecuteOptions.Builder().tries(3)
28+
.desiredStatusCode(200).delay(10).build();
29+
30+
@Deployment
31+
public static WebArchive getDeployment() {
32+
WebArchive war = ShrinkWrap.create(WebArchive.class, "run-in-pod.war");
33+
war.setWebXML(new StringAsset("<web-app/>"));
34+
war.addClass(OpenJDKTest.class);
35+
war.addClass(OpenJDKWebBasicTest.class);
36+
war.addPackage(HttpClientBuilder.class.getPackage());
37+
war.addAsLibraries(Libraries.transitive("org.apache.httpcomponents", "httpclient"));
38+
return war;
39+
}
40+
41+
protected void checkResponse(String url, String expected) throws Exception {
42+
HttpRequest request = HttpClientBuilder.doGET(url);
43+
HttpResponse response = HttpClientBuilder.untrustedConnectionClient().execute(request, execOptions);
44+
String responseString = response.getResponseBodyAsString();
45+
46+
log.log(Level.INFO, responseString);
47+
Assert.assertNotNull(responseString);
48+
Assert.assertEquals(expected, responseString);
49+
}
50+
51+
}

0 commit comments

Comments
 (0)