@@ -52,17 +52,13 @@ public class Domain {
52
52
private String clusterName ;
53
53
private String clusterType ;
54
54
private String serverStartPolicy ;
55
- private String weblogicDomainStorageReclaimPolicy ;
56
- private String weblogicDomainStorageSize ;
57
55
private String loadBalancer = "TRAEFIK" ;
58
56
private int loadBalancerWebPort = 30305 ;
59
57
private String domainHomeImageBuildPath = "" ;
60
58
private String userProjectsDir = "" ;
61
59
private String projectRoot = "" ;
62
60
private boolean ingressPerDomain = true ;
63
61
64
- private String createDomainScript = "" ;
65
- private String inputTemplateFile = "" ;
66
62
private String generatedInputYamlFile ;
67
63
68
64
private static int maxIterations = BaseTest .getMaxIterationsPod (); // 50 * 5 = 250 seconds
@@ -119,9 +115,7 @@ public void verifyPodsCreated() throws Exception {
119
115
logger .info ("Checking if admin pod(" + domainUid + "-" + adminServerName + ") is Running" );
120
116
TestUtils .checkPodCreated (domainUid + "-" + adminServerName , domainNS );
121
117
122
- if (domainMap .get ("serverStartPolicy" ) == null
123
- || (domainMap .get ("serverStartPolicy" ) != null
124
- && !domainMap .get ("serverStartPolicy" ).toString ().trim ().equals ("ADMIN_ONLY" ))) {
118
+ if (!serverStartPolicy .equals ("ADMIN_ONLY" )) {
125
119
// check managed server pods
126
120
for (int i = 1 ; i <= initialManagedServerReplicas ; i ++) {
127
121
logger .info (
@@ -155,9 +149,8 @@ public void verifyServicesCreated() throws Exception {
155
149
+ "-external) is created" );
156
150
TestUtils .checkServiceCreated (domainUid + "-" + adminServerName + "-external" , domainNS );
157
151
}
158
- if (domainMap .get ("serverStartPolicy" ) == null
159
- || (domainMap .get ("serverStartPolicy" ) != null
160
- && !domainMap .get ("serverStartPolicy" ).toString ().trim ().equals ("ADMIN_ONLY" ))) {
152
+
153
+ if (!serverStartPolicy .equals ("ADMIN_ONLY" )) {
161
154
// check managed server services
162
155
for (int i = 1 ; i <= initialManagedServerReplicas ; i ++) {
163
156
logger .info (
@@ -181,18 +174,15 @@ public void verifyServersReady() throws Exception {
181
174
// check admin pod
182
175
logger .info ("Checking if admin server is Running" );
183
176
TestUtils .checkPodReady (domainUid + "-" + adminServerName , domainNS );
184
- if (domainMap .get ("serverStartPolicy" ) == null
185
- || (domainMap .get ("serverStartPolicy" ) != null
186
- && !domainMap .get ("serverStartPolicy" ).toString ().trim ().equals ("ADMIN_ONLY" ))) {
187
177
178
+ if (!serverStartPolicy .equals ("ADMIN_ONLY" )) {
188
179
// check managed server pods
189
180
for (int i = 1 ; i <= initialManagedServerReplicas ; i ++) {
190
181
logger .info ("Checking if managed server (" + managedServerNameBase + i + ") is Running" );
191
182
TestUtils .checkPodReady (domainUid + "-" + managedServerNameBase + i , domainNS );
192
183
}
193
- }
194
- // check no additional servers are started
195
- if (domainMap .get ("serverStartPolicy" ).toString ().trim ().equals ("ADMIN_ONLY" )) {
184
+ } else {
185
+ // check no additional servers are started
196
186
initialManagedServerReplicas = 0 ;
197
187
}
198
188
String additionalManagedServer =
@@ -824,6 +814,12 @@ private int getAdminSericeLBNodePort() throws Exception {
824
814
}
825
815
}
826
816
817
+ /**
818
+ * Create a map with attributes required to create PV and create PV dir by calling
819
+ * PersistentVolume
820
+ *
821
+ * @throws Exception
822
+ */
827
823
private void createPV () throws Exception {
828
824
829
825
Yaml yaml = new Yaml ();
@@ -850,10 +846,6 @@ private void createPV() throws Exception {
850
846
pvMap .put ("weblogicDomainStorageSize" , domainMap .get ("weblogicDomainStorageSize" ));
851
847
}
852
848
pvMap .put ("namespace" , domainNS );
853
-
854
- weblogicDomainStorageReclaimPolicy = (String ) pvMap .get ("weblogicDomainStorageReclaimPolicy" );
855
- weblogicDomainStorageSize = (String ) pvMap .get ("weblogicDomainStorageSize" );
856
-
857
849
pvMap .put ("weblogicDomainStorageNFSServer" , TestUtils .getHostName ());
858
850
859
851
// set pv path
@@ -946,9 +938,7 @@ public void verifyAdminServerRestarted() throws Exception {
946
938
* @throws Exception
947
939
*/
948
940
public void verifyManagedServersRestarted () throws Exception {
949
- if (domainMap .get ("serverStartPolicy" ) == null
950
- || (domainMap .get ("serverStartPolicy" ) != null
951
- && !domainMap .get ("serverStartPolicy" ).toString ().trim ().equals ("ADMIN_ONLY" ))) {
941
+ if (!serverStartPolicy .equals ("ADMIN_ONLY" )) {
952
942
// check managed server pods
953
943
for (int i = 1 ; i <= initialManagedServerReplicas ; i ++) {
954
944
logger .info (
@@ -972,6 +962,11 @@ public void verifyManagedServersRestarted() throws Exception {
972
962
}
973
963
}
974
964
965
+ /**
966
+ * create secret
967
+ *
968
+ * @throws Exception
969
+ */
975
970
private void createSecret () throws Exception {
976
971
Secret secret =
977
972
new Secret (
@@ -996,13 +991,25 @@ private void createSecret() throws Exception {
996
991
}
997
992
}
998
993
994
+ /**
995
+ * Generate domain values yaml using the doamin map
996
+ *
997
+ * @throws Exception
998
+ */
999
999
private void generateInputYaml () throws Exception {
1000
1000
Path parentDir =
1001
1001
Files .createDirectories (Paths .get (userProjectsDir + "/weblogic-domains/" + domainUid ));
1002
1002
generatedInputYamlFile = parentDir + "/weblogic-domain-values.yaml" ;
1003
1003
TestUtils .createInputFile (domainMap , generatedInputYamlFile );
1004
1004
}
1005
1005
1006
+ /**
1007
+ * copy create-domain.py if domain Map contains, git clone docker-images for domain in image and
1008
+ * call create-domain.sh script based on the domain type. Append configOverrides to domain.yaml.
1009
+ *
1010
+ * @param outputDir
1011
+ * @throws Exception
1012
+ */
1006
1013
private void callCreateDomainScript (String outputDir ) throws Exception {
1007
1014
1008
1015
// call different create domain script based on the domain type
@@ -1233,6 +1240,13 @@ private void callWebAppAndCheckForServerNameInResponse(
1233
1240
}
1234
1241
}
1235
1242
1243
+ /**
1244
+ * Reads the create-domain-inputs.yaml from samples and overrides with attribute in input domain
1245
+ * map. Initializes the variables for the attributes in the map to be used later.
1246
+ *
1247
+ * @param inputDomainMap
1248
+ * @throws Exception
1249
+ */
1236
1250
private void initialize (Map <String , Object > inputDomainMap ) throws Exception {
1237
1251
domainMap = inputDomainMap ;
1238
1252
this .userProjectsDir = BaseTest .getUserProjectsDir ();
@@ -1281,8 +1295,8 @@ private void initialize(Map<String, Object> inputDomainMap) throws Exception {
1281
1295
exposeAdminNodePort = ((Boolean ) domainMap .get ("exposeAdminNodePort" )).booleanValue ();
1282
1296
t3ChannelPort = ((Integer ) domainMap .get ("t3ChannelPort" )).intValue ();
1283
1297
clusterName = (String ) domainMap .get ("clusterName" );
1284
- clusterType = (String ) domainMap .get ("clusterType" );
1285
- serverStartPolicy = (String ) domainMap .get ("serverStartPolicy" );
1298
+ clusterType = (String ) domainMap .getOrDefault ("clusterType" , "DYNAMIC " );
1299
+ serverStartPolicy = (( String ) domainMap .get ("serverStartPolicy" )). trim ( );
1286
1300
1287
1301
if (exposeAdminT3Channel ) {
1288
1302
domainMap .put ("t3PublicAddress" , TestUtils .getHostName ());
@@ -1329,58 +1343,7 @@ private void initialize(Map<String, Object> inputDomainMap) throws Exception {
1329
1343
domainMap .values ().removeIf (Objects ::isNull );
1330
1344
1331
1345
// create config map and secret for custom sit config
1332
- if ((domainMap .get ("configOverrides" ) != null )
1333
- && (domainMap .get ("configOverridesFile" ) != null )) {
1334
- // write hostname in config file for public address
1335
-
1336
- String configOverridesFile = domainMap .get ("configOverridesFile" ).toString ();
1337
-
1338
- String cmd =
1339
- "kubectl -n "
1340
- + domainNS
1341
- + " create cm "
1342
- + domainUid
1343
- + "-"
1344
- + domainMap .get ("configOverrides" )
1345
- + " --from-file "
1346
- + configOverridesFile ;
1347
- ExecResult result = ExecCommand .exec (cmd );
1348
- if (result .exitValue () != 0 ) {
1349
- throw new RuntimeException (
1350
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
1351
- }
1352
- cmd =
1353
- "kubectl -n "
1354
- + domainNS
1355
- + " label cm "
1356
- + domainUid
1357
- + "-"
1358
- + domainMap .get ("configOverrides" )
1359
- + " weblogic.domainUID="
1360
- + domainUid ;
1361
- result = ExecCommand .exec (cmd );
1362
- if (result .exitValue () != 0 ) {
1363
- throw new RuntimeException (
1364
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
1365
- }
1366
- // create secret for custom sit config t3 public address
1367
- // create datasource secret for user and password
1368
- cmd =
1369
- "kubectl -n "
1370
- + domainNS
1371
- + " create secret generic "
1372
- + domainUid
1373
- + "-test-secrets"
1374
- + " --from-literal=hostname="
1375
- + TestUtils .getHostName ()
1376
- + " --from-literal=dbusername=root"
1377
- + " --from-literal=dbpassword=root123" ;
1378
- result = ExecCommand .exec (cmd );
1379
- if (result .exitValue () != 0 ) {
1380
- throw new RuntimeException (
1381
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
1382
- }
1383
- }
1346
+ createConfigMapAndSecretForSitConfig ();
1384
1347
}
1385
1348
1386
1349
private String getNodeHost () throws Exception {
@@ -1433,6 +1396,11 @@ private String getNodePort() throws Exception {
1433
1396
}
1434
1397
}
1435
1398
1399
+ /**
1400
+ * clone docker-images sample
1401
+ *
1402
+ * @throws Exception
1403
+ */
1436
1404
private void gitCloneDockerImagesSample () throws Exception {
1437
1405
if (!domainHomeImageBuildPath .isEmpty ()) {
1438
1406
StringBuffer removeAndClone = new StringBuffer ();
@@ -1466,6 +1434,11 @@ private void gitCloneDockerImagesSample() throws Exception {
1466
1434
}
1467
1435
}
1468
1436
1437
+ /**
1438
+ * append configOverrides to domain.yaml
1439
+ *
1440
+ * @throws Exception
1441
+ */
1469
1442
private void appendToDomainYamlAndCreate () throws Exception {
1470
1443
String contentToAppend =
1471
1444
" configOverrides: "
@@ -1584,8 +1557,7 @@ private void changeClusterTypeInCreateDomainJobTemplate() throws Exception {
1584
1557
1585
1558
// change CLUSTER_TYPE to CONFIGURED in create-domain-job-template.yaml for configured cluster
1586
1559
// as samples only support DYNAMIC cluster
1587
- if (domainMap .containsKey ("clusterType" )
1588
- && domainMap .get ("clusterType" ).toString ().equalsIgnoreCase ("CONFIGURED" )) {
1560
+ if (clusterType .equalsIgnoreCase ("CONFIGURED" )) {
1589
1561
1590
1562
// domain in image
1591
1563
if (domainMap .containsKey ("domainHomeImageBase" )
@@ -1604,4 +1576,56 @@ private void changeClusterTypeInCreateDomainJobTemplate() throws Exception {
1604
1576
}
1605
1577
}
1606
1578
}
1579
+
1580
+ /**
1581
+ * create config map and secret for custom situational configuration
1582
+ *
1583
+ * @throws Exception
1584
+ */
1585
+ private void createConfigMapAndSecretForSitConfig () throws Exception {
1586
+
1587
+ if ((domainMap .get ("configOverrides" ) != null )
1588
+ && (domainMap .get ("configOverridesFile" ) != null )) {
1589
+ // write hostname in config file for public address
1590
+ String configOverridesFile = domainMap .get ("configOverridesFile" ).toString ();
1591
+
1592
+ // create configmap
1593
+ String cmd =
1594
+ "kubectl -n "
1595
+ + domainNS
1596
+ + " create cm "
1597
+ + domainUid
1598
+ + "-"
1599
+ + domainMap .get ("configOverrides" )
1600
+ + " --from-file "
1601
+ + configOverridesFile ;
1602
+ TestUtils .exec (cmd );
1603
+
1604
+ // create label for configmap
1605
+ cmd =
1606
+ "kubectl -n "
1607
+ + domainNS
1608
+ + " label cm "
1609
+ + domainUid
1610
+ + "-"
1611
+ + domainMap .get ("configOverrides" )
1612
+ + " weblogic.domainUID="
1613
+ + domainUid ;
1614
+ TestUtils .exec (cmd );
1615
+
1616
+ // create secret for custom sit config t3 public address
1617
+ // create datasource secret for user and password
1618
+ cmd =
1619
+ "kubectl -n "
1620
+ + domainNS
1621
+ + " create secret generic "
1622
+ + domainUid
1623
+ + "-test-secrets"
1624
+ + " --from-literal=hostname="
1625
+ + TestUtils .getHostName ()
1626
+ + " --from-literal=dbusername=root"
1627
+ + " --from-literal=dbpassword=root123" ;
1628
+ TestUtils .exec (cmd );
1629
+ }
1630
+ }
1607
1631
}
0 commit comments