Skip to content

Commit 7104b1c

Browse files
committed
added doc comments
1 parent fcc2a82 commit 7104b1c

File tree

4 files changed

+235
-179
lines changed

4 files changed

+235
-179
lines changed

integration-tests/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ Configuration Overrides Usecases
8282

8383
| Override | Usecase |
8484
| --- | --- |
85-
| Domain override | Override the administration server properties connect-timeout, max-message-size, restart-max, JMXCore and Serverlifecycle debug flags. Also T3Channel public address using Kubernetes secret. The override is verified by JMX client connecting to the serverConfig MBean tree and the values are checked against the expected values. The test client connects to the overridden T3 public address and port to connect to the MBean servers |
86-
| JDBC Resource Override | Override JDBC connection pool properties; initialCapacity, maxCapacity, test-connections-on-reserve, connection-harvest-max-count, inactive-connection-timeout-seconds. Override the JDBC driver parameters like data source URL, DB user and password using kubernetes secret. The test verifies the overridden functionality datasource URL, user/pass by getting the data source connection and verifies the DB name it is connected to. |
87-
| JMS Resource Override | Override UniformDistributedTopic Delivery Failure Parameters, Redelivery limit and Expiration policy. The JMX test client verifies the serverConfig MBean tree for the expected deliver failure parameters, redelivery limit and expiration policy. |
88-
| WLDF Resource Override | Override instrumentation monitors and harvesters in a diagnostics module. The test client verifies the new instrumentation monitors / harvesters set by getting the WLDF resource from serverConfig tree with expected values. |
85+
| Configuration override | Override the administration server properties `connect-timeout`, `max-message-size`, `restart-max`, `debug-server-life-cycle` and `debug-jmx-core` debug flags. Also T3Channel public address using Kubernetes secret. The override is verified by JMX client connecting to the serverConfig MBean tree and the values are checked against the expected values. The test client connects to the overridden T3 public address and port to connect to the MBean servers |
86+
| JDBC Resource Override | Override JDBC connection pool properties; `initialCapacity`, `maxCapacity`, `test-connections-on-reserve`, `connection-harvest-max-count`, `inactive-connection-timeout-seconds`. Override the JDBC driver parameters like data source `URL`, `DB` `user` and `password` using kubernetes secret. The test verifies the overridden functionality datasource `URL`, `user`, `password` by getting the data source connection and running DDL statement it is connected to. |
87+
| JMS Resource Override | Override UniformDistributedTopic Delivery Failure Parameters, `redelivery-limit` and `expiration-policy`. The JMX test client verifies the serverConfig MBean tree for the expected delivery failure parameters, `redelivery-limit` and `expiration-policy`. |
88+
| WLDF Resource Override | Override `wldf-instrumentation-monitor` and `harvester` in a diagnostics module. The test client verifies the new instrumentation monitors / harvesters set by getting the WLDF resource from serverConfig tree with expected values. |
8989

9090
# Directory Configuration and Structure
9191

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

Lines changed: 104 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import java.util.*;
1717
import java.util.logging.Level;
1818
import oracle.kubernetes.operator.utils.Domain;
19-
import oracle.kubernetes.operator.utils.ExecCommand;
2019
import oracle.kubernetes.operator.utils.ExecResult;
2120
import oracle.kubernetes.operator.utils.Operator;
2221
import oracle.kubernetes.operator.utils.TestUtils;
@@ -28,18 +27,19 @@
2827

