Skip to content

Commit be94481

Browse files
committed
Add unit tests
Signed-off-by: doxiao <[email protected]>
1 parent c3e5706 commit be94481

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

kubernetes/internal/create-weblogic-domain.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,10 @@ function createYamlFiles {
608608
apacheConfigFileName="custom_mod_wl_apache.conf"
609609
if [ ! -z "${loadBalancerVolumePath}" ]; then
610610
if [ ! -d ${loadBalancerVolumePath} ]; then
611-
echo -e "\nERROR: \nThe specified loadBalancerVolumePath $loadBalancerVolumePath does not exist! \n"
611+
echo -e "\nERROR - The specified loadBalancerVolumePath $loadBalancerVolumePath does not exist! \n"
612612
fail "Exiting due to a validation error"
613613
elif [ ! -f ${loadBalancerVolumePath}/${apacheConfigFileName} ]; then
614-
echo -e "\nERROR: \nThe required file ${apacheConfigFileName} does not exist under the specified loadBalancerVolumePath $loadBalancerVolumePath! \n"
614+
echo -e "\nERROR - The required file ${apacheConfigFileName} does not exist under the specified loadBalancerVolumePath $loadBalancerVolumePath! \n"
615615
fail "Exiting due to a validation error"
616616
else
617617
enableLoadBalancerVolumePathPrefix="${enabledPrefix}"

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class CreateDomainInputsValidationTest {
5858
private static final String PARAM_LOAD_BALANCER = "loadBalancer";
5959
private static final String PARAM_LOAD_BALANCER_WEB_PORT = "loadBalancerWebPort";
6060
private static final String PARAM_LOAD_BALANCER_DASHBOARD_PORT = "loadBalancerDashboardPort";
61+
private static final String PARAM_LOAD_BALANCER_VOLUME_PATH = "loadBalancerVolumePath";
6162
private static final String PARAM_JAVA_OPTIONS = "javaOptions";
6263
private static final String PARAM_VERSION = "version";
6364

@@ -554,6 +555,26 @@ public void createDomain_with_invalidLoadBalancerDashboardPort_failsAndReturnsEr
554555
failsAndPrints(invalidIntegerParamValueError(PARAM_LOAD_BALANCER_DASHBOARD_PORT, val)));
555556
}
556557

558+
@Test
559+
public void createDomain_with_invalidLoadBalancerVolumePath_failsAndReturnsError()
560+
throws Exception {
561+
String val = "invalid-load-balancer-volume-path";
562+
assertThat(
563+
execCreateDomain(
564+
newInputs().loadBalancer(LOAD_BALANCER_APACHE).loadBalancerVolumePath(val)),
565+
failsAndPrints(missingDirectoryError(PARAM_LOAD_BALANCER_VOLUME_PATH, val)));
566+
}
567+
568+
public void createDomain_with_invalidLoadBalancerVolumePath_missingFile_failsAndReturnsError()
569+
throws Exception {
570+
String val = "/";
571+
assertThat(
572+
execCreateDomain(
573+
newInputs().loadBalancer(LOAD_BALANCER_APACHE).loadBalancerVolumePath(val)),
574+
failsAndPrints(
575+
missingFileError(PARAM_LOAD_BALANCER_VOLUME_PATH, val, "custom-mod-wl-apache.conf")));
576+
}
577+
557578
// TBD - shouldn't we allow empty java options?
558579
@Test
559580
public void createDomain_with_missingJavaOptions_failsAndReturnsError() throws Exception {
@@ -613,6 +634,14 @@ private String invalidRelatedParamValueError(
613634
return errorRegexp("Invalid.*" + param + ".*" + val + " with " + param2 + ".*" + val2);
614635
}
615636

637+
private String missingDirectoryError(String param, String val) {
638+
return errorRegexp(param + ".*" + val + ".*" + "does not exist!");
639+
}
640+
641+
private String missingFileError(String param, String val, String dir) {
642+
return errorRegexp(param + ".*" + val + ".*" + "does not exist under" + ".*" + dir + ".*");
643+
}
644+
616645
private String paramMissingError(String param) {
617646
return errorRegexp(param + ".*missing");
618647
}

0 commit comments

Comments
 (0)