new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItConfigDistributionStrategy.java
private void createDomain() {

    // create WebLogic domain credential secret
    createSecretWithUsernamePassword(wlSecretName, domainNamespace,
        ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);

    createPV(pvName, domainUid, this.getClass().getSimpleName());
    createPVC(pvName, pvcName, domainUid, domainNamespace);

    t3ChannelPort = getNextFreePort(31500, 32767);

    // create a temporary WebLogic domain property file
    File domainPropertiesFile = assertDoesNotThrow(()
        -> File.createTempFile("domain", ".properties"),
        "Failed to create domain properties file");
    Properties p = new Properties();
    p.setProperty("domain_path", "/shared/domains");
    p.setProperty("domain_name", domainUid);
    p.setProperty("cluster_name", clusterName);
    p.setProperty("admin_server_name", adminServerName);
    p.setProperty("managed_server_port", Integer.toString(managedServerPort));
    p.setProperty("admin_server_port", "7001");
    p.setProperty("admin_username", ADMIN_USERNAME_DEFAULT);
    p.setProperty("admin_password", ADMIN_PASSWORD_DEFAULT);
    p.setProperty("admin_t3_public_address", K8S_NODEPORT_HOST);
    p.setProperty("admin_t3_channel_port", Integer.toString(t3ChannelPort));
    p.setProperty("number_of_ms", "2");
    p.setProperty("managed_server_name_base", managedServerNameBase);
    p.setProperty("domain_logs", "/shared/logs");
    p.setProperty("production_mode_enabled", "true");
    assertDoesNotThrow(()
        -> p.store(new FileOutputStream(domainPropertiesFile), "domain properties file"),
        "Failed to write domain properties file");

    // WLST script for creating domain
    Path wlstScript = Paths.get(RESOURCE_DIR, "python-scripts", "wlst-create-domain-onpv.py");

    // create configmap and domain on persistent volume using the WLST script and property file
    createDomainOnPVUsingWlst(wlstScript, domainPropertiesFile.toPath(),
        pvName, pvcName, domainNamespace);

    // create a domain custom resource configuration object
    logger.info("Creating domain custom resource");
    Domain domain = new Domain()
        .apiVersion(DOMAIN_API_VERSION)
        .kind("Domain")
        .metadata(new V1ObjectMeta()
            .name(domainUid)
            .namespace(domainNamespace))
        .spec(new DomainSpec()
            .configuration(new Configuration()
                .overrideDistributionStrategy("DYNAMIC"))
            .domainUid(domainUid)
            .domainHome("/shared/domains/" + domainUid) // point to domain home in pv
            .domainHomeSourceType("PersistentVolume") // set the domain home source type as pv
            .image(image)
            .imagePullPolicy("IfNotPresent")
            .imagePullSecrets(isUseSecret ? Arrays.asList(
                new V1LocalObjectReference()
                    .name(OCR_SECRET_NAME))
                : null)
            .webLogicCredentialsSecret(new V1SecretReference()
                .name(wlSecretName)
                .namespace(domainNamespace))
            .includeServerOutInPodLog(true)
            .logHomeEnabled(Boolean.TRUE)
            .logHome("/shared/logs/" + domainUid)
            .dataHome("")
            .serverStartPolicy("IF_NEEDED")
            .serverPod(new ServerPod() //serverpod
                .addEnvItem(new V1EnvVar()
                    .name("JAVA_OPTIONS")
                    .value("-Dweblogic.debug.DebugSituationalConfig=true"))
                .addEnvItem(new V1EnvVar()
                    .name("JAVA_OPTIONS")
                    .value("-Dweblogic.debug.DebugSituationalConfigDumpXml=true"))
                .addEnvItem(new V1EnvVar()
                    .name("USER_MEM_ARGS")
                    .value("-Djava.security.egd=file:/dev/./urandom "))
                .addVolumesItem(new V1Volume()
                    .name(pvName)
                    .persistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource()
                        .claimName(pvcName)))
                .addVolumeMountsItem(new V1VolumeMount()
                    .mountPath("/shared")
                    .name(pvName)))
            .adminServer(new AdminServer() //admin server
                .serverStartState("RUNNING")
                .adminService(new AdminService()
                    .addChannelsItem(new Channel()
                        .channelName("default")
                        .nodePort(0))
                    .addChannelsItem(new Channel()
                        .channelName("T3Channel")
                        .nodePort(t3ChannelPort))))
            .addClustersItem(new Cluster() //cluster
                .clusterName(clusterName)
                .replicas(replicaCount)
                .serverStartState("RUNNING")));

    // verify the domain custom resource is created
    createDomainAndVerify(domain, domainNamespace);

    // verify the admin server service created
    checkServiceExists(adminServerPodName, domainNamespace);

    // verify admin server pod is ready
    checkPodReady(adminServerPodName, domainUid, domainNamespace);

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

    // verify managed server pods are ready
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Waiting for managed server pod {0} to be ready in namespace {1}",
          managedServerPodNamePrefix + i, domainNamespace);
      checkPodReady(managedServerPodNamePrefix + i, domainUid, domainNamespace);
    }
  }
