Skip to content

Commit d1cfafd

Browse files
committed
combing all junit classes into one and adding full test use cases
1 parent 9adde58 commit d1cfafd

14 files changed

+766
-788
lines changed

integration-tests/pom.xml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -163,29 +163,7 @@
163163
</goals>
164164
<phase>integration-test</phase>
165165
<configuration>
166-
<excludes>
167-
<exclude>**/*Test.java</exclude>
168-
<!-- exclude>**/IT*.java</exclude -->
169-
</excludes>
170-
<!-- just run test suite -->
171-
<includes> <include>**/*TestSuite.java</include> </includes>
172-
</configuration>
173-
</execution>
174-
<execution>
175-
<id>acceptance-test</id>
176-
<goals>
177-
<goal>integration-test</goal>
178-
<goal>verify</goal>
179-
</goals>
180-
<phase>integration-test</phase>
181-
<configuration>
182-
<!-- do not run unit or integration tests -->
183-
<excludes>
184-
<exclude>**/*Test.java</exclude>
185-
<exclude>**/IT*.java</exclude>
186-
</excludes>
187-
<!-- just run acceptance tests -->
188-
<!-- includes> <include>**/*AT.java</include> </includes -->
166+
<skipTests>false</skipTests>
189167
</configuration>
190168
</execution>
191169
</executions>

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

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import java.util.logging.FileHandler;
1111
import java.util.logging.Logger;
1212
import java.util.logging.SimpleFormatter;
13+
import oracle.kubernetes.operator.utils.Domain;
1314
import oracle.kubernetes.operator.utils.ExecCommand;
1415
import oracle.kubernetes.operator.utils.ExecResult;
16+
import oracle.kubernetes.operator.utils.Operator;
1517
import oracle.kubernetes.operator.utils.TestUtils;
1618

1719
/**
@@ -20,6 +22,7 @@
2022
*/
2123
public class BaseTest {
2224
public static final Logger logger = Logger.getLogger("OperatorIT", "OperatorIT");
25+
public static final String TESTWEBAPP = "testwebapp";
2326

2427
private static String resultRoot = "";
2528
private static String pvRoot = "";
@@ -112,6 +115,11 @@ public static void initialize(String appPropsFile) throws Exception {
112115
}
113116
}
114117

118+
logger.info("appProps = " + appProps);
119+
logger.info("maxIterationPod = " + appProps.getProperty("maxIterationsPod"));
120+
logger.info(
121+
"maxIterationPod with default= "
122+
+ appProps.getProperty("maxIterationsPod", "" + maxIterationsPod));
115123
logger.info("RESULT_ROOT =" + resultRoot);
116124
logger.info("PV_ROOT =" + pvRoot);
117125
logger.info("userProjectsDir =" + userProjectsDir);
@@ -132,6 +140,135 @@ public static void initialize(String appPropsFile) throws Exception {
132140
logger.info("Env var BRANCH_NAME " + System.getenv("BRANCH_NAME"));
133141
}
134142

