new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiConfigMapOverride.java
@Test
  @Order(1)
  @DisplayName("Add JDBC/JMS/WLDF SystemResources to a model in image domain")
  @Slow
  @MustNotRunInParallel
  public void testAddMiiSystemResources() {
    final int replicaCount = 2;

    // Create the repo secret to pull the image
    assertDoesNotThrow(() -> createRepoSecret(domainNamespace),
            String.format("createSecret failed for %s", REPO_SECRET_NAME));

    // create secret for admin credentials
    logger.info("Create secret for admin credentials");
    String adminSecretName = "weblogic-credentials";
    assertDoesNotThrow(() -> createDomainSecret(adminSecretName,"weblogic",
            "welcome1", domainNamespace),
            String.format("createSecret failed for %s", adminSecretName));

    // create encryption secret
    logger.info("Create encryption secret");
    String encryptionSecretName = "encryptionsecret";
    assertDoesNotThrow(() -> createDomainSecret(encryptionSecretName, "weblogicenc",
            "weblogicenc", domainNamespace),
             String.format("createSecret failed for %s", encryptionSecretName));

    logger.info("Create database secret");
    final String dbSecretName = domainUid  + "-db-secret";
    assertDoesNotThrow(() -> createDatabaseSecret(dbSecretName, "scott",
            "tiger", "jdbc:oracle:thin:localhost:/ORCLCDB", domainNamespace),
             String.format("createSecret failed for %s", dbSecretName));

    String configMapName = "dsconfigmap";
    createConfigMapAndVerify(
        configMapName, domainUid, domainNamespace,
        Arrays.asList("model.jdbc.yaml", "model.jms.yaml", "model.wldf.yaml"));

    // create the domain CR with no configmap
    createDomainResource(domainUid, domainNamespace, adminSecretName,
        REPO_SECRET_NAME, encryptionSecretName,
        replicaCount, dbSecretName);

    // wait for the domain to exist
    logger.info("Check for domain custom resource in namespace {0}", domainNamespace);
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for domain {0} to be created in namespace {1} "
                    + "(elapsed time {2}ms, remaining time {3}ms)",
                domainUid,
                domainNamespace,
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(domainExists(domainUid, DOMAIN_VERSION, domainNamespace));

    // check admin server pod exists
    logger.info("Check for admin server pod {0} existence in namespace {1}",
        adminServerPodName, domainNamespace);
    checkPodReady(adminServerPodName, domainUid, domainNamespace);

    // check managed server pods exist
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Check for managed server pod {0} existence in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkPodReady(managedServerPrefix + i, domainUid, domainNamespace);
    }

    // check admin server pod is ready
    logger.info("Wait for admin server pod {0} to be ready in namespace {1}",
        adminServerPodName, domainNamespace);
    checkPodReady(adminServerPodName, domainUid, domainNamespace);
    logger.info("Check admin service {0} is created in namespace {1}",
        adminServerPodName, domainNamespace);
    checkServiceExists(adminServerPodName, domainNamespace);

    // check managed server pods are ready
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Wait for managed server pod {0} to be ready in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkPodReady(managedServerPrefix + i, domainUid, domainNamespace);
    }


    // check managed server services created
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Check managed server service {0} is created in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkServiceExists(managedServerPrefix + i, domainNamespace);
    }

    LinkedHashMap<String, DateTime> pods = new LinkedHashMap<>();
    // get the creation time of the admin server pod before patching
    DateTime adminPodCreationTime = getPodCreationTime(domainNamespace,adminServerPodName);
    pods.put(adminServerPodName, adminPodCreationTime);
    // get the creation time of the managed server pods before patching
    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 is {0}", newRestartVersion);

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

    // Even if pods are created, need the service to created
    // before checking the DataSource configuration
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Check managed server service {0} is created in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkServiceExists(managedServerPrefix + i, domainNamespace);
    }

    ExecResult result = null;
    result = checkSystemResourceConfiguration("JDBCSystemResources", "TestDataSource");
    assertNotNull(result, "CheckJDBCSystemResources returned null");
    logger.info("CheckJDBCSystemResource returned {0}", result.toString());
    assertEquals("200", result.stdout(), "DataSource configuration not found");
    logger.info("Found the DataSource configuration");

    result = null;
    result = checkSystemResourceConfiguration("JMSSystemResources", "TestClusterJmsModule");
    assertNotNull(result, "CheckJMSSystemResources returned null");
    logger.info("CheckJMSSystemResource returned {0}", result.toString());
    assertEquals("200", result.stdout(), "JMSSystemResource not found");
    logger.info("Found the JMSSystemResource configuration");

    result = null;
    result = checkSystemResourceConfiguration("WLDFSystemResources", "TestWldfModule");
    assertNotNull(result, "CheckWLDFSystemResources returned null");
    logger.info("CheckWLDFSystemResource returned {0}", result.toString());
    assertEquals("200", result.stdout(), "WLDFSystemResource not found");
    logger.info("Found the WLDFSystemResource configuration");
  }
