Skip to content

Commit 07a8b55

Browse files
committed
Bring over integration tests
1 parent 946e26b commit 07a8b55

File tree

70 files changed

+2986
-1634
lines changed

Some content is hidden

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

70 files changed

+2986
-1634
lines changed

integration-tests/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,20 @@ 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 IMAGE_NAME_WEBLOGIC and IMAGE_TAG_WEBLOGIC if different from container-registry.oracle.com/middleware/weblogic and 12.2.1.3
183+
* export IMAGE_NAME_WEBLOGIC and IMAGE_TAG_WEBLOGIC if different from container-registry.oracle.com/middleware/weblogic and 12.2.1.4
184184
* Setup docker access to WebLogic 12c Images
185185

186186
* Method 1
187187
- 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
188+
- Then sign in to container-registry.oracle.com and signup for access to WebLogic 12.2.1.4 images from container-registry.oracle.com/middleware/weblogic:12.2.1.4
189189
- Then export the following before running the tests:
190190
```
191191
export OCR_USERNAME=<ocr_username>
192192
export OCR_PASSWORD=<ocr_password>
193193
```
194194

195195
* Method 2
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
196+
- Make sure the weblogic image i.e. container-registry.oracle.com/middleware/weblogic:12.2.1.4 already exists locally in a docker repository the k8s cluster can access
197197
- Make sure the weblogic image has patch p29135930 (required for the WebLogic Kubernetes Operator).
198198

199199

@@ -223,6 +223,8 @@ The tests accepts optional env var overrides:
223223
| K8S_NODEPORT_HOST | DNS name of a Kubernetes worker node. Default is the local host's hostname. |
224224
| BRANCH_NAME | Git branch name. Default is determined by calling 'git branch'. |
225225
| LEASE_ID | Set to a unique value to (A) periodically renew a lease on the k8s cluster that indicates that no other test run should attempt to use the cluster, and (B) delete this lease when the test completes. |
226+
| MAX_ITERATIONS | Maximum number of iterations to wait for a pod/application to come up or deploy. |
227+
| WAIT_TIME_SECONDS | Seconds to wait between the iterations. |
226228

