new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIstioMiiDomain.java
@Test
  @DisplayName("Create WebLogic Domain with mii model with istio")
  public void testIstioModelInImage() {
    final String adminServerPodName = domainUid + "-admin-server";
    final String managedServerPrefix = domainUid + "-managed-server";
    final int replicaCount = 2;

    // Create the repo secret to pull the image
    assertDoesNotThrow(() -> createDockerRegistrySecret(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(() -> createSecretWithUsernamePassword(
                                    adminSecretName,
                                    domainNamespace,
                                    "weblogic",
                                    "welcome1"),
        String.format("createSecret failed for %s", adminSecretName));

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

    // create the domain object
    Domain domain = createDomainResource(domainUid,
                                      domainNamespace,
                                      adminSecretName,
                                      REPO_SECRET_NAME,
                                      encryptionSecretName,
                                      replicaCount,
                              MII_BASIC_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG);

    // create model in image domain
    createDomainAndVerify(domain, domainNamespace);

    logger.info("Check admin service {0} is created in namespace {1}",
        adminServerPodName, domainNamespace);
    checkServiceExists(adminServerPodName, 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);

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

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

    String clusterService = domainUid + "-cluster-" + clusterName + "." + domainNamespace + ".svc.cluster.local";

    Map<String, String> templateMap  = new HashMap();
    templateMap.put("NAMESPACE", domainNamespace);
    templateMap.put("DUID", domainUid);
    templateMap.put("ADMIN_SERVICE",adminServerPodName);
    templateMap.put("CLUSTER_SERVICE", clusterService);

    Path srcHttpFile = Paths.get(RESOURCE_DIR, "istio", "istio-http-template.yaml");
    Path targetHttpFile = assertDoesNotThrow(
        () -> generateFileFromTemplate(srcHttpFile.toString(), "istio-http.yaml", templateMap));
    logger.info("Generated Http VS/Gateway file path is {0}", targetHttpFile);
    
    boolean deployRes = assertDoesNotThrow(
        () -> deployHttpIstioGatewayAndVirtualservice(targetHttpFile)); 
    assertTrue(deployRes, "Failed to deploy Http Istio Gateway/VirtualService");

    Path srcDrFile = Paths.get(RESOURCE_DIR, "istio", "istio-dr-template.yaml");
    Path targetDrFile = assertDoesNotThrow(
        () -> generateFileFromTemplate(srcDrFile.toString(), "istio-dr.yaml", templateMap));
    logger.info("Generated DestinationRule file path is {0}", targetDrFile);

    deployRes = assertDoesNotThrow(
        () -> deployIstioDestinationRule(targetDrFile));
    assertTrue(deployRes, "Failed to deploy Istio DestinationRule");

    int istioIngressPort = getIstioHttpIngressPort();
    logger.info("Istio Ingress Port is {0}", istioIngressPort);

    String consoleUrl = "http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/console/login/LoginForm.jsp";
    boolean checkConsole = 
         checkAppUsingHostHeader(consoleUrl, domainNamespace + ".org");
    assertTrue(checkConsole, "Failed to access WebLogic console");
    logger.info("WebLogic console is accessible");


    Path archivePath = Paths.get(ITTESTS_DIR, "../src/integration-tests/apps/testwebapp.war");
    ExecResult result = null;
    result = DeployUtil.deployUsingRest(K8S_NODEPORT_HOST, 
        String.valueOf(istioIngressPort),
        ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, 
        clusterName, archivePath, domainNamespace + ".org", "testwebapp");
    assertNotNull(result, "Application deployment failed");
    logger.info("Application deployment returned {0}", result.toString());
    assertEquals("202", result.stdout(), "Deployment didn't return HTTP status code 202");

    String url = "http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/testwebapp/index.jsp";
    logger.info("Application Access URL {0}", url);
    boolean checkApp = checkAppUsingHostHeader(url, domainNamespace + ".org");
    assertTrue(checkApp, "Failed to access WebLogic application");
  }
/**
   * Create a domain using model-in-image model.
   * Add istio configuration with default readinessPort.
   * Do not add any AdminService under AdminServer configuration.
   * Deploy istio gateways and virtual service.
   * Verify server pods are in ready state and services are created.
   * Verify login to WebLogic console is successful thru istio ingress port.
   * Deploy a web application thru istio http ingress port using REST api.  
   * Access web application thru istio http ingress port using curl.
   */
Create a domain using model-in-image model.
Add istio configuration with default readinessPort.
Do not add any AdminService under AdminServer configuration.
Deploy istio gateways and virtual service.
Verify server pods are in ready state and services are created.
Verify login to WebLogic console is successful thru istio ingress port.
Deploy a web application thru istio http ingress port using REST api.
Access web application thru istio http ingress port using curl.
Create a domain using model - in - image model . Add istio configuration with default readinessPort . Do not add any AdminService under AdminServer configuration . Deploy istio gateways and virtual service . Verify server pods are in ready state and services are created . Verify login to WebLogic console is successful thru istio ingress port . Deploy a web application thru istio http ingress port using REST api . Access web application thru istio http ingress port using curl .
@Test
  @DisplayName("Create WebLogic Domain with mii model with istio")
  public void testIstioModelInImage() {
    final String adminServerPodName = domainUid + "-admin-server";
    final String managedServerPrefix = domainUid + "-managed-server";
    final int replicaCount = 2;
    assertDoesNotThrow(() -> createDockerRegistrySecret(domainNamespace),
        String.format("createSecret failed for %s", REPO_SECRET_NAME));
    logger.info("Create secret for admin credentials");
    String adminSecretName = "weblogic-credentials";
    assertDoesNotThrow(() -> createSecretWithUsernamePassword(
                                    adminSecretName,
                                    domainNamespace,
                                    "weblogic",
                                    "welcome1"),
        String.format("createSecret failed for %s", adminSecretName));
    logger.info("Create encryption secret");
    String encryptionSecretName = "encryptionsecret";
    assertDoesNotThrow(() -> createSecretWithUsernamePassword(
                                      encryptionSecretName,
                                      domainNamespace,
                            "weblogicenc",
                            "weblogicenc"),
                    String.format("createSecret failed for %s", encryptionSecretName));
    Domain domain = createDomainResource(domainUid,
                                      domainNamespace,
                                      adminSecretName,
                                      REPO_SECRET_NAME,
                                      encryptionSecretName,
                                      replicaCount,
                              MII_BASIC_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG);
    createDomainAndVerify(domain, domainNamespace);
    logger.info("Check admin service {0} is created in namespace {1}",
        adminServerPodName, domainNamespace);
    checkServiceExists(adminServerPodName, domainNamespace);
    logger.info("Wait for admin server pod {0} to be ready in namespace {1}",
        adminServerPodName, domainNamespace);
    checkPodReady(adminServerPodName, domainUid, domainNamespace);
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Check managed service {0} is created in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkServiceExists(managedServerPrefix + i, domainNamespace);
    }
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Wait for managed pod {0} to be ready in namespace {1}",
          managedServerPrefix + i, domainNamespace);
      checkPodReady(managedServerPrefix + i, domainUid, domainNamespace);
    }
    String clusterService = domainUid + "-cluster-" + clusterName + "." + domainNamespace + ".svc.cluster.local";
    Map<String, String> templateMap  = new HashMap();
    templateMap.put("NAMESPACE", domainNamespace);
    templateMap.put("DUID", domainUid);
    templateMap.put("ADMIN_SERVICE",adminServerPodName);
    templateMap.put("CLUSTER_SERVICE", clusterService);
    Path srcHttpFile = Paths.get(RESOURCE_DIR, "istio", "istio-http-template.yaml");
    Path targetHttpFile = assertDoesNotThrow(
        () -> generateFileFromTemplate(srcHttpFile.toString(), "istio-http.yaml", templateMap));
    logger.info("Generated Http VS/Gateway file path is {0}", targetHttpFile);
    boolean deployRes = assertDoesNotThrow(
        () -> deployHttpIstioGatewayAndVirtualservice(targetHttpFile)); 
    assertTrue(deployRes, "Failed to deploy Http Istio Gateway/VirtualService");
    Path srcDrFile = Paths.get(RESOURCE_DIR, "istio", "istio-dr-template.yaml");
    Path targetDrFile = assertDoesNotThrow(
        () -> generateFileFromTemplate(srcDrFile.toString(), "istio-dr.yaml", templateMap));
    logger.info("Generated DestinationRule file path is {0}", targetDrFile);
    deployRes = assertDoesNotThrow(
        () -> deployIstioDestinationRule(targetDrFile));
    assertTrue(deployRes, "Failed to deploy Istio DestinationRule");
    int istioIngressPort = getIstioHttpIngressPort();
    logger.info("Istio Ingress Port is {0}", istioIngressPort);
    String consoleUrl = "http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/console/login/LoginForm.jsp";
    boolean checkConsole = 
         checkAppUsingHostHeader(consoleUrl, domainNamespace + ".org");
    assertTrue(checkConsole, "Failed to access WebLogic console");
    logger.info("WebLogic console is accessible");
    Path archivePath = Paths.get(ITTESTS_DIR, "../src/integration-tests/apps/testwebapp.war");
    ExecResult result = null;
    result = DeployUtil.deployUsingRest(K8S_NODEPORT_HOST, 
        String.valueOf(istioIngressPort),
        ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, 
        clusterName, archivePath, domainNamespace + ".org", "testwebapp");
    assertNotNull(result, "Application deployment failed");
    logger.info("Application deployment returned {0}", result.toString());
    assertEquals("202", result.stdout(), "Deployment didn't return HTTP status code 202");
    String url = "http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/testwebapp/index.jsp";
    logger.info("Application Access URL {0}", url);
    boolean checkApp = checkAppUsingHostHeader(url, domainNamespace + ".org");
    assertTrue(checkApp, "Failed to access WebLogic application");
  }
