42
42
import oracle .weblogic .domain .DomainResource ;
43
43
import oracle .weblogic .domain .DomainSpec ;
44
44
import oracle .weblogic .domain .ServerPod ;
45
+ import oracle .weblogic .kubernetes .actions .impl .NginxParams ;
46
+ import oracle .weblogic .kubernetes .actions .impl .Service ;
45
47
import oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes ;
46
48
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
47
49
import oracle .weblogic .kubernetes .annotations .Namespaces ;
66
68
import static oracle .weblogic .kubernetes .TestConstants .IMAGE_PULL_POLICY ;
67
69
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
68
70
import static oracle .weblogic .kubernetes .TestConstants .KUBERNETES_CLI ;
71
+ import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER_PRIVATEIP ;
69
72
import static oracle .weblogic .kubernetes .TestConstants .RESULTS_TEMPFILE ;
70
73
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
71
74
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_12213 ;
93
96
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
94
97
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
95
98
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
99
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getServiceExtIPAddrtOke ;
96
100
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
97
101
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
98
102
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withLongRetryPolicy ;
105
109
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
106
110
import static oracle .weblogic .kubernetes .utils .JobUtils .createDomainJob ;
107
111
import static oracle .weblogic .kubernetes .utils .JobUtils .getIntrospectJobName ;
112
+ import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .createNginxIngressPathRoutingRules ;
113
+ import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .installAndVerifyNginx ;
108
114
import static oracle .weblogic .kubernetes .utils .MySQLDBUtils .createMySQLDB ;
109
115
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
110
116
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
133
139
@ DisplayName ("Verify the overrideDistributionStrategy applies the overrides accordingly to the value set" )
134
140
@ Tag ("kind-parallel" )
135
141
@ Tag ("okd-wls-mrg" )
136
- @ Tag ("oke-sequential " )
142
+ @ Tag ("oke-gate " )
137
143
@ IntegrationTest
138
144
@ Tag ("olcne-mrg" )
139
145
class ItConfigDistributionStrategy {
140
146
141
147
private static String opNamespace = null ;
142
148
private static String domainNamespace = null ;
149
+ private static String nginxNamespace = null ;
150
+ private static NginxParams nginxHelmParams = null ;
143
151
144
152
final String domainUid = "mydomain" ;
145
153
final String clusterName = "mycluster" ;
@@ -155,6 +163,7 @@ class ItConfigDistributionStrategy {
155
163
final String wlSecretName = "weblogic-credentials" ;
156
164
final String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase ;
157
165
int replicaCount = 2 ;
166
+ static String hostAndPort ;
158
167
159
168
static Path clusterViewAppPath ;
160
169
String overridecm = "configoverride-cm" ;
@@ -166,12 +175,13 @@ class ItConfigDistributionStrategy {
166
175
static String dsUrl2 ;
167
176
static String mysql1SvcEndpoint = null ;
168
177
static String mysql2SvcEndpoint = null ;
178
+ private static String ingressIP = null ;
169
179
170
180
String dsName0 = "JdbcTestDataSource-0" ;
171
181
String dsName1 = "JdbcTestDataSource-1" ;
172
182
String dsSecret = domainUid .concat ("-mysql-secret" );
173
183
String adminSvcExtHost = null ;
174
- static String hostHeader ;
184
+ static String hostHeader ;
175
185
176
186
private static LoggingFacade logger = null ;
177
187
@@ -187,7 +197,7 @@ class ItConfigDistributionStrategy {
187
197
* @param namespaces injected by JUnit
188
198
*/
189
199
@ BeforeAll
190
- public void initAll (@ Namespaces (2 ) List <String > namespaces ) throws ApiException , IOException {
200
+ public void initAll (@ Namespaces (3 ) List <String > namespaces ) throws ApiException , IOException {
191
201
logger = getLogger ();
192
202
193
203
logger .info ("Assign a unique namespace for operator" );
@@ -196,10 +206,20 @@ public void initAll(@Namespaces(2) List<String> namespaces) throws ApiException,
196
206
logger .info ("Assign a unique namespace for domain namspace" );
197
207
assertNotNull (namespaces .get (1 ), "Namespace is null" );
198
208
domainNamespace = namespaces .get (1 );
209
+ assertNotNull (namespaces .get (2 ), "Namespace is null" );
210
+ nginxNamespace = namespaces .get (2 );
199
211
200
212
// install operator and verify its running in ready state
201
213
installAndVerifyOperator (opNamespace , domainNamespace );
214
+ ingressIP = K8S_NODEPORT_HOST ;
215
+ if (OKE_CLUSTER_PRIVATEIP ) {
216
+ // install and verify NGINX
217
+ nginxHelmParams = installAndVerifyNginx (nginxNamespace , 0 , 0 );
218
+ String nginxServiceName = nginxHelmParams .getHelmParams ().getReleaseName () + "-ingress-nginx-controller" ;
219
+ ingressIP = getServiceExtIPAddrtOke (nginxServiceName , nginxNamespace ) != null
220
+ ? getServiceExtIPAddrtOke (nginxServiceName , nginxNamespace ) : K8S_NODEPORT_HOST ;
202
221
222
+ }
203
223
// create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
204
224
// this secret is used only for non-kind cluster
205
225
createBaseRepoSecret (domainNamespace );
@@ -232,6 +252,14 @@ public void initAll(@Namespaces(2) List<String> namespaces) throws ApiException,
232
252
233
253
//create and start WebLogic domain
234
254
createDomain ();
255
+ if (OKE_CLUSTER_PRIVATEIP ) {
256
+ String ingressClassName = nginxHelmParams .getIngressClassName ();
257
+ String serviceName = domainUid + "-admin-server" ;
258
+ final int ADMIN_SERVER_PORT = 7001 ;
259
+ String hostAndPort = getHostAndPortOKE ();
260
+ createNginxIngressPathRoutingRules (domainNamespace , ingressClassName ,
261
+ serviceName , ADMIN_SERVER_PORT , hostAndPort );
262
+ }
235
263
236
264
// Expose the admin service external node port as a route for OKD
237
265
adminSvcExtHost = createRouteForOKD (getExternalServicePodName (adminServerPodName ), domainNamespace );
@@ -286,6 +314,9 @@ public void afterEach() {
286
314
headers .put ("host" , hostHeader );
287
315
}
288
316
boolean ipv6 = K8S_NODEPORT_HOST .contains (":" );
317
+ if (OKE_CLUSTER_PRIVATEIP ) {
318
+ hostAndPort = ingressIP ;
319
+ }
289
320
String baseUri = "http://" + hostAndPort + "/clusterview/" ;
290
321
String serverListUri = "ClusterViewServlet?user=" + ADMIN_USERNAME_DEFAULT
291
322
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "&ipv6=" + ipv6 ;
@@ -688,6 +719,9 @@ private Callable<Boolean> configUpdated(String maxMessageSize) {
688
719
headers = new HashMap <>();
689
720
headers .put ("host" , hostHeader );
690
721
}
722
+ if (OKE_CLUSTER_PRIVATEIP ) {
723
+ hostAndPort = ingressIP ;
724
+ }
691
725
String url = "http://" + hostAndPort + appURI ;
692
726
HttpResponse <String > response = OracleHttpClient .get (url , headers , true );
693
727
assertEquals (200 , response .statusCode (), "Status code not equals to 200" );
@@ -714,6 +748,9 @@ private void verifyConfigXMLOverride(boolean configUpdated) {
714
748
headers = new HashMap <>();
715
749
headers .put ("host" , hostHeader );
716
750
}
751
+ if (OKE_CLUSTER_PRIVATEIP ) {
752
+ hostAndPort = getHostAndPortOKE ();
753
+ }
717
754
String baseUri = "http://" + hostAndPort + "/clusterview/" ;
718
755
HttpResponse <String > response = OracleHttpClient .get (baseUri + configUri , headers , true );
719
756
if (response .statusCode () != 200 ) {
@@ -746,6 +783,9 @@ private void verifyResourceJDBC0Override(boolean configUpdated) {
746
783
headers = new HashMap <>();
747
784
headers .put ("host" , hostHeader );
748
785
}
786
+ if (OKE_CLUSTER_PRIVATEIP ) {
787
+ hostAndPort = getHostAndPortOKE ();
788
+ }
749
789
logger .info ("hostAndPort = {0} " , hostAndPort );
750
790
String baseUri = "http://" + hostAndPort + "/clusterview/ConfigServlet?" ;
751
791
//verify datasource attributes of JdbcTestDataSource-0
@@ -786,7 +826,7 @@ private void verifyResourceJDBC0Override(boolean configUpdated) {
786
826
testDatasource (appURI );
787
827
}
788
828
}
789
-
829
+
790
830
private void testDatasource (String appURI ) {
791
831
int port = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
792
832
testUntil (
@@ -799,6 +839,9 @@ private void testDatasource(String appURI) {
799
839
headers = new HashMap <>();
800
840
headers .put ("host" , hostHeader );
801
841
}
842
+ if (OKE_CLUSTER_PRIVATEIP ) {
843
+ hostAndPort = getHostAndPortOKE ();
844
+ }
802
845
logger .info ("hostAndPort = {0} " , hostAndPort );
803
846
String baseUri = "http://" + hostAndPort + "/clusterview/ConfigServlet?" ;
804
847
@@ -837,11 +880,14 @@ private void verifyResourceJDBC1Override(boolean configUpdated) {
837
880
headers = new HashMap <>();
838
881
headers .put ("host" , hostHeader );
839
882
}
883
+ if (OKE_CLUSTER_PRIVATEIP ) {
884
+ hostAndPort = getHostAndPortOKE ();
885
+ }
840
886
String baseUri = "http://" + hostAndPort + "/clusterview/ConfigServlet?" ;
841
887
842
888
//verify datasource attributes of JdbcTestDataSource-0
843
889
String appURI = "resTest=true&resName=" + dsName1 ;
844
- String dsOverrideTestUrl = baseUri + appURI ;
890
+ String dsOverrideTestUrl = baseUri + appURI ;
845
891
HttpResponse <String > response = OracleHttpClient .get (dsOverrideTestUrl , headers , true );
846
892
if (response .statusCode () != 200 ) {
847
893
logger .info ("Response code is not 200 retrying..." );
@@ -891,6 +937,9 @@ private void verifyResourceJDBC1Override(boolean configUpdated) {
891
937
headers = new HashMap <>();
892
938
headers .put ("host" , hostHeader );
893
939
}
940
+ if (OKE_CLUSTER_PRIVATEIP ) {
941
+ hostAndPort = getHostAndPortOKE ();
942
+ }
894
943
String baseUri = "http://" + hostAndPort + "/clusterview/ConfigServlet?" ;
895
944
String appURI = "dsTest=true&dsName=" + dsName1 + "&" + "serverName=" + managedServerNameBase + i ;
896
945
String dsConnectionPoolTestUrl = baseUri + appURI ;
@@ -934,7 +983,7 @@ private void verifyIntrospectorRuns() {
934
983
935
984
//create a standard WebLogic domain.
936
985
private void createDomain () {
937
-
986
+
938
987
String uniquePath = "/shared/" + domainNamespace + "/domains" ;
939
988
940
989
// create WebLogic domain credential secret
@@ -959,7 +1008,7 @@ private void createDomain() {
959
1008
p .setProperty ("admin_server_port" , "7001" );
960
1009
p .setProperty ("admin_username" , ADMIN_USERNAME_DEFAULT );
961
1010
p .setProperty ("admin_password" , ADMIN_PASSWORD_DEFAULT );
962
- p .setProperty ("admin_t3_public_address" , K8S_NODEPORT_HOST );
1011
+ p .setProperty ("admin_t3_public_address" , ingressIP );
963
1012
p .setProperty ("admin_t3_channel_port" , Integer .toString (t3ChannelPort ));
964
1013
p .setProperty ("number_of_ms" , "2" );
965
1014
p .setProperty ("managed_server_name_base" , managedServerNameBase );
@@ -1166,7 +1215,7 @@ private void createJdbcDataSource(String dsName, String user, String password, S
1166
1215
* @param namespace name of the domain namespace in which the job is created
1167
1216
*/
1168
1217
private void createDomainOnPVUsingWlst (Path wlstScriptFile , Path domainPropertiesFile ,
1169
- String pvName , String pvcName , String namespace ) {
1218
+ String pvName , String pvcName , String namespace ) {
1170
1219
logger .info ("Preparing to run create domain job using WLST" );
1171
1220
1172
1221
List <Path > domainScriptFiles = new ArrayList <>();
@@ -1290,4 +1339,13 @@ private void createFileInPod(String podName, String namespace, String password)
1290
1339
assertEquals (0 , result .exitValue (), "mysql execution fails" );
1291
1340
}
1292
1341
1342
+ private static String getHostAndPortOKE () {
1343
+ String nginxServiceName = nginxHelmParams .getHelmParams ().getReleaseName () + "-ingress-nginx-controller" ;
1344
+ int nginxNodePort = assertDoesNotThrow (() -> Service .getServiceNodePort (nginxNamespace , nginxServiceName , "http" ),
1345
+ "Getting Nginx loadbalancer service node port failed" );
1346
+
1347
+ hostAndPort = getServiceExtIPAddrtOke (nginxServiceName , nginxNamespace ) != null
1348
+ ? getServiceExtIPAddrtOke (nginxServiceName , nginxNamespace ) : K8S_NODEPORT_HOST + ":" + nginxNodePort ;
1349
+ return hostAndPort ;
1350
+ }
1293
1351
}
0 commit comments