2928
public class ITSitConfig extends BaseTest {
3029

31-
private static String TESTSCRIPTDIR = "";
32-
33-
private static String ADMINPODNAME = "";
30+
private static String TESTSCRIPTDIR;
31+
private static String ADMINPODNAME;
3432
private static final String DOMAINUID = "customsitconfigdomain";
3533
private static final String ADMINPORT = "30710";
3634
private static final int T3CHANNELPORT = 30091;
3735
private static final String MYSQL_DB_PORT = "31306";
3836
private static String fqdn;
3937
private static String JDBC_URL;
38+
private static String KUBE_EXEC_CMD;
4039

41-
private static Domain domain = null;
40+
private static Domain domain;
4241
private static Operator operator1;
42+
4343
/**
4444
* This method gets called only once before any of the test methods are executed. It does the
4545
* initialization of the integration test properties defined in OperatorIT.properties and setting
@@ -50,21 +50,27 @@ public class ITSitConfig extends BaseTest {
5050
@BeforeClass
5151
public static void staticPrepare() throws Exception {
5252
// initialize test properties and create the directories
53-
5453
if (!QUICKTEST) {
5554
// initialize test properties and create the directories
5655
initialize(APP_PROPS_FILE);
57-
5856
if (operator1 == null) {
5957
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
6058
}
6159
TESTSCRIPTDIR = BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/";
62-
manageMySqlDB(TESTSCRIPTDIR + "/sitconfig/mysql/mysql-dbservices.yml", "create");
60+
// Create the MySql db container
61+
ExecResult result =
62+
TestUtils.exec(
63+
"kubectl create -f " + TESTSCRIPTDIR + "/sitconfig/mysql/mysql-dbservices.yml");
64+
Assert.assertEquals(0, result.exitValue());
65+
6366
fqdn = TestUtils.getHostName();
6467
JDBC_URL = "jdbc:mysql://" + fqdn + ":" + MYSQL_DB_PORT + "/";
68+
// copy the configuration override files to replacing the JDBC_URL token
6569
copySitConfigFiles();
70+
// create weblogic domain with configOverrides
6671
domain = createSitConfigDomain();
6772
Assert.assertNotNull(domain);
73+
// copy the jmx test client file the administratioin server weblogic server pod
6874
ADMINPODNAME = domain.getDomainUid() + "-" + domain.getAdminServerName();
6975
TestUtils.copyFileViaCat(
7076
TESTSCRIPTDIR + "sitconfig/java/SitConfigTests.java",
@@ -76,11 +82,13 @@ public static void staticPrepare() throws Exception {
7682
"runSitConfigTests.sh",
7783
ADMINPODNAME,
7884
domain.getDomainNS());
85+
KUBE_EXEC_CMD =
86+
"kubectl -n " + domain.getDomainNS() + " exec -it " + ADMINPODNAME + " -- bash -c";
7987
}
8088
}
8189

8290
/**
83-
* Releases k8s cluster lease, archives result, pv directories
91+
* Destroy domain, delete the MySql DB container and teardown
8492
*
8593
* @throws Exception
8694
*/
@@ -93,16 +101,21 @@ public static void staticUnPrepare() throws Exception {
93101

94102
destroySitConfigDomain();
95103
tearDown();
96-
manageMySqlDB(TESTSCRIPTDIR + "/sitconfig/mysql-dbservices.yml", "delete");
104+
ExecResult result =
105+
TestUtils.exec(
106+
"kubectl delete -f " + TESTSCRIPTDIR + "/sitconfig/mysql/mysql-dbservices.yml");
107+
// manageMySqlDB(TESTSCRIPTDIR + "/sitconfig/mysql-dbservices.yml", "delete");
97108
logger.info("SUCCESS");
98109
}
99110
}
100111

101112
/**
102-
* This test covers custom situational configuration use cases for config.xml. It sets the
103-
* connect-timeout, max-message-size, restart-max, JMXCore and Serverlifecycle debug flags. Also
104-
* sets the T3Channel public address using Kubernetes secret and verifies all these parameters are
105-
* overridden for domain
113+
* This test covers custom configuration override use cases for config.xml.
114+
*
115+
* <p>The test checks the overridden config.xml attributes connect-timeout, max-message-size,
116+
* restart-max, JMXCore and ServerLifeCycle debug flags, the T3Channel public address. The
117+
* overridden are verified against the ServerConfig MBean tree. It does not verifies whether the
118+
* overridden values are applied to the runtime
106119
*
107120
* @throws Exception
108121
*/
@@ -112,23 +125,32 @@ public void testCustomSitConfigOverridesForDomain() throws Exception {
112125
boolean testCompletedSuccessfully = false;
113126
String testMethod = new Object() {}.getClass().getEnclosingMethod().getName();
114127
logTestBegin(testMethod);
115-
String stdout =
116-
callShellScriptByExecToPod(
117-
"runSitConfigTests.sh",
118-
fqdn + " " + T3CHANNELPORT + " weblogic welcome1 " + testMethod,
119-
ADMINPODNAME,
120-
domain.getDomainNS());
121-
Assert.assertFalse(stdout.toLowerCase().contains("error"));
128+
ExecResult result =
129+
TestUtils.exec(
130+
KUBE_EXEC_CMD
131+
+ " 'sh runSitConfigTests.sh"
132+
+ fqdn
133+
+ " "
134+
+ T3CHANNELPORT
135+
+ " weblogic welcome1 "
136+
+ testMethod
137+
+ "'");
138+
assertResult(result);
122139
testCompletedSuccessfully = true;
123140
logger.log(Level.INFO, "SUCCESS - {0}", testMethod);
124141
}
125142

