Skip to content

Commit 349efe1

Browse files
committed
clusterType create domain job input param - update valid values to upper case, add validation and unit tests
1 parent 8a10a6c commit 349efe1

9 files changed

+67
-13
lines changed

kubernetes/create-weblogic-domain-inputs.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ domainName: base_domain
1414
# This id must be lowercase and unique across all domains in a Kubernetes cluster.
1515
#domainUID: domain1
1616

17-
# Type of WebLogic Cluster (configured or dynamic)
18-
clusterType: dynamic
17+
# Type of WebLogic Cluster
18+
# Legal values are "CONFIGURED" or "DYNAMIC"
19+
clusterType: DYNAMIC
1920

2021
# Determines which WebLogic Servers the Operator will start up
2122
# Legal values are "NONE", "ALL", "ADMIN", "SPECIFIED", or "AUTO"

kubernetes/internal/create-weblogic-domain-job-template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ data:
186186
187187
# Configure machines
188188
# ======================
189-
if cluster_type == "configured":
189+
if cluster_type == "CONFIGURED":
190190
191191
for index in range(0, number_of_ms):
192192
@@ -203,7 +203,7 @@ data:
203203
cd('/')
204204
cl=create(cluster_name, 'Cluster')
205205
206-
if cluster_type == "configured":
206+
if cluster_type == "CONFIGURED":
207207
208208
# Create managed servers
209209
for index in range(0, number_of_ms):

kubernetes/internal/create-weblogic-domain.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,25 @@ function validateStartupControl {
258258
"AUTO")
259259
;;
260260
*)
261-
validationError "Invalid valid for startupControl: ${startupControl}. Valid values are 'NONE', 'ALL', 'ADMIN', 'SPECIFIED', and 'AUTO'."
261+
validationError "Invalid value for startupControl: ${startupControl}. Valid values are 'NONE', 'ALL', 'ADMIN', 'SPECIFIED', and 'AUTO'."
262+
;;
263+
esac
264+
fi
265+
}
266+
267+
#
268+
# Function to validate the cluster type value
269+
#
270+
function validateClusterType {
271+
validateInputParamsSpecified clusterType
272+
if [ ! -z "${clusterType}" ]; then
273+
case ${clusterType} in
274+
"CONFIGURED")
275+
;;
276+
"DYNAMIC")
277+
;;
278+
*)
279+
validationError "Invalid value for clusterType: ${clusterType}. Valid values are 'CONFIGURED' and 'DYNAMIC'."
262280
;;
263281
esac
264282
fi
@@ -362,6 +380,7 @@ function initialize {
362380
validateLoadBalancer
363381
initAndValidateOutputDir
364382
validateStartupControl
383+
validateClusterType
365384
failIfValidationErrors
366385
}
367386

