integration-tests/src/test/java/oracle/kubernetes/operator/ItMonitoringExporter.java
@BeforeEach
  public void prepare() throws Exception {
    Assumptions.assumeTrue(FULLTEST);
    if (operator == null) {
      createResultAndPvDirs(testClassName);
      wlsUser = BaseTest.getUsername();
      wlsPassword = BaseTest.getPassword();

      metricsUrl = exporterUrl + "metrics";
      monitoringExporterDir = getResultDir() + "/monitoring";
      monitoringExporterScriptDir = getResultDir() + "/scripts";
      resourceExporterDir =
          BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/exporter";
      configPath = resourceExporterDir;
      monitoringExporterEndToEndDir = monitoringExporterDir + "/src/samples/kubernetes/end2end/";
      LoggerHelper.getLocal().log(Level.INFO, "Checking if operator and domain are running, if not creating");

      Map<String, Object> operatorMap =
          createOperatorMap(getNewSuffixCount(), true, "monexp");
      domainNS1 = ((ArrayList<String>) operatorMap.get("domainNamespaces")).get(0);
      domainNS2 = "monexp-domainns-" + getNewSuffixCount();
      ((ArrayList<String>) operatorMap.get("domainNamespaces")).add(domainNS2);
      operator = TestUtils.createOperator(operatorMap, Operator.RestCertType.SELF_SIGNED);
      Assertions.assertNotNull(operator);

      namespaceList.append((String)operatorMap.get("namespace"));
      namespaceList.append(" ").append(domainNS1).append(" ").append(domainNS2);
    }
    if (domain == null) {
      Map<String, Object> wlstDomainMap = createDomainMap(getNewSuffixCount(), "monexp");
      wlstDomainMap.put("namespace", domainNS1);
      wlstDomainMap.put("domainUID", domainNS1);
      wlstDomainMap.put("createDomainPyScript",
          "integration-tests/src/test/resources/domain-home-on-pv/create-domain-custom-nap.py");
      domain = TestUtils.createDomain(wlstDomainMap);
      domain.verifyDomainCreated();

      myhost = domain.getHostNameForCurl();
      exporterUrl = "http://" + myhost + ":" + domain.getLoadBalancerWebPort() + "/wls-exporter/";
      LoggerHelper.getLocal().log(Level.INFO, "LB_TYPE is set to: " + System.getenv("LB_TYPE"));
      boolean isTraefik = (domain.getLoadBalancerName().equalsIgnoreCase("TRAEFIK"));
      if (isTraefik) {
        LoggerHelper.getLocal().log(Level.INFO, "Upgrading Traefik");
        upgradeTraefikHostName();
      }
      deployRunMonitoringExporter(domain, operator);
      String testAppName = "httpsessionreptestapp";
      String scriptName = "buildDeployAppInPod.sh";
      domain.buildDeployJavaAppInPod(
          testAppName, scriptName, BaseTest.getUsername(), BaseTest.getPassword());
      setupPv();
      installPrometheusGrafanaWebHookMySqlCoordinator();
    }
    domain.callWebAppAndVerifyLoadBalancing("wls-exporter", false);
    assertTrue(installPromGrafanaWebHookMySqlCoord, "ERROR: Failed to install 3rd party deployments");
  }
/**
   * This method gets called before every test. It creates the result/pv root directories
   * for the test. Creates the operator and domain if its not running.
   *
   * @throws Exception if result/pv/operator/domain creation fails
   */
This method gets called before every test. It creates the result/pv root directories
for the test. Creates the operator and domain if its not running.