126143
/**
127-
* This test covers custom situational configuration use cases for JDBC resource. The resource
128-
* override sets the following connection pool properties. initialCapacity, maxCapacity,
129-
* test-connections-on-reserve, connection-harvest-max-count, inactive-connection-timeout-seconds
130-
* It also overrides the jdbc driver parameters like data source url, db user and password using
131-
* kubernetes secret.
144+
* This test covers custom resource override use cases for JDBC resource.
145+
*
146+
* <p>The resource override sets the following connection pool properties. initialCapacity,
147+
* maxCapacity, test-connections-on-reserve, connection-harvest-max-count,
148+
* inactive-connection-timeout-seconds in the JDBC resource override file. It also overrides the
149+
* jdbc driver parameters like data source url, db user and password using kubernetes secret.
150+
*
151+
* <p>The overridden values are verified against the ServerConfig MBean tree. It does not verifies
152+
* whether the overridden values are applied to the runtime except the JDBC URL which is verified
153+
* at runtime by making a connection to the MySql database and executing a DDL statement.
132154
*
133155
* @throws Exception
134156
*/
@@ -138,21 +160,30 @@ public void testCustomSitConfigOverridesForJdbc() throws Exception {
138160
boolean testCompletedSuccessfully = false;
139161
String testMethod = new Object() {}.getClass().getEnclosingMethod().getName();
140162
logTestBegin(testMethod);
141-
String stdout =
142-
callShellScriptByExecToPod(
143-
"runSitConfigTests.sh",
144-
fqdn + " " + T3CHANNELPORT + " weblogic welcome1 " + testMethod + " " + JDBC_URL,
145-
ADMINPODNAME,
146-
domain.getDomainNS());
147-
Assert.assertFalse(stdout.toLowerCase().contains("error"));
163+
ExecResult result =
164+
TestUtils.exec(
165+
KUBE_EXEC_CMD
166+
+ " 'sh runSitConfigTests.sh"
167+
+ fqdn
168+
+ " "
169+
+ T3CHANNELPORT
170+
+ " weblogic welcome1 "
171+
+ testMethod
172+
+ " "
173+
+ JDBC_URL
174+
+ "'");
175+
assertResult(result);
148176
testCompletedSuccessfully = true;
149177
logger.log(Level.INFO, "SUCCESS - {0}", testMethod);
150178
}
151179

152180
/**
153-
* This test covers custom situational configuration use cases for JMS resource The resource
154-
* override file sets the following Delivery Failure Parameters. Redelivery limit and Expiration
155-
* policy
181+
* This test covers custom resource use cases for JMS resource The JMS resource override file sets
182+
* the following Delivery Failure Parameters. Redelivery limit and Expiration policy for a
183+
* uniform-distributed-topic JMS resource
184+
*
185+
* <p>The overridden values are verified against the ServerConfig MBean tree. It does not verifies
186+
* whether the overridden values are applied to the runtime
156187
*
157188
* @throws Exception
158189
*/
@@ -162,20 +193,30 @@ public void testCustomSitConfigOverridesForJms() throws Exception {
162193
boolean testCompletedSuccessfully = false;
163194
String testMethod = new Object() {}.getClass().getEnclosingMethod().getName();
164195
logTestBegin(testMethod);
165-
String stdout =
166-
callShellScriptByExecToPod(
167-
"runSitConfigTests.sh",
168-
fqdn + " " + T3CHANNELPORT + " weblogic welcome1 " + testMethod,
169-
ADMINPODNAME,
170-
domain.getDomainNS());
171-
Assert.assertFalse(stdout.toLowerCase().contains("error"));
196+
ExecResult result =
197+
TestUtils.exec(
198+
KUBE_EXEC_CMD
199+
+ " 'sh runSitConfigTests.sh"
200+
+ fqdn
201+
+ " "
202+
+ T3CHANNELPORT
203+
+ " weblogic welcome1 "
204+
+ testMethod
205+
+ "'");
206+
assertResult(result);
172207
testCompletedSuccessfully = true;
173208
logger.log(Level.INFO, "SUCCESS - {0}", testMethod);
174209
}
175210

