Skip to content

Commit 162b453

Browse files
committed
use runtimeservice mbean to lookup config values
1 parent 8634b2e commit 162b453

File tree

2 files changed

+42
-68
lines changed

2 files changed

+42
-68
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,14 @@ public void testCustomSitConfigOverridesForDomain() throws Exception {
135135
+ " "
136136
+ T3CHANNELPORT
137137
+ " weblogic welcome1 "
138-
+ domain.getAdminServerName()
139-
+ " "
140138
+ testMethod
141139
+ "'");
142140
assertResult(result);
143141
testCompletedSuccessfully = true;
144142
logger.log(Level.INFO, "SUCCESS - {0}", testMethod);
145143
}
146-
144+
145+
147146
/**
148147
* This test covers custom configuration override use cases for config.xml.
149148
*
@@ -167,9 +166,9 @@ public void testCustomSitConfigOverridesForDomainMS() throws Exception {
167166
+ fqdn
168167
+ " "
169168
+ T3CHANNELPORT
170-
+ " weblogic welcome1 managed-server1 "
169+
+ " weblogic welcome1 "
171170
+ testMethod
172-
+ "'");
171+
+ " managed-server1'");
173172
assertResult(result);
174173
testCompletedSuccessfully = true;
175174
logger.log(Level.INFO, "SUCCESS - {0}", testMethod);
@@ -203,8 +202,6 @@ public void testCustomSitConfigOverridesForJdbc() throws Exception {
203202
+ " "
204203
+ T3CHANNELPORT
205204
+ " weblogic welcome1 "
206-
+ domain.getAdminServerName()
207-
+ " "
208205
+ testMethod
209206
+ " "
210207
+ JDBC_URL
@@ -238,8 +235,6 @@ public void testCustomSitConfigOverridesForJms() throws Exception {
238235
+ " "
239236
+ T3CHANNELPORT
240237
+ " weblogic welcome1 "
241-
+ domain.getAdminServerName()
242-
+ " "
243238
+ testMethod
244239
+ "'");
245240
assertResult(result);
@@ -273,8 +268,6 @@ public void testCustomSitConfigOverridesForWldf() throws Exception {
273268
+ " "
274269
+ T3CHANNELPORT
275270
+ " weblogic welcome1 "
276-
+ domain.getAdminServerName()
277-
+ " "
278271
+ testMethod
279272
+ "'");
280273
assertResult(result);

integration-tests/src/test/resources/sitconfig/java/SitConfigTests.java

Lines changed: 38 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import weblogic.management.configuration.ServerMBean;
3838
import weblogic.management.configuration.WLDFSystemResourceMBean;
3939
import weblogic.management.jmx.MBeanServerInvocationHandler;
40-
import weblogic.management.mbeanservers.edit.ConfigurationManagerMBean;
40+
import weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean;
4141
import weblogic.management.mbeanservers.runtime.RuntimeServiceMBean;
4242
import weblogic.management.runtime.ServerRuntimeMBean;
4343

@@ -62,8 +62,6 @@
6262
public class SitConfigTests {
6363

6464
private MBeanServerConnection runtimeMbs;
65-
private MBeanServerConnection editMbs;
66-
private ConfigurationManagerMBean cfgMgr;
6765
private JMXConnector jmxConnector;
6866
private static ObjectName service;
6967
private RuntimeServiceMBean runtimeServiceMBean;
@@ -74,7 +72,6 @@ public class SitConfigTests {
7472
private String adminPort;
7573
private final String adminUser;
7674
private final String adminPassword;
77-
private final String serverName;
7875

7976
/**
8077
* Main method to create the SitConfigTests object and run the configuration override tests. To
@@ -92,37 +89,36 @@ public static void main(String args[]) throws Exception {
9289
String adminHost = args[0];
9390
String adminPort = args[1];
9491
String adminUser = args[2];
95-
String adminPassword = args[3];
96-
String serverName = args[4];
97-
String testName = args[5];
92+
String adminPassword = args[3];
93+
String testName = args[4];
9894

99-
SitConfigTests test =
100-
new SitConfigTests(adminHost, adminPort, adminUser, adminPassword, serverName);
95+
SitConfigTests test = new SitConfigTests(adminHost, adminPort, adminUser, adminPassword);
10196

10297
ServerRuntimeMBean runtimeMBean = test.runtimeServiceMBean.getServerRuntime();
10398
println("Sitconfig State:" + runtimeMBean.isInSitConfigState());
10499

105100
if (testName.equals("testCustomSitConfigOverridesForDomain")) {
106101
// the values passed to these verify methods are the attribute values overrrideen in the
107102
// config.xml. These are just randomly chosen attributes and values to override
108-
test.verifyDebugFlagJMXCore(serverName, true);
109-
test.verifyDebugFlagServerLifeCycle(serverName, true);
110-
test.verifyMaxMessageSize(serverName, 78787878);
111-
test.verifyConnectTimeout(serverName, 120);
112-
test.verifyRestartMax(serverName, 5);
113-
test.verifyT3ChannelPublicAddress(serverName, adminHost);
114-
test.verifyT3ChannelPublicPort(serverName, 30091);
103+
test.verifyDebugFlagJMXCore(true);
104+
test.verifyDebugFlagServerLifeCycle(true);
105+
test.verifyMaxMessageSize(78787878);
106+
test.verifyConnectTimeout(120);
107+
test.verifyRestartMax(5);
108+
test.verifyT3ChannelPublicAddress(adminHost);
109+
test.verifyT3ChannelPublicPort(30091);
115110
}
116-
111+
117112
if (testName.equals("testCustomSitConfigOverridesForDomainMS")) {
118113
// the values passed to these verify methods are the attribute values overrrideen in the
119114
// config.xml. These are just randomly chosen attributes and values to override
115+
String serverName = args[5];
120116
test.connectToManagedServer(serverName);
121-
test.verifyMaxMessageSize(serverName, 77777777);
117+
test.verifyMaxMessageSize(77777777);
122118
}
123119

124120
if (testName.equals("testCustomSitConfigOverridesForJdbc")) {
125-
String JDBC_URL = args[6];
121+
String JDBC_URL = args[5];
126122
test.testSystemResourcesJDBCAttributeChange("JdbcTestDataSource-0", JDBC_URL);
127123
}
128124

@@ -141,19 +137,16 @@ public static void main(String args[]) throws Exception {
141137
* @param adminHost - administration server t3 public address
142138
* @param adminPort - administration server t3 public port
143139
* @param adminUser - administration server user name
144-
* @param adminPassword - administration server password
145-
* @param serverName - name of the server for which the configuration values to be checked
140+
* @param adminPassword - - administration server password
146141
* @throws Exception when connection cannot be created for reasons like incorrect administration
147142
* server name, port , user name , password or administration server not running
148143
*/
149-
public SitConfigTests(
150-
String adminHost, String adminPort, String adminUser, String adminPassword, String serverName)
144+
public SitConfigTests(String adminHost, String adminPort, String adminUser, String adminPassword)
151145
throws Exception {
152146
this.adminHost = adminHost;
153147
this.adminPort = adminPort;
154148
this.adminUser = adminUser;
155149
this.adminPassword = adminPassword;
156-
this.serverName = serverName;
157150
createConnections();
158151
}
159152

