Skip to content

Commit d1a16eb

Browse files
authored
Merge pull request #1104 from oracle/imageschange_external
Fix integration tests running in external Jenkins OCI env
2 parents 3e4bf91 + afb9352 commit d1a16eb

File tree

14 files changed

+122
-88
lines changed

14 files changed

+122
-88
lines changed

integration-tests/README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,21 @@ K8sTestUtils - uses k8s java client api, this is used only for delete domain use
180180

181181
* Maven and latest Git should be in PATH
182182
* export JAVA_HOME
183-
* export WEBLOGIC_IMAGE_NAME and WEBLOGIC_IMAGE_TAG if different from middleware/weblogic and 12.2.1.3-190111
183+
* export WEBLOGIC_IMAGE_NAME and WEBLOGIC_IMAGE_TAG if different from container-registry.oracle.com/middleware/weblogic and 12.2.1.3
184184
* Setup docker access to WebLogic 12c Images
185185

186186
Method 1
187-
- Setup a personal account on hub.docker.com
188-
- Then sign in to hub.docker.com and signup for access to WebLogic 12c Images via https://hub.docker.com/_/oracle-weblogic-server-12c
187+
- Setup a personal account on container-registry.oracle.com
188+
- Then sign in to container-registry.oracle.com and signup for access to WebLogic 12.2.1.3 images from container-registry.oracle.com/middleware/weblogic:12.2.1.3
189189
- Then export the following before running the tests:
190190
```
191-
export DOCKER_USERNAME=<docker_username>
192-
export DOCKER_PASSWORD=<docker_password>
193-
export DOCKER_EMAIL=<docker_email>
191+
export OCR_USERNAME=<ocr_username>
192+
export OCR_PASSWORD=<ocr_password>
194193
```
195194

196195
Method 2
197-
- Make sure the weblogic image i.e. middleware/weblogic:12.2.1.3-190111 already exists locally in a docker repository the k8s cluster can access
196+
- Make sure the weblogic image i.e. container-registry.oracle.com/middleware/weblogic:12.2.1.3 already exists locally in a docker repository the k8s cluster can access
198197
- Make sure the weblogic image has patch p29135930 (required for the WebLogic Kubernetes Operator).
199-
- If not, see [https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-patch-wls-for-k8s].
200198

201199

202200
* Command to run the tests:

integration-tests/USECASES.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Basic Use Cases described above are verified in all the domain configurations. A
6868
| Server Pods Restarted by modifying properties on the domain resource| Use Case |
6969
| --- | --- |
7070
| Server pods restarted by changing Env property | Verify admin and managed server pods being restarted by property change: `-Dweblogic.StdoutDebugEnabled=false` --> `-Dweblogic.StdoutDebugEnabled=true` |
71-
| Server pods restarted by changing image | Verify admin and managed server pods being restarted by property change: image: `container-registry.oracle.com/middleware/weblogic:12.2.1.3-190111` --> image: `container-registry.oracle.com/middleware/weblogic:duplicate` |
71+
| Server pods restarted by changing image | Verify admin and managed server pods being restarted by property change: image: `container-registry.oracle.com/middleware/weblogic:12.2.1.3` --> image: `container-registry.oracle.com/middleware/weblogic:duplicate` |
7272
| Server pods restarted by changing imagePullPolicy | Verify admin and managed server pods being restarted by property change: imagePullPolicy: IfNotPresent --> imagePullPolicy: Never |
7373
| Server pods restarted by changing includeServerOutInPodLog | Verify admin and managed server pods being restarted by property change: includeServerOutInPodLog: true --> includeServerOutInPodLog: false |
7474
| Server pods restarted by changing logHomeEnable | Verify admin and managed server pods being restarted by property change: logHomeEnabled: true --> logHomeEnabled: false |

