Skip to content

Commit dbcfc81

Browse files
authored
Merge pull request #898 from oracle/voyager-java-integ-test
PR: voyager-java-integ-test
2 parents 3cc674c + ee700d7 commit dbcfc81

File tree

10 files changed

+150
-26
lines changed

10 files changed

+150
-26
lines changed

integration-tests/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ The tests accepts optional env var overrides:
240240
| RESULT_ROOT | The root directory to use for the tests temporary files. See "Directory Configuration and Structure" for defaults and a detailed description of test directories. |
241241
| PV_ROOT | The root directory on the kubernetes cluster used for persistent volumes. See "Directory Configuration and Structure" for defaults and a detailed description of test directories. |
242242
| QUICKTEST | When set to "true", limits testing to a subset of the tests. |
243-
| INGRESSPERDOMAIN | The defult value is true. If you want to test creating LB by kubectl yaml for multiple domains, set it to false. |
243+
| LB_TYPE | The default value is "TRAEFIK". Set to "VOYAGER" if you want to use it as LB. |
244+
| INGRESSPERDOMAIN | The defult value is true. If you want to test creating TRAEFIK LB by kubectl yaml for multiple domains, set it to false. |
244245
| WERCKER | Set to true if invoking from Wercker, set to false or "" if running stand-alone or from Jenkins. Default is "". |
245246
| JENKINS | Set to true if invoking from Jenkins, set to false or "" if running stand-alone or from Wercker. Default is "". |
246247
| K8S_NODEPORT_HOST | DNS name of a Kubernetes worker node. Default is the local host's hostname. |

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ public class ITOperator extends BaseTest {
5757
private static boolean QUICKTEST;
5858
private static boolean SMOKETEST;
5959
private static boolean JENKINS;
60-
private static boolean INGRESSPERDOMAIN = true;
6160

6261
// Set QUICKTEST env var to true to run a small subset of tests.
6362
// Set SMOKETEST env var to true to run an even smaller subset
6463
// of tests, plus leave domain1 up and running when the test completes.
65-
// set INGRESSPERDOMAIN to false to create LB's ingress by kubectl yaml file
6664
static {
6765
QUICKTEST =
6866
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true");
@@ -72,9 +70,6 @@ public class ITOperator extends BaseTest {
7270
if (System.getenv("JENKINS") != null) {
7371
JENKINS = new Boolean(System.getenv("JENKINS")).booleanValue();
7472
}
75-
if (System.getenv("INGRESSPERDOMAIN") != null) {
76-
INGRESSPERDOMAIN = new Boolean(System.getenv("INGRESSPERDOMAIN")).booleanValue();
77-
}
7873
}
7974

8075
/**
@@ -239,12 +234,7 @@ public void testTwoDomainsManagedByTwoOperators() throws Exception {
239234
wlstDomainMap.put("domainUID", "domain1onpvwlst");
240235
wlstDomainMap.put("adminNodePort", new Integer("30702"));
241236
wlstDomainMap.put("t3ChannelPort", new Integer("30031"));
242-
if (!INGRESSPERDOMAIN) {
243-
wlstDomainMap.put("ingressPerDomain", new Boolean("false"));
244-
logger.info(
245-
"domain1onpvwlst ingressPerDomain is set to: "
246-
+ ((Boolean) wlstDomainMap.get("ingressPerDomain")).booleanValue());
247-
}
237+
wlstDomainMap.put("voyagerWebPort", new Integer("30307"));
248238
domain1 = TestUtils.createDomain(wlstDomainMap);
249239
domain1.verifyDomainCreated();
250240
testBasicUseCases(domain1);
@@ -260,12 +250,7 @@ public void testTwoDomainsManagedByTwoOperators() throws Exception {
260250
wdtDomainMap.put("adminNodePort", new Integer("30703"));
261251
wdtDomainMap.put("t3ChannelPort", new Integer("30041"));
262252
// wdtDomainMap.put("clusterType", "Configured");
263-
if (!INGRESSPERDOMAIN) {
264-
wdtDomainMap.put("ingressPerDomain", new Boolean("false"));
265-
logger.info(
266-
"domain2onpvwdt ingressPerDomain is set to: "
267-
+ ((Boolean) wdtDomainMap.get("ingressPerDomain")).booleanValue());
268-
}
253+
wdtDomainMap.put("voyagerWebPort", new Integer("30308"));
269254
domain2 = TestUtils.createDomain(wdtDomainMap);
270255
domain2.verifyDomainCreated();
271256
testBasicUseCases(domain2);
@@ -326,7 +311,6 @@ public void testCreateDomainWithStartPolicyAdminOnly() throws Exception {
326311
try {
327312
domain = TestUtils.createDomain(domainadminonlyFile);
328313
domain.verifyDomainCreated();
329-
330314
} finally {
331315
if (domain != null) {
332316
// create domain on existing dir
@@ -439,6 +423,7 @@ public void testAutoAndCustomSitConfigOverrides() throws Exception {
439423
domainMap.put("domainUID", "customsitdomain");
440424
domainMap.put("adminNodePort", new Integer("30704"));
441425
domainMap.put("t3ChannelPort", new Integer("30051"));
426+
domainMap.put("voyagerWebPort", new Integer("30312"));
442427
// use NFS for this domain on Jenkins, defaultis HOST_PATH
443428
if (System.getenv("JENKINS") != null && System.getenv("JENKINS").equalsIgnoreCase("true")) {
444429
domainMap.put("weblogicDomainStorageType", "NFS");

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

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public class Domain {
6666
private static int maxIterations = BaseTest.getMaxIterationsPod(); // 50 * 5 = 250 seconds
6767
private static int waitTime = BaseTest.getWaitTimePod();
6868

69+
private boolean voyager;
70+
// LB_TYPE is an evn var. Set to "VOYAGER" to use it as loadBalancer
71+
private static String LB_TYPE;
72+
// set INGRESSPERDOMAIN to false to create LB's ingress by kubectl yaml file
73+
private static boolean INGRESSPERDOMAIN = true;
74+
6975
public Domain(String inputYaml) throws Exception {
7076
// read input domain yaml to test
7177
this(TestUtils.loadYaml(inputYaml));
@@ -926,17 +932,35 @@ private void createLoadBalancer() throws Exception {
926932
lbMap.put("namespace", domainNS);
927933
lbMap.put("host", domainUid + ".org");
928934
lbMap.put("serviceName", domainUid + "-cluster-" + domainMap.get("clusterName"));
929-
lbMap.put("loadBalancer", domainMap.getOrDefault("loadBalancer", loadBalancer));
930-
lbMap.put("ingressPerDomain", domainMap.getOrDefault("ingressPerDomain", ingressPerDomain));
935+
if (voyager) {
936+
lbMap.put("loadBalancer", "VOYAGER");
937+
lbMap.put("loadBalancerWebPort", domainMap.get("voyagerWebPort"));
938+
} else {
939+
lbMap.put("loadBalancer", domainMap.getOrDefault("loadBalancer", loadBalancer));
940+
lbMap.put(
941+
"loadBalancerWebPort",
942+
domainMap.getOrDefault("loadBalancerWebPort", new Integer(loadBalancerWebPort)));
943+
}
944+
if (!INGRESSPERDOMAIN) {
945+
lbMap.put("ingressPerDomain", new Boolean("false"));
946+
logger.info("For this domain, INGRESSPERDOMAIN is set to false");
947+
} else {
948+
lbMap.put(
949+
"ingressPerDomain",
950+
domainMap.getOrDefault("ingressPerDomain", new Boolean(ingressPerDomain)));
951+
}
931952
lbMap.put("clusterName", domainMap.get("clusterName"));
932953

933954
loadBalancer = (String) lbMap.get("loadBalancer");
955+
loadBalancerWebPort = ((Integer) lbMap.get("loadBalancerWebPort")).intValue();
934956
ingressPerDomain = ((Boolean) lbMap.get("ingressPerDomain")).booleanValue();
935957
logger.info(
936958
"For this domain loadBalancer is: "
937959
+ loadBalancer
938960
+ " ingressPerDomain is: "
939-
+ ingressPerDomain);
961+
+ ingressPerDomain
962+
+ " loadBalancerWebPort is: "
963+
+ loadBalancerWebPort);
940964

941965
if (loadBalancer.equals("TRAEFIK") && !ingressPerDomain) {
942966
lbMap.put("name", "traefik-hostrouting-" + domainUid);
@@ -946,6 +970,10 @@ private void createLoadBalancer() throws Exception {
946970
lbMap.put("name", "traefik-ingress-" + domainUid);
947971
}
948972

973+
if (loadBalancer.equals("VOYAGER") && ingressPerDomain) {
974+
lbMap.put("name", "voyager-ingress-" + domainUid);
975+
}
976+
949977
if (loadBalancer.equals("APACHE")) {
950978
/* lbMap.put("loadBalancerAppPrepath", "/weblogic");
951979
lbMap.put("loadBalancerExposeAdminPort", new Boolean(true)); */
@@ -1060,11 +1088,11 @@ private void callWebAppAndCheckForServerNameInResponse(
10601088
+ " \n "
10611089
+ result.stdout());
10621090
} else {
1063-
logger.info("webapp invoked successfully");
1091+
logger.info("webapp invoked successfully for curlCmd:" + curlCmd);
10641092
}
10651093
if (verifyLoadBalancing) {
10661094
String response = result.stdout().trim();
1067-
// logger.info("response "+ response);
1095+
// logger.info("response: " + response);
10681096
for (String key : managedServers.keySet()) {
10691097
if (response.contains(key)) {
10701098
managedServers.put(key, new Boolean(true));
@@ -1078,6 +1106,7 @@ private void callWebAppAndCheckForServerNameInResponse(
10781106
// error if any managedserver value is false
10791107
if (verifyLoadBalancing) {
10801108
for (Map.Entry<String, Boolean> entry : managedServers.entrySet()) {
1109+
logger.info("Load balancer will try to reach server " + entry.getKey());
10811110
if (!entry.getValue().booleanValue()) {
10821111
// print service and pods info for debugging
10831112
TestUtils.describeService(domainNS, domainUid + "-cluster-" + clusterName);
@@ -1093,7 +1122,11 @@ private void initialize(Map<String, Object> inputDomainMap) throws Exception {
10931122
domainMap = inputDomainMap;
10941123
this.userProjectsDir = BaseTest.getUserProjectsDir();
10951124
this.projectRoot = BaseTest.getProjectRoot();
1096-
1125+
this.voyager =
1126+
System.getenv("LB_TYPE") != null && System.getenv("LB_TYPE").equalsIgnoreCase("VOYAGER");
1127+
if (System.getenv("INGRESSPERDOMAIN") != null) {
1128+
INGRESSPERDOMAIN = new Boolean(System.getenv("INGRESSPERDOMAIN")).booleanValue();
1129+
}
10971130
domainMap.put("domainName", domainMap.get("domainUID"));
10981131

10991132
// read sample domain inputs

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

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ public LoadBalancer(Map lbMap) throws Exception {
4242
createTraefikIngressPerDomain();
4343
}
4444
}
45+
46+
if (lbMap.get("loadBalancer").equals("VOYAGER")) {
47+
String cmdLb = "helm list voyager-operator | grep DEPLOYED";
48+
logger.info("Executing cmd " + cmdLb);
49+
ExecResult result = ExecCommand.exec(cmdLb);
50+
if (result.exitValue() != 0) {
51+
createVoyagerLoadBalancer();
52+
logger.info("Sleeping for 30 seconds to ensure voyager to be ready");
53+
Thread.sleep(30 * 1000);
54+
}
55+
56+
if (((Boolean) lbMap.get("ingressPerDomain")).booleanValue()) {
57+
logger.info("Is going to createVoyagerIngressPerDomain");
58+
createVoyagerIngressPerDomain();
59+
}
60+
}
4561
}
4662

4763
public void createTraefikLoadBalancer() throws Exception {
@@ -148,6 +164,90 @@ private void createTraefikIngress() throws Exception {
148164
logger.info("Command returned " + outputStr);
149165
}
150166

167+
public void createVoyagerLoadBalancer() throws Exception {
168+
169+
String cmd1 = "helm repo add appscode https://charts.appscode.com/stable/";
170+
logger.info("Executing Add Appscode Chart Repository cmd " + cmd1);
171+
172+
executeHelmCommand(cmd1);
173+
174+
String cmd2 = "helm repo update";
175+
logger.info("Executing Appscode Chart Repository upgrade cmd " + cmd2);
176+
177+
executeHelmCommand(cmd2);
178+
179+
String cmd3 =
180+
"helm install appscode/voyager --name voyager-operator --version 7.4.0 --namespace voyage "
181+
+ "--set cloudProvider=baremetal --set apiserver.enableValidatingWebhook=false";
182+
logger.info("Executing Install voyager operator cmd " + cmd3);
183+
184+
executeHelmCommand(cmd3);
185+
}
186+
187+
private void createVoyagerIngressPerDomain() throws Exception {
188+
upgradeVoyagerNamespace();
189+
logger.info("Sleeping for 20 seconds after upgradeVoyagerNamespace ");
190+
Thread.sleep(20 * 1000);
191+
createVoyagerIngress();
192+
logger.info("Sleeping for 20 seconds after createVoyagerIngress ");
193+
Thread.sleep(20 * 1000);
194+
}
195+
196+
private void upgradeVoyagerNamespace() throws Exception {
197+
198+
StringBuffer cmd = new StringBuffer("helm upgrade ");
199+
cmd.append("--reuse-values ")
200+
.append("--set ")
201+
.append("\"")
202+
.append("kubernetes.namespaces={voyager,")
203+
.append(lbMap.get("namespace"))
204+
.append("}")
205+
.append("\"")
206+
.append(" --version 7.4.0")
207+
.append(" --set cloudProvider=baremetal")
208+
.append(" --set apiserver.enableValidatingWebhook=false")
209+
.append(" voyager-operator")
210+
.append(" appscode/voyager");
211+
212+
logger.info(" upgradeVoyagerNamespace() Running " + cmd.toString());
213+
executeHelmCommand(cmd.toString());
214+
}
215+
216+
private void createVoyagerIngress() throws Exception {
217+
218+
String chartDir = BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/charts";
219+
220+
StringBuffer cmd = new StringBuffer("cd ");
221+
cmd.append(chartDir).append(" && helm install ingress-per-domain ");
222+
cmd.append(" --name ")
223+
.append(lbMap.get("name"))
224+
.append(" --namespace ")
225+
.append(lbMap.get("namespace"))
226+
.append(" --set type=VOYAGER")
227+
.append(" --set ")
228+
.append("wlsDomain.domainUID=")
229+
.append(lbMap.get("domainUID"))
230+
.append(" --set ")
231+
.append("wlsDomain.clusterName=")
232+
.append(lbMap.get("clusterName"))
233+
.append(" --set ")
234+
.append("voyager.webPort=")
235+
.append(lbMap.get("loadBalancerWebPort"));
236+
237+
logger.info("createVoyagerIngress() Running " + cmd.toString());
238+
executeHelmCommand(cmd.toString());
239+
}
240+
241+
private void executeHelmCommand(String cmd) throws Exception {
242+
ExecResult result = ExecCommand.exec(cmd);
243+
if (result.exitValue() != 0) {
244+
logger.info("executeHelmCommand failed with " + cmd);
245+
reportHelmInstallFailure(cmd, result);
246+
}
247+
String outputStr = result.stdout().trim();
248+
logger.info("Command returned " + outputStr);
249+
}
250+
151251
private void reportHelmInstallFailure(String cmd, ExecResult result) throws Exception {
152252
throw new RuntimeException(getExecFailure(cmd, result));
153253
}

integration-tests/src/test/resources/charts/ingress-per-domain/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ voyager:
2424
# web port
2525
webPort: 30305
2626
# stats port
27-
statsPort: 30315
27+
#statsPort: 30315

integration-tests/src/test/resources/domainadminonly.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ namespace: default
1919
serverStartPolicy: ADMIN_ONLY
2020
loadBalancer: TRAEFIK
2121
ingressPerDomain: true
22+
voyagerWebPort: 30309

integration-tests/src/test/resources/domainonpvwdt.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ createDomainFilesDir: wdt
2222
#loadBalancerDashboardPort: 30321
2323
loadBalancer: TRAEFIK
2424
ingressPerDomain: true
25+
voyagerWebPort: 30306

integration-tests/src/test/resources/domainonpvwlst.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ exposeAdminNodePort: true
1616
namespace: default
1717
loadBalancer: TRAEFIK
1818
ingressPerDomain: true
19+
voyagerWebPort: 30305
1920

integration-tests/src/test/resources/domainrecyclepolicy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ namespace: default
1919
weblogicDomainStorageReclaimPolicy: Recycle
2020
loadBalancer: TRAEFIK
2121
ingressPerDomain: true
22+
voyagerWebPort: 30311

integration-tests/src/test/resources/domainsampledefaults.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ domainUID: domainsampledefaults
77
configuredManagedServerCount: 4
88
loadBalancer: TRAEFIK
99
ingressPerDomain: true
10+
voyagerWebPort: 30310

0 commit comments

Comments
 (0)