Skip to content

Commit 8052b5a

Browse files
authored
Integration tests restructure (#205)
* restructure integration tests * reverte groupID default change from oracle:root * handle very bad message from Oracle Container Registry when image is not found * remove integration test base class * removed guava dependency, no longer used
1 parent 413defc commit 8052b5a

File tree

23 files changed

+1386
-841
lines changed

23 files changed

+1386
-841
lines changed

.mvn/maven.config-template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Dtest.dependency.dir=/some/folder/with/installers
1+
-Dtest.staging.dir=/some/folder/with/installers

Jenkinsfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ pipeline {
5858
}
5959
steps {
6060
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'otn-cred', passwordVariable: 'ORACLE_SUPPORT_PASSWORD', usernameVariable: 'ORACLE_SUPPORT_USERNAME']]) {
61-
sh 'mvn verify -Dtest.staging.dir=${STAGING_DIR} -Dtest.groups=gate'
61+
sh '''
62+
cd tests
63+
mvn clean verify -Dtest.staging.dir=${STAGING_DIR} -Dtest.groups=gate
64+
'''
6265
}
6366
}
6467
post {
@@ -76,7 +79,10 @@ pipeline {
7679
}
7780
steps {
7881
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'otn-cred', passwordVariable: 'ORACLE_SUPPORT_PASSWORD', usernameVariable: 'ORACLE_SUPPORT_USERNAME']]) {
79-
sh 'mvn verify -Dtest.staging.dir=${STAGING_DIR} -Dtest.groups=gate,nightly'
82+
sh '''
83+
cd tests
84+
mvn clean verify -Dtest.staging.dir=${STAGING_DIR} -Dtest.groups=gate,nightly
85+
'''
8086
}
8187
}
8288
post {

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,54 @@ The Image Tool provides three functions within the main script:
4141

4242
Use the [Quick Start](site/quickstart.md) guide to create a Linux based WebLogic Docker image.
4343

44+
## Building From Source
45+
46+
The Image Tool installer is available for download on the [Releases](releases) page. If you want
47+
to build the installer from source instead of downloading it, follow these instructions:
48+
- Download and install JDK 8u261+
49+
- Download and install Maven 3.6.3+
50+
- Clone this repository to your local environment using one of the options under `Code` near the top of this page.
51+
- From inside the top-level directory of the cloned project, `weblogic-image-tool`, using Maven, execute one or
52+
more of these phases:
53+
- `validate` - Validate the project is correct and all necessary information is available.
54+
- `compile` - Compile the source code.
55+
- `test` - Test the compiled source code using the JUnit5 framework.
56+
- `package` - Create the installer ZIP file, `imagetool.zip`.
57+
- `verify` - Run integration tests using the JUnit5 framework (Pre-requisite: Docker installed).
58+
- `clean` - Restore the source by removing any items created by `package` or another phase of the build.
59+
60+
**Note:** Maven executes build phases sequentially, `validate`, `compile`, `test`, `package`, `verify`, such that
61+
running `verify` will run all of these phases from `validate` through `package` before executing `verify`.
62+
63+
Because the `package` phase comes before the `verify` phase, it is not necessary to run the integration tests to create
64+
the Image Tool installer. If you are making changes and want to validate those changes in your environment, you will
65+
need to do some additional setup before running the `verify` phase because several of the integration tests require
66+
access to the Oracle Technology Network. To run the integration tests in the
67+
`verify` phase, you must specify three environment variables, `ORACLE_SUPPORT_USERNAME`, `ORACLE_SUPPORT_PASSWORD`,
68+
and `STAGING_DIR`. The first two, Oracle Support user name and password, are used to connect to Oracle OTN for patches.
69+
The third, `STAGING_DIR`, should be a local folder where WebLogic Server installers, JDK installers, and pre-downloaded
70+
patches can be found. The files required in the `STAGING_DIR` depend on which tests that you want to run.
71+
72+
Example: Run a set of integration tests (available groups are `cache`, `gate`, and `nightly`:
73+
```shell script
74+
mvn verify -Dtest.groups=cache
75+
```
76+
77+
Example: Run a single integration test:
78+
```shell script
79+
mvn verify -Dtest.groups=gate,nightly -Dit.test=ITImagetool#createWlsImg
80+
```
81+
82+
Integration Test groups:
83+
- `cache` - Tests that build and manipulate the Image Tool cache.
84+
- `gate` - A basic set of integration tests that are used to validate merge requests, including building several
85+
Docker image (~20 minutes)
86+
- `nightly` - The full set of integration tests building various Docker images including JRF and WLS
87+
installations (~2 hours)
88+
89+
**Note:** In order to run an integration test that builds an image like `createWlsImg`, you must run the `cache`
90+
group first in order to populate the cache with the WLS and JDK installers.
91+
4492
## Samples
4593

4694
* [Create an image with full Internet access](site/create-image-with-internet.md)

imagetool/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@
4343
<artifactId>junit-jupiter-engine</artifactId>
4444
<scope>test</scope>
4545
</dependency>
46-
<dependency>
47-
<groupId>com.google.guava</groupId>
48-
<artifactId>guava</artifactId>
49-
<scope>test</scope>
50-
</dependency>
5146
<dependency>
5247
<groupId>com.github.spullara.mustache.java</groupId>
5348
<artifactId>compiler</artifactId>

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ String getPassword() {
487487
names = {"--chown"},
488488
split = ":",
489489
description = "userid:groupid for JDK/Middleware installs and patches. Default: ${DEFAULT-VALUE}.",
490-
defaultValue = "oracle:root"
490+
defaultValue = "oracle:oracle"
491491
)
492492
private String[] osUserAndGroup;
493493

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/Utils.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,11 @@ public static boolean isEmptyString(String s) {
422422
public static Properties getBaseImageProperties(String dockerImage, String tmpDir)
423423
throws IOException, InterruptedException {
424424

425+
logger.entering(dockerImage, tmpDir);
425426
List<String> imageEnvCmd = Utils.getDockerRunCmd(tmpDir, dockerImage, "test-env.sh");
426-
return Utils.runDockerCommand(imageEnvCmd);
427+
Properties result = Utils.runDockerCommand(imageEnvCmd);
428+
logger.exiting(result);
429+
return result;
427430
}
428431

429432
/**
@@ -726,7 +729,11 @@ public static String getMessage(@PropertyKey(resourceBundle = "ImageTool") Strin
726729
if (bundle.containsKey(key)) {
727730
message = bundle.getString(key);
728731
}
729-
return MessageFormat.format(message, params);
732+
if (params == null || params.length == 0) {
733+
return message;
734+
} else {
735+
return MessageFormat.format(message, params);
736+
}
730737
}
731738

732739
/**

tests/pom.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<properties>
2020
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/../${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
2121
<skipITs>false</skipITs>
22-
<test.staging.dir>MUST BE SET TO DIRECTORY WITH PATCHES AND INSTALLERS</test.staging.dir>
2322
</properties>
2423

2524
<dependencies>
@@ -33,11 +32,6 @@
3332
<artifactId>junit-jupiter-engine</artifactId>
3433
<scope>test</scope>
3534
</dependency>
36-
<dependency>
37-
<groupId>com.google.guava</groupId>
38-
<artifactId>guava</artifactId>
39-
<scope>test</scope>
40-
</dependency>
4135
</dependencies>
4236

4337
<build>
@@ -65,7 +59,7 @@
6559
</requireEnvironmentVariable>
6660
<requireProperty>
6761
<property>test.staging.dir</property>
68-
<message>For integration tests, you must set the test.staging.dir System property to point to the directory where the installers are staged. Or, set STAGING_DIR environment variable.</message>
62+
<message>For integration tests, you must define the test.staging.dir System property to point to the directory where the installers are staged. Or, set STAGING_DIR environment variable.</message>
6963
</requireProperty>
7064
</rules>
7165
</configuration>
@@ -126,9 +120,9 @@
126120
<artifactId>jacoco-maven-plugin</artifactId>
127121
<executions>
128122
<execution>
129-
<id>prepare-agent</id>
123+
<id>prepare-agent-it</id>
130124
<goals>
131-
<goal>prepare-agent-integration</goal>
125+
<goal>prepare-agent</goal>
132126
</goals>
133127
</execution>
134128
<execution>

0 commit comments

Comments
 (0)