Skip to content

Commit 25f5cfc

Browse files
committed
adding non-quick tests domain2, domain3, operator2, domain4
1 parent 739f6e6 commit 25f5cfc

15 files changed

+580
-24
lines changed

integration-tests/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@
153153
</goals>
154154
<phase>integration-test</phase>
155155
<configuration>
156-
<skipTests>false</skipTests>
156+
<excludes>
157+
<exclude>**/*Test.java</exclude>
158+
<!-- exclude>**/IT*.java</exclude -->
159+
</excludes>
160+
<!-- just run test suite -->
161+
<includes> <include>**/*TestSuite.java</include> </includes>
157162
</configuration>
158163
</execution>
159164
<execution>
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
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
3+
// http://oss.oracle.com/licenses/upl.
4+
5+
package oracle.kubernetes.operator;
6+
7+
import java.util.Properties;
8+
import oracle.kubernetes.operator.utils.Domain;
9+
import oracle.kubernetes.operator.utils.Operator;
10+
import oracle.kubernetes.operator.utils.TestUtils;
11+
import org.junit.BeforeClass;
12+
import org.junit.Test;
13+
14+
/**
15+
* Simple JUnit test file used for testing Operator.
16+
*
17+
* <p>This test is used for creating Operator and a single domain which the Operator manages and
18+
* verifies both.
19+
*/
20+
public class ITFourthDomain extends BaseTest {
21+
public static final String TESTWEBAPP = "testwebapp";
22+
23+
// property file used to customize operator properties for operator inputs yaml
24+
private static String opPropsFile = "ITSecondOperator.properties";
25+
26+
// property file used to customize domain properties for domain inputs yaml
27+
private static String domainPropsFile = "ITFourthDomain.properties";
28+
29+
// property file used to configure constants for integration tests
30+
private static String appPropsFile = "OperatorIT.properties";
31+
32+
private static Operator operator;
33+
private static Domain domain;
34+
35+
// properties of operator/domain to use in the test methods
36+
private static Properties operatorProps;
37+
private static Properties domainProps;
38+
39+
private static String domainUid, domainNS;
40+
/**
41+
* This method gets called only once before any of the test methods are executed. It does the
42+
* initialization of the integration test properties defined in OperatorIT.properties and setting
43+
* the resultRoot, pvRoot and projectRoot attributes. It also creates the Operator and domain.
44+
*
45+
* @throws Exception
46+
*/
47+
@BeforeClass
48+
public static void staticPrepare() throws Exception {
49+
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
50+
logger.info("BEGIN");
51+
52+
// initialize test properties and create the directories
53+
initialize(appPropsFile);
54+
// renew lease at the begining for every test method, leaseId is set only for Wercker
55+
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
56+
57+
logger.info("Run once, Creating Operator & " + "waiting for the script to complete execution");
58+
// create operator
59+
operator = TestUtils.createOperator(opPropsFile);
60+
operatorProps = operator.getOperatorProps();
61+
62+
// create domain
63+
domain = TestUtils.createDomain(domainPropsFile);
64+
domainProps = domain.getDomainProps();
65+
66+
// initialize attributes to use in the tests
67+
domainUid = domainProps.getProperty("domainUID");
68+
domainNS = domainProps.getProperty("namespace");
69+
// logger.info("Domain props "+domainProps);
70+
logger.info("SUCCESS");
71+
}
72+
73+
/**
74+
* verify domain1 is unaffected
75+
*
76+
* @throws Exception
77+
*/
78+
public void verifyDomain1() throws Exception {
79+
ITSingleDomain.getDomain().verifyDomainCreated();
80+
}
81+
82+
/**
83+
* Access Operator REST endpoint using admin node host and node port
84+
*
85+
* @throws Exception
86+
*/
87+
@Test
88+
public void testAdminServerExternalService() throws Exception {
89+
logTestBegin("testAdminServerExternalService");
90+
domain.verifyAdminServerExternalService(getUsername(), getPassword());
91+
logger.info("SUCCESS");
92+
}
93+
94+
/**
95+
* Verify t3channel port by deploying webapp using the port
96+
*
97+
* @throws Exception
98+
*/
99+
@Test
100+
public void testAdminT3Channel() throws Exception {
101+
logTestBegin("testAdminT3Channel");
102+
// check if the property is set to true
103+
Boolean exposeAdmint3Channel = new Boolean(domainProps.getProperty("exposeAdminT3Channel"));
104+
105+
if (exposeAdmint3Channel != null && exposeAdmint3Channel.booleanValue()) {
106+
domain.deployWebAppViaWLST(
107+
TESTWEBAPP,
108+
getProjectRoot() + "/src/integration-tests/apps/testwebapp.war",
109+
getUsername(),
110+
getPassword());
111+
} else {
112+
throw new RuntimeException("FAILURE: exposeAdminT3Channel is not set or false");
113+
}
114+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
115+
logger.info("SUCCESS");
116+
}
117+
118+
/**
119+
* Scale the cluster up/down using Operator REST endpoint, load balancing should adjust
120+
* accordingly.
121+
*
122+
* @throws Exception
123+
*/
124+
@Test
125+
public void testClusterScaling() throws Exception {
126+
logTestBegin("testClusterScaling");
127+
String managedServerNameBase = domainProps.getProperty("managedServerNameBase");
128+
int replicas = 3;
129+
String podName = domainUid + "-" + managedServerNameBase + replicas;
130+
String clusterName = domainProps.getProperty("clusterName");
131+
132+
logger.info("Scale domain " + domainUid + " Up to " + replicas + " managed servers");
133+
operator.scale(domainUid, domainProps.getProperty("clusterName"), replicas);
134+
135+
logger.info("Checking if managed pod(" + podName + ") is Running");
136+
TestUtils.checkPodCreated(podName, domainNS);
137+
138+
logger.info("Checking if managed server (" + podName + ") is Running");
139+
TestUtils.checkPodReady(podName, domainNS);
140+
141+
logger.info("Checking if managed service(" + podName + ") is created");
142+
TestUtils.checkServiceCreated(podName, domainNS);
143+
144+
int replicaCnt = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
145+
if (replicaCnt != replicas) {
146+
throw new RuntimeException(
147+
"FAILURE: Cluster replica doesn't match with scaled up size "
148+
+ replicaCnt
149+
+ "/"
150+
+ replicas);
151+
}
152+
153+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
154+
155+
replicas = 2;
156+
podName = domainUid + "-" + managedServerNameBase + (replicas + 1);
157+
logger.info("Scale down to " + replicas + " managed servers");
158+
operator.scale(domainUid, clusterName, replicas);
159+
160+
logger.info("Checking if managed pod(" + podName + ") is deleted");
161+
TestUtils.checkPodDeleted(podName, domainNS);
162+
163+
replicaCnt = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
164+
if (replicaCnt != replicas) {
165+
throw new RuntimeException(
166+
"FAILURE: Cluster replica doesn't match with scaled down size "
167+
+ replicaCnt
168+
+ "/"
169+
+ replicas);
170+
}
171+
172+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
173+
174+
// verfiy scaling has no impact on domains1
175+
ITSingleDomain.getDomain().verifyDomainCreated();
176+
logger.info("SUCCESS");
177+
}
178+
179+
/**
180+
* test delete and recreate domain1 has no impact on domain4
181+
*
182+
* @throws Exception
183+
*/
184+
@Test
185+
public void testDeleteAndRecreteDomain1() throws Exception {
186+
187+
Domain domain1 = ITSingleDomain.getDomain();
188+
domain1.destroy();
189+
domain1.create();
190+
191+
// verify domain4 has no impact
192+
domain.verifyDomainCreated();
193+
}
194+
195+
public static Domain getDomain() {
196+
return domain;
197+
}
198+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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
3+
// http://oss.oracle.com/licenses/upl.
4+
5+
package oracle.kubernetes.operator;
6+
7+
import java.util.Properties;
8+
import oracle.kubernetes.operator.utils.Domain;
9+
import oracle.kubernetes.operator.utils.TestUtils;
10+
import org.junit.AfterClass;
11+
import org.junit.BeforeClass;
12+
import org.junit.Test;
13+
14+
/**
15+
* Simple JUnit test file used for testing Operator.
16+
*
17+
* <p>This test is used for creating a single domain which the Operator manages and verifies both.
18+
*/
19+
public class ITSecondDomain extends BaseTest {
20+
public static final String TESTWEBAPP = "testwebapp";
21+
22+
// property file used to customize domain properties for domain inputs yaml
23+
private static String domainPropsFile = "ITSecondDomain.properties";
24+
25+
// property file used to configure constants for integration tests
26+
private static String appPropsFile = "OperatorIT.properties";
27+
28+
private static Domain domain;
29+
30+
// properties of operator/domain to use in the test methods
31+
private static Properties domainProps;
32+
33+
private static String domainUid, domainNS;
34+
/**
35+
* This method gets called only once before any of the test methods are executed. It creates the
36+
* domain.
37+
*
38+
* @throws Exception
39+
*/
40+
@BeforeClass
41+
public static void staticPrepare() throws Exception {
42+
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
43+
logger.info("BEGIN");
44+
45+
// renew lease at the begining for every test method, leaseId is set only for Wercker
46+
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
47+
48+
logger.info("Run once, Creating Domain & " + "waiting for the script to complete execution");
49+
50+
// create domain
51+
domain = TestUtils.createDomain(domainPropsFile);
52+
domainProps = domain.getDomainProps();
53+
54+
// initialize attributes to use in the tests
55+
domainUid = domainProps.getProperty("domainUID");
56+
domainNS = domainProps.getProperty("namespace");
57+
// logger.info("Domain props "+domainProps);
58+
logger.info("SUCCESS");
59+
}
60+
61+
/**
62+
* Shutdown operator and domain
63+
*
64+
* @throws Exception
65+
*/
66+
@AfterClass
67+
public static void staticUnPrepare() throws Exception {
68+
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
69+
logger.info("BEGIN");
70+
logger.info("Run once, shutdown/deleting operator, domain, pv, etc");
71+
// shutdown operator, domain and cleanup all artifacts and pv dir
72+
if (domain != null) domain.destroy();
73+
74+
logger.info("SUCCESS");
75+
}
76+
77+
/**
78+
* Access Operator REST endpoint using admin node host and node port
79+
*
80+
* @throws Exception
81+
*/
82+
@Test
83+
public void testAdminServerExternalService() throws Exception {
84+
logTestBegin("testAdminServerExternalService");
85+
domain.verifyAdminServerExternalService(getUsername(), getPassword());
86+
logger.info("SUCCESS");
87+
}
88+
89+
/**
90+
* Verify t3channel port by deploying webapp using the port
91+
*
92+
* @throws Exception
93+
*/
94+
@Test
95+
public void testAdminT3Channel() throws Exception {
96+
logTestBegin("testAdminT3Channel");
97+
// check if the property is set to true
98+
Boolean exposeAdmint3Channel = new Boolean(domainProps.getProperty("exposeAdminT3Channel"));
99+
100+
if (exposeAdmint3Channel != null && exposeAdmint3Channel.booleanValue()) {
101+
domain.deployWebAppViaWLST(
102+
TESTWEBAPP,
103+
getProjectRoot() + "/src/integration-tests/apps/testwebapp.war",
104+
getUsername(),
105+
getPassword());
106+
} else {
107+
throw new RuntimeException("FAILURE: exposeAdminT3Channel is not set or false");
108+
}
109+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
110+
logger.info("SUCCESS");
111+
}
112+
}

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

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,32 @@ public static void staticPrepare() throws Exception {
8080
*/
8181
@AfterClass
8282
public static void staticUnPrepare() throws Exception {
83-
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
84-
logger.info("BEGIN");
85-
logger.info("Run once, shutdown/deleting operator, domain, pv, etc");
86-
// shutdown operator, domain and cleanup all artifacts and pv dir
87-
try {
88-
if (domain != null) domain.destroy();
89-
if (operator != null) operator.destroy();
90-
} finally {
91-
String cmd =
92-
"export RESULT_ROOT="
93-
+ getResultRoot()
94-
+ " export PV_ROOT="
95-
+ getPvRoot()
96-
+ " && "
97-
+ getProjectRoot()
98-
+ "/src/integration-tests/bash/cleanup.sh";
99-
ExecResult result = ExecCommand.exec(cmd);
100-
if (result.exitValue() != 0) {
101-
logger.info("FAILED: command to call cleanup script " + cmd + " failed " + result.stderr());
83+
if (System.getenv("QUICK_TEST") != null && System.getenv("QUICK_TEST").equals("true")) {
84+
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
85+
logger.info("BEGIN");
86+
logger.info("Run once, shutdown/deleting operator, domain, pv, etc");
87+
// shutdown operator, domain and cleanup all artifacts and pv dir
88+
try {
89+
if (domain != null) domain.destroy();
90+
if (operator != null) operator.destroy();
91+
} finally {
92+
String cmd =
93+
"export RESULT_ROOT="
94+
+ getResultRoot()
95+
+ " export PV_ROOT="
96+
+ getPvRoot()
97+
+ " && "
98+
+ getProjectRoot()
99+
+ "/src/integration-tests/bash/cleanup.sh";
100+
ExecResult result = ExecCommand.exec(cmd);
101+
if (result.exitValue() != 0) {
102+
logger.info(
103+
"FAILED: command to call cleanup script " + cmd + " failed " + result.stderr());
104+
}
105+
logger.info("Command " + cmd + " returned " + result.stdout() + "\n" + result.stderr());
102106
}
103-
logger.info("Command " + cmd + " returned " + result.stdout() + "\n" + result.stderr());
107+
logger.info("SUCCESS");
104108
}
105-
logger.info("SUCCESS");
106109
}
107110

108111
/**
@@ -233,4 +236,8 @@ public void testOperatorLifecycle() throws Exception {
233236
domain.verifyDomainCreated();
234237
logger.info("SUCCESS");
235238
}
239+
240+
public static Domain getDomain() {
241+
return domain;
242+
}
236243
}

0 commit comments

Comments
 (0)