Skip to content

Commit 7c914a6

Browse files
committed
testing automatic sit config overrides
1 parent 98d5034 commit 7c914a6

File tree

6 files changed

+371
-2
lines changed

6 files changed

+371
-2
lines changed

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class ITOperator extends BaseTest {
4545
private static final String domain3ForDelValueYamlFile = "domain_del_3.yaml";
4646
private static String domain9YamlFile = "domain9.yaml";
4747
private static String domain10YamlFile = "domain10.yaml";
48+
private static String domain11YamlFile = "domain11.yaml";
4849

4950
// property file used to configure constants for integration tests
5051
private static String appPropsFile = "OperatorIT.properties";
@@ -331,6 +332,56 @@ public void testDeleteTwoDomains() throws Exception {
331332
TestUtils.verifyAfterDeletion(domainDel2);
332333
}
333334

335+
@Test
336+
public void testAutoSitConfigOverrides() throws Exception {
337+
Assume.assumeFalse(QUICKTEST);
338+
logTestBegin("testAutoSitConfigOverrides");
339+
try {
340+
// cp py
341+
StringBuffer cmd = new StringBuffer("cd ");
342+
cmd.append(BaseTest.getProjectRoot())
343+
.append(
344+
"/integration-tests/src/test/resources/domain-home-on-pv && cp create-domain.py create-domain.py.bak");
345+
logger.info("Running " + cmd);
346+
347+
ExecResult result = ExecCommand.exec(cmd.toString());
348+
if (result.exitValue() != 0) {
349+
throw new RuntimeException(cmd + " failed");
350+
}
351+
352+
cmd = new StringBuffer("cd ");
353+
cmd.append(BaseTest.getProjectRoot())
354+
.append(
355+
"/integration-tests/src/test/resources/domain-home-on-pv && cp create-domain-auto-sit-config.py create-domain.py");
356+
logger.info("Running " + cmd);
357+
result = ExecCommand.exec(cmd.toString());
358+
if (result.exitValue() != 0) {
359+
throw new RuntimeException(cmd + " failed");
360+
}
361+
362+
if (operator1 == null) {
363+
operator1 = TestUtils.createOperator(op1YamlFile);
364+
}
365+
366+
testAllUseCasesForADomain(operator1, domain11YamlFile);
367+
368+
logger.info("SUCCESS - test1CreateFirstOperatorAndDomain");
369+
} finally {
370+
StringBuffer cmd = new StringBuffer("cd ");
371+
cmd.append(BaseTest.getProjectRoot())
372+
.append(
373+
"/integration-tests/src/test/resources/domain-home-on-pv && cp create-domain.py.bak create-domain.py");
374+
logger.info("Running " + cmd);
375+
376+
ExecResult result = ExecCommand.exec(cmd.toString());
377+
if (result.exitValue() != 0) {
378+
throw new RuntimeException(cmd + " failed");
379+
}
380+
}
381+
// cp py back
382+
383+
}
384+
334385
private void testCreateOperatorManagingDefaultAndTest1NS() throws Exception {
335386
logger.info("Creating Operator & waiting for the script to complete execution");
336387
// create operator1

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ private void createPV() throws Exception {
612612
weblogicDomainStorageSize = (String) pvMap.get("weblogicDomainStorageSize");
613613

614614
// test NFS for domain5 on JENKINS
615-
if (domainUid.equals("domain5")
615+
if (domainUid.equals("domain6")
616616
&& (System.getenv("JENKINS") != null
617617
&& System.getenv("JENKINS").equalsIgnoreCase("true"))) {
618618
pvMap.put("weblogicDomainStorageType", "NFS");
@@ -863,7 +863,9 @@ private void initialize(String inputYaml) throws Exception {
863863
}
864864

865865
domainMap.put("domainHome", "/shared/domains/" + domainUid);
866-
866+
domainMap.put(
867+
"createDomainFilesDir",
868+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv");
867869
String imageName = "store/oracle/weblogic";
868870
if (System.getenv("IMAGE_NAME_WEBLOGIC") != null) {
869871
imageName = System.getenv("IMAGE_NAME_WEBLOGIC");
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
def getEnvVar(var):
5+
val=os.environ.get(var)
6+
if val==None:
7+
print "ERROR: Env var ",var, " not set."
8+
sys.exit(1)
9+
return val
10+
11+
# This python script is used to create a WebLogic domain
12+
13+
domain_uid = getEnvVar("DOMAIN_UID")
14+
server_port = int(getEnvVar("MANAGED_SERVER_PORT"))
15+
domain_path = getEnvVar("DOMAIN_HOME")
16+
cluster_name = getEnvVar("CLUSTER_NAME")
17+
admin_server_name = getEnvVar("ADMIN_SERVER_NAME")
18+
admin_server_name_svc = getEnvVar("ADMIN_SERVER_NAME_SVC")
19+
admin_port = int(getEnvVar("ADMIN_PORT"))
20+
domain_name = getEnvVar("DOMAIN_NAME")
21+
t3_channel_port = int(getEnvVar("T3_CHANNEL_PORT"))
22+
t3_public_address = getEnvVar("T3_PUBLIC_ADDRESS")
23+
number_of_ms = int(getEnvVar("CONFIGURED_MANAGED_SERVER_COUNT"))
24+
cluster_type = getEnvVar("CLUSTER_TYPE")
25+
managed_server_name_base = getEnvVar("MANAGED_SERVER_NAME_BASE")
26+
managed_server_name_base_svc = getEnvVar("MANAGED_SERVER_NAME_BASE_SVC")
27+
domain_logs = getEnvVar("DOMAIN_LOGS_DIR")
28+
script_dir = getEnvVar("CREATE_DOMAIN_SCRIPT_DIR")
29+
production_mode_enabled = getEnvVar("PRODUCTION_MODE_ENABLED")
30+
31+
# Read the domain secrets from the common python file
32+
execfile('%s/read-domain-secret.py' % script_dir)
33+
34+
print('domain_path : [%s]' % domain_path);
35+
print('domain_name : [%s]' % domain_name);
36+
print('admin_server_name : [%s]' % admin_server_name);
37+
print('admin_username : [%s]' % admin_username);
38+
print('admin_port : [%s]' % admin_port);
39+
print('cluster_name : [%s]' % cluster_name);
40+
print('server_port : [%s]' % server_port);
41+
# Open default domain template
42+
# ============================
43+
readTemplate("/u01/oracle/wlserver/common/templates/wls/wls.jar")
44+
45+
set('Name', domain_name)
46+
setOption('DomainName', domain_name)
47+
48+
# Configure the Administration Server
49+
# ===================================
50+
cd('/Servers/AdminServer')
51+
# Give incorrect listenaddress, introspector overrides with sit-config
52+
set('ListenAddress', 'junk')
53+
set('ListenPort', admin_port)
54+
set('Name', admin_server_name)
55+
create('AdminServer','Log')
56+
cd('/Servers/AdminServer/Log/AdminServer')
57+
# Give incorrect filelog, introspector overrides with sit-config
58+
set('FileName', 'dirdoesnotexist')
59+
60+
create('T3Channel', 'NetworkAccessPoint')
61+
cd('/Servers/%s/NetworkAccessPoints/T3Channel' % admin_server_name)
62+
set('PublicPort', t3_channel_port)
63+
set('PublicAddress', t3_public_address)
64+
# Give incorrect listenaddress, introspector overrides with sit-config
65+
set('ListenAddress', 'junk')
66+
set('ListenPort', t3_channel_port)
67+
68+
69+
# Set the admin user's username and password
70+
# ==========================================
71+
cd('/Security/%s/User/weblogic' % domain_name)
72+
cmo.setName(admin_username)
73+
cmo.setPassword(admin_password)
74+
75+
# Write the domain and close the domain template
76+
# ==============================================
77+
setOption('OverwriteDomain', 'true')
78+
79+
# Create a cluster
80+
# ======================
81+
cd('/')
82+
cl=create(cluster_name, 'Cluster')
83+
84+
if cluster_type == "CONFIGURED":
85+
86+
# Create managed servers
87+
for index in range(0, number_of_ms):
88+
cd('/')
89+
90+
msIndex = index+1
91+
name = '%s%s' % (managed_server_name_base, msIndex)
92+
name_svc = '%s%s' % (managed_server_name_base_svc, msIndex)
93+
94+
create(name, 'Server')
95+
cd('/Servers/%s/' % name )
96+
print('managed server name is %s' % name);
97+
set('ListenAddress', '%s-%s' % (domain_uid, name_svc))
98+
set('ListenPort', server_port)
99+
set('NumOfRetriesBeforeMSIMode', 0)
100+
set('RetryIntervalBeforeMSIMode', 1)
101+
set('Cluster', cluster_name)
102+
103+
else:
104+
print('Configuring Dynamic Cluster %s' % cluster_name)
105+
106+
templateName = cluster_name + "-template"
107+
print('Creating Server Template: %s' % templateName)
108+
st1=create(templateName, 'ServerTemplate')
109+
print('Done creating Server Template: %s' % templateName)
110+
cd('/ServerTemplates/%s' % templateName)
111+
cmo.setListenPort(server_port)
112+
cmo.setListenAddress('%s-%s${id}' % (domain_uid, managed_server_name_base_svc))
113+
cmo.setCluster(cl)
114+
print('Done setting attributes for Server Template: %s' % templateName);
115+
116+
117+
cd('/Clusters/%s' % cluster_name)
118+
create(cluster_name, 'DynamicServers')
119+
cd('DynamicServers/%s' % cluster_name)
120+
set('ServerTemplate', st1)
121+
set('ServerNamePrefix', managed_server_name_base)
122+
set('DynamicClusterSize', number_of_ms)
123+
set('MaxDynamicClusterSize', number_of_ms)
124+
set('CalculatedListenPorts', false)
125+
set('Id', 1)
126+
127+
print('Done setting attributes for Dynamic Cluster: %s' % cluster_name);
128+
129+
# Write Domain
130+
# ============
131+
writeDomain(domain_path)
132+
closeTemplate()
133+
print 'Domain Created'
134+
135+
# Update Domain
136+
readDomain(domain_path)
137+
cd('/')
138+
if production_mode_enabled == "true":
139+
cmo.setProductionModeEnabled(true)
140+
else:
141+
cmo.setProductionModeEnabled(false)
142+
updateDomain()
143+
closeDomain()
144+
print 'Domain Updated'
145+
print 'Done'
146+
147+
# Exit WLST
148+
# =========
149+
exit()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
5+
# Include common utility functions
6+
source ${CREATE_DOMAIN_SCRIPT_DIR}/utility.sh
7+
8+
export DOMAIN_HOME=${DOMAIN_HOME_DIR}
9+
10+
# Create the domain
11+
wlst.sh -skipWLSModuleScanning ${CREATE_DOMAIN_SCRIPT_DIR}/create-domain.py
12+
13+
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
def getEnvVar(var):
5+
val=os.environ.get(var)
6+
if val==None:
7+
print "ERROR: Env var ",var, " not set."
8+
sys.exit(1)
9+
return val
10+
11+
# This python script is used to create a WebLogic domain
12+
13+
domain_uid = getEnvVar("DOMAIN_UID")
14+
server_port = int(getEnvVar("MANAGED_SERVER_PORT"))
15+
domain_path = getEnvVar("DOMAIN_HOME")
16+
cluster_name = getEnvVar("CLUSTER_NAME")
17+
admin_server_name = getEnvVar("ADMIN_SERVER_NAME")
18+
admin_server_name_svc = getEnvVar("ADMIN_SERVER_NAME_SVC")
19+
admin_port = int(getEnvVar("ADMIN_PORT"))
20+
domain_name = getEnvVar("DOMAIN_NAME")
21+
t3_channel_port = int(getEnvVar("T3_CHANNEL_PORT"))
22+
t3_public_address = getEnvVar("T3_PUBLIC_ADDRESS")
23+
number_of_ms = int(getEnvVar("CONFIGURED_MANAGED_SERVER_COUNT"))
24+
cluster_type = getEnvVar("CLUSTER_TYPE")
25+
managed_server_name_base = getEnvVar("MANAGED_SERVER_NAME_BASE")
26+
managed_server_name_base_svc = getEnvVar("MANAGED_SERVER_NAME_BASE_SVC")
27+
domain_logs = getEnvVar("DOMAIN_LOGS_DIR")
28+
script_dir = getEnvVar("CREATE_DOMAIN_SCRIPT_DIR")
29+
production_mode_enabled = getEnvVar("PRODUCTION_MODE_ENABLED")
30+
31+
# Read the domain secrets from the common python file
32+
execfile('%s/read-domain-secret.py' % script_dir)
33+
34+
print('domain_path : [%s]' % domain_path);
35+
print('domain_name : [%s]' % domain_name);
36+
print('admin_server_name : [%s]' % admin_server_name);
37+
print('admin_username : [%s]' % admin_username);
38+
print('admin_port : [%s]' % admin_port);
39+
print('cluster_name : [%s]' % cluster_name);
40+
print('server_port : [%s]' % server_port);
41+
# Open default domain template
42+
# ============================
43+
readTemplate("/u01/oracle/wlserver/common/templates/wls/wls.jar")
44+
45+
set('Name', domain_name)
46+
setOption('DomainName', domain_name)
47+
48+
# Configure the Administration Server
49+
# ===================================
50+
cd('/Servers/AdminServer')
51+
# Give incorrect listenaddress, introspector overrides with sit-config
52+
set('ListenAddress', 'junk')
53+
set('ListenPort', admin_port)
54+
set('Name', admin_server_name)
55+
create('AdminServer','Log')
56+
cd('/Servers/AdminServer/Log/AdminServer')
57+
# Give incorrect filelog, introspector overrides with sit-config
58+
set('FileName', 'dirdoesnotexist')
59+
60+
create('T3Channel', 'NetworkAccessPoint')
61+
cd('/Servers/%s/NetworkAccessPoints/T3Channel' % admin_server_name)
62+
set('PublicPort', t3_channel_port)
63+
set('PublicAddress', t3_public_address)
64+
# Give incorrect listenaddress, introspector overrides with sit-config
65+
set('ListenAddress', 'junk')
66+
set('ListenPort', t3_channel_port)
67+
68+
69+
# Set the admin user's username and password
70+
# ==========================================
71+
cd('/Security/%s/User/weblogic' % domain_name)
72+
cmo.setName(admin_username)
73+
cmo.setPassword(admin_password)
74+
75+
# Write the domain and close the domain template
76+
# ==============================================
77+
setOption('OverwriteDomain', 'true')
78+
79+
# Create a cluster
80+
# ======================
81+
cd('/')
82+
cl=create(cluster_name, 'Cluster')
83+
84+
if cluster_type == "CONFIGURED":
85+
86+
# Create managed servers
87+
for index in range(0, number_of_ms):
88+
cd('/')
89+
90+
msIndex = index+1
91+
name = '%s%s' % (managed_server_name_base, msIndex)
92+
name_svc = '%s%s' % (managed_server_name_base_svc, msIndex)
93+
94+
create(name, 'Server')
95+
cd('/Servers/%s/' % name )
96+
print('managed server name is %s' % name);
97+
set('ListenAddress', '%s-%s' % (domain_uid, name_svc))
98+
set('ListenPort', server_port)
99+
set('NumOfRetriesBeforeMSIMode', 0)
100+
set('RetryIntervalBeforeMSIMode', 1)
101+
set('Cluster', cluster_name)
102+
103+
else:
104+
print('Configuring Dynamic Cluster %s' % cluster_name)
105+
106+
templateName = cluster_name + "-template"
107+
print('Creating Server Template: %s' % templateName)
108+
st1=create(templateName, 'ServerTemplate')
109+
print('Done creating Server Template: %s' % templateName)
110+
cd('/ServerTemplates/%s' % templateName)
111+
cmo.setListenPort(server_port)
112+
cmo.setListenAddress('%s-%s${id}' % (domain_uid, managed_server_name_base_svc))
113+
cmo.setCluster(cl)
114+
print('Done setting attributes for Server Template: %s' % templateName);
115+
116+
117+
cd('/Clusters/%s' % cluster_name)
118+
create(cluster_name, 'DynamicServers')
119+
cd('DynamicServers/%s' % cluster_name)
120+
set('ServerTemplate', st1)
121+
set('ServerNamePrefix', managed_server_name_base)
122+
set('DynamicClusterSize', number_of_ms)
123+
set('MaxDynamicClusterSize', number_of_ms)
124+
set('CalculatedListenPorts', false)
125+
set('Id', 1)
126+
127+
print('Done setting attributes for Dynamic Cluster: %s' % cluster_name);
128+
129+
# Write Domain
130+
# ============
131+
writeDomain(domain_path)
132+
closeTemplate()
133+
print 'Domain Created'
134+
135+
# Update Domain
136+
readDomain(domain_path)
137+
cd('/')
138+
if production_mode_enabled == "true":
139+
cmo.setProductionModeEnabled(true)
140+
else:
141+
cmo.setProductionModeEnabled(false)
142+
updateDomain()
143+
closeDomain()
144+
print 'Domain Updated'
145+
print 'Done'
146+
147+
# Exit WLST
148+
# =========
149+
exit()

0 commit comments

Comments
 (0)