Skip to content

Commit 0fed8fb

Browse files
committed
cleanup and add java doc
1 parent c59a03b commit 0fed8fb

File tree

5 files changed

+91
-43
lines changed

5 files changed

+91
-43
lines changed

integration-tests/USECASES.MD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,11 @@ Configuration Overrides Usecases
134134
| Search log level | Use Elasticsearch Count API to query logs of level=INFO and verify that total number of logs for level=INFO is not zero and failed count is zero |
135135
| Search Operator log | Use Elasticsearch Search APIs to query Operator log info and verify that log hits for type=weblogic-operator are not empty |
136136
| Search Weblogic log | Use Elasticsearch Search APIs to query Weblogic log info and verify that log hits for Weblogic servers are not empty |
137+
138+
| Operator Upgrade | Use Case |
139+
| --- | --- |
140+
| Upgrade 2.0 operator to develop | Upgrade the 2.0 operator running a Weblogic domain to develop version of the Operator and verify apiVersion of the domain CRD shows v4 |
141+
| Upgrade 2.0.1 operator to develop | Upgrade the 2.0.1 operator running a Weblogic domain to develop version of the Operator and verify apiVersion of the domain CRD shows v4 |
142+
| Upgrade 2.1 operator to develop | Upgrade the 2.1 operator running a Weblogic domain to develop version of the Operator and verify apiVersion of the domain CRD shows v4 |
143+
| Upgrade 2.2.0 operator to develop | Upgrade the 2.2.0 operator running a Weblogic domain to develop version of the Operator and verify apiVersion of the domain CRD shows v4 |
144+
| Upgrade 2.2.1 operator to develop | Upgrade the 2.2.1 operator running a Weblogic domain to develop version of the Operator and verify apiVersion of the domain CRD shows v4 |

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

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@
2424
import org.junit.Test;
2525
import org.junit.runners.MethodSorters;
2626

