Skip to content

Commit 2a02cff

Browse files
authored
Add test to verify RCU Schema Password change as well as WebLogic Credential update after that (#2368)
* first cut for jrf rcu password change
1 parent 9b74cc8 commit 2a02cff

File tree

9 files changed

+266
-108
lines changed

9 files changed

+266
-108
lines changed

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

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
3636
import static oracle.weblogic.kubernetes.actions.TestActions.patchDomainCustomResource;
3737
import static oracle.weblogic.kubernetes.actions.impl.primitive.Command.defaultCommandParams;
38+
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyUpdateWebLogicCredential;
3839
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodDeleted;
3940
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createDomainAndVerify;
4041
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createMiiImageAndVerify;
@@ -45,7 +46,9 @@
4546
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.dockerLoginAndPushImageToRegistry;
4647
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installAndVerifyOperator;
4748
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.patchServerStartPolicy;
49+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.updateRcuAccessSecret;
4850
import static oracle.weblogic.kubernetes.utils.DbUtils.setupDBandRCUschema;
51+
import static oracle.weblogic.kubernetes.utils.DbUtils.updateRcuPassword;
4952
import static oracle.weblogic.kubernetes.utils.FmwUtils.verifyDomainReady;
5053
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
5154
import static org.awaitility.Awaitility.with;
@@ -54,28 +57,29 @@
5457
import static org.junit.jupiter.api.Assertions.assertTrue;
5558

5659
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
57-
@DisplayName("Test to a create JRF model in image domain and start the domain")
60+
@DisplayName("Test to a create FMW model in image domain and start the domain")
5861
@IntegrationTest
5962
public class ItFmwMiiDomain {
6063

6164
private static String dbNamespace = null;
6265
private static String opNamespace = null;
63-
private static String jrfDomainNamespace = null;
64-
private static String jrfMiiImage = null;
66+
private static String fmwDomainNamespace = null;
67+
private static String fmwMiiImage = null;
6568

66-
private static final String RCUSCHEMAPREFIX = "jrfdomainmii";
69+
private static final String RCUSCHEMAPREFIX = "FMWDOMAINMII";
6770
private static final String ORACLEDBURLPREFIX = "oracledb.";
6871
private static final String ORACLEDBSUFFIX = ".svc.cluster.local:1521/devpdb.k8s";
6972
private static final String RCUSYSUSERNAME = "sys";
7073
private static final String RCUSYSPASSWORD = "Oradoc_db1";
7174
private static final String RCUSCHEMAUSERNAME = "myrcuuser";
7275
private static final String RCUSCHEMAPASSWORD = "Oradoc_db1";
76+
private static final String RCUSCHEMAPASSWORDNEW = "Oradoc_db2";
7377
private static final String modelFile = "model-singleclusterdomain-sampleapp-jrf.yaml";
7478

7579
private static String dbUrl = null;
7680
private static LoggingFacade logger = null;
7781

78-
private String domainUid = "jrfdomain-mii";
82+
private String domainUid = "fmwdomain-mii";
7983
private String adminServerPodName = domainUid + "-admin-server";
8084
private String managedServerPrefix = domainUid + "-managed-server";
8185
private int replicaCount = 2;
@@ -113,9 +117,9 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
113117
assertNotNull(namespaces.get(1), "Namespace is null");
114118
opNamespace = namespaces.get(1);
115119

116-
logger.info("Assign a unique namespace for JRF domain");
120+
logger.info("Assign a unique namespace for FMW domain");
117121
assertNotNull(namespaces.get(2), "Namespace is null");
118-
jrfDomainNamespace = namespaces.get(2);
122+
fmwDomainNamespace = namespaces.get(2);
119123

120124
logger.info("Start DB and create RCU schema for namespace: {0}, RCU prefix: {1}, "
121125
+ "dbUrl: {2}, dbImage: {3}, fmwImage: {4} ", dbNamespace, RCUSCHEMAPREFIX, dbUrl,
@@ -126,15 +130,15 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
126130
+ "dbUrl %s", RCUSCHEMAPREFIX, dbNamespace, dbUrl));
127131

128132
// install operator and verify its running in ready state
129-
installAndVerifyOperator(opNamespace, jrfDomainNamespace);
133+
installAndVerifyOperator(opNamespace, fmwDomainNamespace);
130134

131135
logger.info("For ItFmwMiiDomain using DB image: {0}, FMW image {1}",
132136
DB_IMAGE_TO_USE_IN_SPEC, FMWINFRA_IMAGE_TO_USE_IN_SPEC);
133137

134138
}
135139

