Skip to content

Commit 2f1ff60

Browse files
authored
Merge pull request #805 from oracle/feature/java-integration-tests
READY TO MERGE: Change java tests to use 12.2.1.3 image
2 parents 0848a59 + fc31e01 commit 2f1ff60

File tree

15 files changed

+721
-115
lines changed

15 files changed

+721
-115
lines changed

integration-tests/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Certain properties like weblogicDomainStoragePath, image, externalOperatorCert a
166166

167167
# How does it work
168168

169-
When the tests are run manually with mvn command on hosted Linux, WebLogic image and server jre images are pulled from a local repository wlsldi-v2.docker.oraclecorp.com. Operator image is built with the git branch from where the mvn command is executed.
169+
When the tests are run manually with mvn command on hosted Linux, WebLogic image store/oracle/weblogic:12.2.1.3 is pulled from docker hub or uses local image if one exists. Server jre images are pulled from a local repository wlsldi-v2.docker.oraclecorp.com. Operator image is built with the git branch from where the mvn command is executed.
170170
All the tests that start with IT*.java are run. The test builds the operator, runs a series of tests and archives the results into tar.gz files upon completion.
171171

172172
Integration test classes:
@@ -194,6 +194,12 @@ Secret - to create secret
194194

195195
Command to run the tests:
196196
```
197+
export DOCKER_USERNAME=<docker_username>
198+
export DOCKER_PASSWORD=<docker_password>
199+
export DOCKER_EMAIL=<docker_email>
200+
or
201+
make sure the weblogic image i.e. store/oracle/weblogic:12.2.1.3 already exists locally
202+
197203
mvn clean verify -P java-integration-tests 2>&1 | tee log.txt
198204
```
199205

@@ -207,7 +213,7 @@ The tests accepts optional env var overrides:
207213
| INGRESSPERDOMAIN | The defult value is true. If you want to test creating LB by kubectl yaml for multiple domains, set it to false. |
208214
| WERCKER | Set to true if invoking from Wercker, set to false or "" if running stand-alone or from Jenkins. Default is "". |
209215
| JENKINS | Set to true if invoking from Jenkins, set to false or "" if running stand-alone or from Wercker. Default is "". |
210-
| NODEPORT_HOST | DNS name of a Kubernetes worker node. Default is the local host's hostname. |
216+
| K8S_NODEPORT_HOST | DNS name of a Kubernetes worker node. Default is the local host's hostname. |
211217
| BRANCH_NAME | Git branch name. Default is determined by calling 'git branch'. |
212218
| 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. |
213219

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

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class BaseTest {
3838
private static int waitTimePod = 5;
3939
private static String leaseId = "";
4040
private static String branchName = "";
41-
41+
private static String appLocationInPod = "/u01/oracle/apps";
4242
private static Properties appProps;
4343

4444
public static void initialize(String appPropsFile) throws Exception {
@@ -168,12 +168,65 @@ public void testAdminT3Channel(Domain domain) throws Exception {
168168
Boolean exposeAdmint3Channel = (Boolean) domainMap.get("exposeAdminT3Channel");
169169

170170
if (exposeAdmint3Channel != null && exposeAdmint3Channel.booleanValue()) {
171+
ExecResult result =
172+
TestUtils.kubectlexecNoCheck(
173+
domain.getDomainUid() + ("-") + domainMap.get("adminServerName"),
174+
"" + domainMap.get("namespace"),
175+
" -- mkdir -p " + appLocationInPod);
176+
if (result.exitValue() != 0) {
177+
throw new RuntimeException(
178+
"FAILURE: command to create directory "
179+
+ appLocationInPod
180+
+ " in the pod failed, returned "
181+
+ result.stderr()
182+
+ " "
183+
+ result.stdout());
184+
}
185+
171186
domain.deployWebAppViaWLST(
172187
TESTWEBAPP,
173188
getProjectRoot() + "/src/integration-tests/apps/testwebapp.war",
189+
appLocationInPod,
174190
getUsername(),
175191
getPassword());
176192
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
193+
194+
/* The below check is done for domain-home-in-image domains, it needs 12.2.1.3 patched image
195+
* otherwise managed servers will see unicast errors after app deployment and run as standalone servers, not in cluster.
196+
* Here is the error message
197+
* <Jan 18, 2019 8:54:16,214 PM GMT> <Error> <Kernel> <BEA-000802> <ExecuteRequest failed
198+
* java.lang.AssertionError: LocalGroup should atleast have the local server!.
199+
* java.lang.AssertionError: LocalGroup should atleast have the local server!
200+
* at weblogic.cluster.messaging.internal.GroupImpl.send(GroupImpl.java:176)
201+
* at weblogic.cluster.messaging.internal.server.UnicastFragmentSocket.send(UnicastFragmentSocket.java:97)
202+
* at weblogic.cluster.FragmentSocketWrapper.send(FragmentSocketWrapper.java:84)
203+
* at weblogic.cluster.UnicastSender.send(UnicastSender.java:53)
204+
* at weblogic.cluster.UnicastSender.send(UnicastSender.java:21)
205+
* Truncated. see log file for complete stacktrace
206+
*/
207+
208+
if (domainMap.containsKey("domainHomeImageBase")) {
209+
if (domainMap.get("initialManagedServerReplicas") != null
210+
&& ((Integer) domainMap.get("initialManagedServerReplicas")).intValue() >= 1) {
211+
212+
result =
213+
ExecCommand.exec(
214+
"kubectl logs "
215+
+ domain.getDomainUid()
216+
+ ("-")
217+
+ domainMap.get("managedServerNameBase")
218+
+ "1 -n "
219+
+ domainMap.get("namespace")
220+
+ " | grep BEA-000802");
221+
if (result.exitValue() == 0) {
222+
throw new RuntimeException(
223+
"FAILURE: Managed Servers are not part of the cluster, failing with "
224+
+ result.stdout()
225+
+ ". \n Make sure WebLogic Server 12.2.1.3.0 with patch 29135930 applied is used.");
226+
}
227+
}
228+
}
229+
177230
} else {
178231
logger.info("exposeAdminT3Channel is false, can not test t3ChannelPort");
179232
}
@@ -211,7 +264,12 @@ public void testDomainLifecyle(Operator operator, Domain domain) throws Exceptio
211264
operator.verifyExternalRESTService();
212265
operator.verifyDomainExists(domain.getDomainUid());
213266
domain.verifyDomainCreated();
214-
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
267+
// if domain created with domain home in image, re-deploy the webapp and verify load balancing
268+
if (domain.getDomainMap().containsKey("domainHomeImageBase")) {
269+
testAdminT3Channel(domain);
270+
} else {
271+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
272+
}
215273
domain.verifyAdminServerExternalService(getUsername(), getPassword());
216274
logger.info("Done - testDomainLifecyle");
217275
}
@@ -255,7 +313,26 @@ public void testClusterScaling(Operator operator, Domain domain) throws Exceptio
255313
+ replicas);
256314
}
257315