27-
/**
28-
* Simple JUnit test file used for testing Operator.
29-
*
30-
* <p>This test is used for testing Helm install for Operator(s)
31-
*/
27+
/** Operator upgrade JUnit test file testing the operator upgrade from older releases to develop. */
3228
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
3329
public class ITOperatorUpgrade extends BaseTest {
3430

@@ -44,6 +40,15 @@ public class ITOperatorUpgrade extends BaseTest {
4440
private Domain domain = null;
4541
private static Operator operator;
4642

43+
/**
44+
* Creates operator based on operatorRelease passed to it and then creates a Weblogic domain
45+
* controlled by that operator
46+
*
47+
* @param operatorGitRelease Git branch name of the operator release version
48+
* @param operatorRelease Operator release version from the
49+
* https://hub.docker.com/r/oracle/weblogic-kubernetes-operator/tags
50+
* @throws Exception when operator or domain creation fails
51+
*/
4752
private void setupOperatorAndDomain(String operatorGitRelease, String operatorRelease)
4853
throws Exception {
4954
logger.log(Level.INFO, "+++++++++++++++Beginning Test Setup+++++++++++++++++++++");
@@ -62,21 +67,26 @@ private void setupOperatorAndDomain(String operatorGitRelease, String operatorRe
6267
List<String> dom_ns = new ArrayList<String>();
6368
dom_ns.add(DOM_NS);
6469
operatorMap.put("domainNamespaces", dom_ns);
65-
operator = TestUtils.createOperator(operatorMap, Operator.RESTCertType.LEGACY);
66-
TestUtils.ExecAndPrintLog("kubectl get all --all-namespaces");
70+
operator = TestUtils.createOperator(operatorMap, Operator.RestCertType.LEGACY);
71+
TestUtils.exec("kubectl get all --all-namespaces", true);
6772

6873
Map<String, Object> wlstDomainMap = TestUtils.loadYaml(DOMAININIMAGE_WLST_YAML);
6974
wlstDomainMap.put("domainUID", DUID);
7075
wlstDomainMap.put("namespace", DOM_NS);
7176
wlstDomainMap.put("projectRoot", opUpgradeTmpDir + "/weblogic-kubernetes-operator");
7277
domain = TestUtils.createDomain(wlstDomainMap);
73-
TestUtils.ExecAndPrintLog("kubectl get all --all-namespaces");
78+
TestUtils.exec("kubectl get all --all-namespaces", true);
7479
domain.verifyPodsCreated();
7580
domain.verifyServicesCreated();
7681
domain.verifyServersReady();
7782
logger.log(Level.INFO, "+++++++++++++++Ending Test Setup+++++++++++++++++++++");
7883
}
7984

85+
/**
86+
* cleanup the domain and operator after every test
87+
*
88+
* @throws Exception when domain and operator cleanup fails
89+
*/
8090
@After
8191
public void cleanupOperatorAndDomain() throws Exception {
8292
logger.log(Level.INFO, "+++++++++++++++Beginning AfterTest cleanup+++++++++++++++++++++");
@@ -87,23 +97,23 @@ public void cleanupOperatorAndDomain() throws Exception {
8797
operator.destroy();
8898
}
8999
ExecResult result = cleanup();
90-
TestUtils.ExecAndPrintLog(
100+
TestUtils.exec(
91101
"kubectl delete pods,services,deployments,replicasets,configmaps,services --all --ignore-not-found -n "
92102
+ OP_NS);
93-
TestUtils.ExecAndPrintLog(
103+
TestUtils.exec(
94104
"kubectl delete pods,services,deployments,replicasets,configmaps,services --all --ignore-not-found -n "
95105
+ DOM_NS);
96-
TestUtils.ExecAndPrintLog("kubectl delete crd --all --ignore-not-found");
97-
TestUtils.ExecAndPrintLog("kubectl delete ns " + OP_NS + " --ignore-not-found");
98-
TestUtils.ExecAndPrintLog("kubectl delete ns " + DOM_NS + " --ignore-not-found");
99-
TestUtils.ExecAndPrintLog("kubectl get all --all-namespaces");
106+
TestUtils.exec("kubectl delete crd --all --ignore-not-found");
107+
TestUtils.exec("kubectl delete ns " + OP_NS + " --ignore-not-found");
108+
TestUtils.exec("kubectl delete ns " + DOM_NS + " --ignore-not-found");
109+
TestUtils.exec("kubectl get all --all-namespaces");
100110
logger.log(Level.INFO, "+++++++++++++++Done AfterTest cleanup+++++++++++++++++++++");
101111
}
102112

103113
/**
104114
* Releases k8s cluster lease, archives result, pv directories
105115
*
106-
* @throws Exception
116+
* @throws Exception when deleting pv directories or other tearDown tasks fail.
107117
*/
108118
@AfterClass
109119
public static void staticUnPrepare() throws Exception {
@@ -116,6 +126,11 @@ public static void staticUnPrepare() throws Exception {
116126
}
117127
}
118128

129+
/**
130+
* Test for upgrading Operator from release 2.0 to develop branch
131+
*
132+
* @throws Exception when upgrade fails
133+
*/
119134
@Test
120135
public void testOperatorUpgradeFrom2_0() throws Exception {
121136
String testMethod = new Object() {}.getClass().getEnclosingMethod().getName();
@@ -130,6 +145,11 @@ public void testOperatorUpgradeFrom2_0() throws Exception {
130145
logger.info("SUCCESS - " + testMethod);
131146
}
132147

148+
/**
149+
* Test for upgrading Operator from release 2.0.1 to develop branch
150+
*
151+
* @throws Exception when upgrade fails
152+
*/
133153
@Test
134154
public void testOperatorUpgradeFrom2_0_1() throws Exception {
135155
String testMethod = new Object() {}.getClass().getEnclosingMethod().getName();
@@ -144,6 +164,11 @@ public void testOperatorUpgradeFrom2_0_1() throws Exception {
144164
logger.info("SUCCESS - " + testMethod);
145165
}
146166

167+
/**
168+
* Test for upgrading Operator from release 2.1 to develop branch
169+
*
170+
* @throws Exception when upgrade fails
171+
*/
147172
@Test
148173
public void testOperatorUpgradeFrom2_1() throws Exception {
149174
String testMethod = new Object() {}.getClass().getEnclosingMethod().getName();
@@ -158,6 +183,11 @@ public void testOperatorUpgradeFrom2_1() throws Exception {
158183
logger.info("SUCCESS - " + testMethod);
159184
}
160185

186+
/**
187+
* Test for upgrading Operator from release 2.2.0 to develop branch
188+
*
189+
* @throws Exception when upgrade fails
190+
*/
161191
@Test
162192
public void testOperatorUpgradeFrom2_2_0() throws Exception {
163193
String testMethod = new Object() {}.getClass().getEnclosingMethod().getName();
@@ -172,6 +202,11 @@ public void testOperatorUpgradeFrom2_2_0() throws Exception {
172202
logger.info("SUCCESS - " + testMethod);
173203
}
174204

205+
/**
206+
* Test for upgrading Operator from release 2.2.1 to develop branch
207+
*
208+
* @throws Exception when upgrade fails
209+
*/
175210
@Test
176211
public void testOperatorUpgradeFrom2_2_1() throws Exception {
177212
String testMethod = new Object() {}.getClass().getEnclosingMethod().getName();
@@ -186,25 +221,35 @@ public void testOperatorUpgradeFrom2_2_1() throws Exception {
186221
logger.info("SUCCESS - " + testMethod);
187222
}
188223

224+
/**
225+
* Upgrades operator to develop branch by using the helm upgrade
226+
*
227+
* @param restart boolean parameter used to determine if a restart of domain is checked
228+
* @throws Exception when upgrade fails or basic usecase testing or scaling fails.
229+
*/
189230
private void upgradeOperator(boolean restart) throws Exception {
190231
operator.callHelmUpgrade("image=" + OP_TARGET_RELEASE);
191232
if (restart) {
192233
checkDomainRollingRestarted();
193234
}
194-
checkOperatorVersion(DOM_TARGET_RELEASE_VERSION);
235+
checkOperatorVersion();
195236
testBasicUseCases(domain);
196237
testClusterScaling(operator, domain);
197238
}
198239

199-
private void checkOperatorVersion(String version) throws Exception {
240+
/**
241+
* checks the expected version of the upgraded operator in a loop. In Jenkins it takes nearly 8
242+
* minutes to show the updated value of the domain CRD
243+
*
244+
* @throws Exception when version does not match
245+
*/
246+
private void checkOperatorVersion() throws Exception {
200247
boolean result = false;
201248
logger.log(Level.INFO, "Checking for the domain apiVersion in a loop for up to 15 minutes");
202249
for (int i = 0; i < 900; i = i + 10) {
203-
TestUtils.ExecAndPrintLog(
204-
"kubectl get domain -n " + DOM_NS + " " + DUID + " -o jsonpath={.apiVersion}");
205250
ExecResult exec =
206251
TestUtils.exec(
207-
"kubectl get domain -n " + DOM_NS + " " + DUID + " -o jsonpath={.apiVersion}");
252+
"kubectl get domain -n " + DOM_NS + " " + DUID + " -o jsonpath={.apiVersion}", true);
208253
if (exec.stdout().contains(DOM_TARGET_RELEASE_VERSION)) {
209254
logger.log(Level.INFO, "Got the expected apiVersion");
210255
result = true;
@@ -217,6 +262,11 @@ private void checkOperatorVersion(String version) throws Exception {
217262
}
218263
}
219264

265+
/**
266+
* Check whether the weblogic server instances are rolling restarted
267+
*
268+
* @throws Exception If restart fails or not restarted
269+
*/
220270
private void checkDomainRollingRestarted() throws Exception {
221271
domain.verifyAdminServerRestarted();
222272
TestUtils.checkPodReady(DUID + "-" + domain.getAdminServerName(), DOM_NS);
@@ -228,10 +278,4 @@ private void checkDomainRollingRestarted() throws Exception {
228278
TestUtils.checkPodReady(DUID + "-managed-server" + i, DOM_NS);
229279
}
230280
}
231-
232-
private void printCompVersions() throws Exception {
233-
TestUtils.ExecAndPrintLog("docker images");
234-
TestUtils.ExecAndPrintLog("kubectl get pods -n " + OP_NS + " -o yaml");
235-
TestUtils.ExecAndPrintLog("kubectl get domain " + DUID + " -o yaml -n " + DOM_NS);
236-
}
237281
}

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import javax.jms.QueueConnectionFactory;
3030
import javax.naming.Context;
3131
import javax.naming.InitialContext;
32-
3332
import oracle.kubernetes.operator.BaseTest;
3433
import org.yaml.snakeyaml.Yaml;
3534

@@ -1381,20 +1380,16 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
13811380

13821381
// copy samples to RESULT_DIR
13831382
if (domainMap.containsKey("projectRoot")) {
1384-
logger.log(
1385-
Level.INFO,
1386-
"Copying "
1387-
+ domainMap.get("projectRoot")
1388-
+ "/kubernetes/samples to "
1389-
+ BaseTest.getResultDir());
13901383
TestUtils.exec(
13911384
"cp -rf "
13921385
+ domainMap.get("projectRoot")
13931386
+ "/kubernetes/samples "
1394-
+ BaseTest.getResultDir());
1387+
+ BaseTest.getResultDir(),
1388+
true);
13951389
} else {
13961390
TestUtils.exec(
1397-
"cp -rf " + BaseTest.getProjectRoot() + "/kubernetes/samples " + BaseTest.getResultDir());
1391+
"cp -rf " + BaseTest.getProjectRoot() + "/kubernetes/samples " + BaseTest.getResultDir(),
1392+
true);
13981393
}
13991394

14001395
this.voyager =

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
import java.util.ArrayList;
1111
import java.util.Map;
1212
import java.util.logging.Logger;
13-
1413
import oracle.kubernetes.operator.BaseTest;
1514

1615
/** Operator class with all the utility methods for Operator. */
1716
public class Operator {
1817

19-
public static final String CREATE_OPERATOR_SCRIPT_MESSAGE
20-
= "The Oracle WebLogic Server Kubernetes Operator is deployed";
18+
public static final String CREATE_OPERATOR_SCRIPT_MESSAGE =
19+
"The Oracle WebLogic Server Kubernetes Operator is deployed";
2120
private static final Logger logger = Logger.getLogger("OperatorIT", "OperatorIT");
2221
private static int maxIterationsOp = BaseTest.getMaxIterationsPod(); // 50 * 5 = 250 seconds
2322
private static int waitTimeOp = BaseTest.getWaitTimePod();
@@ -303,7 +302,7 @@ public void callHelmInstall() throws Exception {
303302
StringBuffer cmd = new StringBuffer("");
304303
if (operatorMap.containsKey("operatorGitVersion")
305304
&& operatorMap.containsKey("operatorGitVersionDir")) {
306-
TestUtils.ExecAndPrintLog(
305+
TestUtils.exec(
307306
"cd "
308307
+ operatorMap.get("operatorGitVersionDir")
309308
+ " && git clone -b "
@@ -328,7 +327,6 @@ public void callHelmInstall() throws Exception {
328327
.append(imagePullPolicy)
329328
.append("\" --wait --timeout 60");
330329
logger.info("Running " + cmd);
331-
TestUtils.ExecAndPrintLog("cat " + generatedInputYamlFile);
332330
ExecResult result = ExecCommand.exec(cmd.toString());
333331
if (result.exitValue() != 0) {
334332
reportHelmFailure(cmd.toString(), result);

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import javax.ws.rs.core.HttpHeaders;
2929
import javax.ws.rs.core.MediaType;
3030
import javax.ws.rs.core.Response;
31-
3231
import oracle.kubernetes.operator.BaseTest;
3332
import oracle.kubernetes.operator.utils.Operator.RestCertType;
3433
import org.glassfish.jersey.jsonp.JsonProcessingFeature;
@@ -42,6 +41,7 @@ public class TestUtils {
4241

4342
/**
4443
* Checks if pod is ready.
44+
*
4545
* @param podName pod name
4646
* @param domainNS namespace
4747
* @throws Exception exception
@@ -73,6 +73,7 @@ public static void checkPodReady(String podName, String domainNS, String contain
7373

7474
/**
7575
* Checks that pod is created.
76+
*
7677
* @param podName - pod name
7778
* @param domainNS - domain namespace name
7879
*/
@@ -103,6 +104,7 @@ public static void checkPodTerminating(String podName, String domainNS) throws E
103104

104105
/**
105106
* Checks that service is created.
107+
*
106108
* @param serviceName service name
107109
* @param domainNS namespace
108110
* @throws Exception exception
@@ -144,6 +146,7 @@ public static void checkServiceCreated(String serviceName, String domainNS) thro
144146

145147
/**
146148
* Creates input file.
149+
*
147150
* @param map - map with attributes
148151
* @param generatedInputYamlFile - output file with replaced values
149152
* @throws Exception exception
@@ -742,7 +745,7 @@ public static Operator createOperator(String opYamlFile, RestCertType restCertTy
742745
return operator;
743746
}
744747

745-
public static Operator createOperator(Map<String, Object> inputMap, RESTCertType restCertType)
748+
public static Operator createOperator(Map<String, Object> inputMap, RestCertType restCertType)
746749
throws Exception {
747750
// create op
748751
Operator operator = new Operator(inputMap, restCertType);
@@ -751,7 +754,7 @@ public static Operator createOperator(Map<String, Object> inputMap, RESTCertType
751754
logger.info("Check Operator status");
752755
operator.verifyPodCreated();
753756
operator.verifyOperatorReady();
754-
operator.verifyExternalRESTService();
757+
operator.verifyExternalRestService();
755758

756759
return operator;
757760
}

0 commit comments

Comments
 (0)