Skip to content

Commit 0a0c719

Browse files
authored
Add test to delete System Resource in Mii Domain using ! command (#3931)
* Add test to delete System Resource in Mii Domain using ! command
1 parent 703e1d7 commit 0a0c719

File tree

2 files changed

+133
-9
lines changed

2 files changed

+133
-9
lines changed

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

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -359,23 +359,26 @@ void testMiiCheckSystemResources() {
359359
}
360360

361361
/**
362-
* Start a WebLogic domain using model-in-image with JMS/JDBC SystemResources.
363-
* Create a configmap to delete JMS/JDBC SystemResources.
362+
* Start a WebLogic domain using model-in-image.
363+
* Create 1 configmap with 2 models files, one of them to add JMS/JDBC SystemResources
364+
* and another one to delete JMS/JDBC SystemResources
364365
* Patch the domain resource with the configmap.
365366
* Update the restart version of the domain resource.
366367
* Verify rolling restart of the domain by comparing PodCreationTimestamp
367368
* for all the server pods before and after rolling restart.
368369
* Verify SystemResources are deleted from the domain.
369370
*/
370371
@Test
371-
@Order(4)
372+
@Order(5)
372373
@DisplayName("Delete SystemResources from the domain")
373374
void testMiiDeleteSystemResources() {
374375

375376
String configMapName = "deletesysrescm";
377+
final String modelFileAdd = "model.add.sysresources.yaml";
378+
final String modelFileDelete = "model.delete.sysresources.yaml";
379+
List<String> modelFiles = Arrays.asList(MODEL_DIR + "/" + modelFileAdd, MODEL_DIR + "/" + modelFileDelete);
376380
createConfigMapAndVerify(
377-
configMapName, domainUid, domainNamespace,
378-
Arrays.asList(MODEL_DIR + "/model.delete.sysresourcesbyconfigmap.yaml"));
381+
configMapName, domainUid, domainNamespace, modelFiles);
379382

380383
LinkedHashMap<String, OffsetDateTime> pods = new LinkedHashMap<>();
381384
// get the creation time of the admin server pod before patching
@@ -433,7 +436,7 @@ void testMiiDeleteSystemResources() {
433436
* Verify JMS Server logs are written on PV.
434437
*/
435438
@Test
436-
@Order(5)
439+
@Order(6)
437440
@DisplayName("Add new JDBC/JMS SystemResources to the domain")
438441
void testMiiAddSystemResources() {
439442

@@ -505,7 +508,7 @@ void testMiiAddSystemResources() {
505508
* Verify servers from the new cluster are running.
506509
*/
507510
@Test
508-
@Order(6)
511+
@Order(7)
509512
@DisplayName("Add a dynamic cluster to domain with non-zero replica count")
510513
void testMiiAddDynamicCluster() {
511514

@@ -579,7 +582,7 @@ void testMiiAddDynamicCluster() {
579582
* Check the validity of new credentials by accessing WebLogic RESTful Service
580583
*/
581584
@Test
582-
@Order(7)
585+
@Order(8)
583586
@DisplayName("Change the WebLogic Admin credential of the domain")
584587
void testMiiUpdateWebLogicCredential() {
585588
verifyUpdateWebLogicCredential(adminSvcExtHost, domainNamespace, domainUid, adminServerPodName,
@@ -601,7 +604,7 @@ void testMiiUpdateWebLogicCredential() {
601604
* Make sure JMS Connections and messages are distributed across 4 servers.
602605
*/
603606
@Test
604-
@Order(8)
607+
@Order(9)
605608
@DisplayName("Test modification to Dynamic cluster size parameters")
606609
void testMiiUpdateDynamicClusterSize() {
607610

@@ -745,6 +748,70 @@ private void buildClientOnPod() {
745748
assertEquals(0, result.exitValue(), "Client compilation fails");
746749
}
747750

751+
/**
752+
* Start a WebLogic domain using model-in-image with JMS/JDBC SystemResources.
753+
* Create a empty configmap to delete JMS/JDBC SystemResources
754+
* Patch the domain resource with the configmap.
755+
* Update the restart version of the domain resource.
756+
* Verify rolling restart of the domain by comparing PodCreationTimestamp
757+
* for all the server pods before and after rolling restart.
758+
* Verify SystemResources are deleted from the domain.
759+
*/
760+
@Test
761+
@Order(4)
762+
@DisplayName("Delete SystemResources from the domain")
763+
void testMiiDeleteSystemResourcesByEmptyConfigMap() {
764+
765+
String configMapName = "deletesysrescm";
766+
createConfigMapAndVerify(
767+
configMapName, domainUid, domainNamespace,
768+
Arrays.asList(MODEL_DIR + "/model.delete.sysresourcesbyconfigmap.yaml"));
769+
770+
LinkedHashMap<String, OffsetDateTime> pods = new LinkedHashMap<>();
771+
// get the creation time of the admin server pod before patching
772+
OffsetDateTime adminPodCreationTime = getPodCreationTime(domainNamespace,adminServerPodName);
773+
pods.put(adminServerPodName, adminPodCreationTime);
774+
// get the creation time of the managed server pods before patching
775+
for (int i = 1; i <= replicaCount; i++) {
776+
pods.put(managedServerPrefix + i, getPodCreationTime(domainNamespace, managedServerPrefix + i));
777+
}
778+
779+
StringBuffer patchStr = null;
780+
patchStr = new StringBuffer("[{");
781+
patchStr.append("\"op\": \"replace\",")
782+
.append(" \"path\": \"/spec/configuration/model/configMap\",")
783+
.append(" \"value\": \"" + configMapName + "\"")
784+
.append(" }]");
785+
logger.log(Level.INFO, "Configmap patch string: {0}", patchStr);
786+
787+
patch = new V1Patch(new String(patchStr));
788+
boolean cmPatched = assertDoesNotThrow(() ->
789+
patchDomainCustomResource(domainUid, domainNamespace, patch, "application/json-patch+json"),
790+
"patchDomainCustomResource(configMap) failed ");
791+
assertTrue(cmPatched, "patchDomainCustomResource(configMap) failed");
792+
793+
String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
794+
logger.log(Level.INFO, "New restart version is {0}", newRestartVersion);
795+
796+
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
797+
"Rolling restart failed");
798+
799+
// Even if pods are created, need the service to created
800+
for (int i = 1; i <= replicaCount; i++) {
801+
logger.info("Check managed server service {0} created in namespace {1}",
802+
managedServerPrefix + i, domainNamespace);
803+
checkServiceExists(managedServerPrefix + i, domainNamespace);
804+
}
805+
806+
int adminServiceNodePort
807+
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
808+
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
809+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
810+
"JDBCSystemResources", "TestDataSource", "404");
811+
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
812+
"JMSSystemResources", "TestClusterJmsModule", "404");
813+
}
814+
748815
// Run standalone JMS Client in the pod using wlthint3client.jar in classpath.
749816
// The client sends 300 messsage to a Uniform Distributed Queue.
750817
// Make sure that each destination get excatly 150 messages each.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
resources:
4+
FileStore:
5+
TestClusterFileStore:
6+
Target: 'cluster-1'
7+
JMSServer:
8+
TestClusterJmsServer:
9+
ProductionPausedAtStartup: false
10+
ConsumptionPausedAtStartup: false
11+
Target: 'cluster-1'
12+
PersistentStore: 'TestClusterFileStore'
13+
InsertionPausedAtStartup: false
14+
MessageCompressionOptions: GZIP_DEFAULT_COMPRESSION
15+
Notes: '@@ENV:CUSTOM_ENV@@'
16+
17+
JMSSystemResource:
18+
TestClusterJmsModule:
19+
Target: 'cluster-1'
20+
SubDeployment:
21+
TestClusterSubDeployment:
22+
Target: TestClusterJmsServer
23+
JmsResource:
24+
UniformDistributedQueue:
25+
testUniformQueue:
26+
SubDeploymentName: TestClusterSubDeployment
27+
JNDIName: jms/testUniformQueue
28+
UniformDistributedTopic:
29+
testUniformTopic:
30+
SubDeploymentName: TestClusterSubDeployment
31+
ForwardingPolicy: Partitioned
32+
JNDIName: jms/testUniformTopic
33+
34+
JDBCSystemResource:
35+
TestDataSource:
36+
Target: 'cluster-1'
37+
JdbcResource:
38+
JDBCConnectionPoolParams:
39+
InitialCapacity: 0
40+
MinCapacity: 0
41+
MaxCapacity: 15
42+
JDBCDataSourceParams:
43+
GlobalTransactionsProtocol: OnePhaseCommit
44+
RowPrefetchSize: 200
45+
JNDIName: jdbc/TestDataSource
46+
JDBCDriverParams:
47+
URL: '@@SECRET:@@ENV:DOMAIN_UID@@-db-secret:url@@'
48+
PasswordEncrypted: '@@SECRET:@@ENV:DOMAIN_UID@@-db-secret:password@@'
49+
DriverName: oracle.jdbc.OracleDriver
50+
Properties:
51+
user:
52+
Value: '@@SECRET:@@ENV:DOMAIN_UID@@-db-secret:username@@'
53+
54+
WLDFSystemResource:
55+
'TestWldfModule':
56+
Description: WLDF Module for Mii domain
57+
Target: 'cluster-1'

0 commit comments

Comments
 (0)