Skip to content

Commit 84c3dff

Browse files
authored
Merge pull request #540 from oracle/chshi-OWLS-67963-upd-del-sh
OWLS-67963: Update delete-weblogic-domain-resources.sh
2 parents 6fcb36e + 09932c2 commit 84c3dff

File tree

11 files changed

+578
-80
lines changed

11 files changed

+578
-80
lines changed

integration-tests/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@
6666
<artifactId>snakeyaml</artifactId>
6767
<version>1.21</version>
6868
</dependency>
69-
</dependencies>
69+
<dependency>
70+
<groupId>io.kubernetes</groupId>
71+
<artifactId>client-java</artifactId>
72+
<scope>test</scope>
73+
</dependency>
74+
</dependencies>
7075

7176

7277
<profiles>

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class ITOperator extends BaseTest {
2828
// property file used to customize operator properties for operator inputs yaml
2929
private static String op1YamlFile = "operator1.yaml";
3030
private static String op2YamlFile = "operator2.yaml";
31+
private static final String opForDelYamlFile1 = "operator_del1.yaml";
32+
private static final String opForDelYamlFile2 = "operator_del2.yaml";
3133

3234
// property file used to customize domain properties for domain inputs yaml
3335
private static String domain1YamlFile = "domain1.yaml";
@@ -38,6 +40,9 @@ public class ITOperator extends BaseTest {
3840
private static String domain6YamlFile = "domain6.yaml";
3941
private static String domain7YamlFile = "domain7.yaml";
4042
private static String domain8YamlFile = "domain8.yaml";
43+
private static final String domain1ForDelValueYamlFile = "domain_del_1.yaml";
44+
private static final String domain2ForDelValueYamlFile = "domain_del_2.yaml";
45+
private static final String domain3ForDelValueYamlFile = "domain_del_3.yaml";
4146
private static String domain9YamlFile = "domain9.yaml";
4247
private static String domain10YamlFile = "domain10.yaml";
4348

@@ -46,6 +51,9 @@ public class ITOperator extends BaseTest {
4651

4752
private static Operator operator1, operator2;
4853

54+
private static Operator operatorForDel1;
55+
private static Operator operatorForDel2;
56+
4957
/**
5058
* This method gets called only once before any of the test methods are executed. It does the
5159
* initialization of the integration test properties defined in OperatorIT.properties and setting
@@ -274,6 +282,50 @@ public void testBCreateDomainWithDefaultValuesInSampleInputs() throws Exception
274282
logger.info("SUCCESS - testBCreateDomainWithDefaultValuesInSampleInputs");
275283
}
276284

285+
@Test
286+
public void testDeleteOneDomain() throws Exception {
287+
Assume.assumeFalse(
288+
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
289+
logTestBegin("Deleting one domain.");
290+
291+
if (operatorForDel1 == null) {
292+
logger.info("About to create operator");
293+
operatorForDel1 = TestUtils.createOperator(opForDelYamlFile1);
294+
}
295+
final Domain domain = TestUtils.createDomain(domain1ForDelValueYamlFile);
296+
TestUtils.verifyBeforeDeletion(domain);
297+
298+
logger.info("About to delete domain: " + domain.getDomainUid());
299+
TestUtils.deleteWeblogicDomainResources(domain.getDomainUid());
300+
301+
TestUtils.verifyAfterDeletion(domain);
302+
}
303+
304+
@Test
305+
public void testDeleteTwoDomains() throws Exception {
306+
Assume.assumeFalse(
307+
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
308+
logTestBegin("Deleting two domains.");
309+
310+
if (operatorForDel2 == null) {
311+
logger.info("About to create operator");
312+
operatorForDel2 = TestUtils.createOperator(opForDelYamlFile2);
313+
}
314+
final Domain domainDel1 = TestUtils.createDomain(domain2ForDelValueYamlFile);
315+
final Domain domainDel2 = TestUtils.createDomain(domain3ForDelValueYamlFile);
316+
317+
TestUtils.verifyBeforeDeletion(domainDel1);
318+
TestUtils.verifyBeforeDeletion(domainDel2);
319+
320+
final String domainUidsToBeDeleted =
321+
domainDel1.getDomainUid() + "," + domainDel2.getDomainUid();
322+
logger.info("About to delete domains: " + domainUidsToBeDeleted);
323+
TestUtils.deleteWeblogicDomainResources(domainUidsToBeDeleted);
324+
325+
TestUtils.verifyAfterDeletion(domainDel1);
326+
TestUtils.verifyAfterDeletion(domainDel2);
327+
}
328+
277329
private void testCreateOperatorManagingDefaultAndTest1NS() throws Exception {
278330
logger.info("Creating Operator & waiting for the script to complete execution");
279331
// create operator1

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,27 @@ private void createPV() throws Exception {
636636
}
637637

638638
private void createSecret() throws Exception {
639-
new Secret(
640-
domainNS,
641-
domainMap.getOrDefault("secretName", domainUid + "-weblogic-credentials").toString(),
642-
BaseTest.getUsername(),
643-
BaseTest.getPassword());
644-
domainMap.put("weblogicCredentialsSecretName", domainUid + "-weblogic-credentials");
639+
Secret secret =
640+
new Secret(
641+
domainNS,
642+
domainMap.getOrDefault("secretName", domainUid + "-weblogic-credentials").toString(),
643+
BaseTest.getUsername(),
644+
BaseTest.getPassword());
645+
domainMap.put("weblogicCredentialsSecretName", secret.getSecretName());
646+
final String labelCmd =
647+
String.format(
648+
"kubectl label secret %s weblogic.domainUID=%s -n %s",
649+
secret.getSecretName(), domainUid, domainNS);
650+
ExecResult result = ExecCommand.exec(labelCmd);
651+
if (result.exitValue() != 0) {
652+
throw new RuntimeException(
653+
"FAILURE: command to label secret \""
654+
+ labelCmd
655+
+ "\" failed, returned "
656+
+ result.stdout()
657+
+ "\n"
658+
+ result.stderr());
659+
}
645660
}
646661

647662
private void generateInputYaml() throws Exception {

0 commit comments

Comments
 (0)