258-
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
316+
// make sure cluster service endpoint is updated with the scaled up servers before verifying
317+
// load balancing
318+
int i = 0;
319+
while (i < BaseTest.getMaxIterationsPod()) {
320+
int numberOfServersInEndpoint =
321+
domain.getNumberOfServersInClusterServiceEndpoint((String) domainMap.get("clusterName"));
322+
if (replicaCnt != numberOfServersInEndpoint) {
323+
// check for last iteration
324+
if (i == (BaseTest.getMaxIterationsPod() - 1)) {
325+
throw new RuntimeException("FAILURE: Cluster Serice Endpoint is not updated");
326+
}
327+
Thread.sleep(BaseTest.getWaitTimePod() * 1000);
328+
i++;
329+
} else {
330+
logger.info("Number of servers addresses in endpoint is same as replica count ");
331+
break;
332+
}
333+
}
334+
// commenting the load balance check, bug 29325139
335+
// domain.verifyWebAppLoadBalancing(TESTWEBAPP);
259336

260337
replicas = 2;
261338
podName = domainUid + "-" + managedServerNameBase + (replicas + 1);
@@ -273,8 +350,8 @@ public void testClusterScaling(Operator operator, Domain domain) throws Exceptio
273350
+ "/"
274351
+ replicas);
275352
}
276-
277-
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
353+
// commenting the load balance check, bug 29325139
354+
// domain.verifyWebAppLoadBalancing(TESTWEBAPP);
278355
logger.info("Done - testClusterScaling");
279356
}
280357

