12
12
import java .time .OffsetDateTime ;
13
13
import java .util .ArrayList ;
14
14
import java .util .Arrays ;
15
- import java .util .HashMap ;
16
15
import java .util .LinkedHashMap ;
17
16
import java .util .List ;
18
17
import java .util .Map ;
38
37
import oracle .weblogic .domain .ServerPod ;
39
38
import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
40
39
import oracle .weblogic .kubernetes .actions .impl .primitive .CommandParams ;
41
- import oracle .weblogic .kubernetes .actions .impl .primitive .HelmParams ;
42
40
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
43
41
import oracle .weblogic .kubernetes .annotations .Namespaces ;
44
42
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
49
47
import org .awaitility .core .ConditionEvaluationListener ;
50
48
import org .awaitility .core .ConditionFactory ;
51
49
import org .awaitility .core .EvaluatedCondition ;
52
- import org .junit .jupiter .api .AfterAll ;
53
50
import org .junit .jupiter .api .BeforeAll ;
54
51
import org .junit .jupiter .api .DisplayName ;
55
52
import org .junit .jupiter .api .MethodOrderer ;
88
85
import static oracle .weblogic .kubernetes .actions .TestActions .now ;
89
86
import static oracle .weblogic .kubernetes .actions .TestActions .patchDomainResourceWithNewIntrospectVersion ;
90
87
import static oracle .weblogic .kubernetes .actions .TestActions .scaleCluster ;
91
- import static oracle .weblogic .kubernetes .actions .TestActions .uninstallNginx ;
92
88
import static oracle .weblogic .kubernetes .actions .impl .Domain .patchDomainCustomResource ;
93
89
import static oracle .weblogic .kubernetes .actions .impl .Pod .getPod ;
94
90
import static oracle .weblogic .kubernetes .assertions .TestAssertions .podStateNotChanged ;
107
103
import static oracle .weblogic .kubernetes .utils .ImageUtils .dockerLoginAndPushImageToRegistry ;
108
104
import static oracle .weblogic .kubernetes .utils .JobUtils .createDomainJob ;
109
105
import static oracle .weblogic .kubernetes .utils .JobUtils .getIntrospectJobName ;
110
- import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .createIngressForDomainAndVerify ;
111
- import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .installAndVerifyNginx ;
112
106
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
113
107
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
114
108
import static oracle .weblogic .kubernetes .utils .PatchDomainUtils .patchDomainResource ;
126
120
import static oracle .weblogic .kubernetes .utils .WLSTUtils .executeWLSTScript ;
127
121
import static org .apache .commons .io .FileUtils .copyDirectory ;
128
122
import static org .apache .commons .io .FileUtils .deleteDirectory ;
129
- import static org .assertj .core .api .Assertions .assertThat ;
130
123
import static org .awaitility .Awaitility .with ;
131
124
import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
132
125
import static org .junit .jupiter .api .Assertions .assertEquals ;
@@ -149,10 +142,6 @@ class ItIntrospectVersion {
149
142
150
143
private static final String domainUid = "myintrodomain" ;
151
144
152
- private static String nginxNamespace = null ;
153
- private static int nodeportshttp ;
154
- private static HelmParams nginxHelmParams = null ;
155
-
156
145
private final String wlSecretName = "weblogic-credentials" ;
157
146
158
147
private static String adminSvcExtHost = null ;
@@ -173,6 +162,7 @@ class ItIntrospectVersion {
173
162
174
163
private static Path clusterViewAppPath ;
175
164
private static LoggingFacade logger = null ;
165
+ private final int managedServerPort = 7100 ;
176
166
177
167
/**
178
168
* Assigns unique namespaces for operator and domains.
@@ -182,29 +172,18 @@ class ItIntrospectVersion {
182
172
* @param namespaces injected by JUnit
183
173
*/
184
174
@ BeforeAll
185
- public static void initAll (@ Namespaces (3 ) List <String > namespaces ) {
175
+ public static void initAll (@ Namespaces (2 ) List <String > namespaces ) {
186
176
logger = getLogger ();
187
177
logger .info ("Assign a unique namespace for operator" );
188
178
assertNotNull (namespaces .get (0 ), "Namespace is null" );
189
179
opNamespace = namespaces .get (0 );
190
180
logger .info ("Assign a unique namespace for Introspect Version WebLogic domain" );
191
181
assertNotNull (namespaces .get (1 ), "Namespace is null" );
192
182
introDomainNamespace = namespaces .get (1 );
193
- logger .info ("Assign a unique namespace for NGINX" );
194
- assertNotNull (namespaces .get (2 ), "Namespace is null" );
195
- nginxNamespace = namespaces .get (2 );
196
183
197
184
// install operator and verify its running in ready state
198
185
installAndVerifyOperator (opNamespace , introDomainNamespace );
199
186
200
- // get a free node port for NGINX
201
- nodeportshttp = getNextFreePort ();
202
- int nodeportshttps = getNextFreePort ();
203
-
204
- if (!OKD ) {
205
- nginxHelmParams = installAndVerifyNginx (nginxNamespace , nodeportshttp , nodeportshttps );
206
- }
207
-
208
187
// create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
209
188
// this secret is used only for non-kind cluster
210
189
createSecretForBaseImages (introDomainNamespace );
@@ -242,7 +221,6 @@ void testDomainIntrospectVersionNotRolling() {
242
221
243
222
final String managedServerNameBase = "managed-server" ;
244
223
String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase ;
245
- final int managedServerPort = 7100 ;
246
224
247
225
int replicaCount = 2 ;
248
226
@@ -524,16 +502,6 @@ public void conditionEvaluated(EvaluatedCondition condition) {
524
502
domainUid , introDomainNamespace , pods .get (i ));
525
503
}
526
504
527
- //create ingress controller
528
- if (!OKD ) {
529
- Map <String , Integer > clusterNameMsPortMap = new HashMap <>();
530
- clusterNameMsPortMap .put (clusterName , managedServerPort );
531
- logger .info ("Creating ingress for domain {0} in namespace {1}" , domainUid , introDomainNamespace );
532
- createIngressForDomainAndVerify (domainUid , introDomainNamespace , clusterNameMsPortMap );
533
- } else {
534
- clusterRouteHost = createRouteForOKD (clusterServiceName , introDomainNamespace );
535
- }
536
-
537
505
managedServerNames = new ArrayList <String >();
538
506
for (int i = 1 ; i <= replicaCount + 1 ; i ++) {
539
507
managedServerNames .add (managedServerNameBase + i );
@@ -542,28 +510,12 @@ public void conditionEvaluated(EvaluatedCondition condition) {
542
510
//verify admin server accessibility and the health of cluster members
543
511
verifyMemberHealth (adminServerPodName , managedServerNames , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
544
512
545
- String curlRequest = null ;
513
+ // verify each managed server can see other member in the cluster
546
514
547
- if (OKD ) {
548
- logger .info ("cluster svc host = {0}" , clusterRouteHost );
549
- logger .info ("Accessing the clusterview app through cluster route" );
550
- curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
551
- + "http://%s/clusterview/ClusterViewServlet"
552
- + "\" ?user=" + ADMIN_USERNAME_DEFAULT
553
- + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " , clusterRouteHost );
554
- } else {
555
- //access application in managed servers through NGINX load balancer
556
- logger .info ("Accessing the clusterview app through NGINX load balancer" );
557
- curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
558
- + "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
559
- + "\" ?user=" + ADMIN_USERNAME_DEFAULT
560
- + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " ,
561
- domainUid + "." + introDomainNamespace + "." + clusterName + ".test" , K8S_NODEPORT_HOST , nodeportshttp );
515
+ for (String managedServerName : managedServerNames ) {
516
+ verifyConnectionBetweenClusterMembers (managedServerName , managedServerNames );
562
517
}
563
518
564
- // verify each managed server can see other member in the cluster
565
- verifyServerCommunication (curlRequest , managedServerNames );
566
-
567
519
// verify when a domain resource has spec.introspectVersion configured,
568
520
// all WebLogic server pods will have a label "weblogic.introspectVersion"
569
521
// set to the value of spec.introspectVersion.
@@ -704,26 +656,10 @@ void testDomainIntrospectVersionRolling() {
704
656
//verify admin server accessibility and the health of cluster members
705
657
verifyMemberHealth (adminServerPodName , managedServerNames , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
706
658
707
- String curlRequest = null ;
708
- if (OKD ) {
709
- logger .info ("cluster svc host = {0}" , clusterRouteHost );
710
- logger .info ("Accessing the clusterview app through cluster route" );
711
- curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
712
- + "http://%s/clusterview/ClusterViewServlet"
713
- + "\" ?user=" + ADMIN_USERNAME_DEFAULT
714
- + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " , clusterRouteHost );
715
- } else {
716
- //access application in managed servers through NGINX load balancer
717
- logger .info ("Accessing the clusterview app through NGINX load balancer" );
718
- curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
719
- + "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
720
- + "\" ?user=" + ADMIN_USERNAME_DEFAULT
721
- + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " ,
722
- domainUid + "." + introDomainNamespace + "." + clusterName + ".test" , K8S_NODEPORT_HOST , nodeportshttp );
723
- }
724
-
725
659
// verify each managed server can see other member in the cluster
726
- verifyServerCommunication (curlRequest , managedServerNames );
660
+ for (String managedServerName : managedServerNames ) {
661
+ verifyConnectionBetweenClusterMembers (managedServerName , managedServerNames );
662
+ }
727
663
728
664
// verify when a domain/cluster is rolling restarted without changing the spec.introspectVersion,
729
665
// all server pods' weblogic.introspectVersion label stay unchanged after the pods are restarted.
@@ -1369,22 +1305,6 @@ private void verifyIntrospectVersionLabelValue(String podName, String introspect
1369
1305
}
1370
1306
}
1371
1307
1372
- /**
1373
- * Uninstall Nginx.
1374
- * The cleanup framework does not uninstall Nginx release.
1375
- * Do it here for now.
1376
- */
1377
- @ AfterAll
1378
- public void tearDownAll () {
1379
- // uninstall NGINX release
1380
- if (nginxHelmParams != null ) {
1381
- assertThat (uninstallNginx (nginxHelmParams ))
1382
- .as ("Test uninstallNginx returns true" )
1383
- .withFailMessage ("uninstallNginx() did not return true" )
1384
- .isTrue ();
1385
- }
1386
- }
1387
-
1388
1308
// copy samples directory to a temporary location
1389
1309
private static void setupSample () {
1390
1310
assertDoesNotThrow (() -> {
@@ -1412,4 +1332,17 @@ private String executeLifecycleScript(String script, String extraParams) {
1412
1332
1413
1333
return execResult .toString ();
1414
1334
}
1335
+
1336
+ private void verifyConnectionBetweenClusterMembers (String serverName , List <String > managedServerNames ) {
1337
+ String podName = domainUid + "-" + serverName ;
1338
+ final String command = String .format (
1339
+ "kubectl exec -n " + introDomainNamespace + " " + podName + " -- curl http://"
1340
+ + ADMIN_USERNAME_DEFAULT
1341
+ + ":"
1342
+ + ADMIN_PASSWORD_DEFAULT
1343
+ + "@" + podName + ":%s/clusterview/ClusterViewServlet"
1344
+ + "\" ?user=" + ADMIN_USERNAME_DEFAULT
1345
+ + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " ,managedServerPort );
1346
+ verifyServerCommunication (command , serverName , managedServerNames );
1347
+ }
1415
1348
}
0 commit comments