176211
/**
177-
* This test covers custom situational configuration use cases for diagnostics resource It adds a
178-
* bunch of instrumentation monitors and harvesters in a diagnostics module.
212+
* This test covers custom resource override use cases for diagnostics resource. It adds the
213+
* following instrumentation monitors Connector_After_Inbound Connector_Around_Outbound
214+
* Connector_Around_Tx Connector_Around_Work Connector_Before_Inbound and harvesters for
215+
* weblogic.management.runtime.JDBCServiceRuntimeMBean
216+
* weblogic.management.runtime.ServerRuntimeMBean
217+
*
218+
* <p>The overridden values are verified against the ServerConfig MBean tree. It does not verifies
219+
* whether the overridden values are applied to the runtime
179220
*
180221
* @throws Exception
181222
*/
@@ -185,13 +226,18 @@ public void testCustomSitConfigOverridesForWldf() throws Exception {
185226
boolean testCompletedSuccessfully = false;
186227
String testMethod = new Object() {}.getClass().getEnclosingMethod().getName();
187228
logTestBegin(testMethod);
188-
String stdout =
189-
callShellScriptByExecToPod(
190-
"runSitConfigTests.sh",
191-
fqdn + " " + T3CHANNELPORT + " weblogic welcome1 " + testMethod,
192-
ADMINPODNAME,
193-
domain.getDomainNS());
194-
Assert.assertFalse(stdout.toLowerCase().contains("error"));
229+
TestUtils.exec(fqdn);
230+
ExecResult result =
231+
TestUtils.exec(
232+
KUBE_EXEC_CMD
233+
+ " 'sh runSitConfigTests.sh"
234+
+ fqdn
235+
+ " "
236+
+ T3CHANNELPORT
237+
+ " weblogic welcome1 "
238+
+ testMethod
239+
+ "'");
240+
assertResult(result);
195241
testCompletedSuccessfully = true;
196242
logger.log(Level.INFO, "SUCCESS - {0}", testMethod);
197243
}
@@ -222,54 +268,6 @@ private static void destroySitConfigDomain() throws Exception {
222268
}
223269
}
224270

225-
private static String callShellScriptByExecToPod(
226-
String scriptPath, String arguments, String podName, String namespace) throws Exception {
227-
228-
StringBuffer cmdKubectlSh = new StringBuffer("kubectl -n ");
229-
cmdKubectlSh
230-
.append(namespace)
231-
.append(" exec -it ")
232-
.append(podName)
233-
.append(" -- bash -c 'sh ")
234-
.append(scriptPath)
235-
.append(" ")
236-
.append(arguments)
237-
.append("'");
238-
logger.info("Command to call kubectl sh file " + cmdKubectlSh);
239-
ExecResult result = ExecCommand.exec(cmdKubectlSh.toString());
240-
if (result.exitValue() != 0) {
241-
logger.log(Level.INFO, result.stdout().trim());
242-
throw new RuntimeException(
243-
"FAILURE: command " + cmdKubectlSh + " failed, returned " + result.stderr());
244-
}
245-
logger.log(Level.INFO, result.stdout().trim());
246-
return result.stdout().trim();
247-
}
248-
249-
/**
250-
* create mysql crd
251-
*
252-
* @throws Exception
253-
*/
254-
public static void manageMySqlDB(String dbYaml, String task) throws Exception {
255-
StringBuffer cmd = new StringBuffer("kubectl " + task + " -f ");
256-
cmd.append(dbYaml);
257-
logger.info("Running " + cmd);
258-
ExecResult result = ExecCommand.exec(cmd.toString());
259-
if (result.exitValue() != 0) {
260-
logger.log(Level.INFO, result.stdout().trim());
261-
throw new RuntimeException(
262-
"FAILURE: command "
263-
+ cmd
264-
+ " failed, returned "
265-
+ result.stdout()
266-
+ "\n"
267-
+ result.stderr());
268-
}
269-
String outputStr = result.stdout().trim();
270-
logger.info("Command returned " + outputStr);
271-
}
272-
273271
private static void copySitConfigFiles() throws IOException {
274272
String src_dir = TESTSCRIPTDIR + "/sitconfig/configoverrides";
275273
String dst_dir = sitconfigDir;
@@ -289,4 +287,10 @@ private static void copySitConfigFiles() throws IOException {
289287
Files.write(path, content.getBytes(charset), StandardOpenOption.TRUNCATE_EXISTING);
290288
}
291289
}
290+
291+
private void assertResult(ExecResult result) {
292+
Assert.assertFalse(result.stdout().toLowerCase().contains("error"));
293+
Assert.assertFalse(result.stderr().toLowerCase().contains("error"));
294+
Assert.assertEquals(0, result.exitValue());
295+
}
292296
}

0 commit comments

Comments
 (0)