Skip to content

Commit b33832c

Browse files
committed
Updated to use two different operators for the two testcases.
1 parent ed7704d commit b33832c

File tree

7 files changed

+83
-66
lines changed

7 files changed

+83
-66
lines changed

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

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

3435
// property file used to customize domain properties for domain inputs yaml
3536
private static String domain1YamlFile = "domain1.yaml";
@@ -50,7 +51,8 @@ public class ITOperator extends BaseTest {
5051
private static Operator operator1, operator2;
5152
private static Domain domain1;
5253

53-
private static Operator operatorForDel;
54+
private static Operator operatorForDel1;
55+
private static Operator operatorForDel2;
5456

5557
private K8sTestUtils k8sTestUtils = new K8sTestUtils();
5658

@@ -298,9 +300,9 @@ public void testBCreateDomainWithDefaultValuesInSampleInputs() throws Exception
298300
public void testDeleteOneDomain() throws Exception {
299301
logTestBegin("Deleting one domain.");
300302

301-
if (operatorForDel == null) {
303+
if (operatorForDel1 == null) {
302304
logger.info("About to create operator");
303-
operatorForDel = TestUtils.createOperator(opForDelYamlFile);
305+
operatorForDel1 = TestUtils.createOperator(opForDelYamlFile1);
304306
}
305307
final Domain domain = TestUtils.createDomain(domain1ForDelValueYamlFile);
306308
verifyBeforeDeletion(domain);
@@ -315,9 +317,9 @@ public void testDeleteOneDomain() throws Exception {
315317
public void testDeleteTwoDomains() throws Exception {
316318
logTestBegin("Deleting two domains.");
317319

318-
if (operatorForDel == null) {
320+
if (operatorForDel2 == null) {
319321
logger.info("About to create operator");
320-
operatorForDel = TestUtils.createOperator(opForDelYamlFile);
322+
operatorForDel2 = TestUtils.createOperator(opForDelYamlFile2);
321323
}
322324
final Domain domainDel1 = TestUtils.createDomain(domain2ForDelValueYamlFile);
323325
final Domain domainDel2 = TestUtils.createDomain(domain3ForDelValueYamlFile);

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
@@ -585,12 +585,27 @@ private void createPV() throws Exception {
585585
}
586586

587587
private void createSecret() throws Exception {
588-
new Secret(
589-
domainNS,
590-
domainMap.getOrDefault("secretName", domainUid + "-weblogic-credentials").toString(),
591-
BaseTest.getUsername(),
592-
BaseTest.getPassword());
593-
domainMap.put("weblogicCredentialsSecretName", domainUid + "-weblogic-credentials");
588+
Secret secret =
589+
new Secret(
590+
domainNS,
591+
domainMap.getOrDefault("secretName", domainUid + "-weblogic-credentials").toString(),
592+
BaseTest.getUsername(),
593+
BaseTest.getPassword());
594+
domainMap.put("weblogicCredentialsSecretName", secret.getSecretName());
595+
final String labelCmd =
596+
String.format(
597+
"kubectl label secret %s weblogic.domainUID=%s -n %s",
598+
secret.getSecretName(), domainUid, domainNS);
599+
ExecResult result = ExecCommand.exec(labelCmd);
600+
if (result.exitValue() != 0) {
601+
throw new RuntimeException(
602+
"FAILURE: command to label secret \""
603+
+ labelCmd
604+
+ "\" failed, returned "
605+
+ result.stdout()
606+
+ "\n"
607+
+ result.stderr());
608+
}
594609
}
595610

596611
private void generateInputYaml() throws Exception {

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

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
import io.kubernetes.client.models.V1ClusterRoleBindingList;
1717
import io.kubernetes.client.models.V1ClusterRoleList;
1818
import io.kubernetes.client.models.V1ConfigMapList;
19+
import io.kubernetes.client.models.V1DeploymentList;
1920
import io.kubernetes.client.models.V1JobList;
2021
import io.kubernetes.client.models.V1PersistentVolumeClaimList;
2122
import io.kubernetes.client.models.V1PersistentVolumeList;
2223
import io.kubernetes.client.models.V1PodList;
24+
import io.kubernetes.client.models.V1ReplicaSetList;
2325
import io.kubernetes.client.models.V1RoleBindingList;
2426
import io.kubernetes.client.models.V1RoleList;
2527
import io.kubernetes.client.models.V1SecretList;
@@ -114,47 +116,33 @@ public void verifyJobs(String labelSelectors, int expected) throws Exception {
114116
}
115117

116118
public void verifyNoDeployments(String labelSelectors) throws Exception {
117-
try {
118-
appsV1Api.listDeploymentForAllNamespaces(
119-
null,
120-
null,
121-
Boolean.TRUE,
122-
labelSelectors,
123-
null,
124-
Boolean.FALSE.toString(),
125-
null,
126-
null,
127-
Boolean.FALSE);
128-
assertTrue("No deployments", false);
129-
} catch (ApiException aex) {
130-
if (aex.getCode() == 404) {
131-
assertTrue("No deployements: ", true);
132-
} else {
133-
throw aex;
134-
}
135-
}
119+
V1DeploymentList v1DeploymentList =
120+
appsV1Api.listDeploymentForAllNamespaces(
121+
null,
122+
null,
123+
Boolean.TRUE,
124+
labelSelectors,
125+
null,
126+
Boolean.FALSE.toString(),
127+
null,
128+
null,
129+
Boolean.FALSE);
130+
assertEquals("No deployments", v1DeploymentList.getItems().size(), 0);
136131
}
137132

138133
public void verifyNoReplicaSets(String labelSelectors) throws Exception {
139-
try {
140-
appsV1Api.listReplicaSetForAllNamespaces(
141-
null,
142-
null,
143-
Boolean.TRUE,
144-
labelSelectors,
145-
null,
146-
Boolean.FALSE.toString(),
147-
null,
148-
null,
149-
Boolean.FALSE);
150-
assertTrue("No ReplicaSets", false);
151-
} catch (ApiException aex) {
152-
if (aex.getCode() == 404) {
153-
assertTrue("No ReplicaSets: ", true);
154-
} else {
155-
throw aex;
156-
}
157-
}
134+
V1ReplicaSetList v1ReplicaSetList =
135+
appsV1Api.listReplicaSetForAllNamespaces(
136+
null,
137+
null,
138+
Boolean.TRUE,
139+
labelSelectors,
140+
null,
141+
Boolean.FALSE.toString(),
142+
null,
143+
null,
144+
Boolean.FALSE);
145+
assertEquals("No ReplicaSets", v1ReplicaSetList.getItems().size(), 0);
158146
}
159147

160148
public void verifyServices(String labelSelectors, int expected) throws Exception {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
domainUID: domainuid4del3
5+
exposeAdminT3Channel: true
6+
t3ChannelPort: 30111
7+
exposeAdminNodePort: true
8+
adminNodePort: 30719
9+
namespace: domain-ns-4-del-3

integration-tests/src/test/resources/operator_del.yaml renamed to integration-tests/src/test/resources/operator_del1.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

44
#any property can be provided here from kubernetes/charts/weblogic-operator/values.yaml
5-
releaseName: op-4-del
5+
releaseName: op-4-del-1
66
serviceAccount: weblogic-operator
7-
namespace: weblogic-operator-4-del
8-
domainNamespaces: [ "domain-ns-4-del-1", "domain-ns-4-del-2" ]
7+
namespace: weblogic-operator-4-del-1
8+
domainNamespaces: [ "domain-ns-4-del-1" ]
99
externalRestEnabled: true
1010
externalRestHttpsPort: 32002
1111
javaLoggingLevel: FINE
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
#any property can be provided here from kubernetes/charts/weblogic-operator/values.yaml
5+
releaseName: op-4-del-2
6+
serviceAccount: weblogic-operator
7+
namespace: weblogic-operator-4-del-2
8+
domainNamespaces: [ "domain-ns-4-del-2", "domain-ns-4-del-3" ]
9+
externalRestEnabled: true
10+
externalRestHttpsPort: 32003
11+
javaLoggingLevel: FINE

kubernetes/delete-weblogic-domain-resources.sh

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ EOF
7878
#
7979
function getDomainResources {
8080
local domain_regex=''
81-
local secret_regex=''
8281
if [ "$1" = "all" ]; then
8382
LABEL_SELECTOR="weblogic.domainUID"
8483
else
@@ -87,10 +86,8 @@ function getDomainResources {
8786
for i in "${!UIDS[@]}"; do
8887
if [ $i -gt 0 ]; then
8988
domain_regex="$domain_regex|"
90-
secret_regex="$secret_regex|"
9189
fi
92-
domain_regex="$domain_regex^Domain ${UIDS[$i]}"
93-
secret_regex="$secret_regex^Secret ${UIDS[$i]}"
90+
domain_regex="$domain_regex^Domain ${UIDS[$i]} "
9491
done
9592
fi
9693

@@ -100,7 +97,7 @@ function getDomainResources {
10097
fi
10198

10299
# first, let's get all namespaced types with -l $LABEL_SELECTOR
103-
NAMESPACED_TYPES="pod,job,deploy,rs,service,pvc,ingress,cm,serviceaccount,role,rolebinding"
100+
NAMESPACED_TYPES="pod,job,deploy,rs,service,pvc,ingress,cm,serviceaccount,role,rolebinding,secret"
104101

105102
kubectl get $NAMESPACED_TYPES \
106103
-l "$LABEL_SELECTOR" \
@@ -115,14 +112,9 @@ function getDomainResources {
115112
--all-namespaces=true | egrep "$domain_regex" >> $2
116113
fi
117114

118-
# all secrets
119-
kubectl get secret \
120-
-o=jsonpath='{range .items[*]}{.kind}{" "}{.metadata.name}{" -n "}{.metadata.namespace}{"\n"}{end}' \
121-
--all-namespaces=true | egrep "$secret_regex" >> $2
122-
123115
# now, get all non-namespaced types with -l $LABEL_SELECTOR
124116

125-
NOT_NAMESPACED_TYPES="pv,crd,clusterroles,clusterrolebindings"
117+
NOT_NAMESPACED_TYPES="pv,clusterroles,clusterrolebindings"
126118

127119
kubectl get $NOT_NAMESPACED_TYPES \
128120
-l "$LABEL_SELECTOR" \
@@ -247,8 +239,8 @@ function deleteDomains {
247239
fi
248240
fi
249241

250-
# Delete domains and secretes, if any
251-
cat $tempfile | egrep "^Secret |^Domain " | while read line; do
242+
# Delete domains, if any
243+
cat $tempfile | grep "^Domain " | while read line; do
252244
if [ "$test_mode" = "true" ]; then
253245
echo kubectl delete $line
254246
else

0 commit comments

Comments
 (0)