|
4 | 4 |
|
5 | 5 | package oracle.kubernetes.operator;
|
6 | 6 |
|
| 7 | +import java.nio.charset.Charset; |
| 8 | +import java.nio.charset.StandardCharsets; |
| 9 | +import java.nio.file.Files; |
| 10 | +import java.nio.file.Path; |
| 11 | +import java.nio.file.Paths; |
| 12 | +import java.util.HashMap; |
7 | 13 | import java.util.Map;
|
| 14 | +import java.util.logging.Level; |
8 | 15 | import oracle.kubernetes.operator.utils.DBUtils;
|
| 16 | +import oracle.kubernetes.operator.utils.DomainCRD; |
| 17 | +import oracle.kubernetes.operator.utils.ExecResult; |
9 | 18 | import oracle.kubernetes.operator.utils.JRFDomain;
|
10 | 19 | import oracle.kubernetes.operator.utils.Operator;
|
11 | 20 | import oracle.kubernetes.operator.utils.TestUtils;
|
@@ -368,7 +377,7 @@ public void testAutoAndCustomSitConfigOverrides() throws Exception {
|
368 | 377 | domainMap.put("configOverrides", "sitconfigcm");
|
369 | 378 | domainMap.put(
|
370 | 379 | "configOverridesFile",
|
371 |
| - BaseTest.getProjectRoot() |
| 380 | + getProjectRoot() |
372 | 381 | + "/integration-tests/src/test/resources/domain-home-on-pv/customsitconfig");
|
373 | 382 | domainMap.put("domainUID", "customsitdomain");
|
374 | 383 | domainMap.put("adminNodePort", 30704);
|
@@ -403,6 +412,263 @@ public void testAutoAndCustomSitConfigOverrides() throws Exception {
|
403 | 412 | logger.info("SUCCESS - " + testMethod);
|
404 | 413 | }
|
405 | 414 |
|
| 415 | + /** |
| 416 | + * test the Rolling restart behavior in the jrf domain cluster level currently there are two bugs |
| 417 | + * 29678557, 29720185, the test will fail |
| 418 | + * |
| 419 | + * @throws Exception - if any error occurs |
| 420 | + */ |
| 421 | + @Test |
| 422 | + public void testJRFDomainClusterRestartVersion() throws Exception { |
| 423 | + Assume.assumeFalse(QUICKTEST); |
| 424 | + String testMethod = new Object() {}.getClass().getEnclosingMethod().getName(); |
| 425 | + logTestBegin(testMethod); |
| 426 | + |
| 427 | + if (operator1 == null) { |
| 428 | + operator1 = TestUtils.createOperator(JRF_OPERATOR_FILE_1); |
| 429 | + } |
| 430 | + |
| 431 | + JRFDomain domain1 = null; |
| 432 | + boolean testCompletedSuccessfully = false; |
| 433 | + try { |
| 434 | + Map<String, Object> domain1Map = TestUtils.loadYaml(JRF_DOMAIN_ON_PV_WLST_FILE); |
| 435 | + domain1Map.put("domainUID", "jrfrestart"); |
| 436 | + domain1Map.put("adminNodePort", 30705); |
| 437 | + domain1Map.put("t3ChannelPort", 30025); |
| 438 | + domain1Map.put("voyagerWebPort", 30309); |
| 439 | + domain1Map.put("rcuSchemaPrefix", "jrfrestart"); |
| 440 | + domain1Map.put("initialManagedServerReplicas", 4); |
| 441 | + |
| 442 | + // run RCU script to load db schema |
| 443 | + DBUtils.runRCU(rcuPodName, domain1Map); |
| 444 | + |
| 445 | + // create domain |
| 446 | + logger.info("Creating Domain & verifying the domain creation"); |
| 447 | + domain1 = new JRFDomain(domain1Map); |
| 448 | + domain1.verifyDomainCreated(); |
| 449 | + |
| 450 | + String originalYaml = |
| 451 | + getUserProjectsDir() + "/weblogic-domains/" + domain1.getDomainUid() + "/domain.yaml"; |
| 452 | + |
| 453 | + // Rolling restart the cluster by setting restartVersion at the cluster level |
| 454 | + // Modify the original domain yaml to include restartVersion in cluster level |
| 455 | + DomainCRD crd = new DomainCRD(originalYaml); |
| 456 | + Map<String, Object> clusterRestartVersion = new HashMap(); |
| 457 | + clusterRestartVersion.put("restartVersion", "clusterV1"); |
| 458 | + clusterRestartVersion.put("maxUnavailable", new Integer(2)); |
| 459 | + crd.addObjectNodeToCluster(domain1.getClusterName(), clusterRestartVersion); |
| 460 | + String modYaml = crd.getYamlTree(); |
| 461 | + logger.info(modYaml); |
| 462 | + |
| 463 | + // Write the modified yaml to a new file |
| 464 | + String restartTmpDir = getResultDir() + "/restarttemp"; |
| 465 | + Files.createDirectories(Paths.get(restartTmpDir)); |
| 466 | + Path path = Paths.get(restartTmpDir, "restart.cluster.yaml"); |
| 467 | + logger.log(Level.INFO, "Path of the modified domain.yaml :{0}", path.toString()); |
| 468 | + Charset charset = StandardCharsets.UTF_8; |
| 469 | + Files.write(path, modYaml.getBytes(charset)); |
| 470 | + |
| 471 | + // Apply the new yaml to update the domain crd |
| 472 | + logger.log(Level.INFO, "kubectl apply -f {0}", path.toString()); |
| 473 | + ExecResult exec = TestUtils.exec("kubectl apply -f " + path.toString()); |
| 474 | + logger.info(exec.stdout()); |
| 475 | + |
| 476 | + int expectedMsPodsCount = |
| 477 | + (Integer) domain1.getDomainMap().get("initialManagedServerReplicas"); |
| 478 | + // TODO: this verification will fail due to bug 29678557 |
| 479 | + logger.info("Verifying the number of not ready MS pods can not exceed maxUnavailable value"); |
| 480 | + verifyMSPodsNotReadyCountNotExceedMaxUnAvailable(domain1, expectedMsPodsCount, 2); |
| 481 | + |
| 482 | + // TODO: this verification will fail due to bug 29720185 |
| 483 | + logger.info("Verifying the number of MS pods"); |
| 484 | + if (getMSPodsCount(domain1) != expectedMsPodsCount) { |
| 485 | + throw new Exception( |
| 486 | + "The number of MS pods is not right, expect: " |
| 487 | + + expectedMsPodsCount |
| 488 | + + ", got: " |
| 489 | + + getMSPodsCount(domain1)); |
| 490 | + } |
| 491 | + } finally { |
| 492 | + if (domain1 != null && (JENKINS || testCompletedSuccessfully)) { |
| 493 | + domain1.destroy(); |
| 494 | + } |
| 495 | + } |
| 496 | + logger.info("SUCCESS - " + testMethod); |
| 497 | + } |
| 498 | + |
| 499 | + /** |
| 500 | + * This is the test case to cover bug 29684570. |
| 501 | + * |
| 502 | + * @throws Exception - if any error occurs |
| 503 | + */ |
| 504 | + @Test |
| 505 | + public void testJRFDomainMSPodCreated() throws Exception { |
| 506 | + Assume.assumeFalse(QUICKTEST); |
| 507 | + String testMethod = new Object() {}.getClass().getEnclosingMethod().getName(); |
| 508 | + logTestBegin(testMethod); |
| 509 | + |
| 510 | + if (operator1 == null) { |
| 511 | + operator1 = TestUtils.createOperator(JRF_OPERATOR_FILE_1); |
| 512 | + } |
| 513 | + |
| 514 | + JRFDomain domain1 = null; |
| 515 | + boolean testCompletedSuccessfully = false; |
| 516 | + try { |
| 517 | + Map<String, Object> domain1Map = TestUtils.loadYaml(JRF_DOMAIN_ON_PV_WLST_FILE); |
| 518 | + domain1Map.put("domainUID", "jrfmspod"); |
| 519 | + domain1Map.put("adminNodePort", 30706); |
| 520 | + domain1Map.put("t3ChannelPort", 30026); |
| 521 | + domain1Map.put("voyagerWebPort", 30310); |
| 522 | + domain1Map.put("rcuSchemaPrefix", "jrfmspod"); |
| 523 | + domain1Map.put("initialManagedServerReplicas", 4); |
| 524 | + domain1Map.put("exposeAdminNodePort", false); |
| 525 | + |
| 526 | + // run RCU script to load db schema |
| 527 | + DBUtils.runRCU(rcuPodName, domain1Map); |
| 528 | + |
| 529 | + // create domain |
| 530 | + logger.info("Creating Domain & verifying the domain creation"); |
| 531 | + domain1 = new JRFDomain(domain1Map); |
| 532 | + domain1.verifyDomainCreated(); |
| 533 | + |
| 534 | + } finally { |
| 535 | + if (domain1 != null && (JENKINS || testCompletedSuccessfully)) { |
| 536 | + domain1.destroy(); |
| 537 | + } |
| 538 | + } |
| 539 | + logger.info("SUCCESS - " + testMethod); |
| 540 | + } |
| 541 | + |
| 542 | + /** |
| 543 | + * This is the test case to cover bug 29683926 |
| 544 | + * |
| 545 | + * @throws Exception - if any error occurs |
| 546 | + */ |
| 547 | + @Test |
| 548 | + public void testJRFDomainCreateDomainScriptsMountPath() throws Exception { |
| 549 | + Assume.assumeFalse(QUICKTEST); |
| 550 | + String testMethod = new Object() {}.getClass().getEnclosingMethod().getName(); |
| 551 | + logTestBegin(testMethod); |
| 552 | + |
| 553 | + if (operator1 == null) { |
| 554 | + operator1 = TestUtils.createOperator(JRF_OPERATOR_FILE_1); |
| 555 | + } |
| 556 | + |
| 557 | + JRFDomain domain1 = null; |
| 558 | + boolean testCompletedSuccessfully = false; |
| 559 | + try { |
| 560 | + Map<String, Object> domain1Map = TestUtils.loadYaml(JRF_DOMAIN_ON_PV_WLST_FILE); |
| 561 | + domain1Map.put("domainUID", "jrfcdsmp"); |
| 562 | + domain1Map.put("adminNodePort", 30707); |
| 563 | + domain1Map.put("t3ChannelPort", 30027); |
| 564 | + domain1Map.put("voyagerWebPort", 30311); |
| 565 | + domain1Map.put("rcuSchemaPrefix", "jrfcdsmp"); |
| 566 | + // set the createDomainScriptsMountPath to non-default value |
| 567 | + domain1Map.put("createDomainScriptsMountPath", "/u01/weblogic1"); |
| 568 | + |
| 569 | + // run RCU script to load db schema |
| 570 | + DBUtils.runRCU(rcuPodName, domain1Map); |
| 571 | + |
| 572 | + // create domain |
| 573 | + logger.info("Creating Domain & verifying the domain creation"); |
| 574 | + domain1 = new JRFDomain(domain1Map); |
| 575 | + domain1.verifyDomainCreated(); |
| 576 | + |
| 577 | + } finally { |
| 578 | + if (domain1 != null && (JENKINS || testCompletedSuccessfully)) { |
| 579 | + domain1.destroy(); |
| 580 | + } |
| 581 | + } |
| 582 | + logger.info("SUCCESS - " + testMethod); |
| 583 | + } |
| 584 | + |
| 585 | + /** |
| 586 | + * This test case is to cover bug 29657663 |
| 587 | + * |
| 588 | + * @throws Exception |
| 589 | + */ |
| 590 | + @Test |
| 591 | + public void testJRFDomainAdminPortEnabled() throws Exception { |
| 592 | + Assume.assumeFalse(QUICKTEST); |
| 593 | + String testMethod = new Object() {}.getClass().getEnclosingMethod().getName(); |
| 594 | + logTestBegin(testMethod); |
| 595 | + |
| 596 | + if (operator1 == null) { |
| 597 | + operator1 = TestUtils.createOperator(JRF_OPERATOR_FILE_1); |
| 598 | + } |
| 599 | + |
| 600 | + JRFDomain domain1 = null; |
| 601 | + boolean testCompletedSuccessfully = false; |
| 602 | + try { |
| 603 | + Map<String, Object> domain1Map = TestUtils.loadYaml(JRF_DOMAIN_ON_PV_WLST_FILE); |
| 604 | + domain1Map.put("domainUID", "jrfape"); |
| 605 | + domain1Map.put("adminNodePort", 30708); |
| 606 | + domain1Map.put("t3ChannelPort", 30028); |
| 607 | + domain1Map.put("voyagerWebPort", 30312); |
| 608 | + domain1Map.put("rcuSchemaPrefix", "jrfape"); |
| 609 | + domain1Map.put( |
| 610 | + "createDomainPyScript", |
| 611 | + "integration-tests/src/test/resources/domain-home-on-pv/create-jrfdomain-admin-port-enabled.py"); |
| 612 | + |
| 613 | + // run RCU script to load db schema |
| 614 | + DBUtils.runRCU(rcuPodName, domain1Map); |
| 615 | + |
| 616 | + // create domain |
| 617 | + logger.info("Creating Domain & verifying the domain creation"); |
| 618 | + domain1 = new JRFDomain(domain1Map, true); |
| 619 | + domain1.verifyDomainCreated(); |
| 620 | + |
| 621 | + } finally { |
| 622 | + if (domain1 != null && (JENKINS || testCompletedSuccessfully)) { |
| 623 | + domain1.destroy(); |
| 624 | + } |
| 625 | + } |
| 626 | + logger.info("SUCCESS - " + testMethod); |
| 627 | + } |
| 628 | + |
| 629 | + /** |
| 630 | + * This test case is to cover 29591809 |
| 631 | + * |
| 632 | + * @throws Exception - if any error occurs |
| 633 | + */ |
| 634 | + @Test |
| 635 | + public void testJRFDomainAdminT3Channel() throws Exception { |
| 636 | + Assume.assumeFalse(QUICKTEST); |
| 637 | + String testMethod = new Object() {}.getClass().getEnclosingMethod().getName(); |
| 638 | + logTestBegin(testMethod); |
| 639 | + |
| 640 | + if (operator1 == null) { |
| 641 | + operator1 = TestUtils.createOperator(JRF_OPERATOR_FILE_1); |
| 642 | + } |
| 643 | + |
| 644 | + JRFDomain domain1 = null; |
| 645 | + boolean testCompletedSuccessfully = false; |
| 646 | + try { |
| 647 | + Map<String, Object> domain1Map = TestUtils.loadYaml(JRF_DOMAIN_ON_PV_WLST_FILE); |
| 648 | + domain1Map.put("domainUID", "jrft3"); |
| 649 | + domain1Map.put("adminNodePort", 30709); |
| 650 | + domain1Map.put("t3ChannelPort", 30029); |
| 651 | + domain1Map.put("voyagerWebPort", 30313); |
| 652 | + domain1Map.put("rcuSchemaPrefix", "jrft3"); |
| 653 | + |
| 654 | + // run RCU script to load db schema |
| 655 | + DBUtils.runRCU(rcuPodName, domain1Map); |
| 656 | + |
| 657 | + // create domain |
| 658 | + logger.info("Creating Domain & verifying the domain creation"); |
| 659 | + domain1 = new JRFDomain(domain1Map); |
| 660 | + domain1.verifyDomainCreated(); |
| 661 | + |
| 662 | + // verify the Admin T3Channel is exposed |
| 663 | + testAdminT3Channel(domain1); |
| 664 | + } finally { |
| 665 | + if (domain1 != null && (JENKINS || testCompletedSuccessfully)) { |
| 666 | + domain1.destroy(); |
| 667 | + } |
| 668 | + } |
| 669 | + logger.info("SUCCESS - " + testMethod); |
| 670 | + } |
| 671 | + |
406 | 672 | /**
|
407 | 673 | * deploy testwebapp using admin port
|
408 | 674 | *
|
@@ -445,4 +711,80 @@ private void testAdvancedUseCasesForADomain(Operator operator, JRFDomain domain)
|
445 | 711 | testOperatorLifecycle(operator, domain);
|
446 | 712 | }
|
447 | 713 | }
|
| 714 | + |
| 715 | + private void verifyMSPodsNotReadyCountNotExceedMaxUnAvailable( |
| 716 | + JRFDomain domain, int expectedMSPodsCount, int maxUnavailable) throws Exception { |
| 717 | + int i = 0; |
| 718 | + // first wait for the ms pods to be in terminating state |
| 719 | + while (i < getMaxIterationsPod() && getMSPodsNotReadyCount(domain) < 1) { |
| 720 | + Thread.sleep(2000); |
| 721 | + i++; |
| 722 | + } |
| 723 | + if (getMSPodsNotReadyCount(domain) == 0) { |
| 724 | + throw new Exception("hit timeout while waiting for the first MS pod to be restarted"); |
| 725 | + } |
| 726 | + |
| 727 | + // check the not ready MS pod count should not exceed maxUnavailable value |
| 728 | + i = 0; |
| 729 | + int msPodRunningAndReadyCount = getMSPodsRunningAndReadyCount(domain); |
| 730 | + while (i < getMaxIterationsPod() * 4 && msPodRunningAndReadyCount != expectedMSPodsCount) { |
| 731 | + int msPodsNotReadyCount = getMSPodsNotReadyCount(domain); |
| 732 | + logger.info( |
| 733 | + "Iter [" |
| 734 | + + i |
| 735 | + + "/" |
| 736 | + + getMaxIterationsPod() * 4 |
| 737 | + + "]: MS Pod Not Ready Count: " |
| 738 | + + msPodsNotReadyCount |
| 739 | + + "; MS Pod Running and Ready Count: " |
| 740 | + + msPodRunningAndReadyCount); |
| 741 | + if (msPodsNotReadyCount > maxUnavailable) { |
| 742 | + throw new Exception("number of not ready managed server pods exceeds " + maxUnavailable); |
| 743 | + } |
| 744 | + Thread.sleep(2000); |
| 745 | + i++; |
| 746 | + msPodRunningAndReadyCount = getMSPodsRunningAndReadyCount(domain); |
| 747 | + } |
| 748 | + } |
| 749 | + |
| 750 | + private int getMSPodsNotReadyCount(JRFDomain domain) throws Exception { |
| 751 | + |
| 752 | + String managedServerNameBase = (String) domain.getDomainMap().get("managedServerNameBase"); |
| 753 | + StringBuffer cmd = new StringBuffer(); |
| 754 | + cmd.append("kubectl get pods -n ") |
| 755 | + .append(domain.getDomainNS()) |
| 756 | + .append(" | grep ") |
| 757 | + .append(managedServerNameBase) |
| 758 | + .append(" | grep 0/1 | wc -l"); |
| 759 | + ExecResult result = TestUtils.exec(cmd.toString()); |
| 760 | + |
| 761 | + return Integer.parseInt(result.stdout()); |
| 762 | + } |
| 763 | + |
| 764 | + private int getMSPodsRunningAndReadyCount(JRFDomain domain) throws Exception { |
| 765 | + |
| 766 | + String managedServerNameBase = (String) domain.getDomainMap().get("managedServerNameBase"); |
| 767 | + StringBuffer cmd = new StringBuffer(); |
| 768 | + cmd.append("kubectl get pods -n ") |
| 769 | + .append(domain.getDomainNS()) |
| 770 | + .append(" | grep ") |
| 771 | + .append(managedServerNameBase) |
| 772 | + .append(" | grep 1/1 | grep Running | wc -l"); |
| 773 | + ExecResult result = TestUtils.exec(cmd.toString()); |
| 774 | + |
| 775 | + return Integer.parseInt(result.stdout()); |
| 776 | + } |
| 777 | + |
| 778 | + private int getMSPodsCount(JRFDomain domain) throws Exception { |
| 779 | + String managedServerNameBase = (String) domain.getDomainMap().get("managedServerNameBase"); |
| 780 | + StringBuffer cmd = new StringBuffer(); |
| 781 | + cmd.append("kubectl get pods -n ") |
| 782 | + .append(domain.getDomainNS()) |
| 783 | + .append(" | grep ") |
| 784 | + .append(managedServerNameBase) |
| 785 | + .append(" | wc -l"); |
| 786 | + ExecResult result = TestUtils.exec(cmd.toString()); |
| 787 | + |
| 788 | + return Integer.parseInt(result.stdout()); |
| 789 | + } |
448 | 790 | }
|
0 commit comments