Skip to content

Commit 78e9621

Browse files
committed
auto sit config overrides test
1 parent 5e80c37 commit 78e9621

File tree

7 files changed

+350
-42
lines changed

7 files changed

+350
-42
lines changed

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

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
package oracle.kubernetes.operator;
66

7+
import java.io.File;
8+
import java.nio.file.Files;
9+
import java.nio.file.StandardCopyOption;
710
import oracle.kubernetes.operator.utils.Domain;
811
import oracle.kubernetes.operator.utils.ExecCommand;
912
import oracle.kubernetes.operator.utils.ExecResult;
@@ -251,7 +254,7 @@ public void test5CreateConfiguredDomainInTest2NS() throws Exception {
251254
logger.info("Verify no impact on domain5");
252255
domain5.verifyDomainCreated();
253256
testCompletedSuccessfully = true;
254-
logger.info("SUCCESS - test5CreateConfiguredDomainInTest2NS");
257+
255258
} finally {
256259
if (domain4 != null && (JENKINS || testCompletedSuccessfully)) {
257260
domain4.destroy();
@@ -260,6 +263,7 @@ public void test5CreateConfiguredDomainInTest2NS() throws Exception {
260263
domain5.destroy();
261264
}
262265
}
266+
logger.info("SUCCESS - test5CreateConfiguredDomainInTest2NS");
263267
}
264268

265269
@Test
@@ -459,7 +463,7 @@ public void testDeleteTwoDomains() throws Exception {
459463
logger.info("SUCCESS - testDeleteTwoDomains");
460464
}
461465

