Skip to content

Commit 50506d0

Browse files
authored
[DII] Extend the HDFC usecase to a create a Domain with customized #domain run the Domain LifeCycle usecase (#3527)
* Extend the use case to a create a Domain with customized
1 parent c41d93f commit 50506d0

File tree

4 files changed

+140
-6
lines changed

4 files changed

+140
-6
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// Copyright (c) 2022, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package oracle.weblogic.kubernetes;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
import io.kubernetes.client.custom.V1Patch;
10+
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
11+
import oracle.weblogic.kubernetes.annotations.Namespaces;
12+
import oracle.weblogic.kubernetes.logging.LoggingFacade;
13+
import org.junit.jupiter.api.BeforeAll;
14+
import org.junit.jupiter.api.DisplayName;
15+
import org.junit.jupiter.api.MethodOrderer;
16+
import org.junit.jupiter.api.Order;
17+
import org.junit.jupiter.api.Tag;
18+
import org.junit.jupiter.api.Test;
19+
import org.junit.jupiter.api.TestMethodOrder;
20+
21+
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_SERVER_NAME_BASE;
22+
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
23+
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME;
24+
import static oracle.weblogic.kubernetes.actions.TestActions.patchDomainCustomResource;
25+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
26+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNonEmptySystemProperty;
27+
import static oracle.weblogic.kubernetes.utils.DomainUtils.createAndVerifyDomainInImageUsingWdt;
28+
import static oracle.weblogic.kubernetes.utils.DomainUtils.shutdownDomainAndVerify;
29+
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
30+
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
31+
import static org.junit.jupiter.api.Assertions.assertTrue;
32+
33+
/**
34+
* Tests related to large capacity DII domain and multiple clusters.
35+
*/
36+
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
37+
@DisplayName("Verify the Operator can handle multiple DII domains and clusters at the same time.")
38+
@IntegrationTest
39+
@Tag("okdenv")
40+
class ItLargeCapacityDomainsClustersDII {
41+
42+
private static String opNamespace = null;
43+
private static int numOfDomains = Integer.valueOf(getNonEmptySystemProperty("NUMBER_OF_DOMAINS", "10"));
44+
private static final String baseDomainUid = "domain";
45+
private static List<String> domainNamespaces;
46+
47+
private static final String adminServerName = ADMIN_SERVER_NAME_BASE;
48+
private static int clusterReplicaCount = 2;
49+
private static String clusterName = "cluster-1";
50+
private static LoggingFacade logger;
51+
52+
static String adminSecretName = "weblogic-credentials";
53+
//static String encryptionSecretName = "encryptionsecret";
54+
private static final String wdtModelFileForDomainInImage = "wdt-singlecluster-sampleapp-usingprop-wls.yaml";
55+
56+
/**
57+
* Assigns unique namespaces for operator and domains. Installs operator.
58+
*
59+
* @param namespaces injected by JUnit
60+
*/
61+
@BeforeAll
62+
public static void initAll(@Namespaces(50) List<String> namespaces) {
63+
logger = getLogger();
64+
logger.info("Assign a unique namespace for operator");
65+
opNamespace = namespaces.get(0);
66+
logger.info("Assign a unique namespaces for WebLogic domains");
67+
domainNamespaces = namespaces.subList(1, numOfDomains + 1);
68+
69+
// install operator and verify its running in ready state
70+
installAndVerifyOperator(opNamespace, namespaces.subList(1, 50).toArray(new String[0]));
71+
}
72+
73+
/**
74+
* Test brings up new DII domains and verifies it can successfully start by doing the following.
75+
*
76+
* a. Creates domain resource and deploys in Kubernetes cluster.
77+
* b. Verifies the servers in the new WebLogic domain comes up.
78+
*/
79+
@Order(1)
80+
@Test
81+
@DisplayName("Test DII domains creation")
82+
void testCreateDomains() {
83+
String domainUid;
84+
for (int i = 0; i < numOfDomains; i++) {
85+
domainUid = baseDomainUid + (i + 1);
86+
List<String> appSrcDirList = new ArrayList<>();
87+
appSrcDirList.add(MII_BASIC_APP_NAME);
88+
createAndVerifyDomainInImageUsingWdt(domainUid, domainNamespaces.get(i),
89+
wdtModelFileForDomainInImage, appSrcDirList, adminSecretName, clusterName, clusterReplicaCount);
90+
}
91+
}
92+
93+
/**
94+
* Test restart all existing DII domains.
95+
*
96+
* a. Shutdowns all domains using serverStartPolicy NEVER.
97+
* b. Patch the Domain Resource with cluster serverStartPolicy IF_NEEDED.
98+
* c. Verifies the servers in the domain cluster comes up.
99+
*/
100+
@Order(2)
101+
@Test
102+
@DisplayName("Test DII domain shutdown and startup")
103+
void testRestartDomains() {
104+
String domainUid;
105+
for (int i = 0; i < numOfDomains; i++) {
106+
domainUid = baseDomainUid + (i + 1);
107+
shutdownDomainAndVerify(domainNamespaces.get(i), domainUid, clusterReplicaCount);
108+
logger.info("patch the domain resource with serverStartPolicy to IF_NEEDED");
109+
String patchStr
110+
= "[{"
111+
+ "\"op\": \"replace\", \"path\": \"/spec/serverStartPolicy\", \"value\": \"IF_NEEDED\""
112+
+ "}]";
113+
logger.info("Updating domain configuration using patch string: {0}\n", patchStr);
114+
V1Patch patch = new V1Patch(patchStr);
115+
assertTrue(patchDomainCustomResource(domainUid, domainNamespaces.get(i), patch, V1Patch.PATCH_FORMAT_JSON_PATCH),
116+
"Failed to patch domain");
117+
// check that admin service/pod exists in the domain namespace
118+
logger.info("Checking that admin service/pod {0} exists in namespace {1}",
119+
domainUid + "-" + ADMIN_SERVER_NAME_BASE, domainNamespaces.get(i));
120+
checkPodReadyAndServiceExists(domainUid + "-" + ADMIN_SERVER_NAME_BASE, domainUid, domainNamespaces.get(i));
121+
122+
for (int j = 1; j <= clusterReplicaCount; j++) {
123+
String managedServerPodName = domainUid + "-" + MANAGED_SERVER_NAME_BASE + j;
124+
// check that ms service/pod exists in the domain namespace
125+
logger.info("Checking that clustered ms service/pod {0} exists in namespace {1}",
126+
managedServerPodName, domainNamespaces.get(i));
127+
checkPodReadyAndServiceExists(managedServerPodName, domainUid, domainNamespaces.get(i));
128+
}
129+
}
130+
131+
}
132+
}

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItLargeCapacityDomainsClustersDPV.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import static oracle.weblogic.kubernetes.actions.impl.Domain.patchDomainCustomResource;
6060
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
6161
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
62+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNonEmptySystemProperty;
6263
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
6364
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withLongRetryPolicy;
6465
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapForDomainCreation;
@@ -93,8 +94,8 @@ class ItLargeCapacityDomainsClustersDPV {
9394

9495
private static String opNamespace = null;
9596

96-
private static int numOfDomains = 10;
97-
private static int numOfClusters = 10;
97+
private static int numOfDomains = Integer.valueOf(getNonEmptySystemProperty("NUMBER_OF_DOMAINS", "10"));
98+
private static int numOfClusters = Integer.valueOf(getNonEmptySystemProperty("NUMBER_OF_CLUSTERS", "10"));
9899
private static final String baseDomainUid = "domain";
99100
private static List<String> domainNamespaces;
100101

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItLargeCapacityDomainsClustersMII.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
5858
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
5959
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
60+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNonEmptySystemProperty;
6061
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCredentials;
6162
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
6263
import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret;
@@ -85,8 +86,8 @@ class ItLargeCapacityDomainsClustersMII {
8586

8687
private static String opNamespace = null;
8788

88-
private static int numOfDomains = 10;
89-
private static int numOfClusters = 10;
89+
private static int numOfDomains = Integer.valueOf(getNonEmptySystemProperty("NUMBER_OF_DOMAINS", "10"));
90+
private static int numOfClusters = Integer.valueOf(getNonEmptySystemProperty("NUMBER_OF_CLUSTERS", "10"));
9091
private static final String baseDomainUid = "domain";
9192
private static List<String> domainNamespaces;
9293

kindtest.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ else
305305
echo "Running mvn -Dwdt.download.url=${wdt_download_url} -Dwit.download.url=${wit_download_url} -Dwle.download.url=${wle_download_url} -DPARALLEL_CLASSES=${parallel_run} -DNUMBER_OF_THREADS=${threads} -pl integration-tests -P ${maven_profile_name} verify"
306306
time mvn -Dwdt.download.url="${wdt_download_url}" -Dwit.download.url="${wit_download_url}" -Dwle.download.url="${wle_download_url}" -DPARALLEL_CLASSES="${parallel_run}" -DNUMBER_OF_THREADS="${threads}" -pl integration-tests -P ${maven_profile_name} verify 2>&1 | tee "${RESULT_ROOT}/kindtest.log" || captureLogs
307307
else
308-
echo "Running mvn -Dit.test=!ItLargeCapacityDomainsClustersDPV, !ItLargeCapacityDomainsClustersMII, !ItOperatorWlsUpgrade, !ItDedicatedMode, !ItT3Channel, !ItOperatorFmwUpgrade, !ItOCILoadBalancer, !ItMiiSampleFmwMain, !ItIstioCrossClusters*, !ItMultiDomainModels, !ItOpenshiftIstioMiiDomain -Dwdt.download.url=${wdt_download_url} -Dwit.download.url=${wit_download_url} -Dwle.download.url=${wle_download_url} -DPARALLEL_CLASSES=${parallel_run} -DNUMBER_OF_THREADS=${threads} -pl integration-tests -P integration-tests verify"
309-
time mvn -Dit.test="!ItLargeCapacityDomainsClustersDPV, !ItLargeCapacityDomainsClustersMII, !ItOperatorWlsUpgrade, !ItFmwDomainInPVUsingWDT, !ItFmwDynamicDomainInPV, !ItDedicatedMode, !ItT3Channel, !ItOperatorFmwUpgrade, !ItOCILoadBalancer, !ItMiiSampleFmwMain, !ItIstioCrossClusters*, !ItResilience, !ItMultiDomainModels, !ItOpenshiftIstioMiiDomain" -Dwdt.download.url="${wdt_download_url}" -Dwit.download.url="${wit_download_url}" -Dwle.download.url="${wle_download_url}" -DPARALLEL_CLASSES="${parallel_run}" -DNUMBER_OF_THREADS="${threads}" -pl integration-tests -P integration-tests verify 2>&1 | tee "${RESULT_ROOT}/kindtest.log" || captureLogs
308+
echo "Running mvn -Dit.test=!ItLargeCapacityDomainsClustersDPV, !ItLargeCapacityDomainsClustersMII, !ItLargeCapacityDomainsClustersDII, !ItOperatorWlsUpgrade, !ItDedicatedMode, !ItT3Channel, !ItOperatorFmwUpgrade, !ItOCILoadBalancer, !ItMiiSampleFmwMain, !ItIstioCrossClusters*, !ItMultiDomainModels, !ItOpenshiftIstioMiiDomain -Dwdt.download.url=${wdt_download_url} -Dwit.download.url=${wit_download_url} -Dwle.download.url=${wle_download_url} -DPARALLEL_CLASSES=${parallel_run} -DNUMBER_OF_THREADS=${threads} -pl integration-tests -P integration-tests verify"
309+
time mvn -Dit.test="!ItLargeCapacityDomainsClustersDPV, !ItLargeCapacityDomainsClustersMII, !ItLargeCapacityDomainsClustersDII, !ItOperatorWlsUpgrade, !ItFmwDomainInPVUsingWDT, !ItFmwDynamicDomainInPV, !ItDedicatedMode, !ItT3Channel, !ItOperatorFmwUpgrade, !ItOCILoadBalancer, !ItMiiSampleFmwMain, !ItIstioCrossClusters*, !ItResilience, !ItMultiDomainModels, !ItOpenshiftIstioMiiDomain" -Dwdt.download.url="${wdt_download_url}" -Dwit.download.url="${wit_download_url}" -Dwle.download.url="${wle_download_url}" -DPARALLEL_CLASSES="${parallel_run}" -DNUMBER_OF_THREADS="${threads}" -pl integration-tests -P integration-tests verify 2>&1 | tee "${RESULT_ROOT}/kindtest.log" || captureLogs
310310
fi
311311
fi
312312

0 commit comments

Comments
 (0)