227229
The following additional overrides are currently only used when
228230
SHARED_CLUSTER=true:
@@ -306,7 +308,7 @@ JUnit test results can be seen at "integration-tests/target/failsafe-reports/TES
306308
* Method 1
307309
- Setup a personal account on container-registry.oracle.com
308310
- Then sign in to container-registry.oracle.com and accept license for access to Oracle Database 12c Images: **_container-registry.oracle.com/database/enterprise:12.2.0.1-slim_**
309-
- And get access to FMW Infrastructure 12c Image: **_container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.3_**
311+
- And get access to FMW Infrastructure 12c Image: **_container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.4_**
310312
- export the following before running the tests:
311313
```
312314
export REPO_USERNAME=<ocr_username>
@@ -315,7 +317,7 @@ JUnit test results can be seen at "integration-tests/target/failsafe-reports/TES
315317
```
316318
317319
* Method 2
318-
- Make sure the FMW Infrastructure image i.e. **_container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.3_** and the Oracle database image i.e. **_container-registry.oracle.com/database/enterprise:12.2.0.1-slim_** already exist locally in a docker repository the k8s cluster can access
320+
- Make sure the FMW Infrastructure image i.e. **_container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.4_** and the Oracle database image i.e. **_container-registry.oracle.com/database/enterprise:12.2.0.1-slim_** already exist locally in a docker repository the k8s cluster can access
319321
320322
* Command to run the tests:
321323
```

integration-tests/USECASES.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Basic Use Cases described above are verified in all the domain configurations. A
7070
| Server Pods Restarted by modifying properties on the domain resource| Use Case |
7171
| --- | --- |
7272
| Server pods restarted by changing Env property | Verify admin and managed server pods being restarted by property change: `-Dweblogic.StdoutDebugEnabled=false` --> `-Dweblogic.StdoutDebugEnabled=true` |
73-
| 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` |
73+
| 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.4` --> image: `container-registry.oracle.com/middleware/weblogic:duplicate` |
7474
| Server pods restarted by changing imagePullPolicy | Verify admin and managed server pods being restarted by property change: imagePullPolicy: IfNotPresent --> imagePullPolicy: Never |
7575
| Server pods restarted by changing includeServerOutInPodLog | Verify admin and managed server pods being restarted by property change: includeServerOutInPodLog: true --> includeServerOutInPodLog: false |
7676
| 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: 130 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
import java.nio.file.Files;
77
import java.nio.file.Paths;
8+
import java.text.DateFormat;
9+
import java.text.SimpleDateFormat;
810
import java.util.ArrayList;
11+
import java.util.Date;
912
import java.util.HashMap;
1013
import java.util.Map;
1114
import java.util.Properties;
@@ -50,6 +53,7 @@ public class BaseTest {
5053
public static String GRAFANA_CHART_VERSION;
5154
public static String MONITORING_EXPORTER_VERSION;
5255
public static String MONITORING_EXPORTER_BRANCH;
56+
public static String VOYAGER_VERSION;
5357
public static boolean INGRESSPERDOMAIN = true;
5458
protected static String appLocationInPod = "/u01/oracle/apps";
5559
private static String resultRootCommon = "";
@@ -71,7 +75,12 @@ public class BaseTest {
7175
private static String weblogicImageDevTag;
7276
private static String weblogicImageName;
7377
private static String weblogicImageServer;
78+
private static String oracledbImageTag;
79+
private static String oracledbImageName;
80+
private static String fmwImageTag;
81+
private static String fmwImageName;
7482
private static String domainApiVersion;
83+
private static String crdVersion;
7584
private static int suffixCount = 0;
7685

7786
// Set QUICKTEST env var to true to run a small subset of tests.
@@ -82,6 +91,33 @@ public class BaseTest {
8291
QUICKTEST =
8392
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true");
8493

94+
VOYAGER_VERSION = System.getenv("VOYAGER_VERSION");
95+
if (VOYAGER_VERSION == null) {
96+
VOYAGER_VERSION = "10.0.0";
97+
}
98+
99+
String cmd = "helm version --short --client";
100+
ExecResult result = null;
101+
LoggerHelper.getLocal().log(Level.INFO, "Executing cmd " + cmd);
102+
try {
103+
result = ExecCommand.exec(cmd);
104+
} catch (Exception ex) {
105+
throw new RuntimeException(
106+
"FAILURE: command to get Helm Version "
107+
+ cmd
108+
+ " failed, returned "
109+
+ result.stdout()
110+
+ result.stderr());
111+
}
112+
LoggerHelper.getLocal().log(Level.INFO, result.stdout());
113+
System.out.println("BaseTest: Detected helm client version[" + result.stdout() + "]");
114+
if (result.stdout().contains("v2")) {
115+
throw new RuntimeException(
116+
"FAILURE: BaseTest Unsupported Helm Version ["
117+
+ result.stdout()
118+
+ "]");
119+
}
120+
85121
// if QUICKTEST is false, run all the tests including QUICKTEST
86122
if (!QUICKTEST) {
87123
FULLTEST = true;
@@ -106,7 +142,7 @@ public class BaseTest {
106142
/**
107143
* initializes the application properties and creates directories for results.
108144
*
109-
* @param appPropsFile application properties file
145+
* @param appPropsFile application properties file
110146
* @param testClassName test class name
111147
* @throws Exception exception
112148
*/
@@ -143,10 +179,30 @@ public static void initialize(String appPropsFile, String testClassName)
143179
System.getenv("OCR_SERVER") != null
144180
? System.getenv("OCR_SERVER")
145181
: appProps.getProperty("OCR_SERVER");
182+
fmwImageTag =
183+
System.getenv("IMAGE_TAG_FMWINFRA") != null
184+
? System.getenv("IMAGE_TAG_FMWINFRA")
185+
: appProps.getProperty("fmwImageTag");
186+
fmwImageName =
187+
System.getenv("IMAGE_NAME_FMWINFRA") != null
188+
? System.getenv("IMAGE_NAME_FMWINFRA")
189+
: appProps.getProperty("fmwImageName");
190+
oracledbImageTag =
191+
System.getenv("IMAGE_TAG_ORACLEDB") != null
192+
? System.getenv("IMAGE_TAG_ORACLEDB")
193+
: appProps.getProperty("oracledbImageTag");
194+
oracledbImageName =
195+
System.getenv("IMAGE_NAME_ORACLEDB") != null
196+
? System.getenv("IMAGE_NAME_ORACLEDB")
197+
: appProps.getProperty("oracledbImageName");
146198
domainApiVersion =
147199
System.getenv("DOMAIN_API_VERSION") != null
148200
? System.getenv("DOMAIN_API_VERSION")
149201
: appProps.getProperty("DOMAIN_API_VERSION");
202+
crdVersion =
203+
System.getenv("CRD_VERSION") != null
204+
? System.getenv("CRD_VERSION")
205+
: appProps.getProperty("CRD_VERSION");
150206
WDT_VERSION =
151207
System.getenv("WDT_VERSION") != null
152208
? System.getenv("WDT_VERSION")
@@ -170,13 +226,20 @@ public static void initialize(String appPropsFile, String testClassName)
170226
: appProps.getProperty("MONITORING_EXPORTER_BRANCH", "master");
171227

172228
maxIterationsPod =
173-
new Integer(appProps.getProperty("maxIterationsPod", "" + maxIterationsPod)).intValue();
174-
waitTimePod = new Integer(appProps.getProperty("waitTimePod", "" + waitTimePod)).intValue();
229+
Integer.parseInt(System.getenv("MAX_ITERATIONS") != null
230+
? System.getenv("MAX_ITERATIONS")
231+
: appProps.getProperty("maxIterationsPod", "" + maxIterationsPod));
232+
233+
waitTimePod =
234+
Integer.parseInt(System.getenv("WAIT_TIME_SECONDS") != null
235+
? System.getenv("WAIT_TIME_SECONDS")
236+
: appProps.getProperty("waitTimePod", "" + waitTimePod));
237+
175238
if (System.getenv("RESULT_ROOT") != null) {
176239
resultRootCommon = System.getenv("RESULT_ROOT");
177240
} else {
178241
resultRootCommon = baseDir + "/" + System.getProperty("user.name")
179-
+ "/wl_k8s_test_results";
242+
+ "/wl_k8s_test_results";
180243
}
181244

182245
if (System.getenv("PV_ROOT") != null) {
@@ -211,7 +274,7 @@ protected void createResultAndPvDirs(String testClassName) throws Exception {
211274
// for manual/local run, create file handler, create PVROOT
212275
if (!SHARED_CLUSTER) {
213276
LoggerHelper.getLocal().log(Level.INFO, "Creating PVROOT " + pvRoot);
214-
TestUtils.exec("/usr/local/packages/aime/ias/run_as_root \"mkdir -m777 -p "
277+
TestUtils.execOrAbortProcess("/usr/local/packages/aime/ias/run_as_root \"mkdir -m777 -p "
215278
+ pvRoot + "\"", true);
216279
}
217280

@@ -301,10 +364,50 @@ public static String getWeblogicImageServer() {
301364
return weblogicImageServer;
302365
}
303366

367+
/**
368+
* getter method for fmwImageTag field.
369+
*
370+
* @return image tag of the FMW docker images
371+
*/
372+
public static String getfmwImageTag() {
373+
return fmwImageTag;
374+
}
375+
376+
/**
377+
* getter method for fmwImageName.
378+
*
379+
* @return image name of the FMW docker image
380+
*/
381+
public static String getfmwImageName() {
382+
return fmwImageName;
383+
}
384+
385+
/**
386+
* getter method for oracledbImageTag field.
387+
*
388+
* @return image tag of the Oracle DB docker images
389+
*/
390+
public static String getOracledbImageTag() {
391+
return oracledbImageTag;
392+
}
393+
394+
/**
395+
* getter method for oracledbImageName.
396+
*
397+
* @return image name of the Oracle DB docker image
398+
*/
399+
public static String getOracledbImageName() {
400+
return oracledbImageName;
401+
}
402+
304403
public static String getDomainApiVersion() {
305404
return domainApiVersion;
306405
}
307406

407+
public static String getCrdVersion() {
408+
return crdVersion;
409+
}
410+
308411
protected ExecResult cleanup() throws Exception {
309412
String cmd =
310413
"export RESULT_ROOT="
@@ -389,9 +492,9 @@ public static String getAppLocationOnHost() {
389492
/**
390493
* build web service app inside pod.
391494
*
392-
* @param domain domain
495+
* @param domain domain
393496
* @param testAppName test application name
394-
* @param wsName web service name
497+
* @param wsName web service name
395498
* @throws Exception exception
396499
*/
397500
public static void buildDeployWebServiceApp(Domain domain, String testAppName, String wsName)
@@ -442,7 +545,8 @@ public static void tearDown(String itClassName, String namespaceList) throws Exc
442545

443546
ExecResult result = ExecCommand.exec(cmd.toString());
444547
if (result.exitValue() == 0) {
445-
LoggerHelper.getLocal().log(Level.INFO, "Executed statedump.sh " + result.stdout());
548+
LoggerHelper.getLocal().log(Level.INFO, "Executed statedump.sh "
549+
+ result.stdout() + "\n" + result.stderr());
446550
} else {
447551
LoggerHelper.getLocal().log(Level.INFO, "Execution of statedump.sh failed, "
448552
+ result.stderr() + "\n" + result.stdout());
@@ -504,12 +608,13 @@ public void testAdminT3Channel(Domain domain, boolean verifyLoadBalancing) throw
504608
+ result.stdout());
505609
}
506610

611+
int retriesForDeployment = 10;
507612
domain.deployWebAppViaWlst(
508613
TESTWEBAPP,
509614
getProjectRoot() + "/src/integration-tests/apps/testwebapp.war",
510615
appLocationInPod,
511616
getUsername(),
512-
getPassword());
617+
getPassword(), retriesForDeployment);
513618
domain.callWebAppAndVerifyLoadBalancing(TESTWEBAPP, verifyLoadBalancing);
514619

515620
/* The below check is done for domain-home-in-image domains, it needs 12.2.1.3 patched image
@@ -701,7 +806,7 @@ public void testClusterScaling(Operator operator, Domain domain, boolean verifyL
701806
}
702807

703808
/**
704-
* Scale the cluster up using Weblogic WLDF scaling.
809+
* Scale the cluster up using WebLogic WLDF scaling.
705810
*
706811
* @throws Exception exception
707812
*/
@@ -720,12 +825,13 @@ public void testWldfScaling(Operator operator, Domain domain) throws Exception {
720825
TestUtils.createRbacPoliciesForWldfScaling();
721826

722827
// deploy opensessionapp
828+
int retriesForDeployment = 10;
723829
domain.deployWebAppViaWlst(
724830
"opensessionapp",
725831
getProjectRoot() + "/src/integration-tests/apps/opensessionapp.war",
726832
appLocationInPod,
727833
getUsername(),
728-
getPassword());
834+
getPassword(), retriesForDeployment);
729835

730836
TestUtils.createWldfModule(
731837
adminPodName, domainNS, ((Integer) domainMap.get("t3ChannelPort")).intValue());
@@ -760,6 +866,7 @@ public void testWldfScaling(Operator operator, Domain domain) throws Exception {
760866
*/
761867
public void testOperatorLifecycle(Operator operator, Domain domain) throws Exception {
762868
LoggerHelper.getLocal().log(Level.INFO, "Inside testOperatorLifecycle");
869+
operator.writePodLog(getResultDir() + "/state-dump-logs/");
763870
operator.destroy();
764871
operator.create();
765872
operator.verifyExternalRestService();
@@ -789,7 +896,7 @@ private void copyScalingScriptToPod(String domainUid, String podName, String dom
789896

790897
TestUtils.kubectlexec(podName, domainNS,
791898
"chmod +x /shared/domains/"
792-
+ domainUid + "/bin/scripts/scalingAction.sh");
899+
+ domainUid + "/bin/scripts/scalingAction.sh");
793900

794901
}
795902

@@ -825,6 +932,7 @@ private void callWebAppAndVerifyScaling(Domain domain, int replicas) throws Exce
825932

826933
/**
827934
* Returns a new suffixCount value which can be used to make namespaces,ports unique.
935+
*
828936
* @return new suffixCount
829937
*/
830938
public static int getNewSuffixCount() {
@@ -873,7 +981,7 @@ public Map<String, Object> createOperatorMap(
873981
* @return map with domain input attributes
874982
*/
875983
public Map<String, Object> createDomainMap(
876-
int suffixCount, String prefix) {
984+
int suffixCount, String prefix) {
877985
Map<String, Object> domainMap = new HashMap<String, Object>();
878986
domainMap.put("domainUID", prefix.toLowerCase() + "-domain-" + suffixCount);
879987
domainMap.put("namespace", prefix.toLowerCase() + "-domainns-" + suffixCount);
@@ -937,16 +1045,20 @@ public Map<String, Object> createDomainInImageMap(
9371045
domainMap.put("domainHomeImageBuildPath",
9381046
"./docker-images/OracleWebLogic/samples/12213-domain-home-in-image");
9391047
}
940-
domainMap.put("domainHomeImageBase",
941-
"container-registry.oracle.com/middleware/weblogic:12.2.1.3");
1048+
domainMap.put("domainHomeImageBase", weblogicImageName + ":" + weblogicImageTag);
9421049
domainMap.put("logHomeOnPV", "true");
9431050
domainMap.put("clusterType", "CONFIGURED");
1051+
1052+
// To get unique image name
1053+
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
1054+
Date date = new Date();
1055+
String currentDateTime = dateFormat.format(date) + "-" + System.currentTimeMillis();
1056+
9441057
if (prefix != null && !prefix.trim().equals("")) {
945-
domainMap.put("image", prefix.toLowerCase() + "-dominimage-" + suffixCount + ":latest");
1058+
domainMap.put("image", prefix.toLowerCase() + "-dominimage:" + currentDateTime);
9461059
} else {
947-
domainMap.put("image", "dominimage-" + suffixCount + ":latest");
1060+
domainMap.put("image", "dominimage:" + currentDateTime);
9481061
}
9491062
return domainMap;
9501063
}
951-
9521064
}

0 commit comments

Comments
 (0)