integration-tests/src/test/java/oracle/kubernetes/operator/BaseTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class BaseTest {
7171
private static Properties appProps;
7272
private static String weblogicImageTag;
7373
private static String weblogicImageName;
74+
private static String weblogicImageServer;
7475

7576
// Set QUICKTEST env var to true to run a small subset of tests.
7677
// Set SMOKETEST env var to true to run an even smaller subset of tests
@@ -114,6 +115,10 @@ public static void initialize(String appPropsFile) throws Exception {
114115
System.getenv("IMAGE_NAME_WEBLOGIC") != null
115116
? System.getenv("IMAGE_NAME_WEBLOGIC")
116117
: appProps.getProperty("weblogicImageName");
118+
weblogicImageServer =
119+
System.getenv("OCR_SERVER") != null
120+
? System.getenv("OCR_SERVER")
121+
: appProps.getProperty("OCR_SERVER");
117122
maxIterationsPod =
118123
new Integer(appProps.getProperty("maxIterationsPod", "" + maxIterationsPod)).intValue();
119124
waitTimePod = new Integer(appProps.getProperty("waitTimePod", "" + waitTimePod)).intValue();
@@ -254,6 +259,16 @@ public static String getWeblogicImageTag() {
254259
public static String getWeblogicImageName() {
255260
return weblogicImageName;
256261
}
262+
263+
/**
264+
* getter method for weblogicImageServer
265+
*
266+
* @return registry name of the WLS container
267+
*/
268+
public static String getWeblogicImageServer() {
269+
return weblogicImageServer;
270+
}
271+
257272
/**
258273
* Call the basic usecases tests
259274
*

integration-tests/src/test/java/oracle/kubernetes/operator/ITMonitoringExporter.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,17 +735,21 @@ private static void deployMonitoringExporterPrometethusGrafana(
735735
crdCmd = " kubectl apply -f " + samplesDir + "grafana-deployment.yaml";
736736
result = ExecCommand.exec(crdCmd);
737737
logger.info("command result " + result.stdout().trim());
738-
domain.deployWebAppViaREST(
739-
"wlsexporter", exporterAppPath, BaseTest.getUsername(), BaseTest.getPassword());
738+
Map<String, Object> domainMap = domain.getDomainMap();
739+
// create the app directory in admin pod
740+
TestUtils.kubectlexec(
741+
domain.getDomainUid() + ("-") + domainMap.get("adminServerName"),
742+
"" + domainMap.get("namespace"),
743+
" -- mkdir -p " + appLocationInPod);
744+
domain.deployWebAppViaWLST(
745+
"wls-exporter", exporterAppPath, appLocationInPod, getUsername(), getPassword(), true);
740746
}
741747

742748
private static void redeployMonitoringExporter(Domain domain) throws Exception {
743749
String exporterAppPath = monitoringExporterDir + "/apps/monitoringexporter/wls-exporter.war";
744750

745-
domain.undeployWebAppViaREST(
746-
"wlsexporter", exporterAppPath, BaseTest.getUsername(), BaseTest.getPassword());
747-
domain.deployWebAppViaREST(
748-
"wlsexporter", exporterAppPath, BaseTest.getUsername(), BaseTest.getPassword());
751+
domain.deployWebAppViaWLST(
752+
"wls-exporter", exporterAppPath, appLocationInPod, getUsername(), getPassword(), true);
749753
// check if exporter is up
750754
domain.callWebAppAndVerifyLoadBalancing("wls-exporter", false);
751755
}

integration-tests/src/test/java/oracle/kubernetes/operator/ITMultipleClusters.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import oracle.kubernetes.operator.utils.Operator;
1717
import oracle.kubernetes.operator.utils.TestUtils;
1818
import org.junit.AfterClass;
19+
import org.junit.Assume;
1920
import org.junit.BeforeClass;
2021
import org.junit.FixMethodOrder;
2122
import org.junit.Test;
@@ -45,18 +46,22 @@ public class ITMultipleClusters extends BaseTest {
4546
*/
4647
@BeforeClass
4748
public static void staticPrepare() throws Exception {
48-
// initialize test properties and create the directories
49-
initialize(APP_PROPS_FILE);
50-
String template =
51-
BaseTest.getProjectRoot() + "/kubernetes/samples/scripts/common/domain-template.yaml";
52-
String add =
53-
" - clusterName: %CLUSTER_NAME%-2\n"
54-
+ " serverStartState: \"RUNNING\"\n"
55-
+ " replicas: %INITIAL_MANAGED_SERVER_REPLICAS%\n";
56-
customDomainTemplate = BaseTest.getResultDir() + "/customDomainTemplate.yaml";
57-
Files.copy(
58-
Paths.get(template), Paths.get(customDomainTemplate), StandardCopyOption.REPLACE_EXISTING);
59-
Files.write(Paths.get(customDomainTemplate), add.getBytes(), StandardOpenOption.APPEND);
49+
if (!QUICKTEST) {
50+
// initialize test properties and create the directories
51+
initialize(APP_PROPS_FILE);
52+
String template =
53+
BaseTest.getProjectRoot() + "/kubernetes/samples/scripts/common/domain-template.yaml";
54+
String add =
55+
" - clusterName: %CLUSTER_NAME%-2\n"
56+
+ " serverStartState: \"RUNNING\"\n"
57+
+ " replicas: %INITIAL_MANAGED_SERVER_REPLICAS%\n";
58+
customDomainTemplate = BaseTest.getResultDir() + "/customDomainTemplate.yaml";
59+
Files.copy(
60+
Paths.get(template),
61+
Paths.get(customDomainTemplate),
62+
StandardCopyOption.REPLACE_EXISTING);
63+
Files.write(Paths.get(customDomainTemplate), add.getBytes(), StandardOpenOption.APPEND);
64+
}
6065
}
6166

6267
/**
@@ -66,13 +71,14 @@ public static void staticPrepare() throws Exception {
6671
*/
6772
@AfterClass
6873
public static void staticUnPrepare() throws Exception {
69-
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
70-
logger.info("BEGIN");
71-
logger.info("Run once, release cluster lease");
72-
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
73-
logger.info("SUCCESS");
74+
if (!QUICKTEST) {
75+
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
76+
logger.info("BEGIN");
77+
logger.info("Run once, release cluster lease");
78+
tearDown(new Object() {}.getClass().getEnclosingClass().getSimpleName());
79+
logger.info("SUCCESS");
80+
}
7481
}
75-
7682
/**
7783
* Create 2 configured clusters in a domain each having 2 managed servers. Verify the managed
7884
* servers are running and verify the basic use cases.
@@ -81,6 +87,7 @@ public static void staticUnPrepare() throws Exception {
8187
*/
8288
@Test
8389
public void testCreateDomainTwoConfiguredCluster() throws Exception {
90+
Assume.assumeFalse(QUICKTEST);
8491

8592
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
8693
logTestBegin(testMethodName);
@@ -138,6 +145,7 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
138145
*/
139146
@Test
140147
public void testCreateDomainTwoMixedCluster() throws Exception {
148+
Assume.assumeFalse(QUICKTEST);
141149
String DOMAINUID = "twomixedclusterdomain";
142150
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
143151
logTestBegin(testMethodName);
@@ -194,6 +202,7 @@ public void testCreateDomainTwoMixedCluster() throws Exception {
194202
*/
195203
@Test
196204
public void testCreateDomainTwoClusterWDTInImage() throws Exception {
205+
Assume.assumeFalse(QUICKTEST);
197206
String DOMAINUID = "twoclusterdomainwdt";
198207
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
199208
logTestBegin(testMethodName);

integration-tests/src/test/java/oracle/kubernetes/operator/ITOperator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public void testOperatorRESTUsingCertificateChain() throws Exception {
437437
*/
438438
@Test
439439
public void testDomainInImageUsingWLST() throws Exception {
440-
Assume.assumeFalse(QUICKTEST);
440+
Assume.assumeTrue(QUICKTEST);
441441
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
442442
logTestBegin(testMethodName);
443443

@@ -470,6 +470,7 @@ public void testDomainInImageUsingWLST() throws Exception {
470470
@Test
471471
public void testDomainInImageUsingWDT() throws Exception {
472472
Assume.assumeFalse(QUICKTEST);
473+
473474
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
474475
logTestBegin(testMethodName);
475476

integration-tests/src/test/java/oracle/kubernetes/operator/ITPodsRestart.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void testServerPodsRestartByChangingIncludeServerOutInPodLog() throws Exc
184184
/**
185185
* Modify the domain scope property on the domain resource using kubectl apply -f domain.yaml
186186
* Verify that all the server pods in the domain got re-started .The property tested is: image:
187-
* "container-registry.oracle.com/middleware/weblogic:12.2.1.3-190111" --> image:
187+
* "container-registry.oracle.com/middleware/weblogic:12.2.1.3" --> image:
188188
* "container-registry.oracle.com/middleware/weblogic:duplicate"
189189
*
190190
* @throws Exception
@@ -196,22 +196,25 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
196196
logTestBegin(testMethodName);
197197

198198
try {
199+
TestUtils.ExecAndPrintLog("docker images");
199200
logger.info(
200201
"About to verifyDomainServerPodRestart for Domain: "
201202
+ domain.getDomainUid()
202203
+ " Image property: "
203204
+ getWeblogicImageName()
204205
+ ":"
205206
+ getWeblogicImageTag()
206-
+ " to /weblogick8s/middleware/weblogic:duplicate");
207+
+ " to "
208+
+ "/weblogick8s/middleware/weblogic:duplicate");
207209

208210
if (BaseTest.SHARED_CLUSTER) {
209211
String newImage =
210212
System.getenv("REPO_REGISTRY") + "/weblogick8s/middleware/weblogic:duplicate";
211-
212213
// tag image with repo name
213-
TestUtils.exec(
214-
"docker tag " + getWeblogicImageName() + ":" + getWeblogicImageTag() + " " + newImage);
214+
String tag =
215+
"docker tag " + getWeblogicImageName() + ":" + getWeblogicImageTag() + " " + newImage;
216+
TestUtils.ExecAndPrintLog(tag);
217+
TestUtils.ExecAndPrintLog("docker images");
215218

216219
// login and push image to ocir
217220
TestUtils.loginAndPushImageToOCIR(newImage);
@@ -230,6 +233,7 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
230233
domain.verifyDomainServerPodRestart(
231234
"\"" + getWeblogicImageName() + ":" + getWeblogicImageTag() + "\"",
232235
"\"" + newImage + "\"");
236+
233237
} else {
234238
TestUtils.exec(
235239
"docker tag "

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,11 @@ public void deployWebAppViaREST(
379379
.append(":")
380380
.append(getNodePort())
381381
.append("/management/weblogic/latest/edit/appDeployments")
382-
.append(" --write-out %{http_code} -o /dev/null");
383-
logger.fine("Command to deploy webapp " + cmd);
382+
.append(" --write-out %{http_code} ");
383+
logger.info("Command to deploy webapp " + cmd);
384384
ExecResult result = TestUtils.exec(cmd.toString());
385385
String output = result.stdout().trim();
386+
logger.info("curl output " + output + " \n err " + result.stderr());
386387
if (!output.contains("202")) {
387388
throw new RuntimeException("FAILURE: Webapp deployment failed with response code " + output);
388389
}

integration-tests/src/test/java/oracle/kubernetes/operator/utils/TestUtils.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ public static ExecResult exec(String cmd) throws Exception {
238238
logger.info(
239239
"Command "
240240
+ cmd
241-
+ " failed with stderr = "
241+
+ " return value "
242+
+ result.exitValue()
243+
+ " \n failed with stderr = "
242244
+ result.stderr()
243245
+ " \n stdout = "
244246
+ result.stdout());
@@ -1400,4 +1402,17 @@ public static ExecResult loginAndPushImageToOCIR(String image) throws Exception
14001402
+ result.stderr());
14011403
return result;
14021404
}
1405+
1406+
public static void ExecAndPrintLog(String command) throws Exception {
1407+
ExecResult result = ExecCommand.exec(command);
1408+
logger.info(
1409+
"\nCommand "
1410+
+ command
1411+
+ "\nreturn value: "
1412+
+ result.exitValue()
1413+
+ "\nstderr = "
1414+
+ result.stderr()
1415+
+ "\nstdout = "
1416+
+ result.stdout());
1417+
}
14031418
}

integration-tests/src/test/resources/OperatorIT.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ username=weblogic
77
password=welcome1
88
maxIterationsPod=25
99
waitTimePod=10
10-
weblogicImageTag = 12.2.1.3-190111
10+
weblogicImageTag = 12.2.1.3
1111
weblogicImageName = container-registry.oracle.com/middleware/weblogic
12+
OCR_SERVER="container-registry.oracle.com"

0 commit comments

Comments
 (0)