7171import static oracle .weblogic .kubernetes .utils .AuxiliaryImageUtils .createAndPushAuxiliaryImage ;
7272import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterAndVerify ;
7373import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterResource ;
74+ import static oracle .weblogic .kubernetes .utils .ClusterUtils .deleteClusterCustomResourceAndVerify ;
7475import static oracle .weblogic .kubernetes .utils .CommonTestUtils .addSccToDBSvcAccount ;
7576import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
7677import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
7778import static oracle .weblogic .kubernetes .utils .DbUtils .startOracleDB ;
7879import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
80+ import static oracle .weblogic .kubernetes .utils .DomainUtils .deleteDomainResource ;
7981import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyDomainReady ;
8082import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
8183import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
84+ import static oracle .weblogic .kubernetes .utils .PersistentVolumeUtils .createPV ;
85+ import static oracle .weblogic .kubernetes .utils .PersistentVolumeUtils .createPVC ;
8286import static oracle .weblogic .kubernetes .utils .PersistentVolumeUtils .createPVHostPathDir ;
8387import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
8488import static oracle .weblogic .kubernetes .utils .SecretUtils .createOpsswalletpasswordSecret ;
@@ -107,7 +111,6 @@ class ItFmwDomainInPVSimplified {
107111 private static String dbUrl = null ;
108112 private static LoggingFacade logger = null ;
109113 private static String DOMAINHOMEPREFIX = null ;
110- private static final String domainUid = "jrfonpv-simplified" ;
111114 private static final String clusterName = "cluster-1" ;
112115 private static final int replicaCount = 2 ;
113116
@@ -164,11 +167,13 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
164167
165168 /**
166169 * Create a basic FMW domain on PV using simplified feature.
170+ * Operator will create PV/PVC/RCU/Domain.
167171 * Verify Pod is ready and service exists for both admin server and managed servers.
168172 */
169173 @ Test
170- @ DisplayName ("Create a FMW domainon on PV using WDT" )
171- void testFmwDomainOnPVUsingWdt () {
174+ @ DisplayName ("Create a FMW domain on PV using simplified feature, Operator creates PV/PVC/RCU/Domain" )
175+ void testOperatorCreatesPvPvcRcuDomain () {
176+ String domainUid = "jrfonpv-simplified" ;
172177 final String pvName = getUniqueName (domainUid + "-pv-" );
173178 final String pvcName = getUniqueName (domainUid + "-pvc-" );
174179 final int t3ChannelPort = getNextFreePort ();
@@ -180,7 +185,7 @@ void testFmwDomainOnPVUsingWdt() {
180185 ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
181186
182187 // create a model property file
183- File fmwModelPropFile = createWdtPropertyFile ();
188+ File fmwModelPropFile = createWdtPropertyFile ("jrfonpv-simplified1" , RCUSCHEMAPREFIX + "1" );
184189
185190 // create domainCreationImage
186191 String domainCreationImageName = DOMAIN_IMAGES_REPO + "jrf-domain-on-pv-image" ;
@@ -207,39 +212,163 @@ void testFmwDomainOnPVUsingWdt() {
207212
208213 // create a domain resource
209214 logger .info ("Creating domain custom resource" );
215+ Map <String , Quantity > pvCapacity = new HashMap <>();
216+ pvCapacity .put ("storage" , new Quantity ("10Gi" ));
217+
218+ Map <String , Quantity > pvcRequest = new HashMap <>();
219+ pvcRequest .put ("storage" , new Quantity ("10Gi" ));
220+
221+ Configuration configuration = new Configuration ()
222+ .initializeDomainOnPV (new InitializeDomainOnPV ()
223+ .persistentVolume (new PersistentVolume ()
224+ .metadata (new V1ObjectMeta ()
225+ .name (pvName ))
226+ .spec (new PersistentVolumeSpec ()
227+ .storageClassName (storageClassName )
228+ .capacity (pvCapacity )
229+ .persistentVolumeReclaimPolicy ("Retain" )
230+ .hostPath (new V1HostPathVolumeSource ()
231+ .path (getHostPath (pvName , this .getClass ().getSimpleName ())))))
232+ .persistentVolumeClaim (new PersistentVolumeClaim ()
233+ .metadata (new V1ObjectMeta ()
234+ .name (pvcName ))
235+ .spec (new PersistentVolumeClaimSpec ()
236+ .storageClassName (storageClassName )
237+ .resources (new V1ResourceRequirements ()
238+ .requests (pvcRequest ))))
239+ .domain (new DomainOnPV ()
240+ .createMode (CreateIfNotExists .DOMAIN_AND_RCU )
241+ .domainCreationImages (Collections .singletonList (domainCreationImage ))
242+ .domainType (DomainOnPVType .JRF )
243+ .opss (new Opss ()
244+ .walletPasswordSecret (opsswalletpassSecretName ))));
245+
210246 DomainResource domain = createDomainResourceOnPv (
211- domainUid ,
212- domainNamespace ,
213- wlSecretName ,
214- clusterName ,
215- pvName ,
216- pvcName ,
217- DOMAINHOMEPREFIX ,
218- replicaCount ,
219- t3ChannelPort ,
220- Collections .singletonList (domainCreationImage ),
221- opsswalletpassSecretName );
247+ domainUid ,
248+ domainNamespace ,
249+ wlSecretName ,
250+ clusterName ,
251+ pvName ,
252+ pvcName ,
253+ DOMAINHOMEPREFIX ,
254+ replicaCount ,
255+ t3ChannelPort ,
256+ configuration );
222257
223258 // Set the inter-pod anti-affinity for the domain custom resource
224259 setPodAntiAffinity (domain );
225260
226261 // create a domain custom resource and verify domain is created
227262 createDomainAndVerify (domain , domainNamespace );
228263
229- // verify that all servers are ready and EM console is accessible
264+ // verify that all servers are ready
230265 verifyDomainReady (domainNamespace , domainUid , replicaCount , "nosuffix" );
266+
267+ // delete the domain
268+ deleteDomainResource (domainNamespace , domainUid );
269+ // delete the cluster
270+ deleteClusterCustomResourceAndVerify (domainUid + "-" + clusterName , domainNamespace );
231271 }
232272
233- private File createWdtPropertyFile () {
273+ /**
274+ * Create a basic FMW domain on PV using simplified feature.
275+ * User creates PV/PVC, operator creates RCU and domain
276+ * Verify Pod is ready and service exists for both admin server and managed servers.
277+ */
278+ @ Test
279+ @ DisplayName ("Create a FMW domainon on PV. User creates PV/PVC and operator creates RCU and domain" )
280+ void testUserCreatesPvPvcOperatorCreatesRcuDomain () {
281+ String domainUid = "jrfonpv-simplified2" ;
282+ final String pvName = getUniqueName (domainUid + "-pv-" );
283+ final String pvcName = getUniqueName (domainUid + "-pvc-" );
284+ final int t3ChannelPort = getNextFreePort ();
285+ final String wlSecretName = domainUid + "-weblogic-credentials" ;
286+ final String fmwModelFile = fmwModelFilePrefix + ".yaml" ;
287+
288+ // create FMW domain credential secret
289+ createSecretWithUsernamePassword (wlSecretName , domainNamespace ,
290+ ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
291+
292+ // create persistent volume and persistent volume claim for domain
293+ createPV (pvName , domainUid , this .getClass ().getSimpleName ());
294+ createPVC (pvName , pvcName , domainUid , domainNamespace );
295+
296+ // create a model property file
297+ File fmwModelPropFile = createWdtPropertyFile (domainUid , RCUSCHEMAPREFIX + "2" );
298+
299+ // create domainCreationImage
300+ String domainCreationImageName = DOMAIN_IMAGES_REPO + "jrf-domain-on-pv-image2" ;
301+ // create image with model and wdt installation files
302+ WitParams witParams =
303+ new WitParams ()
304+ .modelImageName (domainCreationImageName )
305+ .modelImageTag (MII_BASIC_IMAGE_TAG )
306+ .modelFiles (Collections .singletonList (MODEL_DIR + "/" + fmwModelFile ))
307+ .modelVariableFiles (Collections .singletonList (fmwModelPropFile .getAbsolutePath ()));
308+ createAndPushAuxiliaryImage (domainCreationImageName , MII_BASIC_IMAGE_TAG , witParams );
309+
310+ DomainCreationImage domainCreationImage =
311+ new DomainCreationImage ().image (domainCreationImageName + ":" + MII_BASIC_IMAGE_TAG );
312+
313+ // create opss wallet password secret
314+ String opsswalletpassSecretName = domainUid + "-opss-wallet-password-secret" ;
315+ logger .info ("Create OPSS wallet password secret" );
316+ assertDoesNotThrow (() -> createOpsswalletpasswordSecret (
317+ opsswalletpassSecretName ,
318+ domainNamespace ,
319+ ADMIN_PASSWORD_DEFAULT ),
320+ String .format ("createSecret failed for %s" , opsswalletpassSecretName ));
321+
322+ // create a domain resource
323+ logger .info ("Creating domain custom resource" );
324+ Configuration configuration =
325+ new Configuration ()
326+ .initializeDomainOnPV (new InitializeDomainOnPV ()
327+ .domain (new DomainOnPV ()
328+ .createMode (CreateIfNotExists .DOMAIN_AND_RCU )
329+ .domainCreationImages (Collections .singletonList (domainCreationImage ))
330+ .domainType (DomainOnPVType .JRF )
331+ .opss (new Opss ()
332+ .walletPasswordSecret (opsswalletpassSecretName ))));
333+
334+ DomainResource domain = createDomainResourceOnPv (
335+ domainUid ,
336+ domainNamespace ,
337+ wlSecretName ,
338+ clusterName ,
339+ pvName ,
340+ pvcName ,
341+ DOMAINHOMEPREFIX ,
342+ replicaCount ,
343+ t3ChannelPort ,
344+ configuration );
345+
346+ // Set the inter-pod anti-affinity for the domain custom resource
347+ setPodAntiAffinity (domain );
348+
349+ // create a domain custom resource and verify domain is created
350+ createDomainAndVerify (domain , domainNamespace );
351+
352+ // verify that all servers are ready
353+ verifyDomainReady (domainNamespace , domainUid , replicaCount , "nosuffix" );
354+
355+ // delete the domain
356+ deleteDomainResource (domainNamespace , domainUid );
357+ // delete the cluster
358+ deleteClusterCustomResourceAndVerify (domainUid + "-" + clusterName , domainNamespace );
359+ }
360+
361+ private File createWdtPropertyFile (String domainName , String rcuSchemaPrefix ) {
234362
235363 // create property file used with domain model file
236364 Properties p = new Properties ();
237365 p .setProperty ("rcuDb" , dbUrl );
238- p .setProperty ("rcuSchemaPrefix" , RCUSCHEMAPREFIX );
366+ p .setProperty ("rcuSchemaPrefix" , rcuSchemaPrefix );
239367 p .setProperty ("rcuSchemaPassword" , RCUSCHEMAPASSWORD );
240368 p .setProperty ("rcuSysPassword" , RCUSYSPASSWORD );
241369 p .setProperty ("adminUsername" , ADMIN_USERNAME_DEFAULT );
242370 p .setProperty ("adminPassword" , ADMIN_PASSWORD_DEFAULT );
371+ p .setProperty ("domainName" , domainName );
243372
244373 // create a model property file
245374 File domainPropertiesFile = assertDoesNotThrow (() ->
@@ -263,14 +392,7 @@ private DomainResource createDomainResourceOnPv(String domainUid,
263392 String domainInHomePrefix ,
264393 int replicaCount ,
265394 int t3ChannelPort ,
266- List <DomainCreationImage > domainCreationImages ,
267- String walletPasswordSecret ) {
268-
269- Map <String , Quantity > pvCapacity = new HashMap <>();
270- pvCapacity .put ("storage" , new Quantity ("10Gi" ));
271-
272- Map <String , Quantity > pvcRequest = new HashMap <>();
273- pvcRequest .put ("storage" , new Quantity ("10Gi" ));
395+ Configuration configuration ) {
274396
275397 // create a domain custom resource configuration object
276398 DomainResource domain = new DomainResource ()
@@ -319,38 +441,16 @@ private DomainResource createDomainResourceOnPv(String domainUid,
319441 .addChannelsItem (new Channel ()
320442 .channelName ("T3Channel" )
321443 .nodePort (t3ChannelPort ))))
322- .configuration (new Configuration ()
323- .initializeDomainOnPV (new InitializeDomainOnPV ()
324- .persistentVolume (new PersistentVolume ()
325- .metadata (new V1ObjectMeta ()
326- .name (pvName ))
327- .spec (new PersistentVolumeSpec ()
328- .storageClassName (storageClassName )
329- .capacity (pvCapacity )
330- .persistentVolumeReclaimPolicy ("Retain" )
331- .hostPath (new V1HostPathVolumeSource ()
332- .path (getHostPath (pvName , this .getClass ().getSimpleName ())))))
333- .persistentVolumeClaim (new PersistentVolumeClaim ()
334- .metadata (new V1ObjectMeta ()
335- .name (pvcName ))
336- .spec (new PersistentVolumeClaimSpec ()
337- .storageClassName (storageClassName )
338- .resources (new V1ResourceRequirements ()
339- .requests (pvcRequest ))))
340- .domain (new DomainOnPV ()
341- .createMode (CreateIfNotExists .DOMAIN_AND_RCU )
342- .domainCreationImages (domainCreationImages )
343- .domainType (DomainOnPVType .JRF )
344- .opss (new Opss ()
345- .walletPasswordSecret (walletPasswordSecret ))))));
444+ .configuration (configuration ));
346445
347446 // create cluster resource for the domain
348- if (!Cluster .doesClusterExist (clusterName , CLUSTER_VERSION , domainNamespace )) {
349- ClusterResource cluster = createClusterResource (clusterName ,
447+ String clusterResName = domainUid + "-" + clusterName ;
448+ if (!Cluster .doesClusterExist (clusterResName , CLUSTER_VERSION , domainNamespace )) {
449+ ClusterResource cluster = createClusterResource (clusterResName ,
350450 clusterName , domainNamespace , replicaCount );
351451 createClusterAndVerify (cluster );
352452 }
353- domain .getSpec ().withCluster (new V1LocalObjectReference ().name (clusterName ));
453+ domain .getSpec ().withCluster (new V1LocalObjectReference ().name (clusterResName ));
354454
355455 return domain ;
356456 }
0 commit comments