Skip to content

Commit 6ea1164

Browse files
committed
Initial import of Red Hat's OpenJDK OCP testsuite to GitHub.
0 parents  commit 6ea1164

File tree

98 files changed

+6102
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+6102
-0
lines changed

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Maven
2+
target
3+
# Maven keycloak.js changes for "war-app-html5" and "war-app-profile-html5" example applications
4+
test-sso/src/test/resources/apps/war-app-html5/src/main/webapp/keycloak.js
5+
test-sso/src/test/resources/apps/war-app-profile-html5/src/main/webapp/keycloak.js
6+
7+
# Eclipse
8+
.settings
9+
.classpath
10+
.project
11+
12+
# temp files
13+
log
14+
tmp
15+
log.txt
16+
*.log
17+
18+
# vim
19+
.*.swp
20+
21+
# Intellij
22+
.idea/
23+
*.iml
24+
*.iws
25+
26+
# Test properties
27+
test.properties
28+
29+
# Properties used in runtime
30+
used-test.properties
31+
32+
# Images used in runtime
33+
used-images.properties
34+
35+
# Templates used for tests
36+
used-templates.properties
37+
38+
# Usage report
39+
usage.json
40+
41+
# Indy
42+
infra/maven-cache/indy
43+
44+
# Ansible
45+
*.retry
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright 2007-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.net.*;
17+
import java.io.*;
18+
import java.nio.channels.*;
19+
import java.util.Properties;
20+
21+
public class MavenWrapperDownloader {
22+
23+
private static final String WRAPPER_VERSION = "0.5.5";
24+
/**
25+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26+
*/
27+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29+
30+
/**
31+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32+
* use instead of the default one.
33+
*/
34+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35+
".mvn/wrapper/maven-wrapper.properties";
36+
37+
/**
38+
* Path where the maven-wrapper.jar will be saved to.
39+
*/
40+
private static final String MAVEN_WRAPPER_JAR_PATH =
41+
".mvn/wrapper/maven-wrapper.jar";
42+
43+
/**
44+
* Name of the property which should be used to override the default download url for the wrapper.
45+
*/
46+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47+
48+
public static void main(String args[]) {
49+
System.out.println("- Downloader started");
50+
File baseDirectory = new File(args[0]);
51+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52+
53+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
54+
// wrapperUrl parameter.
55+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56+
String url = DEFAULT_DOWNLOAD_URL;
57+
if(mavenWrapperPropertyFile.exists()) {
58+
FileInputStream mavenWrapperPropertyFileInputStream = null;
59+
try {
60+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61+
Properties mavenWrapperProperties = new Properties();
62+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64+
} catch (IOException e) {
65+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66+
} finally {
67+
try {
68+
if(mavenWrapperPropertyFileInputStream != null) {
69+
mavenWrapperPropertyFileInputStream.close();
70+
}
71+
} catch (IOException e) {
72+
// Ignore ...
73+
}
74+
}
75+
}
76+
System.out.println("- Downloading from: " + url);
77+
78+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79+
if(!outputFile.getParentFile().exists()) {
80+
if(!outputFile.getParentFile().mkdirs()) {
81+
System.out.println(
82+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83+
}
84+
}
85+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86+
try {
87+
downloadFileFromURL(url, outputFile);
88+
System.out.println("Done");
89+
System.exit(0);
90+
} catch (Throwable e) {
91+
System.out.println("- Error downloading");
92+
e.printStackTrace();
93+
System.exit(1);
94+
}
95+
}
96+
97+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99+
String username = System.getenv("MVNW_USERNAME");
100+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101+
Authenticator.setDefault(new Authenticator() {
102+
@Override
103+
protected PasswordAuthentication getPasswordAuthentication() {
104+
return new PasswordAuthentication(username, password);
105+
}
106+
});
107+
}
108+
URL website = new URL(urlString);
109+
ReadableByteChannel rbc;
110+
rbc = Channels.newChannel(website.openStream());
111+
FileOutputStream fos = new FileOutputStream(destination);
112+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113+
fos.close();
114+
rbc.close();
115+
}
116+
117+
}

.mvn/wrapper/maven-wrapper.jar