@@ -176,6 +169,7 @@ private void createConnections() throws Exception {
176169
runtimeServiceMBean =
177170
(RuntimeServiceMBean)
178171
MBeanServerInvocationHandler.newProxyInstance(runtimeMbs, runtimeserviceObjectName);
172+
ObjectName domainServiceObjectName = new ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME);
179173
}
180174

181175
/**
@@ -224,6 +218,7 @@ private MBeanServerConnection lookupMBeanServerConnection(
224218
if (mBeanServerConnection == null) {
225219
throw new Exception("MBean server connection is null");
226220
}
221+
227222
return mBeanServerConnection;
228223
}
229224

@@ -234,11 +229,9 @@ private MBeanServerConnection lookupMBeanServerConnection(
234229
*
235230
* @param expectedValue - boolean value to be checked in the debug-jmx-core attribute in
236231
* ServerMBean in ServerConfig tree.
237-
* @param serverName - name of the weblogic server instance for which the debug flag to be checked
238-
* as a String
239232
*/
240-
protected void verifyDebugFlagJMXCore(String serverName, boolean expectedValue) {
241-
ServerMBean serverMBean = getServerMBean(serverName);
233+
protected void verifyDebugFlagJMXCore(boolean expectedValue) {
234+
ServerMBean serverMBean = getServerMBean();
242235
ServerDebugMBean serverDebugMBean = serverMBean.getServerDebug();
243236
boolean debugFlag = serverDebugMBean.getDebugJMXCore();
244237
assert expectedValue == debugFlag
@@ -250,14 +243,11 @@ protected void verifyDebugFlagJMXCore(String serverName, boolean expectedValue)
250243
* with the expected value, a boolean value set in the configuration override file config.xml.Uses
251244
* Java assertions to verify if both the values match.
252245
*
253-
* @param serverName name of the weblogic server instance for which the debug flag to be checked
254-
* as a String
255246
* @param expectedValue - boolean value to be checked in the debug-server-life-cycle attribute in
256-
* ServerMBean in ServerConfig MBean tree * @param serverName - name of the weblogic server
257-
* instance for which the debug flag to be checked as a String
247+
* ServerMBean in ServerConfig MBean tree
258248
*/
259-
protected void verifyDebugFlagServerLifeCycle(String serverName, boolean expectedValue) {
260-
ServerMBean serverMBean = getServerMBean(serverName);
249+
protected void verifyDebugFlagServerLifeCycle(boolean expectedValue) {
250+
ServerMBean serverMBean = getServerMBean();
261251
ServerDebugMBean serverDebugMBean = serverMBean.getServerDebug();
262252
boolean debugFlag = serverDebugMBean.getDebugServerLifeCycle();
263253
assert expectedValue == debugFlag
@@ -271,11 +261,9 @@ protected void verifyDebugFlagServerLifeCycle(String serverName, boolean expecte
271261
*
272262
* @param expectedValue - integer value to be checked in the connect-timeout attribute in
273263
* ServerMBean in ServerConfig tree.
274-
* @param serverName - name of the weblogic server instance for which the connect timeout to be
275-
* checked as a String
276264
*/
277-
protected void verifyConnectTimeout(String serverName, int expectedValue) {
278-
ServerMBean serverMBean = getServerMBean(serverName);
265+
protected void verifyConnectTimeout(int expectedValue) {
266+
ServerMBean serverMBean = getServerMBean();
279267
int got = serverMBean.getConnectTimeout();
280268
assert expectedValue == got
281269
: "Didn't get the expected value " + expectedValue + " for ConnectTimeout";
@@ -288,11 +276,9 @@ protected void verifyConnectTimeout(String serverName, int expectedValue) {
288276
*
289277
* @param expectedValue - integer value to be checked in the restart-max attribute in ServerMBean
290278
* in ServerConfig tree.
291-
* @param serverName - name of the weblogic server instance for which the restart max to be
292-
* checked as a String
293279
*/
294-
protected void verifyRestartMax(String serverName, int expectedValue) {
295-
ServerMBean serverMBean = getServerMBean(serverName);
280+
protected void verifyRestartMax(int expectedValue) {
281+
ServerMBean serverMBean = getServerMBean();
296282
int got = serverMBean.getRestartMax();
297283
assert expectedValue == got
298284
: "Didn't get the expected value " + expectedValue + " for RestartMax";
@@ -305,11 +291,9 @@ protected void verifyRestartMax(String serverName, int expectedValue) {
305291
*
306292
* @param expectedValue - integer value to be checked in the max-message-size attribute in
307293
* ServerMBean in ServerConfig tree
308-
* @param serverName - name of the weblogic server instance for which the max message size to be
309-
* checked as a String
310294
*/
311-
protected void verifyMaxMessageSize(String serverName, int expectedValue) {
312-
ServerMBean serverMBean = getServerMBean(serverName);
295+
protected void verifyMaxMessageSize(int expectedValue) {
296+
ServerMBean serverMBean = getServerMBean();
313297
int got = serverMBean.getMaxMessageSize();
314298
assert expectedValue == got
315299
: "Didn't get the expected value " + expectedValue + " for MaxMessageSize";
@@ -320,15 +304,14 @@ protected void verifyMaxMessageSize(String serverName, int expectedValue) {
320304
* matches with the expected value, a string value set in the configuration override file
321305
* config.xml. Uses Java assertions to verify if both the values match.
322306
*
323-
* @param serverName name of the weblogic server instance for which the t3 public address to be
324-
* checked as a String
325307
* @param expectedValue - string value to be checked in the public-address attribute in
326308
* ServerMBean in ServerConfig tree.
327309
*/
328-
protected void verifyT3ChannelPublicAddress(String serverName, String expectedValue) {
310+
protected void verifyT3ChannelPublicAddress(String expectedValue) {
329311
boolean got = false;
330-
ServerMBean serverMBean = getServerMBean(serverName);
312+
ServerMBean serverMBean = getServerMBean();
331313
NetworkAccessPointMBean[] networkAccessPoints = serverMBean.getNetworkAccessPoints();
314+
332315
for (NetworkAccessPointMBean networkAccessPoint : networkAccessPoints) {
333316
if (networkAccessPoint.getName().equals("T3Channel")) {
334317
assert expectedValue.equals(networkAccessPoint.getPublicAddress())
@@ -343,13 +326,12 @@ protected void verifyT3ChannelPublicAddress(String serverName, String expectedVa
343326
*
344327
* @param expectedValue - integer value to be checked in the public-port attribute in ServerMBean
345328
* in ServerConfig tree
346-
* @param serverName - name of the weblogic server instance for which the t3 port to be checked as
347-
* a String
348329
*/
349-
protected void verifyT3ChannelPublicPort(String serverName, int expectedValue) {
330+
protected void verifyT3ChannelPublicPort(int expectedValue) {
350331
boolean got = false;
351-
ServerMBean serverMBean = getServerMBean(serverName);
332+
ServerMBean serverMBean = getServerMBean();
352333
NetworkAccessPointMBean[] networkAccessPoints = serverMBean.getNetworkAccessPoints();
334+
353335
for (NetworkAccessPointMBean networkAccessPoint : networkAccessPoints) {
354336
if (networkAccessPoint.getName().equals("T3Channel")) {
355337
assert expectedValue == networkAccessPoint.getPublicPort()
@@ -361,10 +343,9 @@ protected void verifyT3ChannelPublicPort(String serverName, int expectedValue) {
361343
/**
362344
* Looks up the ServerMBean from RuntimeServiceMBean.
363345
*
364-
* @param the name weblogic server instance for which to lookup the ServerMBean
365346
* @return the ServerMBean reference
366347
*/
367-
private ServerMBean getServerMBean(String serverName) {
348+
private ServerMBean getServerMBean() {
368349
ServerMBean serverMBean = runtimeServiceMBean.getServerConfiguration();
369350
println("ServerMBean: " + serverMBean);
370351

@@ -601,7 +582,7 @@ protected WLDFSystemResourceMBean getWLDFSystemModule(String resourceName) {
601582
return wldfResource;
602583
}
603584

604-
private void connectToManagedServer(String serverName) throws Exception {
585+
private void connectToManagedServer(String serverName) throws Exception {
605586
ServerMBean[] servers = runtimeServiceMBean.getDomainConfiguration().getServers();
606587
try {
607588
for (ServerMBean server : servers) {

0 commit comments

Comments
 (0)