Skip to content

Commit 2467fb0

Browse files
committed
leave domain running for a failed standalone run
1 parent d9a3e6f commit 2467fb0

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ITOperator.java

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,22 @@ public void test1CreateFirstOperatorAndDomain() throws Exception {
125125

126126
logTestBegin("test1CreateFirstOperatorAndDomain");
127127
logger.info("Creating Operator & waiting for the script to complete execution");
128-
Domain domain1 = null;
129128
// create operator1
130129
operator1 = TestUtils.createOperator(op1YamlFile);
130+
Domain domain1 = null;
131+
boolean testCompletedSuccessfully = false;
131132
try {
132133
domain1 = testDomainCreation(domain1YamlFile);
133134
domain1.verifyDomainCreated();
134135
testBasicUseCases(domain1);
135136
testAdvancedUseCasesForADomain(operator1, domain1);
136137

137138
if (!SMOKETEST) domain1.testWlsLivenessProbe();
139+
testCompletedSuccessfully = true;
138140
} finally {
139141

140-
if (domain1 != null && JENKINS) domain1.shutdownUsingServerStartPolicy();
142+
if (domain1 != null && (JENKINS || testCompletedSuccessfully))
143+
domain1.shutdownUsingServerStartPolicy();
141144
}
142145

143146
logger.info("SUCCESS - test1CreateFirstOperatorAndDomain");
@@ -150,7 +153,7 @@ public void test2CreateAnotherDomainInDefaultNS() throws Exception {
150153
logTestBegin("test2CreateAnotherDomainInDefaultNS");
151154
logger.info("Creating Domain domain2 & verifing the domain creation");
152155
Domain domain2 = null;
153-
156+
boolean testCompletedSuccessfully = false;
154157
if (operator1 == null) {
155158
operator1 = TestUtils.createOperator(op1YamlFile);
156159
}
@@ -159,8 +162,9 @@ public void test2CreateAnotherDomainInDefaultNS() throws Exception {
159162
domain2 = testDomainCreation(domain2YamlFile);
160163
domain2.verifyDomainCreated();
161164
testBasicUseCases(domain2);
165+
testCompletedSuccessfully = true;
162166
} finally {
163-
if (domain2 != null && JENKINS) {
167+
if (domain2 != null && (JENKINS || testCompletedSuccessfully)) {
164168
logger.info("Destroy domain2");
165169
domain2.destroy();
166170
}
@@ -178,14 +182,16 @@ public void test3CreateDomainInTest1NS() throws Exception {
178182
operator1 = TestUtils.createOperator(op1YamlFile);
179183
}
180184
Domain domain3 = null;
185+
boolean testCompletedSuccessfully = false;
181186
try {
182187
// create domain3
183188
domain3 = testDomainCreation(domain3YamlFile);
184189
domain3.verifyDomainCreated();
185190
testBasicUseCases(domain3);
186191
testWLDFScaling(operator1, domain3);
192+
testCompletedSuccessfully = true;
187193
} finally {
188-
if (domain3 != null && JENKINS) {
194+
if (domain3 != null && (JENKINS || testCompletedSuccessfully)) {
189195
domain3.destroy();
190196
}
191197
}
@@ -217,7 +223,7 @@ public void test5CreateConfiguredDomainInTest2NS() throws Exception {
217223
}
218224

219225
Domain domain4 = null, domain5 = null;
220-
226+
boolean testCompletedSuccessfully = false;
221227
try {
222228
domain4 = testDomainCreation(domain4YamlFile);
223229
domain4.verifyDomainCreated();
@@ -244,12 +250,13 @@ public void test5CreateConfiguredDomainInTest2NS() throws Exception {
244250

245251
logger.info("Verify no impact on domain5");
246252
domain5.verifyDomainCreated();
253+
testCompletedSuccessfully = true;
247254
logger.info("SUCCESS - test5CreateConfiguredDomainInTest2NS");
248255
} finally {
249-
if (domain4 != null && JENKINS) {
256+
if (domain4 != null && (JENKINS || testCompletedSuccessfully)) {
250257
domain4.destroy();
251258
}
252-
if (domain5 != null && JENKINS) {
259+
if (domain5 != null && (JENKINS || testCompletedSuccessfully)) {
253260
domain5.destroy();
254261
}
255262
}
@@ -267,12 +274,13 @@ public void test6CreateDomainWithStartPolicyAdminOnly() throws Exception {
267274
logger.info("Creating Domain domain6 & verifing the domain creation");
268275
// create domain6
269276
Domain domain6 = null;
270-
277+
boolean testCompletedSuccessfully = false;
271278
try {
272279
domain6 = testDomainCreation(domain6YamlFile);
273280
domain6.verifyDomainCreated();
281+
testCompletedSuccessfully = true;
274282
} finally {
275-
if (domain6 != null && JENKINS) domain6.destroy();
283+
if (domain6 != null && (JENKINS || testCompletedSuccessfully)) domain6.destroy();
276284
}
277285

278286
logger.info("SUCCESS - test6CreateDomainWithStartPolicyAdminOnly");
@@ -290,6 +298,7 @@ public void test7CreateDomainPVReclaimPolicyRecycle() throws Exception {
290298
logger.info("Creating Domain domain7 & verifing the domain creation");
291299
// create domain7
292300
Domain domain7 = null;
301+
293302
try {
294303
domain7 = testDomainCreation(domain7YamlFile);
295304
domain7.verifyDomainCreated();
@@ -315,7 +324,7 @@ public void test8CreateDomainOnExistingDir() throws Exception {
315324
domain8 = testDomainCreation(domain8YamlFile);
316325
domain8.verifyDomainCreated();
317326
} finally {
318-
if (domain8 != null && JENKINS) {
327+
if (domain8 != null) {
319328
// create domain on existing dir
320329
domain8.destroy();
321330
}
@@ -334,15 +343,16 @@ public void testACreateDomainApacheLB() throws Exception {
334343
if (operator1 == null) {
335344
operator1 = TestUtils.createOperator(op1YamlFile);
336345
}
337-
346+
boolean testCompletedSuccessfully = false;
338347
// create domain9
339348
Domain domain9 = null;
340349
try {
341350
domain9 = testDomainCreation(domain9YamlFile);
342351
domain9.verifyDomainCreated();
343352
domain9.verifyAdminConsoleViaLB();
353+
testCompletedSuccessfully = true;
344354
} finally {
345-
if (domain9 != null && JENKINS) domain9.destroy();
355+
if (domain9 != null && (JENKINS || testCompletedSuccessfully)) domain9.destroy();
346356
}
347357
logger.info("SUCCESS - testACreateDomainApacheLB");
348358
}
@@ -359,13 +369,15 @@ public void testBCreateDomainWithDefaultValuesInSampleInputs() throws Exception
359369

360370
// create domain10
361371
Domain domain10 = null;
372+
boolean testCompletedSuccessfully = false;
362373
try {
363374
domain10 = testDomainCreation(domain10YamlFile);
364375
domain10.verifyDomainCreated();
365376
testBasicUseCases(domain10);
366377
testAdvancedUseCasesForADomain(operator1, domain10);
378+
testCompletedSuccessfully = true;
367379
} finally {
368-
if (domain10 != null && JENKINS) domain10.destroy();
380+
if (domain10 != null && (JENKINS || testCompletedSuccessfully)) domain10.destroy();
369381
}
370382

371383
logger.info("SUCCESS - testBCreateDomainWithDefaultValuesInSampleInputs");
@@ -381,6 +393,7 @@ public void testDeleteOneDomain() throws Exception {
381393
operatorForDel1 = TestUtils.createOperator(opForDelYamlFile1);
382394
}
383395
Domain domain = null;
396+
boolean testCompletedSuccessfully = false;
384397
try {
385398
domain = testDomainCreation(domain1ForDelValueYamlFile);
386399
domain.verifyDomainCreated();
@@ -390,8 +403,9 @@ public void testDeleteOneDomain() throws Exception {
390403
TestUtils.deleteWeblogicDomainResources(domain.getDomainUid());
391404

392405
TestUtils.verifyAfterDeletion(domain);
406+
testCompletedSuccessfully = true;
393407
} finally {
394-
if (domain != null && JENKINS) domain.destroy();
408+
if (domain != null && (JENKINS || testCompletedSuccessfully)) domain.destroy();
395409
}
396410
logger.info("SUCCESS - testDeleteOneDomain");
397411
}
@@ -406,6 +420,7 @@ public void testDeleteTwoDomains() throws Exception {
406420
operatorForDel2 = TestUtils.createOperator(opForDelYamlFile2);
407421
}
408422
Domain domainDel1 = null, domainDel2 = null;
423+
boolean testCompletedSuccessfully = false;
409424
try {
410425
domainDel1 = testDomainCreation(domain2ForDelValueYamlFile);
411426
domainDel1.verifyDomainCreated();
@@ -422,9 +437,10 @@ public void testDeleteTwoDomains() throws Exception {
422437

423438
TestUtils.verifyAfterDeletion(domainDel1);
424439
TestUtils.verifyAfterDeletion(domainDel2);
440+
testCompletedSuccessfully = true;
425441
} finally {
426-
if (domainDel1 != null && JENKINS) domainDel1.destroy();
427-
if (domainDel2 != null && JENKINS) domainDel2.destroy();
442+
if (domainDel1 != null && (JENKINS || testCompletedSuccessfully)) domainDel1.destroy();
443+
if (domainDel2 != null && (JENKINS || testCompletedSuccessfully)) domainDel2.destroy();
428444
}
429445
logger.info("SUCCESS - testDeleteTwoDomains");
430446
}
@@ -438,12 +454,14 @@ public void testAutoSitConfigOverrides() throws Exception {
438454
operator1 = TestUtils.createOperator(op1YamlFile);
439455
}
440456
Domain domain11 = null;
457+
boolean testCompletedSuccessfully = false;
441458
try {
442459
// cp py
443460
copyCreateDomainScript();
444461
domain11 = testDomainCreation(domain11YamlFile);
445462
domain11.verifyDomainCreated();
446463
testBasicUseCases(domain11);
464+
testCompletedSuccessfully = true;
447465
logger.info("SUCCESS - testAutoSitConfigOverrides");
448466
} finally {
449467

@@ -457,7 +475,7 @@ public void testAutoSitConfigOverrides() throws Exception {
457475
throw new RuntimeException(cmd + " failed");
458476
}
459477

460-
if (domain11 != null && JENKINS) {
478+
if (domain11 != null && (JENKINS || testCompletedSuccessfully)) {
461479
domain11.destroy();
462480
}
463481
}

0 commit comments

Comments
 (0)