5
5
6
6
import static org .junit .Assert .assertTrue ;
7
7
8
- import java .io .IOException ;
9
- import java .nio .charset .StandardCharsets ;
10
8
import java .nio .file .Files ;
11
9
import java .nio .file .Paths ;
12
10
import java .nio .file .StandardCopyOption ;
13
11
import java .nio .file .StandardOpenOption ;
14
12
import java .util .Map ;
13
+ import java .util .logging .Level ;
15
14
import oracle .kubernetes .operator .utils .Domain ;
16
15
import oracle .kubernetes .operator .utils .K8sTestUtils ;
17
16
import oracle .kubernetes .operator .utils .Operator ;
@@ -34,7 +33,7 @@ public class ITMultipleClusters extends BaseTest {
34
33
private static final String TWO_CONFIGURED_CLUSTER_SCRIPT =
35
34
"create-domain-two-configured-cluster.py" ;
36
35
private static final String TWO_MIXED_CLUSTER_SCRIPT = "create-domain-two-mixed-cluster.py" ;
37
- private static String template ;
36
+ private static String customDomainTemplate ;
38
37
private static final String DOMAINUID = "twoconfigclustdomain" ;
39
38
40
39
/**
@@ -48,8 +47,16 @@ public class ITMultipleClusters extends BaseTest {
48
47
public static void staticPrepare () throws Exception {
49
48
// initialize test properties and create the directories
50
49
initialize (APP_PROPS_FILE );
51
- template =
50
+ String template =
52
51
BaseTest .getProjectRoot () + "/kubernetes/samples/scripts/common/domain-template.yaml" ;
52
+ String add =
53
+ " - clusterName: %CLUSTER_NAME%-2\n "
54
+ + " serverStartState: \" RUNNING\" \n "
55
+ + " replicas: %INITIAL_MANAGED_SERVER_REPLICAS%\n " ;
56
+ customDomainTemplate = BaseTest .getResultDir () + "/customDomainTemplate.yaml" ;
57
+ Files .copy (
58
+ Paths .get (template ), Paths .get (customDomainTemplate ), StandardCopyOption .REPLACE_EXISTING );
59
+ Files .write (Paths .get (customDomainTemplate ), add .getBytes (), StandardOpenOption .APPEND );
53
60
}
54
61
55
62
/**
@@ -89,6 +96,7 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
89
96
Map <String , Object > domainMap = TestUtils .loadYaml (DOMAINONPV_WLST_YAML );
90
97
domainMap .put ("domainUID" , DOMAINUID );
91
98
domainMap .put ("clusterType" , "CONFIGURED" );
99
+ domainMap .put ("customDomainTemplate" , customDomainTemplate );
92
100
domainMap .put (
93
101
"createDomainPyScript" ,
94
102
"integration-tests/src/test/resources/domain-home-on-pv/"
@@ -98,10 +106,17 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
98
106
&& ((String ) domainMap .get ("loadBalancer" )).equalsIgnoreCase ("VOYAGER" ))) {
99
107
domainMap .put ("voyagerWebPort" , new Integer ("30366" ));
100
108
}
101
- addCluster2ToDomainTemplate ();
102
109
domain = TestUtils .createDomain (domainMap );
103
110
domain .verifyDomainCreated ();
104
- verifyServersStatus (domain );
111
+ String pods [] = {
112
+ DOMAINUID + "-" + domain .getAdminServerName (),
113
+ DOMAINUID + "-managed-server" ,
114
+ DOMAINUID + "-managed-server1" ,
115
+ DOMAINUID + "-managed-server2" ,
116
+ DOMAINUID + "-new-managed-server1" ,
117
+ DOMAINUID + "-new-managed-server2" ,
118
+ };
119
+ verifyServersStatus (domain , pods );
105
120
testBasicUseCases (domain );
106
121
if (!SMOKETEST ) {
107
122
domain .testWlsLivenessProbe ();
@@ -111,7 +126,6 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
111
126
if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully )) {
112
127
domain .destroy ();
113
128
}
114
- restoreDomainTemplate ();
115
129
}
116
130
logger .info ("SUCCESS - " + testMethodName );
117
131
}
@@ -138,6 +152,7 @@ public void testCreateDomainTwoMixedCluster() throws Exception {
138
152
try {
139
153
Map <String , Object > domainMap = TestUtils .loadYaml (DOMAINONPV_WLST_YAML );
140
154
domainMap .put ("domainUID" , DOMAINUID );
155
+ domainMap .put ("customDomainTemplate" , customDomainTemplate );
141
156
domainMap .put (
142
157
"createDomainPyScript" ,
143
158
"integration-tests/src/test/resources/domain-home-on-pv/" + TWO_MIXED_CLUSTER_SCRIPT );
@@ -146,10 +161,18 @@ public void testCreateDomainTwoMixedCluster() throws Exception {
146
161
&& ((String ) domainMap .get ("loadBalancer" )).equalsIgnoreCase ("VOYAGER" ))) {
147
162
domainMap .put ("voyagerWebPort" , new Integer ("30377" ));
148
163
}
149
- addCluster2ToDomainTemplate ();
150
164
domain = TestUtils .createDomain (domainMap );
151
165
domain .verifyDomainCreated ();
152
- verifyServersStatus (domain );
166
+ String pods [] = {
167
+ DOMAINUID + "-" + domain .getAdminServerName (),
168
+ DOMAINUID + "-managed-server" ,
169
+ DOMAINUID + "-managed-server1" ,
170
+ DOMAINUID + "-managed-server2" ,
171
+ DOMAINUID + "-new-managed-server1" ,
172
+ DOMAINUID + "-new-managed-server2" ,
173
+ };
174
+ verifyServersStatus (domain , pods );
175
+
153
176
testBasicUseCases (domain );
154
177
if (!SMOKETEST ) {
155
178
domain .testWlsLivenessProbe ();
@@ -159,58 +182,73 @@ public void testCreateDomainTwoMixedCluster() throws Exception {
159
182
if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully )) {
160
183
domain .destroy ();
161
184
}
162
- restoreDomainTemplate ();
163
185
}
164
186
logger .info ("SUCCESS - " + testMethodName );
165
187
}
166
188
167
189
/**
168
- * Append a second cluster to the domain template
190
+ * Create 2 dynamic clusters in a domain using WDT in inimage each having 2 managed servers.
191
+ * Verify the managed servers are running and verify the basic use cases.
169
192
*
170
- * @throws IOException when append fails
193
+ * @throws Exception
171
194
*/
172
- private void addCluster2ToDomainTemplate () throws IOException {
173
- String add =
174
- " - clusterName: %CLUSTER_NAME%-2 \n "
175
- + " serverStartState: \" RUNNING \" \n "
176
- + " replicas: %INITIAL_MANAGED_SERVER_REPLICAS% \n " ;
177
- logger .info ("Making a backup of the domain template file:" + template );
178
- if (! Files . exists ( Paths . get ( template + ".org" )) ) {
179
- Files . copy ( Paths . get ( template ), Paths . get ( template + ".org" ) );
195
+ @ Test
196
+ public void testCreateDomainTwoClusterWDTInImage () throws Exception {
197
+ String DOMAINUID = "twoclusterdomainwdt" ;
198
+ String testMethodName = new Object () {}. getClass (). getEnclosingMethod (). getName ();
199
+ logTestBegin ( testMethodName ) ;
200
+ logger .info ("Creating Operator & waiting for the script to complete execution" );
201
+ if (operator1 == null ) {
202
+ operator1 = TestUtils . createOperator ( OPERATOR1_YAML );
180
203
}
181
- Files .write (Paths .get (template ), add .getBytes (), StandardOpenOption .APPEND );
182
- byte [] readAllBytes = Files .readAllBytes (Paths .get (template ));
183
- logger .info (new String (readAllBytes , StandardCharsets .UTF_8 ));
184
- }
185
-
186
- /**
187
- * Restore the domain template to original state when test is finished
188
- *
189
- * @throws IOException
190
- */
191
- private void restoreDomainTemplate () throws IOException {
192
- Files .copy (
193
- Paths .get (template + ".org" ), Paths .get (template ), StandardCopyOption .REPLACE_EXISTING );
194
- Files .delete (Paths .get (template + ".org" ));
204
+ Domain domain = null ;
205
+ boolean testCompletedSuccessfully = false ;
206
+ try {
207
+ Map <String , Object > domainMap = TestUtils .loadYaml (DOMAININIMAGE_WDT_YAML );
208
+ domainMap .put ("domainUID" , DOMAINUID );
209
+ domainMap .put ("customDomainTemplate" , customDomainTemplate );
210
+ if ((System .getenv ("LB_TYPE" ) != null && System .getenv ("LB_TYPE" ).equalsIgnoreCase ("VOYAGER" ))
211
+ || (domainMap .containsKey ("loadBalancer" )
212
+ && ((String ) domainMap .get ("loadBalancer" )).equalsIgnoreCase ("VOYAGER" ))) {
213
+ domainMap .put ("voyagerWebPort" , new Integer ("30377" ));
214
+ }
215
+ domainMap .put (
216
+ "customWdtTemplate" ,
217
+ BaseTest .getProjectRoot ()
218
+ + "/integration-tests/src/test/resources/multipleclusters/wdtmultipledynclusters.yml" );
219
+ domain = TestUtils .createDomain (domainMap );
220
+ domain .verifyDomainCreated ();
221
+ String pods [] = {
222
+ DOMAINUID + "-" + domain .getAdminServerName (),
223
+ DOMAINUID + "-managed-server1" ,
224
+ DOMAINUID + "-managed-server2" ,
225
+ DOMAINUID + "-managed-server-21" ,
226
+ DOMAINUID + "-managed-server-22" ,
227
+ };
228
+ verifyServersStatus (domain , pods );
229
+ testBasicUseCases (domain );
230
+ if (!SMOKETEST ) {
231
+ domain .testWlsLivenessProbe ();
232
+ }
233
+ testCompletedSuccessfully = true ;
234
+ } finally {
235
+ if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully )) {
236
+ domain .destroy ();
237
+ }
238
+ }
239
+ logger .log (Level .INFO , "SUCCESS - {0}" , testMethodName );
195
240
}
196
241
197
242
/**
198
243
* Verifies all of the servers in the cluster are in Running status
199
244
*
200
245
* @param Domain
246
+ * @param String array pod names to check the status for
201
247
*/
202
- private void verifyServersStatus (Domain domain ) {
248
+ private void verifyServersStatus (Domain domain , String [] pods ) {
203
249
K8sTestUtils testUtil = new K8sTestUtils ();
204
250
String domain1LabelSelector = String .format ("weblogic.domainUID in (%s)" , DOMAINUID );
205
251
String namespace = domain .getDomainNS ();
206
- String pods [] = {
207
- DOMAINUID + "-" + domain .getAdminServerName (),
208
- DOMAINUID + "-managed-server" ,
209
- DOMAINUID + "-managed-server1" ,
210
- DOMAINUID + "-managed-server2" ,
211
- DOMAINUID + "-new-managed-server1" ,
212
- DOMAINUID + "-new-managed-server2" ,
213
- };
214
252
for (String pod : pods ) {
215
253
assertTrue (
216
254
pod + " Pod not running" , testUtil .isPodRunning (namespace , domain1LabelSelector , pod ));
0 commit comments