49.5 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018, 2020 ocp-openjdk-test authors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Red Hat OpenJDK OpenShift Container Platform(OCP) Test Suite
2+
***
3+
This test suite is designed to be executed against current versions of Red Hat's OpenJDK containers.
4+
5+
| Operating System version | OpenJDK Version | Link to Container |
6+
|--------------------------|-----------------|--------------------------------------------------------------------------------------------------------------------------------------|
7+
| Rhel 7 | 8 | [openjdk18-openshift](https://catalog.redhat.com/software/containers/redhat-openjdk-18/openjdk18-openshift/58ada5701fbe981673cd6b10) |
8+
| Rhel 7 | 11 | [openjdk-11-rhel7](https://catalog.redhat.com/software/containers/openjdk/openjdk-11-rhel7/5bf57185dd19c775cddc4ce5) |
9+
| UBI 8 | 8 | [openjdk-8](https://catalog.redhat.com/software/containers/ubi8/openjdk-8/5dd6a48dbed8bd164a09589a) |
10+
| UBI 8 | 11 | [openjdk-11](https://catalog.redhat.com/software/containers/ubi8/openjdk-11/5dd6a4b45a13461646f677f4) |
11+
| UBI 8 | 17 | [openjdk-17](https://catalog.redhat.com/software/containers/ubi8/openjdk-17/618bdbf34ae3739687568813) |
12+
| UBI 9 | 11 | [openjdk-11](https://catalog.redhat.com/software/containers/ubi9/openjdk-11/61ee7bafed74b2ffb22b07ab) |
13+
| UBI 9 | 17 | [openjdk-17](https://catalog.redhat.com/software/containers/ubi9/openjdk-17/61ee7c26ed74b2ffb22b07f6) |
14+
**Note**: `OpenJDK runtime images are not currently supported by this test suite.`
15+
16+
***
17+
18+
19+
This test suite is based on the XTF project [https://github.com/xtf-cz/xtf] that leverages JUnit 5, Fabric8 Kubernetes Client [https://github.com/fabric8io/kubernetes-client/] and other useful libraries to unify and simplify interactions with OpenShift.
20+
21+
22+
****
23+
24+
## Test Execution
25+
26+
Use `mvn clean` to remove existing test artifacts from your sandbox.
27+
28+
To execute the UBI 8 or UBI 9 images you must create a (Limit Range) [https://docs.openshift.com/container-platform/4.13/nodes/clusters/nodes-cluster-limit-ranges.html]]
29+
To execute the test suite by hand against a defined version of Red Hat's OpenJDK containers issue the following command.
30+
31+
* `MAVEN_HOME=/usr/bin/ mvn clean test -P 8 -P smoke -Dmaven.home=/usr/bin/`
32+
* `MAVEN_HOME=/usr/bin/ mvn clean test -P 11 -P smoke -Dmaven.home=/usr/bin/`
33+
* `MAVEN_HOME=/usr/bin/ mvn clean test -P 17 -P smoke -Dmaven.home=/usr/bin/`
34+
35+
Notice this will execute the test for OpenJDK version 8, 11, or 17. These are the only versions that are supported for testing. To simplify the test execution a `run.sh` has been added. This is the preferred approach to executing tests against the UBI 8 and UBI 9 images.
36+
37+
For UBI 8 and UBI 9 images it is recommended to use the bash script for the execution of the testsuite. The bash script will create the OCP projects as defined in the `global-test.properties` and then create a limit-range resource as defined by the `limit_range.yaml` file.
38+
```bash
39+
bash run.sh --jdk-version=8
40+
bash run.sh --jdk-version=11
41+
bash run.sh --jdk-version=17
42+
```
43+
44+
## Configuration
45+
To configure the test suite for execution against the OpenJDK Image Under Test (IUT) you must have the following.
46+
1. An execution node that can execute a Maven-based Java application.
47+
2. A running instance of Red Hat's OpenShift Container Platform(OCP) with admin access.
48+
49+
Configure the `global-test.properties` to describe your environment as well as two OCP projects that the test suite runs against.
50+
51+
```yaml
52+
#mocked settings
53+
xtf.openshift.namespace=<project_name>
54+
xtf.bm.namespace=<build_project_name>
55+
xtf.openshift.url=<result from 'oc whoami --show-server'>
56+
xtf.openshift.token=<result from 'oc whoami -t'>
57+
xtf.openshift.admin.token=<result from 'oc whoami -t'>
58+
```
59+
60+
#### Token auth
61+
``` yaml
62+
#past example
63+
xtf.openshift.url=https://api.servername:6443
64+
xtf.openshift.token=sha256~lfGBHTDiL1PxVZrM3wMvnU_bvgZyJhZLsb_iU_Zrhwk
65+
xtf.openshift.admin.token=sha256~lfGBHTDiL1PxVZrM3wMvnU_bvgZyJhZLsb_iU_Zrhwk
66+
xtf.openshift.namespace=alpha
67+
xtf.bm.namespace=alpha-builds
68+
69+
```
70+
71+
72+

global-test.properties

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#############################################
2+
###### Image Definition with XTF core #######
3+
#############################################
4+
5+
# UBI 8 (Rhel 8) version of the container
6+
xtf.openjdk.8.image=registry.access.redhat.com/ubi8/openjdk-8:1.17-1.1693366248
7+
xtf.openjdk.8.version=1.8.0
8+
9+
# UBI 8 (Rhel 8) version of the container
10+
xtf.openjdk.11.image=registry.access.redhat.com/ubi8/openjdk-11:1.17-1.1693366250
11+
xtf.openjdk.11.version=11
12+
13+
#JDK 17 image reference
14+
xtf.openjdk.17.image=registry.access.redhat.com/ubi8/openjdk-17:1.17-1.1693366272
15+
xtf.openjdk.17.version=17
16+
17+
#############################################
18+
xtf.openshift.namespace=jdk
19+
xtf.bm.namespace=jdk-build

limit_range.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: "v1"
2+
kind: "LimitRange"
3+
metadata:
4+
name: "openjdk-qe-default-limits"
5+
spec:
6+
limits:
7+
- type: Container
8+
default:
9+
cpu: "2"
10+
memory: 512Mi
11+
defaultRequest:
12+
cpu: "1"
13+
memory: 256Mi

0 commit comments

Comments
 (0)