//create a standard WebLogic domain.
create a standard WebLogic domain.
create a standard WebLogic domain .
private void createDomain() {
    createSecretWithUsernamePassword(wlSecretName, domainNamespace,
        ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
    createPV(pvName, domainUid, this.getClass().getSimpleName());
    createPVC(pvName, pvcName, domainUid, domainNamespace);
    t3ChannelPort = getNextFreePort(31500, 32767);
    File domainPropertiesFile = assertDoesNotThrow(()
        -> File.createTempFile("domain", ".properties"),
        "Failed to create domain properties file");
    Properties p = new Properties();
    p.setProperty("domain_path", "/shared/domains");
    p.setProperty("domain_name", domainUid);
    p.setProperty("cluster_name", clusterName);
    p.setProperty("admin_server_name", adminServerName);
    p.setProperty("managed_server_port", Integer.toString(managedServerPort));
    p.setProperty("admin_server_port", "7001");
    p.setProperty("admin_username", ADMIN_USERNAME_DEFAULT);
    p.setProperty("admin_password", ADMIN_PASSWORD_DEFAULT);
    p.setProperty("admin_t3_public_address", K8S_NODEPORT_HOST);
    p.setProperty("admin_t3_channel_port", Integer.toString(t3ChannelPort));
    p.setProperty("number_of_ms", "2");
    p.setProperty("managed_server_name_base", managedServerNameBase);
    p.setProperty("domain_logs", "/shared/logs");
    p.setProperty("production_mode_enabled", "true");
    assertDoesNotThrow(()
        -> p.store(new FileOutputStream(domainPropertiesFile), "domain properties file"),
        "Failed to write domain properties file");
    Path wlstScript = Paths.get(RESOURCE_DIR, "python-scripts", "wlst-create-domain-onpv.py");
    createDomainOnPVUsingWlst(wlstScript, domainPropertiesFile.toPath(),
        pvName, pvcName, domainNamespace);
    logger.info("Creating domain custom resource");
    Domain domain = new Domain()
        .apiVersion(DOMAIN_API_VERSION)
        .kind("Domain")
        .metadata(new V1ObjectMeta()
            .name(domainUid)
            .namespace(domainNamespace))
        .spec(new DomainSpec()
            .configuration(new Configuration()
                .overrideDistributionStrategy("DYNAMIC"))
            .domainUid(domainUid)
            .domainHome("/shared/domains/" + domainUid) 
            .domainHomeSourceType("PersistentVolume") 
            .image(image)
            .imagePullPolicy("IfNotPresent")
            .imagePullSecrets(isUseSecret ? Arrays.asList(
                new V1LocalObjectReference()
                    .name(OCR_SECRET_NAME))
                : null)
            .webLogicCredentialsSecret(new V1SecretReference()
                .name(wlSecretName)
                .namespace(domainNamespace))
            .includeServerOutInPodLog(true)
            .logHomeEnabled(Boolean.TRUE)
            .logHome("/shared/logs/" + domainUid)
            .dataHome("")
            .serverStartPolicy("IF_NEEDED")
            .serverPod(new ServerPod() 
                .addEnvItem(new V1EnvVar()
                    .name("JAVA_OPTIONS")
                    .value("-Dweblogic.debug.DebugSituationalConfig=true"))
                .addEnvItem(new V1EnvVar()
                    .name("JAVA_OPTIONS")
                    .value("-Dweblogic.debug.DebugSituationalConfigDumpXml=true"))
                .addEnvItem(new V1EnvVar()
                    .name("USER_MEM_ARGS")
                    .value("-Djava.security.egd=file:/dev/./urandom "))
                .addVolumesItem(new V1Volume()
                    .name(pvName)
                    .persistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource()
                        .claimName(pvcName)))
                .addVolumeMountsItem(new V1VolumeMount()
                    .mountPath("/shared")
                    .name(pvName)))
            .adminServer(new AdminServer() 
                .serverStartState("RUNNING")
                .adminService(new AdminService()
                    .addChannelsItem(new Channel()
                        .channelName("default")
                        .nodePort(0))
                    .addChannelsItem(new Channel()
                        .channelName("T3Channel")
                        .nodePort(t3ChannelPort))))
            .addClustersItem(new Cluster() 
                .clusterName(clusterName)
                .replicas(replicaCount)
                .serverStartState("RUNNING")));
    createDomainAndVerify(domain, domainNamespace);
    checkServiceExists(adminServerPodName, domainNamespace);
    checkPodReady(adminServerPodName, domainUid, domainNamespace);
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Checking managed server service {0} is created in namespace {1}",
          managedServerPodNamePrefix + i, domainNamespace);
      checkServiceExists(managedServerPodNamePrefix + i, domainNamespace);
    }
    for (int i = 1; i <= replicaCount; i++) {
      logger.info("Waiting for managed server pod {0} to be ready in namespace {1}",
          managedServerPodNamePrefix + i, domainNamespace);
      checkPodReady(managedServerPodNamePrefix + i, domainUid, domainNamespace);
    }
  }
