|
20 | 20 | import oracle.weblogic.kubernetes.annotations.IntegrationTest; |
21 | 21 | import oracle.weblogic.kubernetes.annotations.Namespaces; |
22 | 22 | import oracle.weblogic.kubernetes.logging.LoggingFacade; |
| 23 | +import oracle.weblogic.kubernetes.utils.TestUtils; |
23 | 24 | import org.apache.commons.io.FileUtils; |
24 | 25 | import org.awaitility.core.ConditionFactory; |
25 | 26 | import org.junit.jupiter.api.BeforeAll; |
|
34 | 35 | import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT; |
35 | 36 | import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT; |
36 | 37 | import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_IMAGES_REPO; |
| 38 | +import static oracle.weblogic.kubernetes.TestConstants.KIND_REPO; |
37 | 39 | import static oracle.weblogic.kubernetes.TestConstants.MII_AUXILIARY_IMAGE_NAME; |
38 | 40 | import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME; |
39 | 41 | import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG; |
|
49 | 51 | import static oracle.weblogic.kubernetes.actions.TestActions.defaultAppParams; |
50 | 52 | import static oracle.weblogic.kubernetes.actions.TestActions.deleteImage; |
51 | 53 | import static oracle.weblogic.kubernetes.actions.TestActions.dockerPush; |
| 54 | +import static oracle.weblogic.kubernetes.actions.TestActions.dockerTag; |
52 | 55 | import static oracle.weblogic.kubernetes.actions.TestActions.getDomainCustomResource; |
53 | 56 | import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort; |
54 | 57 | import static oracle.weblogic.kubernetes.actions.TestActions.patchDomainCustomResource; |
55 | 58 | import static oracle.weblogic.kubernetes.assertions.TestAssertions.verifyRollingRestartOccurred; |
56 | 59 | import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createDomainResource; |
| 60 | +import static oracle.weblogic.kubernetes.utils.CommonPatchTestUtils.patchDomainResource; |
| 61 | +import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists; |
57 | 62 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkSystemResourceConfig; |
58 | 63 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkSystemResourceConfiguration; |
59 | 64 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createDomainAndVerify; |
60 | 65 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createOcirRepoSecret; |
61 | 66 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createSecretWithUsernamePassword; |
| 67 | +import static oracle.weblogic.kubernetes.utils.CommonTestUtils.dockerLoginAndPushImageToRegistry; |
62 | 68 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getExternalServicePodName; |
63 | 69 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getPodsWithTimeStamps; |
64 | 70 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installAndVerifyOperator; |
@@ -235,12 +241,7 @@ public void testCreateDomainUsingMultipleAuxiliaryImages() { |
235 | 241 | adminServerPodName, managedServerPrefix, replicaCount); |
236 | 242 |
|
237 | 243 | // check configuration for JMS |
238 | | - int adminServiceNodePort |
239 | | - = getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"); |
240 | | - assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid"); |
241 | | - assertTrue(checkSystemResourceConfiguration(adminServiceNodePort, "JMSSystemResources", |
242 | | - "TestClusterJmsModule2", "200"), "JMSSystemResources not found"); |
243 | | - logger.info("Found the JMSSystemResource configuration"); |
| 244 | + checkConfiguredJMSresouce(domainNamespace, adminServerPodName); |
244 | 245 |
|
245 | 246 | //checking the order of loading for the common mount images, expecting file with content =2 |
246 | 247 | assertDoesNotThrow(() -> FileUtils.deleteQuietly(Paths.get(RESULTS_ROOT, "/test.txt").toFile())); |
@@ -300,11 +301,75 @@ public void testUpdateDataSourceInDomainUsingAuxiliaryImage() { |
300 | 301 |
|
301 | 302 | patchDomainWithAuxiliaryImageAndVerify(miiAuxiliaryImage1, miiAuxiliaryImage3, domainUid, domainNamespace); |
302 | 303 |
|
303 | | - assertTrue(checkSystemResourceConfig(adminServiceNodePort, |
304 | | - "JDBCSystemResources/TestDataSource/JDBCResource/JDBCDriverParams", |
305 | | - "jdbc:oracle:thin:@\\/\\/localhost:7001\\/dbsvc"), "Can't find expected URL configuration for DataSource"); |
| 304 | + checkConfiguredJDBCresouce(domainNamespace, adminServerPodName); |
| 305 | + } |
| 306 | + |
| 307 | + /** |
| 308 | + * Patch the domain with the different base image name. |
| 309 | + * Verify all the pods are restarted and back to ready state. |
| 310 | + * Verify configured JMS and JDBC resources. |
| 311 | + */ |
| 312 | + @Test |
| 313 | + @Order(3) |
| 314 | + @DisplayName("Test to update Base Weblogic Image Name") |
| 315 | + public void testUpdateBaseImageName() { |
| 316 | + // get the original domain resource before update |
| 317 | + Domain domain1 = assertDoesNotThrow(() -> getDomainCustomResource(domainUid, domainNamespace), |
| 318 | + String.format("getDomainCustomResource failed with ApiException when tried to get domain %s in namespace %s", |
| 319 | + domainUid, domainNamespace)); |
| 320 | + assertNotNull(domain1, "Got null domain resource"); |
| 321 | + assertNotNull(domain1.getSpec(), domain1 + "/spec is null"); |
| 322 | + |
| 323 | + // get the map with server pods and their original creation timestamps |
| 324 | + podsWithTimeStamps = getPodsWithTimeStamps(domainNamespace, adminServerPodName, managedServerPrefix, |
| 325 | + replicaCount); |
| 326 | + |
| 327 | + //print out the original image name |
| 328 | + String imageName = domain1.getSpec().getImage(); |
| 329 | + logger.info("Currently the image name used for the domain is: {0}", imageName); |
| 330 | + |
| 331 | + //change image name to imageUpdate |
| 332 | + String imageTag = TestUtils.getDateAndTimeStamp(); |
| 333 | + String imageUpdate = KIND_REPO != null ? KIND_REPO |
| 334 | + + (WEBLOGIC_IMAGE_NAME + ":" + imageTag).substring(TestConstants.BASE_IMAGES_REPO.length() + 1) |
| 335 | + : WEBLOGIC_IMAGE_NAME + ":" + imageTag; |
| 336 | + dockerTag(imageName, imageUpdate); |
| 337 | + dockerLoginAndPushImageToRegistry(imageUpdate); |
| 338 | + |
| 339 | + StringBuffer patchStr = null; |
| 340 | + patchStr = new StringBuffer("[{"); |
| 341 | + patchStr.append("\"op\": \"replace\",") |
| 342 | + .append(" \"path\": \"/spec/image\",") |
| 343 | + .append("\"value\": \"") |
| 344 | + .append(imageUpdate) |
| 345 | + .append("\"}]"); |
| 346 | + logger.info("PatchStr for imageUpdate: {0}", patchStr.toString()); |
| 347 | + |
| 348 | + assertTrue(patchDomainResource(domainUid, domainNamespace, patchStr), |
| 349 | + "patchDomainCustomResource(imageUpdate) failed"); |
| 350 | + |
| 351 | + domain1 = assertDoesNotThrow(() -> getDomainCustomResource(domainUid, domainNamespace), |
| 352 | + String.format("getDomainCustomResource failed with ApiException when tried to get domain %s in namespace %s", |
| 353 | + domainUid, domainNamespace)); |
| 354 | + assertNotNull(domain1, "Got null domain resource after patching"); |
| 355 | + assertNotNull(domain1.getSpec(), domain1 + " /spec is null"); |
| 356 | + |
| 357 | + //print out image name in the new patched domain |
| 358 | + logger.info("In the new patched domain image name is: {0}", domain1.getSpec().getImage()); |
| 359 | + |
| 360 | + // verify the server pods are rolling restarted and back to ready state |
| 361 | + logger.info("Verifying rolling restart occurred for domain {0} in namespace {1}", |
| 362 | + domainUid, domainNamespace); |
| 363 | + assertTrue(verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace), |
| 364 | + String.format("Rolling restart failed for domain %s in namespace %s", domainUid, domainNamespace)); |
| 365 | + |
| 366 | + checkPodReadyAndServiceExists(adminServerPodName, domainUid, domainNamespace); |
| 367 | + |
| 368 | + // check configuration for JMS |
| 369 | + checkConfiguredJMSresouce(domainNamespace, adminServerPodName); |
| 370 | + //check configuration for JDBC |
| 371 | + checkConfiguredJDBCresouce(domainNamespace, adminServerPodName); |
306 | 372 |
|
307 | | - logger.info("Found the DataResource configuration"); |
308 | 373 | } |
309 | 374 |
|
310 | 375 | private static void patchDomainWithAuxiliaryImageAndVerify(String oldImageName, String newImageName, |
@@ -400,4 +465,24 @@ private void createAuxiliaryImage(String stageDirPath, String dockerFileLocation |
400 | 465 | .command(cmdToExecute)) |
401 | 466 | .execute(), String.format("Failed to execute", cmdToExecute)); |
402 | 467 | } |
| 468 | + |
| 469 | + private void checkConfiguredJMSresouce(String domainNamespace, String adminServerPodName) { |
| 470 | + int adminServiceNodePort |
| 471 | + = getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"); |
| 472 | + assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid"); |
| 473 | + assertTrue(checkSystemResourceConfiguration(adminServiceNodePort, "JMSSystemResources", |
| 474 | + "TestClusterJmsModule2", "200"), "JMSSystemResources not found"); |
| 475 | + logger.info("Found the JMSSystemResource configuration"); |
| 476 | + } |
| 477 | + |
| 478 | + private void checkConfiguredJDBCresouce(String domainNamespace, String adminServerPodName) { |
| 479 | + int adminServiceNodePort |
| 480 | + = getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"); |
| 481 | + assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid"); |
| 482 | + assertTrue(checkSystemResourceConfig(adminServiceNodePort, |
| 483 | + "JDBCSystemResources/TestDataSource/JDBCResource/JDBCDriverParams", |
| 484 | + "jdbc:oracle:thin:@\\/\\/localhost:7001\\/dbsvc"), "Can't find expected URL configuration for DataSource"); |
| 485 | + logger.info("Found the DataResource configuration"); |
| 486 | + } |
| 487 | + |
403 | 488 | } |
0 commit comments