@@ -308,6 +385,7 @@ public void testWLDFScaling(Operator operator, Domain domain) throws Exception {
308385
domain.deployWebAppViaWLST(
309386
"opensessionapp",
310387
getProjectRoot() + "/src/integration-tests/apps/opensessionapp.war",
388+
appLocationInPod,
311389
getUsername(),
312390
getPassword());
313391

@@ -394,6 +472,10 @@ public static String getPassword() {
394472
return password;
395473
}
396474

475+
public static String getResultDir() {
476+
return resultDir;
477+
}
478+
397479
public static int getMaxIterationsPod() {
398480
return maxIterationsPod;
399481
}
@@ -421,10 +503,9 @@ private void copyScalingScriptToPod(
421503
TestUtils.createDirUnderDomainPV(dirPathToCreate);
422504

423505
// copy script to pod
424-
TestUtils.kubectlcp(
506+
TestUtils.copyFileViaCat(
425507
getProjectRoot() + "/src/scripts/scaling/scalingAction.sh",
426508
"/shared/domains/" + domainUID + "/bin/scripts/scalingAction.sh",
427-
// "/shared/scalingAction.sh",
428509
podName,
429510
domainNS);
430511
}

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

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
public class ITOperator extends BaseTest {
3232

3333
// property file used to customize operator properties for operator inputs yaml
34+
3435
private static String operator1File = "operator1.yaml";
3536
private static String operator2File = "operator2.yaml";
3637
private static final String operator_bcFile = "operator_bc.yaml";
@@ -42,6 +43,8 @@ public class ITOperator extends BaseTest {
4243
private static String domainadminonlyFile = "domainadminonly.yaml";
4344
private static String domainrecyclepolicyFile = "domainrecyclepolicy.yaml";
4445
private static String domainsampledefaultsFile = "domainsampledefaults.yaml";
46+
private static String domaininimagewlstFile = "domaininimagewlst.yaml";
47+
private static String domaininimagewdtFile = "domaininimagewdt.yaml";
4548

4649
// property file used to configure constants for integration tests
4750
private static String appPropsFile = "OperatorIT.properties";
@@ -509,6 +512,71 @@ public void testOperatorRESTUsingCertificateChain() throws Exception {
509512
logger.info("SUCCESS - testOperatorRESTUsingCertificateChain");
510513
}
511514

515+
/**
516+
* Create Operator and create domain using domain-in-image option. Verify the domain is started
517+
* successfully and web application can be deployed and accessed.
518+
*
519+
* @throws Exception
520+
*/
521+
// @Test
522+
public void testDomainInImageUsingWLST() throws Exception {
523+
Assume.assumeFalse(QUICKTEST);
524+
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
525+
logTestBegin(testMethodName);
526+
527+
logger.info("Checking if operator1 is running, if not creating");
528+
if (operator1 == null) {
529+
operator1 = TestUtils.createOperator(operator1File);
530+
}
531+
logger.info("Creating Domain & verifing the domain creation");
532+
// create domain
533+
Domain domain = null;
534+
boolean testCompletedSuccessfully = false;
535+
try {
536+
domain = TestUtils.createDomain(domaininimagewlstFile);
537+
domain.verifyDomainCreated();
538+
539+
testBasicUseCases(domain);
540+
testClusterScaling(operator1, domain);
541+
testCompletedSuccessfully = true;
542+
} finally {
543+
if (domain != null && (JENKINS || testCompletedSuccessfully)) domain.destroy();
544+
}
545+
logger.info("SUCCESS - " + testMethodName);
546+
}
547+
/**
548+
* Create Operator and create domain using domain-in-image option. Verify the domain is started
549+
* successfully and web application can be deployed and accessed.
550+
*
551+
* @throws Exception
552+
*/
553+
// @Test
554+
public void testDomainInImageUsingWDT() throws Exception {
555+
Assume.assumeFalse(QUICKTEST);
556+
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
557+
logTestBegin(testMethodName);
558+
559+
logger.info("Checking if operator1 is running, if not creating");
560+
if (operator1 == null) {
561+
operator1 = TestUtils.createOperator(operator1File);
562+
}
563+
logger.info("Creating Domain & verifing the domain creation");
564+
// create domain
565+
Domain domain = null;
566+
boolean testCompletedSuccessfully = false;
567+
try {
568+
domain = TestUtils.createDomain(domaininimagewdtFile);
569+
domain.verifyDomainCreated();
570+
571+
testBasicUseCases(domain);
572+
testClusterScaling(operator1, domain);
573+
testCompletedSuccessfully = true;
574+
} finally {
575+
if (domain != null && (JENKINS || testCompletedSuccessfully)) domain.destroy();
576+
}
577+
logger.info("SUCCESS - " + testMethodName);
578+
}
579+
512580
private Domain testAdvancedUseCasesForADomain(Operator operator, Domain domain) throws Exception {
513581
if (!SMOKETEST) {
514582
testClusterScaling(operator, domain);

0 commit comments

Comments
 (0)