462-
// @Test
466+
@Test
463467
public void testAutoSitConfigOverrides() throws Exception {
464468
Assume.assumeFalse(QUICKTEST);
465469
logTestBegin("testAutoSitConfigOverrides");
@@ -469,26 +473,30 @@ public void testAutoSitConfigOverrides() throws Exception {
469473
}
470474
Domain domain11 = null;
471475
boolean testCompletedSuccessfully = false;
476+
String createDomainScriptDir =
477+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv";
472478
try {
479+
473480
// cp py
474-
copyCreateDomainScript();
481+
Files.copy(
482+
new File(createDomainScriptDir + "/create-domain.py").toPath(),
483+
new File(createDomainScriptDir + "/create-domain.py.bak").toPath(),
484+
StandardCopyOption.REPLACE_EXISTING);
485+
Files.copy(
486+
new File(createDomainScriptDir + "/create-domain-auto-sit-config.py").toPath(),
487+
new File(createDomainScriptDir + "/create-domain.py").toPath(),
488+
StandardCopyOption.REPLACE_EXISTING);
489+
475490
domain11 = testDomainCreation(domain11YamlFile);
476491
domain11.verifyDomainCreated();
477492
testBasicUseCases(domain11);
478493
testCompletedSuccessfully = true;
479494
logger.info("SUCCESS - testAutoSitConfigOverrides");
480495
} finally {
481-
482-
StringBuffer cmd = new StringBuffer("cd ");
483-
cmd.append(BaseTest.getProjectRoot())
484-
.append(
485-
"/integration-tests/src/test/resources/domain-home-on-pv && cp create-domain.py.bak create-domain.py");
486-
logger.info("Running " + cmd);
487-
ExecResult result = ExecCommand.exec(cmd.toString());
488-
if (result.exitValue() != 0) {
489-
throw new RuntimeException(cmd + " failed");
490-
}
491-
496+
Files.copy(
497+
new File(createDomainScriptDir + "/create-domain.py.bak").toPath(),
498+
new File(createDomainScriptDir + "/create-domain.py").toPath(),
499+
StandardCopyOption.REPLACE_EXISTING);
492500
if (domain11 != null && (JENKINS || testCompletedSuccessfully)) {
493501
domain11.destroy();
494502
}
@@ -512,27 +520,4 @@ private void testBasicUseCases(Domain domain) throws Exception {
512520
testAdminT3Channel(domain);
513521
testAdminServerExternalService(domain);
514522
}
515-
516-
private void copyCreateDomainScript() throws Exception {
517-
String createDomainScriptPath =
518-
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv";
519-
520-
StringBuffer cmd = new StringBuffer("cd ");
521-
cmd.append(createDomainScriptPath).append(" && cp create-domain.py create-domain.py.bak");
522-
logger.info("Running " + cmd);
523-
524-
ExecResult result = ExecCommand.exec(cmd.toString());
525-
if (result.exitValue() != 0) {
526-
throw new RuntimeException(cmd + " failed");
527-
}
528-
529-
cmd = new StringBuffer("cd ");
530-
cmd.append(createDomainScriptPath)
531-
.append(" && cp create-domain-auto-sit-config.py create-domain.py");
532-
logger.info("Running " + cmd);
533-
result = ExecCommand.exec(cmd.toString());
534-
if (result.exitValue() != 0) {
535-
throw new RuntimeException(cmd + " failed");
536-
}
537-
}
538523
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -863,9 +863,9 @@ private void initialize(String inputYaml) throws Exception {
863863
}
864864

865865
domainMap.put("domainHome", "/shared/domains/" + domainUid);
866-
/* domainMap.put(
867-
"createDomainFilesDir",
868-
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv"); */
866+
domainMap.put(
867+
"createDomainFilesDir",
868+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv");
869869
String imageName = "store/oracle/weblogic";
870870
if (System.getenv("IMAGE_NAME_WEBLOGIC") != null) {
871871
imageName = System.getenv("IMAGE_NAME_WEBLOGIC");

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ public static void deletePVC(String pvcName, String namespace) throws Exception
177177
StringBuffer cmd = new StringBuffer("kubectl delete pvc ");
178178
cmd.append(pvcName).append(" -n ").append(namespace);
179179
logger.info("Deleting PVC " + cmd);
180-
ExecCommand.exec(cmd.toString());
180+
ExecResult result = ExecCommand.exec(cmd.toString());
181+
if (result.exitValue() != 0) {
182+
throw new RuntimeException(
183+
"FAILURE: delete PVC failed with " + result.stderr() + " \n " + result.stdout());
184+
}
181185
}
182186

183187
public static boolean checkPVReleased(String pvBaseName, String namespace) throws Exception {
@@ -186,7 +190,7 @@ public static boolean checkPVReleased(String pvBaseName, String namespace) throw
186190

187191
int i = 0;
188192
while (i < BaseTest.getMaxIterationsPod()) {
189-
logger.info("Checking if PV is Released " + cmd);
193+
logger.info("Iteration " + i + " Checking if PV is Released " + cmd);
190194
ExecResult result = ExecCommand.exec(cmd.toString());
191195
if (result.exitValue() != 0
192196
|| result.exitValue() == 0 && !result.stdout().contains("Released")) {
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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+
56+
create('T3Channel', 'NetworkAccessPoint')
57+
cd('/Servers/%s/NetworkAccessPoints/T3Channel' % admin_server_name)
58+
set('PublicPort', t3_channel_port)
59+
set('PublicAddress', t3_public_address)
60+
# Give incorrect listenaddress, introspector overrides with sit-config
61+
set('ListenAddress', 'junk')
62+
set('ListenPort', t3_channel_port)
63+
64+
cd('/Servers/%s' % admin_server_name)
65+
create(admin_server_name,'Log')
66+
cd('/Servers/%s/Log/%s' % (admin_server_name, admin_server_name))
67+
# Give incorrect filelog, introspector overrides with sit-config
68+
set('FileName', 'dirdoesnotexist')
69+
70+
71+
72+
# Set the admin user's username and password
73+
# ==========================================
74+
cd('/Security/%s/User/weblogic' % domain_name)
75+
cmo.setName(admin_username)
76+
cmo.setPassword(admin_password)
77+
78+
# Write the domain and close the domain template
79+
# ==============================================
80+
setOption('OverwriteDomain', 'true')
81+
82+
# Create a cluster
83+
# ======================
84+
cd('/')
85+
cl=create(cluster_name, 'Cluster')
86+
87+
if cluster_type == "CONFIGURED":
88+
89+
# Create managed servers
90+
for index in range(0, number_of_ms):
91+
cd('/')
92+
93+
msIndex = index+1
94+
name = '%s%s' % (managed_server_name_base, msIndex)
95+
name_svc = '%s%s' % (managed_server_name_base_svc, msIndex)
96+
97+
create(name, 'Server')
98+
cd('/Servers/%s/' % name )
99+
print('managed server name is %s' % name);
100+
set('ListenAddress', '%s-%s' % (domain_uid, name_svc))
101+
set('ListenPort', server_port)
102+
set('NumOfRetriesBeforeMSIMode', 0)
103+
set('RetryIntervalBeforeMSIMode', 1)
104+
set('Cluster', cluster_name)
105+
106+
else:
107+
print('Configuring Dynamic Cluster %s' % cluster_name)
108+
109+
templateName = cluster_name + "-template"
110+
print('Creating Server Template: %s' % templateName)
111+
st1=create(templateName, 'ServerTemplate')
112+
print('Done creating Server Template: %s' % templateName)
113+
cd('/ServerTemplates/%s' % templateName)
114+
cmo.setListenPort(server_port)
115+
cmo.setListenAddress('%s-%s${id}' % (domain_uid, managed_server_name_base_svc))
116+
cmo.setCluster(cl)
117+
print('Done setting attributes for Server Template: %s' % templateName);
118+
119+
120+
cd('/Clusters/%s' % cluster_name)
121+
create(cluster_name, 'DynamicServers')
122+
cd('DynamicServers/%s' % cluster_name)
123+
set('ServerTemplate', st1)
124+
set('ServerNamePrefix', managed_server_name_base)
125+
set('DynamicClusterSize', number_of_ms)
126+
set('MaxDynamicClusterSize', number_of_ms)
127+
set('CalculatedListenPorts', false)
128+
set('Id', 1)
129+
130+
print('Done setting attributes for Dynamic Cluster: %s' % cluster_name);
131+
132+
# Write Domain
133+
# ============
134+
writeDomain(domain_path)
135+
closeTemplate()
136+
print 'Domain Created'
137+
138+
# Update Domain
139+
readDomain(domain_path)
140+
cd('/')
141+
if production_mode_enabled == "true":
142+
cmo.setProductionModeEnabled(true)
143+
else:
144+
cmo.setProductionModeEnabled(false)
145+
updateDomain()
146+
closeDomain()
147+
print 'Domain Updated'
148+
print 'Done'
149+
150+
# Exit WLST
151+
# =========
152+
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+

0 commit comments

Comments
 (0)