/**
   * Start a WebLogic domain with out any pre-defined configmap.
   * Create a configmap with a sparse JDBC/JMS/WLDF model files.
   * Patch the domain resource with the configmap.
   * Update the restart version of the domain resource.
   * Verify rolling restart of the domain by comparing PodCreationTimestamp
   * for all the server pods before and after rolling restart.
   * Verify SystemResource configurations using Rest API call to admin server.
   */
Start a WebLogic domain with out any pre-defined configmap.
Create a configmap with a sparse JDBC/JMS/WLDF model files.
Patch the domain resource with the configmap.
Update the restart version of the domain resource.
Verify rolling restart of the domain by comparing PodCreationTimestamp
for all the server pods before and after rolling restart.
Verify SystemResource configurations using Rest API call to admin server.
Start a WebLogic domain with out any pre - defined configmap . Create a configmap with a sparse JDBC / JMS / WLDF model files . Patch the domain resource with the configmap . Update the restart version of the domain resource . Verify rolling restart of the domain by comparing PodCreationTimestamp for all the server pods before and after rolling restart . Verify SystemResource configurations using Rest API call to admin server .
@Test
  @Order(1)
  @DisplayName("Add JDBC/JMS/WLDF SystemResources to a model in image domain")
  @Slow
  @MustNotRunInParallel
  public void testAddMiiSystemResources() {
    final int replicaCount = 2;
    assertDoesNotThrow(() -> createRepoSecret(domainNamespace),
            String.format("createSecret failed for %s", REPO_SECRET_NAME));
    logger.info("Create secret for admin credentials");
    String adminSecretName = "weblogic-credentials";
    assertDoesNotThrow(() -> createDomainSecret(adminSecretName,"weblogic",
            "welcome1", domainNamespace),
            String.format("createSecret failed for %s", adminSecretName));
    logger.info("Create encryption secret");
    String encryptionSecretName = "encryptionsecret";
    assertDoesNotThrow(() -> createDomainSecret(encryptionSecretName, "weblogicenc",
            "weblogicenc", domainNamespace),
             String.format("createSecret failed for %s", encryptionSecretName));
    logger.info("Create database secret");
    final String dbSecretName = domainUid  + "-db-secret";
    assertDoesNotThrow(() -> createDatabaseSecret(dbSecretName, "scott",
            "tiger", "jdbc:oracle:thin:localhost:/ORCLCDB", domainNamespace),
             String.format("createSecret failed for %s", dbSecretName));
    String configMapName = "dsconfigmap";
    createConfigMapAndVerify(
        configMapName, domainUid, domainNamespace,
        Arrays.asList("model.jdbc.yaml", "model.jms.yaml", "model.wldf.yaml"));
    createDomainResource(domainUid, domainNamespace, adminSecretName,
        REPO_SECRET_NAME, encryptionSecretName,
        replicaCount, dbSecretName);
    logger.info("Check for domain custom resource in namespace {0}", domainNamespace);
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for domain {0} to be created in namespace {1} "
                    + "(elapsed time {2}ms, remaining time {3}ms)",
                domainUid,
                domainNamespace,
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(domainExists(domainUid, DOMAIN_VERSION, domainNamespace));
    logger.info("Check for admin server pod {0} existence in namespace {1}",
        adminServerPodName, domainNamespace);
    checkPodReady(adminServerPodName, domainUid, domainNamespace);
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Check for managed server pod {0} existence in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkPodReady(managedServerPrefix + i, domainUid, domainNamespace);
    }
    logger.info("Wait for admin server pod {0} to be ready in namespace {1}",
        adminServerPodName, domainNamespace);
    checkPodReady(adminServerPodName, domainUid, domainNamespace);
    logger.info("Check admin service {0} is created in namespace {1}",
        adminServerPodName, domainNamespace);
    checkServiceExists(adminServerPodName, domainNamespace);
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Wait for managed server pod {0} to be ready in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkPodReady(managedServerPrefix + i, domainUid, domainNamespace);
    }
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Check managed server service {0} is created in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkServiceExists(managedServerPrefix + i, domainNamespace);
    }
    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 is {0}", newRestartVersion);
    assertTrue(assertDoesNotThrow(
        () -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
         "More than one pod was restarted at same time"),
        "Rolling restart failed");
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Check managed server service {0} is created in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkServiceExists(managedServerPrefix + i, domainNamespace);
    }
    ExecResult result = null;
    result = checkSystemResourceConfiguration("JDBCSystemResources", "TestDataSource");
    assertNotNull(result, "CheckJDBCSystemResources returned null");
    logger.info("CheckJDBCSystemResource returned {0}", result.toString());
    assertEquals("200", result.stdout(), "DataSource configuration not found");
    logger.info("Found the DataSource configuration");
    result = null;
    result = checkSystemResourceConfiguration("JMSSystemResources", "TestClusterJmsModule");
    assertNotNull(result, "CheckJMSSystemResources returned null");
    logger.info("CheckJMSSystemResource returned {0}", result.toString());
    assertEquals("200", result.stdout(), "JMSSystemResource not found");
    logger.info("Found the JMSSystemResource configuration");
    result = null;
    result = checkSystemResourceConfiguration("WLDFSystemResources", "TestWldfModule");
    assertNotNull(result, "CheckWLDFSystemResources returned null");
    logger.info("CheckWLDFSystemResource returned {0}", result.toString());
    assertEquals("200", result.stdout(), "WLDFSystemResource not found");
    logger.info("Found the WLDFSystemResource configuration");
  }