@@ -466,7 +485,6 @@ function createYamlFiles {
466485
sed -i -e "s:%INITIAL_MANAGED_SERVER_REPLICAS%:${initialManagedServerReplicas}:g" ${dcrOutput}
467486
sed -i -e "s:%EXPOSE_T3_CHANNEL_PREFIX%:${exposeAdminT3ChannelPrefix}:g" ${dcrOutput}
468487
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${dcrOutput}
469-
sed -i -e "s:%CLUSTER_TYPE%:${clusterType}:g" ${dcrOutput}
470488
sed -i -e "s:%EXPOSE_ADMIN_PORT_PREFIX%:${exposeAdminNodePortPrefix}:g" ${dcrOutput}
471489
sed -i -e "s:%ADMIN_NODE_PORT%:${adminNodePort}:g" ${dcrOutput}
472490
sed -i -e "s:%JAVA_OPTIONS%:${javaOptions}:g" ${dcrOutput}

src/integration-tests/bash/run.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,12 +2625,12 @@ function test_suite {
26252625
op_define oper2 weblogic-operator-2 test2 32001
26262626

26272627
# DOM_KEY OP_KEY NAMESPACE DOMAIN_UID STARTUP_CONTROL WL_CLUSTER_NAME WL_CLUSTER_TYPE MS_BASE_NAME ADMIN_PORT ADMIN_WLST_PORT ADMIN_NODE_PORT MS_PORT LOAD_BALANCER_WEB_PORT LOAD_BALANCER_DASHBOARD_PORT
2628-
dom_define domain1 oper1 default domain1 AUTO cluster-1 dynamic managed-server 7001 30012 30701 8001 30305 30315
2629-
dom_define domain2 oper1 default domain2 AUTO cluster-1 dynamic managed-server 7011 30031 30702 8021 30306 30316
2630-
dom_define domain3 oper1 test1 domain3 AUTO cluster-1 dynamic managed-server 7021 30041 30703 8031 30307 30317
2631-
dom_define domain4 oper2 test2 domain4 AUTO cluster-1 configured managed-server 7041 30051 30704 8041 30308 30318
2632-
dom_define domain5 oper1 default domain5 ADMIN cluster-1 dynamic managed-server 7051 30061 30705 8051 30309 30319
2633-
dom_define domain6 oper1 default domain6 AUTO cluster-1 dynamic managed-server 7061 30071 30706 8061 30310 30320
2628+
dom_define domain1 oper1 default domain1 AUTO cluster-1 DYNAMIC managed-server 7001 30012 30701 8001 30305 30315
2629+
dom_define domain2 oper1 default domain2 AUTO cluster-1 DYNAMIC managed-server 7011 30031 30702 8021 30306 30316
2630+
dom_define domain3 oper1 test1 domain3 AUTO cluster-1 DYNAMIC managed-server 7021 30041 30703 8031 30307 30317
2631+
dom_define domain4 oper2 test2 domain4 AUTO cluster-1 CONFIGURED managed-server 7041 30051 30704 8041 30308 30318
2632+
dom_define domain5 oper1 default domain5 ADMIN cluster-1 DYNAMIC managed-server 7051 30061 30705 8051 30309 30319
2633+
dom_define domain6 oper1 default domain6 AUTO cluster-1 DYNAMIC managed-server 7061 30071 30706 8061 30310 30320
26342634

26352635
# create namespaces for domains (the operator job creates a namespace if needed)
26362636
# TODO have the op_define commands themselves create target namespace if it doesn't already exist, or test if the namespace creation is needed in the first place, and if so, ask MikeG to create them as part of domain create job

src/test/java/oracle/kubernetes/operator/create/CreateDomainGeneratedFilesBaseTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ protected void assertThatActualCreateDomainPyIsCorrect(String actualCreateDomain
290290
server_port = %MANAGED_SERVER_PORT%
291291
cluster_name = "%CLUSTER_NAME%"
292292
number_of_ms = %NUMBER_OF_MS%
293+
cluster_type = "%CLUSTER_TYPE%"
293294
print('domain_name : [%DOMAIN_NAME%]');
294295
print('admin_port : [%ADMIN_PORT%]');
295296
set('Name', '%DOMAIN_NAME%')

src/test/java/oracle/kubernetes/operator/create/CreateDomainGeneratedFilesOptionalFeaturesEnabledTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static void setup() throws Exception {
2525
CreateDomainInputs.newInputs()
2626
.exposeAdminNodePort("true")
2727
.exposeAdminT3Channel("true")
28+
.clusterType("CONFIGURED")
2829
.weblogicImagePullSecretName("test-weblogic-image-pull-secret-name")
2930
.loadBalancer(LOAD_BALANCER_TRAEFIK)
3031
.weblogicDomainStorageType(STORAGE_TYPE_NFS)

src/test/java/oracle/kubernetes/operator/create/CreateDomainInputs.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class CreateDomainInputs {
3939
public static final String STARTUP_CONTROL_ADMIN = "ADMIN";
4040
public static final String STARTUP_CONTROL_SPECIFIED = "SPECIFIED";
4141
public static final String STARTUP_CONTROL_AUTO = "AUTO";
42+
public static final String CLUSTER_TYPE_CONFIGURED = "CONFIGURED";
43+
public static final String CLUSTER_TYPE_DYNAMIC = "DYNAMIC";
4244

4345
private static final String DEFAULT_INPUTS = "kubernetes/create-weblogic-domain-inputs.yaml";
4446

@@ -79,6 +81,7 @@ public static CreateDomainInputs newInputs() throws Exception {
7981
.adminPort("7002")
8082
.adminServerName("TestAdminServer")
8183
.clusterName("TestCluster")
84+
.clusterType(CLUSTER_TYPE_DYNAMIC)
8285
.domainName("TestDomain")
8386
.domainUID("test-domain-uid")
8487
.javaOptions("TestJavaOptions")

src/test/java/oracle/kubernetes/operator/create/CreateDomainInputsFileTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void defaultInputsFile_hasCorrectContents() throws Exception {
4747
.adminPort("7001")
4848
.adminServerName("admin-server")
4949
.clusterName("cluster-1")
50-
.clusterType("dynamic")
50+
.clusterType("DYNAMIC")
5151
.domainName("base_domain")
5252
.domainUID("")
5353
.exposeAdminNodePort("false")

src/test/java/oracle/kubernetes/operator/create/CreateDomainInputsValidationTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class CreateDomainInputsValidationTest {
2626
private static final String PARAM_DOMAIN_UID = "domainUID";
2727
private static final String PARAM_STARTUP_CONTROL = "startupControl";
2828
private static final String PARAM_CLUSTER_NAME = "clusterName";
29+
private static final String PARAM_CLUSTER_TYPE = "clusterType";
2930
private static final String PARAM_CONFIGURED_MANAGED_SERVER_COUNT = "configuredManagedServerCount";
3031
private static final String PARAM_INITIAL_MANAGED_SERVER_REPLICAS = "initialManagedServerReplicas";
3132
private static final String PARAM_MANAGED_SERVER_NAME_BASE = "managedServerNameBase";
@@ -155,6 +156,31 @@ public void createDomain_with_invalidStartupControl_failsAndReturnsError() throw
155156
failsAndPrints(invalidEnumParamValueError(PARAM_STARTUP_CONTROL, val)));
156157
}
157158

159+
@Test
160+
public void createDomain_with_missingClusterType_failsAndReturnsError() throws Exception {
161+
assertThat(
162+
execCreateDomain(newInputs().clusterType("")),
163+
failsAndPrints(paramMissingError(PARAM_CLUSTER_TYPE)));
164+
}
165+
166+
@Test
167+
public void createDomain_with_clusterTypeConfigured_succeeds() throws Exception {
168+
createDomain_with_validClusterType_succeeds(CLUSTER_TYPE_CONFIGURED);
169+
}
170+
171+
@Test
172+
public void createDomain_with_clusterTypeDynamic_succeeds() throws Exception {
173+
createDomain_with_validClusterType_succeeds(CLUSTER_TYPE_DYNAMIC);
174+
}
175+
176+
@Test
177+
public void createDomain_with_invalidClusterType_failsAndReturnsError() throws Exception {
178+
String val = "Invalid-cluster-type";
179+
assertThat(
180+
execCreateDomain(newInputs().clusterType(val)),
181+
failsAndPrints(invalidEnumParamValueError(PARAM_CLUSTER_TYPE, val)));
182+
}
183+
158184
@Test
159185
public void createDomain_with_missingClusterName_failsAndReturnsError() throws Exception {
160186
assertThat(
@@ -487,6 +513,10 @@ private void createDomain_with_validStartupControl_succeeds(String startupContro
487513
createDomain_with_validInputs_succeeds(newInputs().startupControl(startupControl));
488514
}
489515

516+
private void createDomain_with_validClusterType_succeeds(String clusterType) throws Exception {
517+
createDomain_with_validInputs_succeeds(newInputs().clusterType(clusterType));
518+
}
519+
490520
private void createDomain_with_validInputs_succeeds(CreateDomainInputs inputs) throws Exception {
491521
// throws an error if the inputs are not valid, succeeds otherwise:
492522
GeneratedDomainYamlFiles.generateDomainYamlFiles(inputs).remove();

0 commit comments

Comments
 (0)