143+
/**
144+
* Access Operator REST endpoint using admin node host and node port
145+
*
146+
* @throws Exception
147+
*/
148+
public void testAdminServerExternalService(Domain domain) throws Exception {
149+
logTestBegin("testAdminServerExternalService");
150+
domain.verifyAdminServerExternalService(getUsername(), getPassword());
151+
logger.info("SUCCESS");
152+
}
153+
154+
/**
155+
* Verify t3channel port by deploying webapp using the port
156+
*
157+
* @throws Exception
158+
*/
159+
public void testAdminT3Channel(Domain domain) throws Exception {
160+
logTestBegin("testAdminT3Channel");
161+
Properties domainProps = domain.getDomainProps();
162+
// check if the property is set to true
163+
Boolean exposeAdmint3Channel = new Boolean(domainProps.getProperty("exposeAdminT3Channel"));
164+
165+
if (exposeAdmint3Channel != null && exposeAdmint3Channel.booleanValue()) {
166+
domain.deployWebAppViaWLST(
167+
TESTWEBAPP,
168+
getProjectRoot() + "/src/integration-tests/apps/testwebapp.war",
169+
getUsername(),
170+
getPassword());
171+
} else {
172+
throw new RuntimeException("FAILURE: exposeAdminT3Channel is not set or false");
173+
}
174+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
175+
logger.info("SUCCESS");
176+
}
177+
178+
/**
179+
* Restarting the domain should not have any impact on Operator managing the domain, web app load
180+
* balancing and node port service
181+
*
182+
* @throws Exception
183+
*/
184+
public void testDomainLifecyle(Operator operator, Domain domain) throws Exception {
185+
logTestBegin("testDomainLifecyle");
186+
domain.destroy();
187+
domain.create();
188+
operator.verifyExternalRESTService();
189+
operator.verifyDomainExists(domain.getDomainUid());
190+
domain.verifyDomainCreated();
191+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
192+
domain.verifyAdminServerExternalService(getUsername(), getPassword());
193+
logger.info("SUCCESS");
194+
}
195+
196+
/**
197+
* Scale the cluster up/down using Operator REST endpoint, load balancing should adjust
198+
* accordingly.
199+
*
200+
* @throws Exception
201+
*/
202+
public void testClusterScaling(Operator operator, Domain domain) throws Exception {
203+
logTestBegin("testClusterScaling");
204+
Properties domainProps = domain.getDomainProps();
205+
String domainUid = domain.getDomainUid();
206+
String domainNS = domainProps.getProperty("namespace");
207+
String managedServerNameBase = domainProps.getProperty("managedServerNameBase");
208+
int replicas = 3;
209+
String podName = domain.getDomainUid() + "-" + managedServerNameBase + replicas;
210+
String clusterName = domainProps.getProperty("clusterName");
211+
212+
logger.info(
213+
"Scale domain " + domain.getDomainUid() + " Up to " + replicas + " managed servers");
214+
operator.scale(domainUid, domainProps.getProperty("clusterName"), replicas);
215+
216+
logger.info("Checking if managed pod(" + podName + ") is Running");
217+
TestUtils.checkPodCreated(podName, domainNS);
218+
219+
logger.info("Checking if managed server (" + podName + ") is Running");
220+
TestUtils.checkPodReady(podName, domainNS);
221+
222+
logger.info("Checking if managed service(" + podName + ") is created");
223+
TestUtils.checkServiceCreated(podName, domainNS);
224+
225+
int replicaCnt = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
226+
if (replicaCnt != replicas) {
227+
throw new RuntimeException(
228+
"FAILURE: Cluster replica doesn't match with scaled up size "
229+
+ replicaCnt
230+
+ "/"
231+
+ replicas);
232+
}
233+
234+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
235+
236+
replicas = 2;
237+
podName = domainUid + "-" + managedServerNameBase + (replicas + 1);
238+
logger.info("Scale down to " + replicas + " managed servers");
239+
operator.scale(domainUid, clusterName, replicas);
240+
241+
logger.info("Checking if managed pod(" + podName + ") is deleted");
242+
TestUtils.checkPodDeleted(podName, domainNS);
243+
244+
replicaCnt = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
245+
if (replicaCnt != replicas) {
246+
throw new RuntimeException(
247+
"FAILURE: Cluster replica doesn't match with scaled down size "
248+
+ replicaCnt
249+
+ "/"
250+
+ replicas);
251+
}
252+
253+
domain.verifyWebAppLoadBalancing(TESTWEBAPP);
254+
logger.info("SUCCESS");
255+
}
256+
257+
/**
258+
* Restarting Operator should not impact the running domain
259+
*
260+
* @throws Exception
261+
*/
262+
public void testOperatorLifecycle(Operator operator, Domain domain) throws Exception {
263+
logTestBegin("testOperatorLifecycle");
264+
operator.destroy();
265+
operator.create();
266+
operator.verifyExternalRESTService();
267+
operator.verifyDomainExists(domain.getDomainUid());
268+
domain.verifyDomainCreated();
269+
logger.info("SUCCESS");
270+
}
271+
135272
public static String getResultRoot() {
136273
return resultRoot;
137274
}

0 commit comments

Comments
 (0)