Skip to content

Commit ababb85

Browse files
committed
build wdt archive dynamically
1 parent 8de9e40 commit ababb85

File tree

4 files changed

+140
-26
lines changed

4 files changed

+140
-26
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ public static ExecResult cleanup() throws Exception {
305305
+ getProjectRoot()
306306
+ "/src/integration-tests/bash/cleanup.sh";
307307
logger.info("Command to call cleanup script " + cmd);
308+
308309
return ExecCommand.exec(cmd);
309310
}
310311

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

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import oracle.kubernetes.operator.utils.TestUtils;
1212
import org.junit.AfterClass;
1313
import org.junit.Assert;
14-
import org.junit.Assume;
1514
import org.junit.BeforeClass;
1615
import org.junit.FixMethodOrder;
1716
import org.junit.Test;
@@ -28,6 +27,7 @@ public class ITCoherenceTests extends BaseTest {
2827

2928
private static final String PROXY_CLIENT_SCRIPT = "buildRunProxyClient.sh";
3029
private static final String PROXY_CLIENT_APP_NAME = "coherence-proxy-client";
30+
private static final String PROXY_SERVER_APP_NAME = "coherence-proxy-server";
3131
private static final String OP_CACHE_LOAD = "load";
3232
private static final String OP_CACHE_VALIDATE = "validate";
3333
private static final String PROXY_PORT = "9000";
@@ -70,11 +70,13 @@ public void testRollingRestart() throws Exception {
7070
Assert.assertNotNull(domain);
7171

7272
try {
73+
// Build and run the proxy client on the admin VM to load the cache
7374
copyAndExecuteProxyClientInPod(OP_CACHE_LOAD);
7475

7576
// Do the rolling restart
76-
restartDomainByChangingEnvProperty();
77+
// restartDomainByChangingEnvProperty();
7778

79+
// Build and run the proxy client on the admin VM to validate the cache
7880
copyAndExecuteProxyClientInPod(OP_CACHE_VALIDATE);
7981
} finally {
8082
destroyDomain();
@@ -83,7 +85,8 @@ public void testRollingRestart() throws Exception {
8385
}
8486

8587
/**
86-
* Copy the shell script file and all coherence app files over to the admin pod.
88+
* Since the coherence.jar is not open source, we need to build the proxy client on the admin VM, which has the
89+
* coherence.jar. Copy the shell script file and all coherence app files over to the admin pod.
8790
* Then run the script to build the proxy client and run the proxy test.
8891
*
8992
* @param cacheOp - cache operation
@@ -133,26 +136,6 @@ private static void copyAndExecuteProxyClientInPod(String cacheOp) {
133136
}
134137
}
135138

136-
/**
137-
* Modify the domain scope env property on the domain resource using kubectl apply -f domain.yaml
138-
* Verify that all the server pods in the domain got re-started. The property tested is: env:
139-
* "-Dweblogic.StdoutDebugEnabled=false"--> "-Dweblogic.StdoutDebugEnabled=true"
140-
*
141-
* @throws Exception
142-
*/
143-
private void restartDomainByChangingEnvProperty() throws Exception {
144-
145-
// The default cmd loop sleep is too long and we could miss states like terminating. Change
146-
// the
147-
// sleep and iterations
148-
//
149-
setWaitTimePod(2);
150-
setMaxIterationsPod(125);
151-
152-
domain.verifyDomainServerPodRestart(
153-
"\"-Dweblogic.StdoutDebugEnabled=false\"", "\"-Dweblogic.StdoutDebugEnabled=true\"");
154-
}
155-
156139
/**
157140
* Create the domain
158141
*
@@ -161,9 +144,8 @@ private void restartDomainByChangingEnvProperty() throws Exception {
161144
*/
162145
private Domain createDomain() throws Exception {
163146

164-
// TODO - Don't hardcode the archive location
165147
Map<String, String> envMap = new HashMap();
166-
envMap.put("CUSTOM_WDT_ARCHIVE", "/Users/pmackin/archive-proxy.zip");
148+
envMap.put("CUSTOM_WDT_ARCHIVE", buildProxyServerWdtZip());
167149

168150
// create domain
169151
Domain domain = null;
@@ -192,4 +174,41 @@ private static void destroyDomain() throws Exception {
192174
}
193175
}
194176

177+
/**
178+
* Modify the domain scope env property on the domain resource using kubectl apply -f domain.yaml
179+
* Verify that all the server pods in the domain got re-started. The property tested is: env:
180+
* "-Dweblogic.StdoutDebugEnabled=false"--> "-Dweblogic.StdoutDebugEnabled=true"
181+
*
182+
* @throws Exception
183+
*/
184+
private void restartDomainByChangingEnvProperty() throws Exception {
185+
186+
// The default cmd loop sleep is too long and we could miss states like terminating. Change
187+
// the
188+
// sleep and iterations
189+
//
190+
setWaitTimePod(2);
191+
setMaxIterationsPod(125);
192+
193+
domain.verifyDomainServerPodRestart(
194+
"\"-Dweblogic.StdoutDebugEnabled=false\"", "\"-Dweblogic.StdoutDebugEnabled=true\"");
195+
}
196+
197+
/**
198+
* Build the WDT zip that contains the Coherence proxy server
199+
*
200+
* @return the WDT zip path
201+
*/
202+
private static String buildProxyServerWdtZip() {
203+
204+
// Build the proxy server gar file
205+
String garPath = getResultDir() + "/coh-proxy-server.gar";
206+
String cohAppLocationOnHost = BaseTest.getAppLocationOnHost() + "/" + PROXY_SERVER_APP_NAME;
207+
TestUtils.buildJarArchive(garPath, cohAppLocationOnHost);
208+
209+
// Build the WDT zip
210+
String wdtArchivePath = getResultDir() + "/coh-wdt-archive.zip";
211+
TestUtils.buildWdtZip(wdtArchivePath, new String[] {garPath}, getResultDir());
212+
return wdtArchivePath;
213+
}
195214
}

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

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,100 @@ public static String callShellScriptByExecToPod(
10781078
return result.stdout().trim();
10791079
}
10801080

1081+
/**
1082+
* Build a jar archive. The archive will only include the directory structure below the srcDir.
1083+
*
1084+
* @param jarPath Jar file path for resulting archive
1085+
* @param srcDir source directory
1086+
*/
1087+
public static void buildJarArchive(
1088+
String jarPath, String srcDir) {
1089+
1090+
try {
1091+
StringBuffer cmd = new StringBuffer("jar -cf ");
1092+
cmd
1093+
.append(jarPath)
1094+
.append(" -C ")
1095+
.append(srcDir)
1096+
.append(" . ")
1097+
;
1098+
logger.info("Command to call build a jar file " + cmd);
1099+
ExecResult result = ExecCommand.exec(cmd.toString());
1100+
if (result.exitValue() != 0) {
1101+
throw new RuntimeException(
1102+
"FAILURE: command " + cmd + " failed, returned " + result.stderr());
1103+
}
1104+
} catch (Exception e) {
1105+
throw new RuntimeException(e);
1106+
}
1107+
}
1108+
1109+
/**
1110+
* Build a zip archive. The archive will only include the directory structure below the srcDir.
1111+
*
1112+
* @param zipPath zip file path for resulting archive
1113+
* @param srcDir source directory
1114+
*/
1115+
public static void buildZipArchive(
1116+
String zipPath, String srcDir) {
1117+
1118+
try {
1119+
StringBuffer cmd = new StringBuffer();
1120+
cmd
1121+
.append("cd ")
1122+
.append(srcDir)
1123+
.append(" ; zip -r ")
1124+
.append(zipPath)
1125+
.append(" . ")
1126+
;
1127+
logger.info("Command to call build a zip file " + cmd);
1128+
ExecResult result = ExecCommand.exec(cmd.toString());
1129+
if (result.exitValue() != 0) {
1130+
throw new RuntimeException(
1131+
"FAILURE: command " + cmd + " failed, returned " + result.stderr());
1132+
}
1133+
} catch (Exception e) {
1134+
throw new RuntimeException(e);
1135+
}
1136+
}
1137+
1138+
/**
1139+
* Build a WDT zip archive, which consists of a set of archives structured as follows:
1140+
*
1141+
* wlsdeploy/applications/archive1, archive2, etc
1142+
*
1143+
* for example, the WDT archive with 3 artifacts could have the following...
1144+
*
1145+
* wlsdeploy/applications/archive1.ear, wlsdeploy/applications/coh-archive.gar, wlsdeploy/applications/mywebapp.war
1146+
*
1147+
* Copy each archive to temp location then build the WDT archive
1148+
*
1149+
* @param wdtArchivePath path where new archive should be created
1150+
* @param archivePaths array of archives to be included in the WDT archive
1151+
* @param tmpDirRoot tmp directory that can be used to create the archve
1152+
*/
1153+
public static void buildWdtZip(
1154+
String wdtArchivePath, String[] archivePaths, String tmpDirRoot) {
1155+
1156+
try {
1157+
// Create temp directory strucuture for the WDT archive
1158+
String archiveRoot = tmpDirRoot + "/wdt-archive-root";
1159+
String archiveDest = archiveRoot + "/wlsdeploy/applications";
1160+
File archiveDestDir = new File(archiveDest);
1161+
archiveDestDir.mkdirs();
1162+
1163+
// Copy archives to the dest
1164+
for (String archivePath: archivePaths) {
1165+
copyFile(archivePath, archiveDest + "/" + new File(archivePath).getName());
1166+
}
1167+
1168+
// Build the WDT zip
1169+
buildZipArchive(wdtArchivePath, archiveRoot);
1170+
} catch (Exception e) {
1171+
throw new RuntimeException(e);
1172+
}
1173+
}
1174+
10811175
/**
10821176
* exec into the pod and call the shell script with given arguments.
10831177
*

integration-tests/src/test/resources/wdt/coh-wdt-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ resources:
3737
appDeployments:
3838
Application:
3939
'coh-proxy-gar-1.0':
40-
SourcePath: 'wlsdeploy/applications/coh-proxy-gar-1.0.gar'
40+
SourcePath: 'wlsdeploy/applications/coh-proxy-server.gar'
4141
ModuleType: gar
4242
Target: '@@PROP:CLUSTER_NAME@@'

0 commit comments

Comments
 (0)