@ Test @ Order ( 1 ) @ DisplayName ( "Add JDBC/JMS/WLDF SystemResources to a model in image domain" ) @ Slow @ MustNotRunInParallel public void testAddMiiSystemResources ( ) { final int replicaCount = 2 ; assertDoesNotThrow ( ( ) -> createRepoSecret ( domainNamespace ) , String . format ( "createSecret failed for %s" , REPO_SECRET_NAME ) ) ; logger . info ( "Create secret for admin credentials" ) ; String adminSecretName = "weblogic-credentials" ; assertDoesNotThrow ( ( ) -> createDomainSecret ( adminSecretName , "weblogic" , "welcome1" , domainNamespace ) , String . format ( "createSecret failed for %s" , adminSecretName ) ) ; logger . info ( "Create encryption secret" ) ; String encryptionSecretName = "encryptionsecret" ; assertDoesNotThrow ( ( ) -> createDomainSecret ( encryptionSecretName , "weblogicenc" , "weblogicenc" , domainNamespace ) , String . format ( "createSecret failed for %s" , encryptionSecretName ) ) ; logger . info ( "Create database secret" ) ; final String dbSecretName = domainUid + "-db-secret" ; assertDoesNotThrow ( ( ) -> createDatabaseSecret ( dbSecretName , "scott" , "tiger" , "jdbc:oracle:thin:localhost:/ORCLCDB" , domainNamespace ) , String . format ( "createSecret failed for %s" , dbSecretName ) ) ; String configMapName = "dsconfigmap" ; createConfigMapAndVerify ( configMapName , domainUid , domainNamespace , Arrays . asList ( "model.jdbc.yaml" , "model.jms.yaml" , "model.wldf.yaml" ) ) ; createDomainResource ( domainUid , domainNamespace , adminSecretName , REPO_SECRET_NAME , encryptionSecretName , replicaCount , dbSecretName ) ; logger . info ( "Check for domain custom resource in namespace {0}" , domainNamespace ) ; withStandardRetryPolicy . conditionEvaluationListener ( condition -> logger . info ( "Waiting for domain {0} to be created in namespace {1} " + "(elapsed time {2}ms, remaining time {3}ms)" , domainUid , domainNamespace , condition . getElapsedTimeInMS ( ) , condition . getRemainingTimeInMS ( ) ) ) . until ( domainExists ( domainUid , DOMAIN_VERSION , domainNamespace ) ) ; logger . info ( "Check for admin server pod {0} existence in namespace {1}" , adminServerPodName , domainNamespace ) ; checkPodReady ( adminServerPodName , domainUid , domainNamespace ) ; for ( int i = 1 ; i <= replicaCount ; i ++ ) { logger . info ( "Check for managed server pod {0} existence in namespace {1}" , managedServerPrefix + i , domainNamespace ) ; checkPodReady ( managedServerPrefix + i , domainUid , domainNamespace ) ; } logger . info ( "Wait for admin server pod {0} to be ready in namespace {1}" , adminServerPodName , domainNamespace ) ; checkPodReady ( adminServerPodName , domainUid , domainNamespace ) ; logger . info ( "Check admin service {0} is created in namespace {1}" , adminServerPodName , domainNamespace ) ; checkServiceExists ( adminServerPodName , domainNamespace ) ; for ( int i = 1 ; i <= replicaCount ; i ++ ) { logger . info ( "Wait for managed server pod {0} to be ready in namespace {1}" , managedServerPrefix + i , domainNamespace ) ; checkPodReady ( managedServerPrefix + i , domainUid , domainNamespace ) ; } for ( int i = 1 ; i <= replicaCount ; i ++ ) { logger . info ( "Check managed server service {0} is created in namespace {1}" , managedServerPrefix + i , domainNamespace ) ; checkServiceExists ( managedServerPrefix + i , domainNamespace ) ; } 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 is {0}" , newRestartVersion ) ; assertTrue ( assertDoesNotThrow ( ( ) -> ( verifyRollingRestartOccurred ( pods , 1 , domainNamespace ) ) , "More than one pod was restarted at same time" ) , "Rolling restart failed" ) ; for ( int i = 1 ; i <= replicaCount ; i ++ ) { logger . info ( "Check managed server service {0} is created in namespace {1}" , managedServerPrefix + i , domainNamespace ) ; checkServiceExists ( managedServerPrefix + i , domainNamespace ) ; } ExecResult result = null ; result = checkSystemResourceConfiguration ( "JDBCSystemResources" , "TestDataSource" ) ; assertNotNull ( result , "CheckJDBCSystemResources returned null" ) ; logger . info ( "CheckJDBCSystemResource returned {0}" , result . toString ( ) ) ; assertEquals ( "200" , result . stdout ( ) , "DataSource configuration not found" ) ; logger . info ( "Found the DataSource configuration" ) ; result = null ; result = checkSystemResourceConfiguration ( "JMSSystemResources" , "TestClusterJmsModule" ) ; assertNotNull ( result , "CheckJMSSystemResources returned null" ) ; logger . info ( "CheckJMSSystemResource returned {0}" , result . toString ( ) ) ; assertEquals ( "200" , result . stdout ( ) , "JMSSystemResource not found" ) ; logger . info ( "Found the JMSSystemResource configuration" ) ; result = null ; result = checkSystemResourceConfiguration ( "WLDFSystemResources" , "TestWldfModule" ) ; assertNotNull ( result , "CheckWLDFSystemResources returned null" ) ; logger . info ( "CheckWLDFSystemResource returned {0}" , result . toString ( ) ) ; assertEquals ( "200" , result . stdout ( ) , "WLDFSystemResource not found" ) ; logger . info ( "Found the WLDFSystemResource configuration" ) ; }
Start a WebLogic domain with out any pre-defined configmap.
Start a WebLogic domain with out any pre - defined configmap .
// Create the repo secret to pull the image // create secret for admin credentials // create encryption secret // create the domain CR with no configmap // wait for the domain to exist // check admin server pod exists // check managed server pods exist // check admin server pod is ready // check managed server pods are ready // check managed server services created // get the creation time of the admin server pod before patching // get the creation time of the managed server pods before patching // Even if pods are created, need the service to created // before checking the DataSource configuration