Skip to content

Commit 1c403f3

Browse files
committed
unit tests
1 parent d9268ef commit 1c403f3

File tree

4 files changed

+112
-1
lines changed

4 files changed

+112
-1
lines changed

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/WlsServerConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public boolean isLocalAdminProtocolChannelSecure() {
210210
for (NetworkAccessPoint nap : networkAccessPoints) {
211211
if (nap.isAdminProtocol()) {
212212
adminProtocolPortFound = true;
213-
adminProtocolPortSecure = false;
213+
adminProtocolPortSecure = true;
214214
break;
215215
}
216216
}

operator/src/test/java/oracle/kubernetes/operator/helpers/PodHelperTestBase.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,16 @@ public void whenPodCreated_readinessProbeHasDefinedTuning() {
360360
hasExpectedTuning(READINESS_INITIAL_DELAY, READINESS_TIMEOUT, READINESS_PERIOD));
361361
}
362362

363+
@Test
364+
public void whenPodCreatedWithAdminPortEnabled_readinessProbeHasReadinessCommand() {
365+
final Integer ADMIN_PORT = 9002;
366+
domainTopology.getServerConfig(serverName).setAdminPort(ADMIN_PORT);
367+
V1HTTPGetAction getAction = getCreatedPodSpecContainer().getReadinessProbe().getHttpGet();
368+
assertThat(getAction.getPath(), equalTo("/weblogic/ready"));
369+
assertThat(getAction.getPort().getIntValue(), equalTo(ADMIN_PORT));
370+
assertThat(getAction.getScheme(), equalTo("HTTPS"));
371+
}
372+
363373
@Test
364374
public void whenPodCreatedWithDomainV2Settings_livenessProbeHasConfiguredTuning() {
365375
configureServer()

operator/src/test/java/oracle/kubernetes/operator/wlsconfig/WlsDynamicServerConfigTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package oracle.kubernetes.operator.wlsconfig;
66

7+
import static org.hamcrest.MatcherAssert.assertThat;
8+
import static org.hamcrest.Matchers.is;
79
import static org.junit.Assert.assertEquals;
810
import static org.junit.Assert.assertNull;
911

@@ -84,4 +86,17 @@ public void testCreateWithCalculatedDefaultPorts() {
8486
assertEquals(new Integer(9102), networkAccessPoint1.getListenPort());
8587
assertNull(networkAccessPoint1.getPublicPort());
8688
}
89+
90+
@Test
91+
public void verifyAdminPortIsSetOnServerConfigs() {
92+
final int ADMIN_PORT = 9002;
93+
List<NetworkAccessPoint> networkAccessPointList = new ArrayList<>();
94+
WlsServerConfig template =
95+
new WlsServerConfig("template1", null, null, null, null, 9002, networkAccessPointList);
96+
97+
WlsServerConfig wlsServerConfig =
98+
WlsDynamicServerConfig.create("server1", 2, "cluster1", "domain1", true, template);
99+
100+
assertThat(wlsServerConfig.getAdminPort(), is(ADMIN_PORT));
101+
}
87102
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at
3+
// http://oss.oracle.com/licenses/upl.
4+
5+
package oracle.kubernetes.operator.wlsconfig;
6+
7+
import static org.hamcrest.CoreMatchers.is;
8+
import static org.junit.Assert.*;
9+
10+
import org.junit.Test;
11+
12+
public class WlsServerConfigTest {
13+
14+
static final int LISTEN_PORT = 8001;
15+
static final int SSL_LISTEN_PORT = 8002;
16+
static final int ADMIN_PORT = 9002;
17+
static final int NAP_ADMIN_PORT = 8082;
18+
static final int NAP_NON_ADMIN_PORT = 8081;
19+
20+
@Test
21+
public void verify_getLocalAdminProtocolChannelPort_returnsListenPort() {
22+
WlsServerConfig wlsServerConfig = createConfigWithOnlyListenPort();
23+
assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(LISTEN_PORT));
24+
assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(false));
25+
}
26+
27+
@Test
28+
public void verify_getLocalAdminProtocolChannelPort_returnsSslListenPort() {
29+
WlsServerConfig wlsServerConfig = createConfigWithListenPortAndSslListenPort();
30+
assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(SSL_LISTEN_PORT));
31+
assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(true));
32+
}
33+
34+
@Test
35+
public void verify_getLocalAdminProtocolChannelPort_returnsAdminPort() {
36+
WlsServerConfig wlsServerConfig = createConfigWithAllListenPorts();
37+
assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(ADMIN_PORT));
38+
assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(true));
39+
}
40+
41+
@Test
42+
public void verify_getLocalAdminProtocolChannelPort_withAdminNAP_returnsNapAdminPort() {
43+
WlsServerConfig wlsServerConfig = createConfigWithAdminNAP();
44+
assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(NAP_ADMIN_PORT));
45+
assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(true));
46+
}
47+
48+
@Test
49+
public void verify_getLocalAdminProtocolChannelPort_withNonAdminNAP_returnsAdminPort() {
50+
WlsServerConfig wlsServerConfig = createConfigWithNonAdminNAP();
51+
assertThat(wlsServerConfig.getLocalAdminProtocolChannelPort(), is(ADMIN_PORT));
52+
assertThat(wlsServerConfig.isLocalAdminProtocolChannelSecure(), is(true));
53+
}
54+
55+
WlsServerConfig createConfigWithOnlyListenPort() {
56+
WlsServerConfig wlsServerConfig = new WlsServerConfig();
57+
wlsServerConfig.setListenPort(LISTEN_PORT);
58+
return wlsServerConfig;
59+
}
60+
61+
WlsServerConfig createConfigWithListenPortAndSslListenPort() {
62+
WlsServerConfig wlsServerConfig = createConfigWithOnlyListenPort();
63+
wlsServerConfig.setSslListenPort(SSL_LISTEN_PORT);
64+
return wlsServerConfig;
65+
}
66+
67+
WlsServerConfig createConfigWithAllListenPorts() {
68+
WlsServerConfig wlsServerConfig = createConfigWithListenPortAndSslListenPort();
69+
wlsServerConfig.setAdminPort(ADMIN_PORT);
70+
return wlsServerConfig;
71+
}
72+
73+
WlsServerConfig createConfigWithAdminNAP() {
74+
WlsServerConfig wlsServerConfig = createConfigWithAllListenPorts();
75+
wlsServerConfig.addNetworkAccessPoint(
76+
new NetworkAccessPoint("admin-channel", "admin", NAP_ADMIN_PORT, null));
77+
return wlsServerConfig;
78+
}
79+
80+
WlsServerConfig createConfigWithNonAdminNAP() {
81+
WlsServerConfig wlsServerConfig = createConfigWithAllListenPorts();
82+
wlsServerConfig.addNetworkAccessPoint(
83+
new NetworkAccessPoint("non-admin-channel", "t3", NAP_NON_ADMIN_PORT, null));
84+
return wlsServerConfig;
85+
}
86+
}

0 commit comments

Comments
 (0)