136140
/**
137-
* Create a basic JRF model in image domain.
141+
* Create a basic FMW model in image domain.
138142
* Verify Pod is ready and service exists for both admin server and managed servers.
139143
* Verify EM console is accessible.
140144
*/
@@ -144,13 +148,13 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
144148
public void testFmwModelInImage() {
145149
// Create the repo secret to pull the image
146150
// this secret is used only for non-kind cluster
147-
createOcirRepoSecret(jrfDomainNamespace);
151+
createOcirRepoSecret(fmwDomainNamespace);
148152

149153
// create secret for admin credentials
150154
logger.info("Create secret for admin credentials");
151155
assertDoesNotThrow(() -> createSecretWithUsernamePassword(
152156
adminSecretName,
153-
jrfDomainNamespace,
157+
fmwDomainNamespace,
154158
"weblogic",
155159
"welcome1"),
156160
String.format("createSecret failed for %s", adminSecretName));
@@ -159,7 +163,7 @@ public void testFmwModelInImage() {
159163
logger.info("Create encryption secret");
160164
assertDoesNotThrow(() -> createSecretWithUsernamePassword(
161165
encryptionSecretName,
162-
jrfDomainNamespace,
166+
fmwDomainNamespace,
163167
"weblogicenc",
164168
"weblogicenc"),
165169
String.format("createSecret failed for %s", encryptionSecretName));
@@ -169,7 +173,7 @@ public void testFmwModelInImage() {
169173
rcuaccessSecretName, RCUSCHEMAPREFIX, RCUSCHEMAPASSWORD, dbUrl);
170174
assertDoesNotThrow(() -> createRcuAccessSecret(
171175
rcuaccessSecretName,
172-
jrfDomainNamespace,
176+
fmwDomainNamespace,
173177
RCUSCHEMAPREFIX,
174178
RCUSCHEMAPASSWORD,
175179
dbUrl),
@@ -178,13 +182,13 @@ public void testFmwModelInImage() {
178182
logger.info("Create OPSS wallet password secret");
179183
assertDoesNotThrow(() -> createOpsswalletpasswordSecret(
180184
opsswalletpassSecretName,
181-
jrfDomainNamespace,
185+
fmwDomainNamespace,
182186
"welcome1"),
183187
String.format("createSecret failed for %s", opsswalletpassSecretName));
184188

185189
logger.info("Create an image with jrf model file");
186190
final List<String> modelList = Collections.singletonList(MODEL_DIR + "/" + modelFile);
187-
jrfMiiImage = createMiiImageAndVerify(
191+
fmwMiiImage = createMiiImageAndVerify(
188192
"jrf-mii-image",
189193
modelList,
190194
Collections.singletonList(MII_BASIC_APP_NAME),
@@ -194,21 +198,21 @@ public void testFmwModelInImage() {
194198
false);
195199

196200
// push the image to a registry to make it accessible in multi-node cluster
197-
dockerLoginAndPushImageToRegistry(jrfMiiImage);
201+
dockerLoginAndPushImageToRegistry(fmwMiiImage);
198202

199203
// create the domain object
200204
Domain domain = FmwUtils.createDomainResource(domainUid,
201-
jrfDomainNamespace,
205+
fmwDomainNamespace,
202206
adminSecretName,
203207
OCIR_SECRET_NAME,
204208
encryptionSecretName,
205209
rcuaccessSecretName,
206210
opsswalletpassSecretName,
207211
replicaCount,
208-
jrfMiiImage);
212+
fmwMiiImage);
209213

210-
createDomainAndVerify(domain, jrfDomainNamespace);
211-
verifyDomainReady(jrfDomainNamespace, domainUid, replicaCount);
214+
createDomainAndVerify(domain, fmwDomainNamespace);
215+
verifyDomainReady(fmwDomainNamespace, domainUid, replicaCount);
212216
}
213217

214218
/**
@@ -223,11 +227,53 @@ public void testFmwModelInImage() {
223227
@Test
224228
@DisplayName("Reuse the same RCU schema to restart JRF domain")
225229
public void testReuseRCUschemalToRestartDomain() {
226-
saveAndRestoreOpssWalletfileSecret(jrfDomainNamespace, domainUid, opsswalletfileSecretName);
230+
saveAndRestoreOpssWalletfileSecret(fmwDomainNamespace, domainUid, opsswalletfileSecretName);
227231
shutdownDomain();
228232
patchDomainWithWalletFileSecret(opsswalletfileSecretName);
229233
startupDomain();
230-
verifyDomainReady(jrfDomainNamespace, domainUid, replicaCount);
234+
verifyDomainReady(fmwDomainNamespace, domainUid, replicaCount);
235+
}
236+
237+
/**
238+
* Shutdown the FMW domain completely.
239+
* Update all the passwords for the RCU schema.
240+
* Update the RCU access secret with new RCU schema password.
241+
* Start the domain and verify domain is up and running.
242+
*/
243+
@Order(3)
244+
@Test
245+
@DisplayName("Update RCU schema password")
246+
public void testUpdateRcuSchemaPassword() {
247+
shutdownDomain();
248+
logger.info("Updating RCU schema password with dbNamespace: {0}, RCU prefix: {1}, new schemapassword: {2}",
249+
dbNamespace, RCUSCHEMAPREFIX, RCUSCHEMAPASSWORDNEW);
250+
updateRcuPassword(dbNamespace, RCUSCHEMAPREFIX, RCUSCHEMAPASSWORDNEW);
251+
logger.info("Updating RCU access secret: {0}, with prefix: {1}, new schemapassword: {2}, dbUrl: {3})",
252+
rcuaccessSecretName, RCUSCHEMAPREFIX, RCUSCHEMAPASSWORDNEW, dbUrl);
253+
assertDoesNotThrow(() -> updateRcuAccessSecret(
254+
rcuaccessSecretName,
255+
fmwDomainNamespace,
256+
RCUSCHEMAPREFIX,
257+
RCUSCHEMAPASSWORDNEW,
258+
dbUrl),
259+
String.format("update Secret failed for %s with new schema password %s", rcuaccessSecretName,
260+
RCUSCHEMAPASSWORDNEW));
261+
startupDomain();
262+
verifyDomainReady(fmwDomainNamespace, domainUid, replicaCount);
263+
}
264+
265+
/**
266+
* After updating RCU schema password change the WebLogic Admin credential of the domain.
267+
* Update domainRestartVersion to trigger a rolling restart of server pods.
268+
* Verify all the server pods are re-started in a rolling fashion.
269+
* Check the validity of new credentials by accessing WebLogic RESTful Service.
270+
*/
271+
@Order(4)
272+
@Test
273+
@DisplayName("Update WebLogic Credentials after updating RCU schema password")
274+
public void testUpdateWebLogicCredentialAfterUpdateRcuSchemaPassword() {
275+
verifyUpdateWebLogicCredential(fmwDomainNamespace, domainUid, adminServerPodName,
276+
managedServerPrefix, replicaCount, "-c1");
231277
}
232278

233279
/**
@@ -269,13 +315,13 @@ private void saveAndRestoreOpssWalletfileSecret(String namespace, String domainU
269315
* Shutdown the domain by setting serverStartPolicy as "NEVER".
270316
*/
271317
private void shutdownDomain() {
272-
patchServerStartPolicy("/spec/serverStartPolicy", "NEVER", jrfDomainNamespace, domainUid);
318+
patchServerStartPolicy("/spec/serverStartPolicy", "NEVER", fmwDomainNamespace, domainUid);
273319
logger.info("Domain is patched to stop entire WebLogic domain");
274320

275321
// make sure all the server pods are removed after patch
276-
checkPodDeleted(adminServerPodName, domainUid, jrfDomainNamespace);
322+
checkPodDeleted(adminServerPodName, domainUid, fmwDomainNamespace);
277323
for (int i = 1; i <= replicaCount; i++) {
278-
checkPodDeleted(managedServerPrefix + i, domainUid, jrfDomainNamespace);
324+
checkPodDeleted(managedServerPrefix + i, domainUid, fmwDomainNamespace);
279325
}
280326

281327
logger.info("Domain shutdown success");
@@ -286,7 +332,7 @@ private void shutdownDomain() {
286332
* Startup the domain by setting serverStartPolicy as "IF_NEEDED".
287333
*/
288334
private void startupDomain() {
289-
patchServerStartPolicy("/spec/serverStartPolicy", "IF_NEEDED", jrfDomainNamespace, domainUid);
335+
patchServerStartPolicy("/spec/serverStartPolicy", "IF_NEEDED", fmwDomainNamespace, domainUid);
290336
logger.info("Domain is patched to start all servers in the domain");
291337
}
292338

@@ -305,10 +351,10 @@ private boolean patchDomainWithWalletFileSecret(String opssWalletFileSecretName)
305351
.append("\"}]");
306352

307353
logger.info("Adding opssWalletPasswordSecretName for domain {0} in namespace {1} using patch string: {2}",
308-
domainUid, jrfDomainNamespace, patchStr.toString());
354+
domainUid, fmwDomainNamespace, patchStr.toString());
309355

310356
V1Patch patch = new V1Patch(new String(patchStr));
311357

312-
return patchDomainCustomResource(domainUid, jrfDomainNamespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH);
358+
return patchDomainCustomResource(domainUid, fmwDomainNamespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH);
313359
}
314360
}

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

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@
5757

5858
import static java.util.concurrent.TimeUnit.MINUTES;
5959
import static java.util.concurrent.TimeUnit.SECONDS;
60-
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
61-
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_PATCH;
62-
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
63-
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_PATCH;
6460
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET;
6561
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
6662
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
@@ -85,7 +81,7 @@
8581
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
8682
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podDoesNotExist;
8783
import static oracle.weblogic.kubernetes.assertions.TestAssertions.verifyRollingRestartOccurred;
88-
import static oracle.weblogic.kubernetes.utils.CommonPatchTestUtils.patchDomainWithNewSecretAndVerify;
84+
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyUpdateWebLogicCredential;
8985
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodDeleted;
9086
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodDoesNotExist;
9187
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReady;
@@ -98,13 +94,11 @@
9894
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createPV;
9995
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createPVC;
10096
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createSecretForBaseImages;
101-
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createSecretWithUsernamePassword;
10297
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createfixPVCOwnerContainer;
10398
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getExternalServicePodName;
10499
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getPodCreationTime;
105100
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installAndVerifyOperator;
106101
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.setPodAntiAffinity;
107-
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCredentials;
108102
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
109103
import static oracle.weblogic.kubernetes.utils.FileUtils.copyFileToPod;
110104
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
@@ -739,56 +733,8 @@ public void testMiiAddConfiguredCluster() {
739733
@Order(9)
740734
@DisplayName("Change the WebLogic Admin credential of the domain")
741735
public void testMiiUpdateWebLogicCredential() {
742-
final boolean VALID = true;
743-
final boolean INVALID = false;
744-
745-
LinkedHashMap<String, OffsetDateTime> pods = new LinkedHashMap<>();
746-
// get the creation time of the admin server pod before patching
747-
OffsetDateTime adminPodCreationTime = getPodCreationTime(domainNamespace,adminServerPodName);
748-
pods.put(adminServerPodName, adminPodCreationTime);
749-
// get the creation time of the managed server pods before patching
750-
for (int i = 1; i <= replicaCount; i++) {
751-
pods.put(managedServerPrefix + i, getPodCreationTime(domainNamespace, managedServerPrefix + i));
752-
}
753-
754-
logger.info("Check that before patching current credentials are valid and new credentials are not");
755-
verifyCredentials(adminServerPodName, domainNamespace, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, VALID);
756-
verifyCredentials(adminServerPodName, domainNamespace, ADMIN_USERNAME_PATCH, ADMIN_PASSWORD_PATCH, INVALID);
757-
758-
// create a new secret for admin credentials
759-
logger.info("Create a new secret that contains new WebLogic admin credentials");
760-
String adminSecretName = "weblogic-credentials-new";
761-
assertDoesNotThrow(() -> createSecretWithUsernamePassword(
762-
adminSecretName,
763-
domainNamespace,
764-
ADMIN_USERNAME_PATCH,
765-
ADMIN_PASSWORD_PATCH),
766-
String.format("createSecret failed for %s", adminSecretName));
767-
768-
// patch the domain resource with the new secret and verify that the domain resource is patched.
769-
logger.info("Patch domain {0} in namespace {1} with the secret {2}, and verify the result",
770-
domainUid, domainNamespace, adminSecretName);
771-
String restartVersion = patchDomainWithNewSecretAndVerify(
772-
domainUid,
773-
domainNamespace,
774-
adminServerPodName,
775-
managedServerPrefix,
776-
replicaCount,
777-
adminSecretName);
778-
779-
logger.info("Wait for domain {0} admin server pod {1} in namespace {2} to be restarted",
780-
domainUid, adminServerPodName, domainNamespace);
781-
782-
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
783-
"Rolling restart failed");
784-
785-
// check if the new credentials are valid and the old credentials are not valid any more
786-
logger.info("Check that after patching current credentials are not valid and new credentials are");
787-
verifyCredentials(adminServerPodName, domainNamespace, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, INVALID);
788-
verifyCredentials(adminServerPodName, domainNamespace, ADMIN_USERNAME_PATCH, ADMIN_PASSWORD_PATCH, VALID);
789-
790-
logger.info("Domain {0} in namespace {1} is fully started after changing WebLogic credentials secret",
791-
domainUid, domainNamespace);
736+
verifyUpdateWebLogicCredential(domainNamespace, domainUid, adminServerPodName,
737+
managedServerPrefix, replicaCount);
792738
}
793739

794740
/**

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,6 @@ public void testOperatorRestartWhenPodRoll() {
285285
String restartVersion = CommonPatchTestUtils.patchDomainWithNewSecretAndVerify(
286286
domainUid,
287287
domainNamespace,
288-
adminServerPodName,
289-
managedServerPrefix,
290-
replicaCount,
291288
adminSecretName);
292289

293290
// wait till rolling restart has started by checking admin server pod has restarted

integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/TestAssertions.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,9 @@ public static Callable<Boolean> credentialsValid(
441441
String podName,
442442
String namespace,
443443
String username,
444-
String password) {
445-
return () -> Domain.credentialsValid(host, podName, namespace, username, password);
444+
String password,
445+
String... args) {
446+
return () -> Domain.credentialsValid(host, podName, namespace, username, password, args);
446447
}
447448

448449
/**
@@ -461,8 +462,9 @@ public static Callable<Boolean> credentialsNotValid(
461462
String podName,
462463
String namespace,
463464
String username,
464-
String password) {
465-
return () -> Domain.credentialsNotValid(host, podName, namespace, username, password);
465+
String password,
466+
String... args) {
467+
return () -> Domain.credentialsNotValid(host, podName, namespace, username, password, args);
466468
}
467469

468470
/**

0 commit comments

Comments
 (0)