new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAddCluster.java
@Test
  @Order(1)
  @DisplayName("Add a cluster to model in image domain with default replica count")
  @Slow
  @MustNotRunInParallel
  public void testAddMiiClusteriWithNoReplica() {

    // This test uses the WebLogic domain created in BeforeAll method
    // BeforeEach method ensures that the server pods are running

    String configMapName = "noreplicaconfigmap";
    createClusterConfigMap(configMapName, "model.config.cluster.yaml");

    LinkedHashMap<String, DateTime> pods = new LinkedHashMap<>();

    // get the creation time of the server pods before patching
    DateTime adminPodCreationTime = getPodCreationTime(domainNamespace, adminServerPodName);
    pods.put(adminServerPodName, adminPodCreationTime);
    for (int i = 1; i <= replicaCount; i++) {
      pods.put(managedServerPrefix + i, getPodCreationTime(domainNamespace, managedServerPrefix + i));
    }

    StringBuffer patchStr = null;
    patchStr = new StringBuffer("[{");
    patchStr.append("\"op\": \"replace\",")
        .append(" \"path\": \"/spec/configuration/model/configMap\",")
        .append(" \"value\":  \"" + configMapName + "\"")
        .append(" }]");
    logger.log(Level.INFO, "Configmap patch string: {0}", patchStr);

    patch = new V1Patch(new String(patchStr));
    boolean cmPatched = assertDoesNotThrow(() ->
            patchDomainCustomResource(domainUid, domainNamespace, patch, "application/json-patch+json"),
        "patchDomainCustomResource(configMap)  failed ");
    assertTrue(cmPatched, "patchDomainCustomResource(configMap) failed");

    String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
    logger.log(Level.INFO, "New restart version : {0}", newRestartVersion);

    assertTrue(assertDoesNotThrow(
        () -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
         "More than one pod was restarted at same time"),
        "Rolling restart failed");

    // The ServerNamePrefix for the new configured cluster is config-server
    // Make sure the managed server from new cluster is not running

    String newServerPodName = domainUid + "-config-server1";
    checkPodNotCreated(newServerPodName, domainUid, domainNamespace);

    boolean isServerConfigured = checkManagedServerConfiguration("config-server1");
    assertTrue(isServerConfigured, "Could not find new managed server configuration");
    logger.info("Found new managed server configuration");
  }
/**
   * Patch the domain resource with the configmap to add a cluster.
   * Update the restart version of the domain resource to 1.
   * Verify rolling restart of the domain by comparing PodCreationTimestamp
   * before and after rolling restart.
   * Verify servers from new cluster are not in running state, because i
   * the spec level replica count to zero(default).
   */
Patch the domain resource with the configmap to add a cluster.
Update the restart version of the domain resource to 1.
Verify rolling restart of the domain by comparing PodCreationTimestamp
before and after rolling restart.
Verify servers from new cluster are not in running state, because i
the spec level replica count to zero(default).
Patch the domain resource with the configmap to add a cluster . Update the restart version of the domain resource to 1 . Verify rolling restart of the domain by comparing PodCreationTimestamp before and after rolling restart . Verify servers from new cluster are not in running state because i the spec level replica count to zero ( default ) .
@Test
  @Order(1)
  @DisplayName("Add a cluster to model in image domain with default replica count")
  @Slow
  @MustNotRunInParallel
  public void testAddMiiClusteriWithNoReplica() {
    String configMapName = "noreplicaconfigmap";
    createClusterConfigMap(configMapName, "model.config.cluster.yaml");
    LinkedHashMap<String, DateTime> pods = new LinkedHashMap<>();
    DateTime adminPodCreationTime = getPodCreationTime(domainNamespace, adminServerPodName);
    pods.put(adminServerPodName, adminPodCreationTime);
    for (int i = 1; i <= replicaCount; i++) {
      pods.put(managedServerPrefix + i, getPodCreationTime(domainNamespace, managedServerPrefix + i));
    }
    StringBuffer patchStr = null;
    patchStr = new StringBuffer("[{");
    patchStr.append("\"op\": \"replace\",")
        .append(" \"path\": \"/spec/configuration/model/configMap\",")
        .append(" \"value\":  \"" + configMapName + "\"")
        .append(" }]");
    logger.log(Level.INFO, "Configmap patch string: {0}", patchStr);
    patch = new V1Patch(new String(patchStr));
    boolean cmPatched = assertDoesNotThrow(() ->
            patchDomainCustomResource(domainUid, domainNamespace, patch, "application/json-patch+json"),
        "patchDomainCustomResource(configMap)  failed ");
    assertTrue(cmPatched, "patchDomainCustomResource(configMap) failed");
    String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
    logger.log(Level.INFO, "New restart version : {0}", newRestartVersion);
    assertTrue(assertDoesNotThrow(
        () -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
         "More than one pod was restarted at same time"),
        "Rolling restart failed");
    String newServerPodName = domainUid + "-config-server1";
    checkPodNotCreated(newServerPodName, domainUid, domainNamespace);
    boolean isServerConfigured = checkManagedServerConfiguration("config-server1");
    assertTrue(isServerConfigured, "Could not find new managed server configuration");
    logger.info("Found new managed server configuration");
  }
