integration-tests/src/test/java/oracle/kubernetes/operator/ItMonitoringExporter.java
private static void createWlsImageAndDeploy() throws Exception {
    LoggerHelper.getLocal().log(Level.INFO, " Starting to create WLS Image");
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();
    currentDateTime = dateFormat.format(date) + "-" + System.currentTimeMillis();
    String image = domainNS2 + "-image:" + currentDateTime;
    executeShelScript(
        resourceExporterDir,
        monitoringExporterScriptDir,
        "createWLSImage.sh",
        monitoringExporterDir + " " + resourceExporterDir
            + " " + domainNS2
        + " " + currentDateTime
        + " " + wlsUser
        + " " +  wlsPassword, "createWLSImage.out");

    // for remote k8s cluster and domain in image case, push the domain image to OCIR
    if (BaseTest.SHARED_CLUSTER) {
      TestUtils.createDockerRegistrySecret(
          "ocirsecret",
          System.getenv("REPO_REGISTRY"),
          System.getenv("REPO_USERNAME"),
          System.getenv("REPO_PASSWORD"),
          System.getenv("REPO_EMAIL"),
          domainNS2);
      String oldImage = image;
      image = System.getenv("REPO_REGISTRY")
            + "/weblogick8s/"
            + oldImage;
      loginAndTagImage(oldImage, image);
      // create ocir registry secret in the same ns as domain which is used while pulling the domain
      // image

      TestUtils.loginAndPushImageToOcir(image);
    }

    replaceStringInFile(monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml",
        domainNS2 + "-image:1.0", image);
    replaceStringInFile(monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml",
        "30703", String.valueOf(31000 + getNewSuffixCount()));
    replaceStringInFile(monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml",
        "30701", String.valueOf(30800 + getNewSuffixCount()));
    LoggerHelper.getLocal().log(Level.INFO, " Starting to create secret");
    String crdCmd =
        "kubectl -n " + domainNS2 + " create secret generic " + domainNS2 + "-weblogic-credentials "
            + "  --from-literal=username="
            + wlsUser
            + "  --from-literal=password="
            + wlsPassword;
    TestUtils.execOrAbortProcess(crdCmd);

    // apply new domain yaml and verify pod restart
    crdCmd =
        " kubectl apply -f " + monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml";
    TestUtils.execOrAbortProcess(crdCmd);

    TestUtils.checkPodReady(domainNS2 + "-admin-server", domainNS2);
    TestUtils.checkPodReady(domainNS2 + "-managed-server-1", domainNS2);
    TestUtils.checkPodReady(domainNS2 + "-managed-server-2", domainNS2);

    replaceStringInFile(monitoringExporterEndToEndDir + "/util/curl.yaml", "default", domainNS2);
    // apply curl to the pod
    crdCmd = " kubectl apply -f " + monitoringExporterEndToEndDir + "/util/curl.yaml";
    TestUtils.execOrAbortProcess(crdCmd);

    TestUtils.checkPodReady("curl", domainNS2);
    // access metrics
    crdCmd =
        "kubectl exec -n " + domainNS2 + "  curl -- curl http://"
            + wlsUser
            + ":"
            + wlsPassword
            + "@" + domainNS2 + "-managed-server-1:8001/wls-exporter/metrics";
    ExecResult result = TestUtils.execOrAbortProcess(crdCmd);
    assertTrue((result.stdout().contains("wls_servlet_execution_time_average")));
    crdCmd =
        "kubectl exec -n " + domainNS2 + " curl -- curl http://"
            + wlsUser
            + ":"
            + wlsPassword
            + "@" + domainNS2 + "-managed-server-2:8001/wls-exporter/metrics";
    result = TestUtils.execOrAbortProcess(crdCmd);
    assertTrue((result.stdout().contains("wls_servlet_execution_time_average")));
  }
/**
   * Install wls image tool and update wls pods.
   *
   * @throws Exception if could not run the command successfully to create WLSImage and deploy
   */