@throws Exception if result/pv/operator/domain creation fails
This method gets called before every test . It creates the result / pv root directories for the test . Creates the operator and domain if its not running . @throws Exception if result / pv / operator / domain creation fails
@BeforeEach
  public void prepare() throws Exception {
    Assumptions.assumeTrue(FULLTEST);
    if (operator == null) {
      createResultAndPvDirs(testClassName);
      wlsUser = BaseTest.getUsername();
      wlsPassword = BaseTest.getPassword();
      metricsUrl = exporterUrl + "metrics";
      monitoringExporterDir = getResultDir() + "/monitoring";
      monitoringExporterScriptDir = getResultDir() + "/scripts";
      resourceExporterDir =
          BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/exporter";
      configPath = resourceExporterDir;
      monitoringExporterEndToEndDir = monitoringExporterDir + "/src/samples/kubernetes/end2end/";
      LoggerHelper.getLocal().log(Level.INFO, "Checking if operator and domain are running, if not creating");
      Map<String, Object> operatorMap =
          createOperatorMap(getNewSuffixCount(), true, "monexp");
      domainNS1 = ((ArrayList<String>) operatorMap.get("domainNamespaces")).get(0);
      domainNS2 = "monexp-domainns-" + getNewSuffixCount();
      ((ArrayList<String>) operatorMap.get("domainNamespaces")).add(domainNS2);
      operator = TestUtils.createOperator(operatorMap, Operator.RestCertType.SELF_SIGNED);
      Assertions.assertNotNull(operator);
      namespaceList.append((String)operatorMap.get("namespace"));
      namespaceList.append(" ").append(domainNS1).append(" ").append(domainNS2);
    }
    if (domain == null) {
      Map<String, Object> wlstDomainMap = createDomainMap(getNewSuffixCount(), "monexp");
      wlstDomainMap.put("namespace", domainNS1);
      wlstDomainMap.put("domainUID", domainNS1);
      wlstDomainMap.put("createDomainPyScript",
          "integration-tests/src/test/resources/domain-home-on-pv/create-domain-custom-nap.py");
      domain = TestUtils.createDomain(wlstDomainMap);
      domain.verifyDomainCreated();
      myhost = domain.getHostNameForCurl();
      exporterUrl = "http://" + myhost + ":" + domain.getLoadBalancerWebPort() + "/wls-exporter/";
      LoggerHelper.getLocal().log(Level.INFO, "LB_TYPE is set to: " + System.getenv("LB_TYPE"));
      boolean isTraefik = (domain.getLoadBalancerName().equalsIgnoreCase("TRAEFIK"));
      if (isTraefik) {
        LoggerHelper.getLocal().log(Level.INFO, "Upgrading Traefik");
        upgradeTraefikHostName();
      }
      deployRunMonitoringExporter(domain, operator);
      String testAppName = "httpsessionreptestapp";
      String scriptName = "buildDeployAppInPod.sh";
      domain.buildDeployJavaAppInPod(
          testAppName, scriptName, BaseTest.getUsername(), BaseTest.getPassword());
      setupPv();
      installPrometheusGrafanaWebHookMySqlCoordinator();
    }
    domain.callWebAppAndVerifyLoadBalancing("wls-exporter", false);
    assertTrue(installPromGrafanaWebHookMySqlCoord, "ERROR: Failed to install 3rd party deployments");
  }
@ BeforeEach public void prepare ( ) throws Exception { Assumptions . assumeTrue ( FULLTEST ) ; if ( operator == null ) { createResultAndPvDirs ( testClassName ) ; wlsUser = BaseTest . getUsername ( ) ; wlsPassword = BaseTest . getPassword ( ) ; metricsUrl = exporterUrl + "metrics" ; monitoringExporterDir = getResultDir ( ) + "/monitoring" ; monitoringExporterScriptDir = getResultDir ( ) + "/scripts" ; resourceExporterDir = BaseTest . getProjectRoot ( ) + "/integration-tests/src/test/resources/exporter" ; configPath = resourceExporterDir ; monitoringExporterEndToEndDir = monitoringExporterDir + "/src/samples/kubernetes/end2end/" ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "Checking if operator and domain are running, if not creating" ) ; Map < String , Object > operatorMap = createOperatorMap ( getNewSuffixCount ( ) , true , "monexp" ) ; domainNS1 = ( ( ArrayList < String > ) operatorMap . get ( "domainNamespaces" ) ) . get ( 0 ) ; domainNS2 = "monexp-domainns-" + getNewSuffixCount ( ) ; ( ( ArrayList < String > ) operatorMap . get ( "domainNamespaces" ) ) . add ( domainNS2 ) ; operator = TestUtils . createOperator ( operatorMap , Operator . RestCertType . SELF_SIGNED ) ; Assertions . assertNotNull ( operator ) ; namespaceList . append ( ( String ) operatorMap . get ( "namespace" ) ) ; namespaceList . append ( " " ) . append ( domainNS1 ) . append ( " " ) . append ( domainNS2 ) ; } if ( domain == null ) { Map < String , Object > wlstDomainMap = createDomainMap ( getNewSuffixCount ( ) , "monexp" ) ; wlstDomainMap . put ( "namespace" , domainNS1 ) ; wlstDomainMap . put ( "domainUID" , domainNS1 ) ; wlstDomainMap . put ( "createDomainPyScript" , "integration-tests/src/test/resources/domain-home-on-pv/create-domain-custom-nap.py" ) ; domain = TestUtils . createDomain ( wlstDomainMap ) ; domain . verifyDomainCreated ( ) ; myhost = domain . getHostNameForCurl ( ) ; exporterUrl = "http://" + myhost + ":" + domain . getLoadBalancerWebPort ( ) + "/wls-exporter/" ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "LB_TYPE is set to: " + System . getenv ( "LB_TYPE" ) ) ; boolean isTraefik = ( domain . getLoadBalancerName ( ) . equalsIgnoreCase ( "TRAEFIK" ) ) ; if ( isTraefik ) { LoggerHelper . getLocal ( ) . log ( Level . INFO , "Upgrading Traefik" ) ; upgradeTraefikHostName ( ) ; } deployRunMonitoringExporter ( domain , operator ) ; String testAppName = "httpsessionreptestapp" ; String scriptName = "buildDeployAppInPod.sh" ; domain . buildDeployJavaAppInPod ( testAppName , scriptName , BaseTest . getUsername ( ) , BaseTest . getPassword ( ) ) ; setupPv ( ) ; installPrometheusGrafanaWebHookMySqlCoordinator ( ) ; } domain . callWebAppAndVerifyLoadBalancing ( "wls-exporter" , false ) ; assertTrue ( installPromGrafanaWebHookMySqlCoord , "ERROR: Failed to install 3rd party deployments" ) ; }
This method gets called before every test.
This method gets called before every test .