private void createDomain ( ) { createSecretWithUsernamePassword ( wlSecretName , domainNamespace , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ) ; createPV ( pvName , domainUid , this . getClass ( ) . getSimpleName ( ) ) ; createPVC ( pvName , pvcName , domainUid , domainNamespace ) ; t3ChannelPort = getNextFreePort ( 31500 , 32767 ) ; File domainPropertiesFile = assertDoesNotThrow ( ( ) -> File . createTempFile ( "domain" , ".properties" ) , "Failed to create domain properties file" ) ; Properties p = new Properties ( ) ; p . setProperty ( "domain_path" , "/shared/domains" ) ; p . setProperty ( "domain_name" , domainUid ) ; p . setProperty ( "cluster_name" , clusterName ) ; p . setProperty ( "admin_server_name" , adminServerName ) ; p . setProperty ( "managed_server_port" , Integer . toString ( managedServerPort ) ) ; p . setProperty ( "admin_server_port" , "7001" ) ; p . setProperty ( "admin_username" , ADMIN_USERNAME_DEFAULT ) ; p . setProperty ( "admin_password" , ADMIN_PASSWORD_DEFAULT ) ; p . setProperty ( "admin_t3_public_address" , K8S_NODEPORT_HOST ) ; p . setProperty ( "admin_t3_channel_port" , Integer . toString ( t3ChannelPort ) ) ; p . setProperty ( "number_of_ms" , "2" ) ; p . setProperty ( "managed_server_name_base" , managedServerNameBase ) ; p . setProperty ( "domain_logs" , "/shared/logs" ) ; p . setProperty ( "production_mode_enabled" , "true" ) ; assertDoesNotThrow ( ( ) -> p . store ( new FileOutputStream ( domainPropertiesFile ) , "domain properties file" ) , "Failed to write domain properties file" ) ; Path wlstScript = Paths . get ( RESOURCE_DIR , "python-scripts" , "wlst-create-domain-onpv.py" ) ; createDomainOnPVUsingWlst ( wlstScript , domainPropertiesFile . toPath ( ) , pvName , pvcName , domainNamespace ) ; logger . info ( "Creating domain custom resource" ) ; Domain domain = new Domain ( ) . apiVersion ( DOMAIN_API_VERSION ) . kind ( "Domain" ) . metadata ( new V1ObjectMeta ( ) . name ( domainUid ) . namespace ( domainNamespace ) ) . spec ( new DomainSpec ( ) . configuration ( new Configuration ( ) . overrideDistributionStrategy ( "DYNAMIC" ) ) . domainUid ( domainUid ) . domainHome ( "/shared/domains/" + domainUid ) . domainHomeSourceType ( "PersistentVolume" ) . image ( image ) . imagePullPolicy ( "IfNotPresent" ) . imagePullSecrets ( isUseSecret ? Arrays . asList ( new V1LocalObjectReference ( ) . name ( OCR_SECRET_NAME ) ) : null ) . webLogicCredentialsSecret ( new V1SecretReference ( ) . name ( wlSecretName ) . namespace ( domainNamespace ) ) . includeServerOutInPodLog ( true ) . logHomeEnabled ( Boolean . TRUE ) . logHome ( "/shared/logs/" + domainUid ) . dataHome ( "" ) . serverStartPolicy ( "IF_NEEDED" ) . serverPod ( new ServerPod ( ) . addEnvItem ( new V1EnvVar ( ) . name ( "JAVA_OPTIONS" ) . value ( "-Dweblogic.debug.DebugSituationalConfig=true" ) ) . addEnvItem ( new V1EnvVar ( ) . name ( "JAVA_OPTIONS" ) . value ( "-Dweblogic.debug.DebugSituationalConfigDumpXml=true" ) ) . addEnvItem ( new V1EnvVar ( ) . name ( "USER_MEM_ARGS" ) . value ( "-Djava.security.egd=file:/dev/./urandom " ) ) . addVolumesItem ( new V1Volume ( ) . name ( pvName ) . persistentVolumeClaim ( new V1PersistentVolumeClaimVolumeSource ( ) . claimName ( pvcName ) ) ) . addVolumeMountsItem ( new V1VolumeMount ( ) . mountPath ( "/shared" ) . name ( pvName ) ) ) . adminServer ( new AdminServer ( ) . serverStartState ( "RUNNING" ) . adminService ( new AdminService ( ) . addChannelsItem ( new Channel ( ) . channelName ( "default" ) . nodePort ( 0 ) ) . addChannelsItem ( new Channel ( ) . channelName ( "T3Channel" ) . nodePort ( t3ChannelPort ) ) ) ) . addClustersItem ( new Cluster ( ) . clusterName ( clusterName ) . replicas ( replicaCount ) . serverStartState ( "RUNNING" ) ) ) ; createDomainAndVerify ( domain , domainNamespace ) ; checkServiceExists ( adminServerPodName , domainNamespace ) ; checkPodReady ( adminServerPodName , domainUid , domainNamespace ) ; for ( int i = 1 ; i <= replicaCount ; i ++ ) { logger . info ( "Checking managed server service {0} is created in namespace {1}" , managedServerPodNamePrefix + i , domainNamespace ) ; checkServiceExists ( managedServerPodNamePrefix + i , domainNamespace ) ; } for ( int i = 1 ; i <= replicaCount ; i ++ ) { logger . info ( "Waiting for managed server pod {0} to be ready in namespace {1}" , managedServerPodNamePrefix + i , domainNamespace ) ; checkPodReady ( managedServerPodNamePrefix + i , domainUid , domainNamespace ) ; } }
create a standard WebLogic domain.
create a standard WebLogic domain .
// create WebLogic domain credential secret // create a temporary WebLogic domain property file // WLST script for creating domain // create configmap and domain on persistent volume using the WLST script and property file // create a domain custom resource configuration object // point to domain home in pv // set the domain home source type as pv //serverpod //admin server //cluster // verify the domain custom resource is created // verify the admin server service created // verify admin server pod is ready // verify managed server services created // verify managed server pods are ready