Skip to content

Commit 8ad16e7

Browse files
xiancaoddsharpe
authored andcommitted
Enable system test (#84)
* enable system test * fix WDT RCU parameter * remove docker login in the test * use known location for installers * remove http_proxy
1 parent 7e34bb7 commit 8ad16e7

File tree

3 files changed

+28
-54
lines changed

3 files changed

+28
-54
lines changed

Diff for: Jenkinsfile

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,12 @@ pipeline {
3030
}
3131
}
3232
}
33-
}
33+
stage ('SystemTest') {
34+
steps {
35+
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'otn-cred', passwordVariable: 'ORACLE_SUPPORT_PASSWORD', usernameVariable: 'ORACLE_SUPPORT_USERNAME']]) {
36+
sh 'mvn verify'
37+
}
38+
}
39+
}
40+
}
3441
}

Diff for: imagetool/src/test/java/com/oracle/weblogic/imagetool/integration/BaseTest.java

+15-37
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@ public class BaseTest {
1717
protected static final Logger logger = Logger.getLogger(ITImagetool.class.getName());
1818
protected static final String PS = File.pathSeparator;
1919
protected static final String FS = File.separator;
20-
private static final String OCIR_SERVER = "phx.ocir.io";
21-
private static final String OCIR_TENENT = "weblogick8s";
22-
private static final String OCR_SERVER = "container-registry.oracle.com";
2320
protected static final String BASE_OS_IMG = "phx.ocir.io/weblogick8s/oraclelinux";
2421
protected static final String BASE_OS_IMG_TAG = "7-4imagetooltest";
25-
protected static final String ORACLE_DB_IMG = "container-registry.oracle.com/database/enterprise";
22+
protected static final String ORACLE_DB_IMG = "phx.ocir.io/weblogick8s/database/enterprise";
2623
protected static final String ORACLE_DB_IMG_TAG = "12.2.0.1-slim";
27-
private static final String DB_CONTAINER_NAME = "InfraDB";
24+
protected static final String DB_CONTAINER_NAME = "InfraDB";
2825
private static String projectRoot = "";
2926
protected static String wlsImgBldDir = "";
3027
protected static String wlsImgCacheDir = "";
3128
protected static String imagetool = "";
3229
private static int maxIterations = 50;
3330
private static int waitTime = 5;
34-
private static String IMAGETOOLZIPFILE = "imagetool.zip";
35-
private static String IMAGETOOLDIR = "imagetool";
31+
private static final String IMAGETOOLZIPFILE = "imagetool.zip";
32+
private static final String IMAGETOOLDIR = "imagetool";
33+
private static final String INSTALLERCACHEDIR = "/scratch/artifacts/imagetool";
3634

3735
protected static void initialize() throws Exception {
3836
logger.info("Initializing the tests ...");
@@ -61,11 +59,11 @@ protected static void initialize() throws Exception {
6159
protected static void setup() throws Exception {
6260

6361
logger.info("Setting up the test environment ...");
64-
String command = "/bin/rm -rf " + getImagetoolHome();
62+
String command = "rm -rf " + getImagetoolHome();
6563
executeNoVerify(command);
6664

6765
// unzip the weblogic-image-tool/imagetool/target/imagetool.zip
68-
command = "/bin/unzip " + getTargetDir() + FS + IMAGETOOLZIPFILE;
66+
command = "unzip " + getTargetDir() + FS + IMAGETOOLZIPFILE;
6967
executeNoVerify(command);
7068

7169
command = "source " + getImagetoolHome() + FS + "bin" + FS + "setup.sh";
@@ -74,10 +72,10 @@ protected static void setup() throws Exception {
7472

7573
protected static void cleanup() throws Exception {
7674
logger.info("cleaning up the test environment ...");
77-
String command = "/bin/rm -rf " + wlsImgCacheDir;
75+
String command = "rm -rf " + wlsImgCacheDir;
7876
executeNoVerify(command);
7977

80-
command = "/bin/mkdir " + wlsImgCacheDir;
78+
command = "mkdir " + wlsImgCacheDir;
8179
executeNoVerify(command);
8280

8381
// clean up the docker images
@@ -88,35 +86,18 @@ protected static void cleanup() throws Exception {
8886
executeNoVerify(command);
8987

9088
// clean up the possible left over wlsimgbuilder_temp*
91-
command = "/bin/rm -rf " + wlsImgBldDir + FS + "wlsimgbuilder_temp*";
89+
command = "rm -rf " + wlsImgBldDir + FS + "wlsimgbuilder_temp*";
9290
executeNoVerify(command);
9391
}
9492

9593
protected static void pullBaseOSDockerImage() throws Exception {
9694
logger.info("Pulling OS base images from OCIR ...");
97-
String ocir_username = System.getenv("OCIR_USERNAME");
98-
String ocir_password = System.getenv("OCIR_PASSWORD");
99-
100-
if(ocir_username == null || ocir_password == null) {
101-
throw new Exception("You need to set OCIR_USERNAME and OCIR_PASSWORD environment variable to pull base" +
102-
" OS image " + BASE_OS_IMG + ":" + BASE_OS_IMG_TAG);
103-
}
104-
105-
pullDockerImage(OCIR_SERVER, OCIR_TENENT + "/" + ocir_username , ocir_password, BASE_OS_IMG,
106-
BASE_OS_IMG_TAG);
95+
pullDockerImage(BASE_OS_IMG, BASE_OS_IMG_TAG);
10796
}
10897

10998
protected static void pullOracleDBDockerImage() throws Exception {
110-
logger.info("Pulling Oracle DB image from OCR ...");
111-
String ocr_username = System.getenv("OCR_USERNAME");
112-
String ocr_password = System.getenv("OCR_PASSWORD");
113-
114-
if(ocr_username == null || ocr_password == null) {
115-
throw new Exception("You need to set OCR_USERNAME and OCR_PASSWORD environment variable to pull DB " +
116-
"image " + ORACLE_DB_IMG + ":" + ORACLE_DB_IMG_TAG);
117-
}
118-
119-
pullDockerImage(OCR_SERVER, ocr_username, ocr_password, ORACLE_DB_IMG, ORACLE_DB_IMG_TAG);
99+
logger.info("Pulling Oracle DB image from OCIR ...");
100+
pullDockerImage(ORACLE_DB_IMG, ORACLE_DB_IMG_TAG);
120101
}
121102

122103
protected static void downloadInstallers(String... installers) throws Exception {
@@ -157,7 +138,7 @@ protected static String getImagetoolHome() throws Exception {
157138
}
158139

159140
protected static String getInstallerCacheDir() {
160-
return getProjectRoot() + FS + "caches";
141+
return INSTALLERCACHEDIR;
161142
}
162143

163144
protected static String getWDTResourcePath() {
@@ -265,11 +246,8 @@ private ExecResult executeAndVerify(String command, boolean isRedirectToOut) thr
265246
return result;
266247
}
267248

268-
private static void pullDockerImage(String repoServer, String username, String password,
269-
String imagename, String imagetag) throws Exception {
249+
private static void pullDockerImage(String imagename, String imagetag) throws Exception {
270250

271-
ExecCommand.exec("docker login " + repoServer + " -u " + username +
272-
" -p " + password);
273251
ExecCommand.exec("docker pull " + imagename + ":" + imagetag);
274252

275253
// verify the docker image is pulled

Diff for: imagetool/src/test/java/com/oracle/weblogic/imagetool/integration/ITImagetool.java

+5-16
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.junit.Test;
1212
import org.junit.FixMethodOrder;
1313
import org.junit.runners.MethodSorters;
14-
1514
import java.nio.file.Files;
1615
import java.nio.file.Path;
1716
import java.nio.file.Paths;
@@ -46,8 +45,6 @@ public class ITImagetool extends BaseTest {
4645
private static final String WDT_MODEL2 = "simple-topology2.yaml";
4746
private static String oracleSupportUsername;
4847
private static String oracleSupportPassword;
49-
private static String httpProxy;
50-
private static String httpsProxy;
5148

5249
@BeforeClass
5350
public static void staticPrepare() throws Exception {
@@ -74,13 +71,6 @@ public static void staticPrepare() throws Exception {
7471
throw new Exception("Please set environment variables ORACLE_SUPPORT_USERNAME and ORACLE_SUPPORT_PASSWORD" +
7572
" for Oracle Support credentials to download the patches.");
7673
}
77-
78-
// get http proxy
79-
httpProxy = System.getenv("HTTP_PROXY");
80-
httpsProxy = System.getenv("HTTPS_PROXY");
81-
if(httpProxy == null || httpsProxy == null) {
82-
throw new Exception("Please set environment variable HTTP_PROXY and HTTPS_PROXY");
83-
}
8474
}
8575

8676
@AfterClass
@@ -354,8 +344,7 @@ public void testBCreateFMWImgFullInternetAccess() throws Exception {
354344
addInstallerToCache("jdk", JDK_VERSION, jdkPath);
355345

356346
String command = imagetool + " create --version=" + WLS_VERSION + " --tag imagetool:" + testMethodName +
357-
" --latestPSU --user " + oracleSupportUsername + " --passwordEnv ORACLE_SUPPORT_PASSWORD --httpProxyUrl " +
358-
httpProxy + " --httpsProxyUrl " + httpsProxy + " --type fmw";
347+
" --latestPSU --user " + oracleSupportUsername + " --passwordEnv ORACLE_SUPPORT_PASSWORD --type fmw";
359348
logger.info("Executing command: " + command);
360349
ExecCommand.exec(command, true);
361350

@@ -439,10 +428,10 @@ public void testDCreateJRFDomainImgUsingWDT() throws Exception {
439428
Path source = Paths.get(wdtModel);
440429
Path dest = Paths.get(tmpWdtModel);
441430
Files.copy(source, dest, StandardCopyOption.REPLACE_EXISTING);
442-
String host = System.getenv("HOST");
443-
if (host == null) {
444-
throw new Exception("There is no HOST environment variable defined");
445-
}
431+
String getDBContainerIP = "docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' " +
432+
DB_CONTAINER_NAME;
433+
String host = ExecCommand.exec(getDBContainerIP).stdout().trim();
434+
logger.info("DEBUG: DB_HOST=" + host);
446435
replaceStringInFile(tmpWdtModel, "%DB_HOST%", host);
447436

448437
String command = imagetool + " create --fromImage " +

0 commit comments

Comments
 (0)