1313import java .nio .file .StandardCopyOption ;
1414import java .time .OffsetDateTime ;
1515import java .util .ArrayList ;
16- import java .util .Arrays ;
16+ import java .util .Collections ;
1717import java .util .HashMap ;
1818import java .util .LinkedHashMap ;
1919import java .util .List ;
2222import java .util .concurrent .Callable ;
2323import java .util .concurrent .TimeUnit ;
2424
25+ import io .kubernetes .client .custom .Quantity ;
2526import io .kubernetes .client .custom .V1Patch ;
2627import io .kubernetes .client .openapi .ApiException ;
2728import io .kubernetes .client .openapi .models .V1Container ;
2829import io .kubernetes .client .openapi .models .V1EnvVar ;
29- import io .kubernetes .client .openapi .models .V1LocalObjectReference ;
3030import io .kubernetes .client .openapi .models .V1ObjectMeta ;
31- import io .kubernetes .client .openapi .models .V1PersistentVolumeClaimVolumeSource ;
3231import io .kubernetes .client .openapi .models .V1Pod ;
3332import io .kubernetes .client .openapi .models .V1Secret ;
3433import io .kubernetes .client .openapi .models .V1Service ;
35- import io .kubernetes .client .openapi .models .V1Volume ;
36- import io .kubernetes .client .openapi .models .V1VolumeMount ;
37- import oracle .weblogic .domain .AdminServer ;
38- import oracle .weblogic .domain .AdminService ;
39- import oracle .weblogic .domain .Channel ;
40- import oracle .weblogic .domain .ClusterResource ;
34+ import io .kubernetes .client .util .Yaml ;
4135import oracle .weblogic .domain .Configuration ;
36+ import oracle .weblogic .domain .CreateIfNotExists ;
37+ import oracle .weblogic .domain .DomainCreationImage ;
38+ import oracle .weblogic .domain .DomainOnPV ;
39+ import oracle .weblogic .domain .DomainOnPVType ;
4240import oracle .weblogic .domain .DomainResource ;
43- import oracle .weblogic .domain .DomainSpec ;
44- import oracle .weblogic .domain .ServerPod ;
4541import oracle .weblogic .kubernetes .actions .impl .NginxParams ;
4642import oracle .weblogic .kubernetes .actions .impl .Service ;
4743import oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes ;
44+ import oracle .weblogic .kubernetes .actions .impl .primitive .WitParams ;
4845import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
4946import oracle .weblogic .kubernetes .annotations .Namespaces ;
5047import oracle .weblogic .kubernetes .logging .LoggingFacade ;
6461import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
6562import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
6663import static oracle .weblogic .kubernetes .TestConstants .BASE_IMAGES_REPO_SECRET_NAME ;
67- import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
68- import static oracle .weblogic .kubernetes .TestConstants .IMAGE_PULL_POLICY ;
64+ import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_IMAGES_PREFIX ;
6965import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
7066import static oracle .weblogic .kubernetes .TestConstants .KUBERNETES_CLI ;
67+ import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
68+ import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
7169import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER_PRIVATEIP ;
7270import static oracle .weblogic .kubernetes .TestConstants .RESULTS_TEMPFILE ;
7371import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
7472import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_12213 ;
7573import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
7674import static oracle .weblogic .kubernetes .actions .ActionConstants .APP_DIR ;
75+ import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
7776import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
7877import static oracle .weblogic .kubernetes .actions .ActionConstants .WORK_DIR ;
7978import static oracle .weblogic .kubernetes .actions .TestActions .createSecret ;
8988import static oracle .weblogic .kubernetes .actions .impl .Domain .patchDomainCustomResource ;
9089import static oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes .listConfigMaps ;
9190import static oracle .weblogic .kubernetes .assertions .TestAssertions .podStateNotChanged ;
91+ import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .createAndPushAuxiliaryImage ;
9292import static oracle .weblogic .kubernetes .utils .BuildApplication .buildApplication ;
93- import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterAndVerify ;
94- import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterResource ;
9593import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
9694import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
9795import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
104102import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapFromFiles ;
105103import static oracle .weblogic .kubernetes .utils .DeployUtil .deployUsingWlst ;
106104import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
105+ import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainResourceOnPv ;
107106import static oracle .weblogic .kubernetes .utils .ExecCommand .exec ;
108107import static oracle .weblogic .kubernetes .utils .FileUtils .replaceStringInFile ;
108+ import static oracle .weblogic .kubernetes .utils .FmwUtils .getConfiguration ;
109109import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
110110import static oracle .weblogic .kubernetes .utils .JobUtils .createDomainJob ;
111111import static oracle .weblogic .kubernetes .utils .JobUtils .getIntrospectJobName ;
114114import static oracle .weblogic .kubernetes .utils .MySQLDBUtils .createMySQLDB ;
115115import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
116116import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
117- import static oracle .weblogic .kubernetes .utils .PersistentVolumeUtils .createPV ;
118- import static oracle .weblogic .kubernetes .utils .PersistentVolumeUtils .createPVC ;
119117import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
120118import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodExists ;
121119import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodReady ;
122120import static oracle .weblogic .kubernetes .utils .PodUtils .getExternalServicePodName ;
123121import static oracle .weblogic .kubernetes .utils .PodUtils .getPodCreationTime ;
124- import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
125122import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
126123import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
127124import static oracle .weblogic .kubernetes .utils .WLSTUtils .executeWLSTScript ;
@@ -155,8 +152,7 @@ class ItConfigDistributionStrategy {
155152 final String adminServerName = "admin-server" ;
156153 final int adminPort = 7001 ;
157154 final String adminServerPodName = domainUid + "-" + adminServerName ;
158- final String managedServerNameBase = "ms-" ;
159- final int managedServerPort = 8001 ;
155+ final String managedServerNameBase = "managed-server" ;
160156 int t3ChannelPort ;
161157 final String pvName = getUniqueName (domainUid + "-pv-" );
162158 final String pvcName = getUniqueName (domainUid + "-pvc-" );
@@ -169,12 +165,8 @@ class ItConfigDistributionStrategy {
169165 String overridecm = "configoverride-cm" ;
170166 LinkedHashMap <String , OffsetDateTime > podTimestamps ;
171167
172- static int mysqlDBPort1 ;
173- static int mysqlDBPort2 ;
174168 static String dsUrl1 ;
175169 static String dsUrl2 ;
176- static String mysql1SvcEndpoint = null ;
177- static String mysql2SvcEndpoint = null ;
178170 private static String ingressIP = null ;
179171
180172 String dsName0 = "JdbcTestDataSource-0" ;
@@ -983,104 +975,67 @@ private void verifyIntrospectorRuns() {
983975
984976 //create a standard WebLogic domain.
985977 private void createDomain () {
986-
987- String uniquePath = "/shared/" + domainNamespace + "/domains" ;
978+ String uniqueDomainHome = "/shared/" + domainNamespace + "/domains" ;
988979
989980 // create WebLogic domain credential secret
990981 createSecretWithUsernamePassword (wlSecretName , domainNamespace ,
991982 ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
992-
993- createPV (pvName , domainUid , this .getClass ().getSimpleName ());
994- createPVC (pvName , pvcName , domainUid , domainNamespace );
995-
983+ final String wlsModelFilePrefix = "model-dci-introspect" ;
984+ final String wlsModelFile = wlsModelFilePrefix + ".yaml" ;
996985 t3ChannelPort = getNextFreePort ();
997-
998- // create a temporary WebLogic domain property file
999- File domainPropertiesFile = assertDoesNotThrow (()
1000- -> File .createTempFile ("domain" , ".properties" , new File (RESULTS_TEMPFILE )),
1001- "Failed to create domain properties file" );
1002- Properties p = new Properties ();
1003- p .setProperty ("domain_path" , uniquePath );
1004- p .setProperty ("domain_name" , domainUid );
1005- p .setProperty ("cluster_name" , clusterName );
1006- p .setProperty ("admin_server_name" , adminServerName );
1007- p .setProperty ("managed_server_port" , Integer .toString (managedServerPort ));
1008- p .setProperty ("admin_server_port" , "7001" );
1009- p .setProperty ("admin_username" , ADMIN_USERNAME_DEFAULT );
1010- p .setProperty ("admin_password" , ADMIN_PASSWORD_DEFAULT );
1011- p .setProperty ("admin_t3_public_address" , ingressIP );
1012- p .setProperty ("admin_t3_channel_port" , Integer .toString (t3ChannelPort ));
1013- p .setProperty ("number_of_ms" , "2" );
1014- p .setProperty ("managed_server_name_base" , managedServerNameBase );
1015- p .setProperty ("domain_logs" , uniquePath + "/logs" );
1016- p .setProperty ("production_mode_enabled" , "true" );
1017- assertDoesNotThrow (()
1018- -> p .store (new FileOutputStream (domainPropertiesFile ), "domain properties file" ),
1019- "Failed to write domain properties file" );
1020-
1021- // WLST script for creating domain
1022- Path wlstScript = Paths .get (RESOURCE_DIR , "python-scripts" , "wlst-create-domain-onpv.py" );
1023-
1024- // create configmap and domain on persistent volume using the WLST script and property file
1025- createDomainOnPVUsingWlst (wlstScript , domainPropertiesFile .toPath (),
1026- pvName , pvcName , domainNamespace );
1027-
1028- // create a domain custom resource configuration object
986+ File wlsModelPropFile = ItIntrospectVersion .createWdtPropertyFile (wlsModelFilePrefix ,
987+ K8S_NODEPORT_HOST , t3ChannelPort );
988+ // create domainCreationImage
989+ String domainCreationImageName = DOMAIN_IMAGES_PREFIX + "configdist-domain-on-pv-image" ;
990+ // create image with model and wdt installation files
991+ WitParams witParams
992+ = new WitParams ()
993+ .modelImageName (domainCreationImageName )
994+ .modelImageTag (MII_BASIC_IMAGE_TAG )
995+ .modelFiles (Collections .singletonList (MODEL_DIR + "/" + wlsModelFile ))
996+ .modelVariableFiles (Collections .singletonList (wlsModelPropFile .getAbsolutePath ()));
997+ createAndPushAuxiliaryImage (domainCreationImageName , MII_BASIC_IMAGE_TAG , witParams );
998+
999+ DomainCreationImage domainCreationImage
1000+ = new DomainCreationImage ().image (domainCreationImageName + ":" + MII_BASIC_IMAGE_TAG );
1001+
1002+ // create a domain resource
10291003 logger .info ("Creating domain custom resource" );
1030- DomainResource domain = new DomainResource ()
1031- .apiVersion (DOMAIN_API_VERSION )
1032- .kind ("Domain" )
1033- .metadata (new V1ObjectMeta ()
1034- .name (domainUid )
1035- .namespace (domainNamespace ))
1036- .spec (new DomainSpec ()
1037- .configuration (new Configuration ()
1038- .overrideDistributionStrategy ("Dynamic" )
1039- .introspectorJobActiveDeadlineSeconds (300L ))
1040- .domainUid (domainUid )
1041- .domainHome (uniquePath + "/" + domainUid ) // point to domain home in pv
1042- .domainHomeSourceType ("PersistentVolume" ) // set the domain home source type as pv
1043- .image (WEBLOGIC_IMAGE_TO_USE_IN_SPEC )
1044- .imagePullPolicy (IMAGE_PULL_POLICY )
1045- .imagePullSecrets (Arrays .asList (
1046- new V1LocalObjectReference ()
1047- .name (BASE_IMAGES_REPO_SECRET_NAME ))) // this secret is used only in non-kind cluster
1048- .webLogicCredentialsSecret (new V1LocalObjectReference ()
1049- .name (wlSecretName ))
1050- .includeServerOutInPodLog (true )
1051- .logHomeEnabled (Boolean .TRUE )
1052- .logHome (uniquePath + "/logs/" + domainUid )
1053- .dataHome ("" )
1054- .serverStartPolicy ("IfNeeded" )
1055- .serverPod (new ServerPod () //serverpod
1056- .addEnvItem (new V1EnvVar ()
1057- .name ("JAVA_OPTIONS" )
1058- .value ("-Dweblogic.debug.DebugSituationalConfig=true "
1059- + "-Dweblogic.debug.DebugSituationalConfigDumpXml=true " ))
1060- .addEnvItem (new V1EnvVar ()
1061- .name ("USER_MEM_ARGS" )
1062- .value ("-Djava.security.egd=file:/dev/./urandom " ))
1063- .addVolumesItem (new V1Volume ()
1064- .name (pvName )
1065- .persistentVolumeClaim (new V1PersistentVolumeClaimVolumeSource ()
1066- .claimName (pvcName )))
1067- .addVolumeMountsItem (new V1VolumeMount ()
1068- .mountPath ("/shared" )
1069- .name (pvName )))
1070- .adminServer (new AdminServer () //admin server
1071- .adminService (new AdminService ()
1072- .addChannelsItem (new Channel ()
1073- .channelName ("default" )
1074- .nodePort (0 )))));
1075- setPodAntiAffinity (domain );
1076-
1077- // create cluster object
1078- ClusterResource cluster = createClusterResource (clusterResName ,
1079- clusterName , domainNamespace , replicaCount );
1080- logger .info ("Creating cluster resource {0} in namespace {1}" , clusterResName , domainNamespace );
1081- createClusterAndVerify (cluster );
1082- // set cluster references
1083- domain .getSpec ().withCluster (new V1LocalObjectReference ().name (clusterResName ));
1004+ Map <String , Quantity > pvCapacity = new HashMap <>();
1005+ pvCapacity .put ("storage" , new Quantity ("2Gi" ));
1006+
1007+ Map <String , Quantity > pvcRequest = new HashMap <>();
1008+ pvcRequest .put ("storage" , new Quantity ("2Gi" ));
1009+ Configuration configuration = null ;
1010+ final String storageClassName = "weblogic-domain-storage-class" ;
1011+ if (OKE_CLUSTER ) {
1012+ configuration = getConfiguration (pvcName , pvcRequest , "oci-fss" );
1013+ } else {
1014+ configuration = getConfiguration (pvName , pvcName , pvCapacity , pvcRequest , storageClassName ,
1015+ ItIntrospectVersion .class .getName ());
1016+ }
1017+ configuration .getInitializeDomainOnPV ().domain (new DomainOnPV ()
1018+ .createMode (CreateIfNotExists .DOMAIN )
1019+ .domainCreationImages (Collections .singletonList (domainCreationImage ))
1020+ .domainType (DomainOnPVType .WLS ));
1021+ configuration .overrideDistributionStrategy ("Dynamic" );
1022+
1023+ DomainResource domain = createDomainResourceOnPv (domainUid ,
1024+ domainNamespace ,
1025+ wlSecretName ,
1026+ clusterName ,
1027+ pvName ,
1028+ pvcName ,
1029+ new String []{BASE_IMAGES_REPO_SECRET_NAME },
1030+ uniqueDomainHome ,
1031+ 2 ,
1032+ t3ChannelPort ,
1033+ configuration );
1034+ domain .spec ().serverPod ().addEnvItem (new V1EnvVar ()
1035+ .name ("JAVA_OPTIONS" )
1036+ .value ("-Dweblogic.debug.DebugSituationalConfig=true "
1037+ + "-Dweblogic.debug.DebugSituationalConfigDumpXml=true " ));
1038+ logger .info (Yaml .dump (domain ));
10841039
10851040 // verify the domain custom resource is created
10861041 createDomainAndVerify (domain , domainNamespace );
0 commit comments