Install wls image tool and update wls pods.
@throws Exception if could not run the command successfully to create WLSImage and deploy
Install wls image tool and update wls pods . @throws Exception if could not run the command successfully to create WLSImage and deploy
private static void createWlsImageAndDeploy() throws Exception {
    LoggerHelper.getLocal().log(Level.INFO, " Starting to create WLS Image");
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();
    currentDateTime = dateFormat.format(date) + "-" + System.currentTimeMillis();
    String image = domainNS2 + "-image:" + currentDateTime;
    executeShelScript(
        resourceExporterDir,
        monitoringExporterScriptDir,
        "createWLSImage.sh",
        monitoringExporterDir + " " + resourceExporterDir
            + " " + domainNS2
        + " " + currentDateTime
        + " " + wlsUser
        + " " +  wlsPassword, "createWLSImage.out");
    if (BaseTest.SHARED_CLUSTER) {
      TestUtils.createDockerRegistrySecret(
          "ocirsecret",
          System.getenv("REPO_REGISTRY"),
          System.getenv("REPO_USERNAME"),
          System.getenv("REPO_PASSWORD"),
          System.getenv("REPO_EMAIL"),
          domainNS2);
      String oldImage = image;
      image = System.getenv("REPO_REGISTRY")
            + "/weblogick8s/"
            + oldImage;
      loginAndTagImage(oldImage, image);
      TestUtils.loginAndPushImageToOcir(image);
    }
    replaceStringInFile(monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml",
        domainNS2 + "-image:1.0", image);
    replaceStringInFile(monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml",
        "30703", String.valueOf(31000 + getNewSuffixCount()));
    replaceStringInFile(monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml",
        "30701", String.valueOf(30800 + getNewSuffixCount()));
    LoggerHelper.getLocal().log(Level.INFO, " Starting to create secret");
    String crdCmd =
        "kubectl -n " + domainNS2 + " create secret generic " + domainNS2 + "-weblogic-credentials "
            + "  --from-literal=username="
            + wlsUser
            + "  --from-literal=password="
            + wlsPassword;
    TestUtils.execOrAbortProcess(crdCmd);
    crdCmd =
        " kubectl apply -f " + monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml";
    TestUtils.execOrAbortProcess(crdCmd);
    TestUtils.checkPodReady(domainNS2 + "-admin-server", domainNS2);
    TestUtils.checkPodReady(domainNS2 + "-managed-server-1", domainNS2);
    TestUtils.checkPodReady(domainNS2 + "-managed-server-2", domainNS2);
    replaceStringInFile(monitoringExporterEndToEndDir + "/util/curl.yaml", "default", domainNS2);
    crdCmd = " kubectl apply -f " + monitoringExporterEndToEndDir + "/util/curl.yaml";
    TestUtils.execOrAbortProcess(crdCmd);
    TestUtils.checkPodReady("curl", domainNS2);
    crdCmd =
        "kubectl exec -n " + domainNS2 + "  curl -- curl http://"
            + wlsUser
            + ":"
            + wlsPassword
            + "@" + domainNS2 + "-managed-server-1:8001/wls-exporter/metrics";
    ExecResult result = TestUtils.execOrAbortProcess(crdCmd);
    assertTrue((result.stdout().contains("wls_servlet_execution_time_average")));
    crdCmd =
        "kubectl exec -n " + domainNS2 + " curl -- curl http://"
            + wlsUser
            + ":"
            + wlsPassword
            + "@" + domainNS2 + "-managed-server-2:8001/wls-exporter/metrics";
    result = TestUtils.execOrAbortProcess(crdCmd);
    assertTrue((result.stdout().contains("wls_servlet_execution_time_average")));
  }