@ Test @ DisplayName ( "Create WebLogic Domain with mii model with istio" ) public void testIstioModelInImage ( ) { final String adminServerPodName = domainUid + "-admin-server" ; final String managedServerPrefix = domainUid + "-managed-server" ; final int replicaCount = 2 ; assertDoesNotThrow ( ( ) -> createDockerRegistrySecret ( domainNamespace ) , String . format ( "createSecret failed for %s" , REPO_SECRET_NAME ) ) ; logger . info ( "Create secret for admin credentials" ) ; String adminSecretName = "weblogic-credentials" ; assertDoesNotThrow ( ( ) -> createSecretWithUsernamePassword ( adminSecretName , domainNamespace , "weblogic" , "welcome1" ) , String . format ( "createSecret failed for %s" , adminSecretName ) ) ; logger . info ( "Create encryption secret" ) ; String encryptionSecretName = "encryptionsecret" ; assertDoesNotThrow ( ( ) -> createSecretWithUsernamePassword ( encryptionSecretName , domainNamespace , "weblogicenc" , "weblogicenc" ) , String . format ( "createSecret failed for %s" , encryptionSecretName ) ) ; Domain domain = createDomainResource ( domainUid , domainNamespace , adminSecretName , REPO_SECRET_NAME , encryptionSecretName , replicaCount , MII_BASIC_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG ) ; createDomainAndVerify ( domain , domainNamespace ) ; logger . info ( "Check admin service {0} is created in namespace {1}" , adminServerPodName , domainNamespace ) ; checkServiceExists ( adminServerPodName , domainNamespace ) ; logger . info ( "Wait for admin server pod {0} to be ready in namespace {1}" , adminServerPodName , domainNamespace ) ; checkPodReady ( adminServerPodName , domainUid , domainNamespace ) ; for ( int i = 1 ; i <= replicaCount ; i ++ ) { logger . info ( "Check managed service {0} is created in namespace {1}" , managedServerPrefix + i , domainNamespace ) ; checkServiceExists ( managedServerPrefix + i , domainNamespace ) ; } for ( int i = 1 ; i <= replicaCount ; i ++ ) { logger . info ( "Wait for managed pod {0} to be ready in namespace {1}" , managedServerPrefix + i , domainNamespace ) ; checkPodReady ( managedServerPrefix + i , domainUid , domainNamespace ) ; } String clusterService = domainUid + "-cluster-" + clusterName + "." + domainNamespace + ".svc.cluster.local" ; Map < String , String > templateMap = new HashMap ( ) ; templateMap . put ( "NAMESPACE" , domainNamespace ) ; templateMap . put ( "DUID" , domainUid ) ; templateMap . put ( "ADMIN_SERVICE" , adminServerPodName ) ; templateMap . put ( "CLUSTER_SERVICE" , clusterService ) ; Path srcHttpFile = Paths . get ( RESOURCE_DIR , "istio" , "istio-http-template.yaml" ) ; Path targetHttpFile = assertDoesNotThrow ( ( ) -> generateFileFromTemplate ( srcHttpFile . toString ( ) , "istio-http.yaml" , templateMap ) ) ; logger . info ( "Generated Http VS/Gateway file path is {0}" , targetHttpFile ) ; boolean deployRes = assertDoesNotThrow ( ( ) -> deployHttpIstioGatewayAndVirtualservice ( targetHttpFile ) ) ; assertTrue ( deployRes , "Failed to deploy Http Istio Gateway/VirtualService" ) ; Path srcDrFile = Paths . get ( RESOURCE_DIR , "istio" , "istio-dr-template.yaml" ) ; Path targetDrFile = assertDoesNotThrow ( ( ) -> generateFileFromTemplate ( srcDrFile . toString ( ) , "istio-dr.yaml" , templateMap ) ) ; logger . info ( "Generated DestinationRule file path is {0}" , targetDrFile ) ; deployRes = assertDoesNotThrow ( ( ) -> deployIstioDestinationRule ( targetDrFile ) ) ; assertTrue ( deployRes , "Failed to deploy Istio DestinationRule" ) ; int istioIngressPort = getIstioHttpIngressPort ( ) ; logger . info ( "Istio Ingress Port is {0}" , istioIngressPort ) ; String consoleUrl = "http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/console/login/LoginForm.jsp" ; boolean checkConsole = checkAppUsingHostHeader ( consoleUrl , domainNamespace + ".org" ) ; assertTrue ( checkConsole , "Failed to access WebLogic console" ) ; logger . info ( "WebLogic console is accessible" ) ; Path archivePath = Paths . get ( ITTESTS_DIR , "../src/integration-tests/apps/testwebapp.war" ) ; ExecResult result = null ; result = DeployUtil . deployUsingRest ( K8S_NODEPORT_HOST , String . valueOf ( istioIngressPort ) , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT , clusterName , archivePath , domainNamespace + ".org" , "testwebapp" ) ; assertNotNull ( result , "Application deployment failed" ) ; logger . info ( "Application deployment returned {0}" , result . toString ( ) ) ; assertEquals ( "202" , result . stdout ( ) , "Deployment didn't return HTTP status code 202" ) ; String url = "http://" + K8S_NODEPORT_HOST + ":" + istioIngressPort + "/testwebapp/index.jsp" ; logger . info ( "Application Access URL {0}" , url ) ; boolean checkApp = checkAppUsingHostHeader ( url , domainNamespace + ".org" ) ; assertTrue ( checkApp , "Failed to access WebLogic application" ) ; }
Create a domain using model-in-image model.
Create a domain using model - in - image model .
// Create the repo secret to pull the image // create secret for admin credentials // create encryption secret // create the domain object // create model in image domain // check admin server pod is ready // check managed server services created // check managed server pods are ready