@ Test @ Order ( 1 ) @ DisplayName ( "Add a cluster to model in image domain with default replica count" ) @ Slow @ MustNotRunInParallel public void testAddMiiClusteriWithNoReplica ( ) { String configMapName = "noreplicaconfigmap" ; createClusterConfigMap ( configMapName , "model.config.cluster.yaml" ) ; LinkedHashMap < String , DateTime > pods = new LinkedHashMap < > ( ) ; DateTime adminPodCreationTime = getPodCreationTime ( domainNamespace , adminServerPodName ) ; pods . put ( adminServerPodName , adminPodCreationTime ) ; for ( int i = 1 ; i <= replicaCount ; i ++ ) { pods . put ( managedServerPrefix + i , getPodCreationTime ( domainNamespace , managedServerPrefix + i ) ) ; } StringBuffer patchStr = null ; patchStr = new StringBuffer ( "[{" ) ; patchStr . append ( "\"op\": \"replace\"," ) . append ( " \"path\": \"/spec/configuration/model/configMap\"," ) . append ( " \"value\":  \"" + configMapName + "\"" ) . append ( " }]" ) ; logger . log ( Level . INFO , "Configmap patch string: {0}" , patchStr ) ; patch = new V1Patch ( new String ( patchStr ) ) ; boolean cmPatched = assertDoesNotThrow ( ( ) -> patchDomainCustomResource ( domainUid , domainNamespace , patch , "application/json-patch+json" ) , "patchDomainCustomResource(configMap)  failed " ) ; assertTrue ( cmPatched , "patchDomainCustomResource(configMap) failed" ) ; String newRestartVersion = patchDomainResourceWithNewRestartVersion ( domainUid , domainNamespace ) ; logger . log ( Level . INFO , "New restart version : {0}" , newRestartVersion ) ; assertTrue ( assertDoesNotThrow ( ( ) -> ( verifyRollingRestartOccurred ( pods , 1 , domainNamespace ) ) , "More than one pod was restarted at same time" ) , "Rolling restart failed" ) ; String newServerPodName = domainUid + "-config-server1" ; checkPodNotCreated ( newServerPodName , domainUid , domainNamespace ) ; boolean isServerConfigured = checkManagedServerConfiguration ( "config-server1" ) ; assertTrue ( isServerConfigured , "Could not find new managed server configuration" ) ; logger . info ( "Found new managed server configuration" ) ; }
Patch the domain resource with the configmap to add a cluster.
Patch the domain resource with the configmap to add a cluster .
// This test uses the WebLogic domain created in BeforeAll method // BeforeEach method ensures that the server pods are running // get the creation time of the server pods before patching // The ServerNamePrefix for the new configured cluster is config-server // Make sure the managed server from new cluster is not running