private static void createWlsImageAndDeploy ( ) throws Exception { LoggerHelper . getLocal ( ) . log ( Level . INFO , " Starting to create WLS Image" ) ; DateFormat dateFormat = new SimpleDateFormat ( "yyyy-MM-dd" ) ; Date date = new Date ( ) ; currentDateTime = dateFormat . format ( date ) + "-" + System . currentTimeMillis ( ) ; String image = domainNS2 + "-image:" + currentDateTime ; executeShelScript ( resourceExporterDir , monitoringExporterScriptDir , "createWLSImage.sh" , monitoringExporterDir + " " + resourceExporterDir + " " + domainNS2 + " " + currentDateTime + " " + wlsUser + " " + wlsPassword , "createWLSImage.out" ) ; if ( BaseTest . SHARED_CLUSTER ) { TestUtils . createDockerRegistrySecret ( "ocirsecret" , System . getenv ( "REPO_REGISTRY" ) , System . getenv ( "REPO_USERNAME" ) , System . getenv ( "REPO_PASSWORD" ) , System . getenv ( "REPO_EMAIL" ) , domainNS2 ) ; String oldImage = image ; image = System . getenv ( "REPO_REGISTRY" ) + "/weblogick8s/" + oldImage ; loginAndTagImage ( oldImage , image ) ; TestUtils . loginAndPushImageToOcir ( image ) ; } replaceStringInFile ( monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml" , domainNS2 + "-image:1.0" , image ) ; replaceStringInFile ( monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml" , "30703" , String . valueOf ( 31000 + getNewSuffixCount ( ) ) ) ; replaceStringInFile ( monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml" , "30701" , String . valueOf ( 30800 + getNewSuffixCount ( ) ) ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , " Starting to create secret" ) ; String crdCmd = "kubectl -n " + domainNS2 + " create secret generic " + domainNS2 + "-weblogic-credentials " + "  --from-literal=username=" + wlsUser + "  --from-literal=password=" + wlsPassword ; TestUtils . execOrAbortProcess ( crdCmd ) ; crdCmd = " kubectl apply -f " + monitoringExporterEndToEndDir + "/demo-domains/domainInImage.yaml" ; TestUtils . execOrAbortProcess ( crdCmd ) ; TestUtils . checkPodReady ( domainNS2 + "-admin-server" , domainNS2 ) ; TestUtils . checkPodReady ( domainNS2 + "-managed-server-1" , domainNS2 ) ; TestUtils . checkPodReady ( domainNS2 + "-managed-server-2" , domainNS2 ) ; replaceStringInFile ( monitoringExporterEndToEndDir + "/util/curl.yaml" , "default" , domainNS2 ) ; crdCmd = " kubectl apply -f " + monitoringExporterEndToEndDir + "/util/curl.yaml" ; TestUtils . execOrAbortProcess ( crdCmd ) ; TestUtils . checkPodReady ( "curl" , domainNS2 ) ; crdCmd = "kubectl exec -n " + domainNS2 + "  curl -- curl http://" + wlsUser + ":" + wlsPassword + "@" + domainNS2 + "-managed-server-1:8001/wls-exporter/metrics" ; ExecResult result = TestUtils . execOrAbortProcess ( crdCmd ) ; assertTrue ( ( result . stdout ( ) . contains ( "wls_servlet_execution_time_average" ) ) ) ; crdCmd = "kubectl exec -n " + domainNS2 + " curl -- curl http://" + wlsUser + ":" + wlsPassword + "@" + domainNS2 + "-managed-server-2:8001/wls-exporter/metrics" ; result = TestUtils . execOrAbortProcess ( crdCmd ) ; assertTrue ( ( result . stdout ( ) . contains ( "wls_servlet_execution_time_average" ) ) ) ; }
Install wls image tool and update wls pods.
Install wls image tool and update wls pods .
// for remote k8s cluster and domain in image case, push the domain image to OCIR // create ocir registry secret in the same ns as domain which is used while pulling the domain // image // apply new domain yaml and verify pod restart // apply curl to the pod // access metrics