Skip to content

Commit fb81a0d

Browse files
authored
add Functional Regression tests for OWLS-106473, OWLS-106637 (#4041)
* add functional regression tests.
1 parent 2b0de2f commit fb81a0d

10 files changed

+911
-11
lines changed

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

Lines changed: 500 additions & 0 deletions
Large diffs are not rendered by default.

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonTestUtils.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,32 @@ public static boolean checkSystemResourceConfig(String adminSvcExtHost, int node
720720
.executeAndVerify(expectedValue);
721721
}
722722

723+
/**
724+
* Check the system resource configuration using REST API.
725+
* @param adminSvcExtHost Used only in OKD env - this is the route host created for AS external service
726+
* @param nodePort admin node port
727+
* @param expectedValue expected value returned in the REST call
728+
* @return true if the REST API results matches expected status code
729+
*/
730+
public static boolean checkSystemResourceDomainConfig(String adminSvcExtHost, int nodePort,
731+
String expectedValue) {
732+
final LoggingFacade logger = getLogger();
733+
734+
String hostAndPort = (OKD) ? adminSvcExtHost : K8S_NODEPORT_HOST + ":" + nodePort;
735+
logger.info("hostAndPort = {0} ", hostAndPort);
736+
737+
StringBuffer curlString = new StringBuffer("curl --user ");
738+
curlString.append(ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT)
739+
.append(" http://" + hostAndPort)
740+
.append("/management/weblogic/latest/domainConfig/");
741+
742+
logger.info("checkSystemResource: curl command {0}", new String(curlString));
743+
return Command
744+
.withParams(new CommandParams()
745+
.command(curlString.toString()))
746+
.executeAndVerify(expectedValue);
747+
}
748+
723749
/**
724750
* Check the system resource runtime using REST API.
725751
* @param adminSvcExtHost Used only in OKD env - this is the route host created for AS external service

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/DomainUtils.java

Lines changed: 186 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,46 @@ public static void createDomainAndVerify(DomainResource domain,
187187
public static void createDomainAndVerify(String domainUid, DomainResource domain,
188188
String domainNamespace, String adminServerPodName,
189189
String managedServerPodNamePrefix, int replicaCount) {
190+
createDomainAndVerify(domainUid, domain, domainNamespace, adminServerPodName, managedServerPodNamePrefix,
191+
replicaCount, true);
192+
}
193+
194+
/**
195+
* Create a domain in the specified namespace, wait up to five minutes until the domain exists and
196+
* verify the servers are running.
197+
*
198+
* @param domainUid domain
199+
* @param domain the oracle.weblogic.domain.DomainResource object to create domain custom resource
200+
* @param domainNamespace namespace in which the domain will be created
201+
* @param adminServerPodName admin server pod name
202+
* @param managedServerPodNamePrefix managed server pod prefix
203+
* @param replicaCount replica count
204+
* @param verifyServerPods whether to verify server pods of the domain
205+
*/
206+
public static void createDomainAndVerify(String domainUid, DomainResource domain,
207+
String domainNamespace, String adminServerPodName,
208+
String managedServerPodNamePrefix, int replicaCount,
209+
boolean verifyServerPods) {
190210
LoggingFacade logger = getLogger();
191211

192212
// create domain and verify
193213
createDomainAndVerify(domain, domainNamespace);
194214

195-
// check that admin service/pod exists in the domain namespace
196-
logger.info("Checking that admin service/pod {0} exists in namespace {1}",
197-
adminServerPodName, domainNamespace);
198-
checkPodReadyAndServiceExists(adminServerPodName, domainUid, domainNamespace);
215+
if (verifyServerPods) {
216+
// check that admin service/pod exists in the domain namespace
217+
logger.info("Checking that admin service/pod {0} exists in namespace {1}",
218+
adminServerPodName, domainNamespace);
219+
checkPodReadyAndServiceExists(adminServerPodName, domainUid, domainNamespace);
199220

200-
for (int i = 1; i <= replicaCount; i++) {
201-
String managedServerPodName = managedServerPodNamePrefix + i;
221+
for (int i = 1; i <= replicaCount; i++) {
222+
String managedServerPodName = managedServerPodNamePrefix + i;
202223

203-
// check that ms service/pod exists in the domain namespace
204-
logger.info("Checking that clustered ms service/pod {0} exists in namespace {1}",
205-
managedServerPodName, domainNamespace);
206-
checkPodReadyAndServiceExists(managedServerPodName, domainUid, domainNamespace);
224+
// check that ms service/pod exists in the domain namespace
225+
logger.info("Checking that clustered ms service/pod {0} exists in namespace {1}",
226+
managedServerPodName, domainNamespace);
227+
checkPodReadyAndServiceExists(managedServerPodName, domainUid, domainNamespace);
228+
}
207229
}
208-
209230
}
210231

211232
/**
@@ -643,6 +664,109 @@ public static DomainResource createDomainOnPvUsingWdt(String domainUid,
643664
return domain;
644665
}
645666

667+
/**
668+
* Create a domain in PV using WDT.
669+
*
670+
* @param domainUid uid of the domain
671+
* @param domainNamespace namespace in which the domain will be created
672+
* @param wlSecretName WLS secret name
673+
* @param clusterName WLS domain cluster name
674+
* @param replicaCount domain replica count
675+
* @param testClassName the test class name calling this method
676+
* @param wdtModelFile WDT model file to create the domain
677+
* @param verifyServerPods whether to verify the server pods
678+
* @return oracle.weblogic.domain.Domain objects
679+
*/
680+
public static DomainResource createDomainOnPvUsingWdt(String domainUid,
681+
String domainNamespace,
682+
String wlSecretName,
683+
String clusterName,
684+
int replicaCount,
685+
String testClassName,
686+
String wdtModelFile,
687+
boolean verifyServerPods) {
688+
689+
int t3ChannelPort = getNextFreePort();
690+
691+
final String pvName = getUniqueName(domainUid + "-pv-"); // name of the persistent volume
692+
final String pvcName = getUniqueName(domainUid + "-pvc-"); // name of the persistent volume claim
693+
694+
// create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
695+
// this secret is used only for non-kind cluster
696+
createBaseRepoSecret(domainNamespace);
697+
698+
// create WebLogic domain credential secret
699+
createSecretWithUsernamePassword(wlSecretName, domainNamespace, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
700+
701+
// create persistent volume and persistent volume claim for domain
702+
// these resources should be labeled with domainUid for cleanup after testing
703+
704+
createPV(pvName, domainUid, testClassName);
705+
createPVC(pvName, pvcName, domainUid, domainNamespace);
706+
707+
String labelSelector = String.format("weblogic.domainUid in (%s)", domainUid);
708+
LoggingFacade logger = getLogger();
709+
// check the persistent volume and persistent volume claim exist
710+
testUntil(
711+
assertDoesNotThrow(() -> pvExists(pvName, labelSelector),
712+
String.format("pvExists failed with ApiException when checking pv %s", pvName)),
713+
logger,
714+
"persistent volume {0} exists",
715+
pvName);
716+
717+
testUntil(
718+
assertDoesNotThrow(() -> pvcExists(pvcName, domainNamespace),
719+
String.format("pvcExists failed with ApiException when checking pvc %s in namespace %s",
720+
pvcName, domainNamespace)),
721+
logger,
722+
"persistent volume claim {0} exists in namespace {1}",
723+
pvcName,
724+
domainNamespace);
725+
726+
727+
// create a temporary WebLogic domain property file as a input for WDT model file
728+
File domainPropertiesFile = assertDoesNotThrow(() -> createTempFile("domainonpv" + domainUid, "properties"),
729+
"Failed to create domain properties file");
730+
731+
Properties p = new Properties();
732+
p.setProperty("adminUsername", ADMIN_USERNAME_DEFAULT);
733+
p.setProperty("adminPassword", ADMIN_PASSWORD_DEFAULT);
734+
p.setProperty("domainName", domainUid);
735+
p.setProperty("adminServerName", ADMIN_SERVER_NAME_BASE);
736+
p.setProperty("productionModeEnabled", "true");
737+
p.setProperty("clusterName", clusterName);
738+
p.setProperty("configuredManagedServerCount", "4");
739+
p.setProperty("managedServerNameBase", MANAGED_SERVER_NAME_BASE);
740+
p.setProperty("t3ChannelPort", Integer.toString(t3ChannelPort));
741+
p.setProperty("t3PublicAddress", K8S_NODEPORT_HOST);
742+
p.setProperty("managedServerPort", "8001");
743+
p.setProperty("adminServerSslPort", "7002");
744+
assertDoesNotThrow(() ->
745+
p.store(new FileOutputStream(domainPropertiesFile), "WDT properties file"),
746+
"Failed to write domain properties file");
747+
748+
// shell script to download WDT and run the WDT createDomain script
749+
Path wdtScript = get(RESOURCE_DIR, "bash-scripts", "setup_wdt.sh");
750+
751+
// create configmap and domain in persistent volume using WDT
752+
runCreateDomainOnPVJobUsingWdt(wdtScript, get(RESOURCE_DIR, "wdt-models", wdtModelFile),
753+
domainPropertiesFile.toPath(),
754+
domainUid, pvName, pvcName, domainNamespace, testClassName);
755+
756+
DomainResource domain = createDomainResourceForDomainOnPV(domainUid, domainNamespace, wlSecretName, pvName, pvcName,
757+
clusterName, replicaCount);
758+
759+
// Verify the domain custom resource is created.
760+
// Also verify the admin server pod and managed server pods are up and running.
761+
if (verifyServerPods) {
762+
createDomainAndVerify(domainUid, domain, domainNamespace, domainUid + "-" + ADMIN_SERVER_NAME_BASE,
763+
domainUid + "-" + MANAGED_SERVER_NAME_BASE, replicaCount);
764+
} else {
765+
createDomainAndVerify(domain, domainNamespace);
766+
}
767+
return domain;
768+
}
769+
646770
/**
647771
* Create domain with domain-on-pv type and verify the domain is created.
648772
* Also verify the admin server pod and managed server pods are up and running.
@@ -964,6 +1088,57 @@ public static DomainResource createAndVerifyDomainInImageUsingWdt(String domainU
9641088
clusterName, replicaCount);
9651089
}
9661090

1091+
/**
1092+
* Create a WebLogic domain in image using WDT.
1093+
*
1094+
* @param domainUid domain uid
1095+
* @param domainNamespace namespace in which the domain to be created
1096+
* @param wdtModelFileForDomainInImage WDT model file used to create domain image
1097+
* @param appSrcDirList list of the app src in WDT model file
1098+
* @param propertyFiles list of property files
1099+
* @param wlSecretName wls admin secret name
1100+
* @param clusterName cluster name
1101+
* @param replicaCount replica count of the cluster
1102+
* @return oracle.weblogic.domain.DomainResource object
1103+
*/
1104+
public static DomainResource createDomainInImageUsingWdt(String domainUid,
1105+
String domainNamespace,
1106+
String wdtModelFileForDomainInImage,
1107+
List<String> appSrcDirList,
1108+
List<String> propertyFiles,
1109+
String wlSecretName,
1110+
String clusterName,
1111+
int replicaCount) {
1112+
1113+
// create secret for admin credentials
1114+
getLogger().info("Create secret for admin credentials");
1115+
createSecretWithUsernamePassword(wlSecretName, domainNamespace, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
1116+
1117+
// create image with model files
1118+
getLogger().info("Creating image with model file and verify");
1119+
String domainInImageWithWDTImage = createImageAndVerify("domaininimage-wdtimage",
1120+
Collections.singletonList(MODEL_DIR + "/" + wdtModelFileForDomainInImage), appSrcDirList,
1121+
propertyFiles,
1122+
WEBLOGIC_IMAGE_NAME, WEBLOGIC_IMAGE_TAG, WLS_DOMAIN_TYPE, false,
1123+
domainUid, false);
1124+
1125+
// repo login and push image to registry if necessary
1126+
imageRepoLoginAndPushImageToRegistry(domainInImageWithWDTImage);
1127+
1128+
// Create the repo secret to pull the image
1129+
// this secret is used only for non-kind cluster
1130+
createTestRepoSecret(domainNamespace);
1131+
1132+
// create the domain custom resource
1133+
DomainResource domain = createDomainResourceForDomainInImage(domainUid, domainNamespace, domainInImageWithWDTImage,
1134+
wlSecretName, clusterName, replicaCount);
1135+
1136+
// create domain and verify
1137+
createDomainAndVerify(domain, domainNamespace);
1138+
1139+
return domain;
1140+
}
1141+
9671142
/**
9681143
* Create domain resource with domain-in-image type.
9691144
*
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2023, 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+
domainInfo:
5+
AdminUserName: 'weblogic'
6+
AdminPassword: 'welcome1'
7+
8+
topology:
9+
Name: "wls-domain1"
10+
ProductionModeEnabled: 'true'
11+
AdminServerName: "admin-server"
12+
Cluster:
13+
"cluster-1":
14+
Server:
15+
"admin-server":
16+
ListenPort: 7001
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2023, 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+
domainInfo:
5+
AdminUserName: '@@SECRET:__weblogic-credentials__:username@@'
6+
AdminPassword: '@@SECRET:__weblogic-credentials__:password@@'
7+
8+
topology:
9+
Name: "wls-domain1"
10+
ProductionModeEnabled: 'true'
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright (c) 2023, 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+
domainInfo:
5+
AdminUserName: '@@SECRET:__weblogic-credentials__:username@@'
6+
AdminPassword: '@@SECRET:__weblogic-credentials__:password@@'
7+
8+
topology:
9+
Name: "wls-domain1"
10+
ProductionModeEnabled: 'true'
11+
AdminServerName: "new-admin-server"
12+
Cluster:
13+
"cluster-1":
14+
DynamicServers:
15+
ServerTemplate: "cluster-1-template"
16+
ServerNamePrefix: "managed-server"
17+
DynamicClusterSize: 5
18+
MaxDynamicClusterSize: 5
19+
CalculatedListenPorts: false
20+
Server:
21+
"admin-server":
22+
ListenPort: 7001
23+
ServerTemplate:
24+
"cluster-1-template":
25+
Cluster: "cluster-1"
26+
ListenPort : 8001
27+
WebServer:
28+
WebServerLog:
29+
BufferSizeKb: 1
30+
31+
appDeployments:
32+
Application:
33+
myear:
34+
SourcePath: "wlsdeploy/applications/sample-app.ear"
35+
ModuleType: ear
36+
Target: 'cluster-1'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 2023, 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+
domainInfo:
5+
AdminUserName: '@@SECRET:__weblogic-credentials__:username@@'
6+
AdminPassword: '@@SECRET:__weblogic-credentials__:password@@'
7+
8+
topology:
9+
Name: "wls-domain1"
10+
ProductionModeEnabled: 'true'
11+
Cluster:
12+
"cluster-1":
13+
DynamicServers:
14+
ServerTemplate: "cluster-1-template"
15+
ServerNamePrefix: "managed-server"
16+
DynamicClusterSize: 5
17+
MaxDynamicClusterSize: 5
18+
CalculatedListenPorts: false
19+
Server:
20+
"AdminServer":
21+
ListenPort: 7001
22+
ServerTemplate:
23+
"cluster-1-template":
24+
Cluster: "cluster-1"
25+
ListenPort : 8001
26+
WebServer:
27+
WebServerLog:
28+
BufferSizeKb: 1
29+
30+
appDeployments:
31+
Application:
32+
myear:
33+
SourcePath: "wlsdeploy/applications/sample-app.ear"
34+
ModuleType: ear
35+
Target: 'cluster-1'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 2023, 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+
domainInfo:
5+
AdminUserName: '@@SECRET:__weblogic-credentials__:username@@'
6+
AdminPassword: '@@SECRET:__weblogic-credentials__:password@@'
7+
8+
topology:
9+
Name: "wls-domain1"
10+
ProductionModeEnabled: 'true'
11+
Cluster:
12+
"cluster-1":
13+
DynamicServers:
14+
ServerTemplate: "cluster-1-template"
15+
ServerNamePrefix: "managed-server"
16+
DynamicClusterSize: 5
17+
MaxDynamicClusterSize: 5
18+
CalculatedListenPorts: false
19+
Server:
20+
"adminserver":
21+
ListenPort: 7001
22+
ServerTemplate:
23+
"cluster-1-template":
24+
Cluster: "cluster-1"
25+
ListenPort : 8001
26+
WebServer:
27+
WebServerLog:
28+
BufferSizeKb: 1
29+
30+
appDeployments:
31+
Application:
32+
myear:
33+
SourcePath: "wlsdeploy/applications/sample-app.ear"
34+
ModuleType: ear
35+
Target: 'cluster-1'

0 commit comments

Comments
 (0)