28
28
import oracle .weblogic .kubernetes .annotations .Namespaces ;
29
29
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
30
30
import oracle .weblogic .kubernetes .utils .BuildApplication ;
31
- import oracle .weblogic .kubernetes .utils .ExecCommand ;
32
31
import oracle .weblogic .kubernetes .utils .ExecResult ;
33
- import org .awaitility .core .ConditionFactory ;
34
32
import org .junit .jupiter .api .BeforeAll ;
35
33
import org .junit .jupiter .api .DisplayName ;
36
- import org .junit .jupiter .api .Tag ;
37
34
import org .junit .jupiter .api .Test ;
38
35
39
- import static java .util .concurrent .TimeUnit .MINUTES ;
40
- import static java .util .concurrent .TimeUnit .SECONDS ;
41
36
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
42
37
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
43
38
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
44
- import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
45
39
import static oracle .weblogic .kubernetes .TestConstants .MANAGED_SERVER_NAME_BASE ;
46
40
import static oracle .weblogic .kubernetes .TestConstants .OCIR_SECRET_NAME ;
47
41
import static oracle .weblogic .kubernetes .TestConstants .OKD ;
48
- import static oracle .weblogic .kubernetes .TestConstants .VOYAGER_CHART_NAME ;
49
42
import static oracle .weblogic .kubernetes .actions .ActionConstants .APP_DIR ;
50
43
import static oracle .weblogic .kubernetes .actions .TestActions .createDomainCustomResource ;
51
44
import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
52
45
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
46
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
47
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
48
+ import static oracle .weblogic .kubernetes .utils .ExecCommand .exec ;
53
49
import static oracle .weblogic .kubernetes .utils .ImageUtils .createImageAndVerify ;
54
50
import static oracle .weblogic .kubernetes .utils .ImageUtils .createOcirRepoSecret ;
55
51
import static oracle .weblogic .kubernetes .utils .ImageUtils .dockerLoginAndPushImageToRegistry ;
56
- import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .installAndVerifyVoyager ;
57
- import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .installVoyagerIngressAndVerify ;
52
+ import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .createTraefikIngressForDomainAndVerify ;
53
+ import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .installAndVerifyTraefik ;
58
54
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
59
55
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
60
56
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodReady ;
61
57
import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
62
58
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
63
59
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
64
- import static org .awaitility .Awaitility .with ;
65
60
import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
66
61
import static org .junit .jupiter .api .Assertions .assertEquals ;
67
62
import static org .junit .jupiter .api .Assertions .assertFalse ;
71
66
// Test to associate a Coherence Cluster with multiple WebLogic server clusters.
72
67
@ DisplayName ("Test to associate a Coherence Cluster with multiple WebLogic server clusters" )
73
68
@ IntegrationTest
74
- @ Tag ("okdenv" )
75
69
class ItManagedCoherence {
76
70
77
71
// constants for Coherence
@@ -89,21 +83,15 @@ class ItManagedCoherence {
89
83
private static final int MANAGED_SERVER_PORT = 8001 ;
90
84
private static final int replicaCount = 2 ;
91
85
private static String adminServerPodName = domainUid + "-admin-server" ;
92
- private static String cluster1Hostname = null ;
93
- private static String cluster2Hostname = null ;
94
86
95
87
private static String opNamespace = null ;
96
88
private static String domainNamespace = null ;
97
- private static ConditionFactory withStandardRetryPolicy = null ;
98
89
99
- // constants for Voyager
100
- private static String cloudProvider = "baremetal" ;
101
- private static boolean enableValidatingWebhook = false ;
102
- private static HelmParams voyagerHelmParams = null ;
90
+ private static HelmParams traefikHelmParams = null ;
103
91
private static LoggingFacade logger = null ;
104
92
105
93
/**
106
- * Install Voyager and operator, build two Coherence applications
94
+ * Install Traefik and operator, build two Coherence applications
107
95
* 1. Coherence applications are packaged as Grid ARchives (GAR) and
108
96
* deployed on storage-enabled managed Coherence servers in cluster-2
109
97
* 2. Coherence application GAR is packaged within an EAR and
@@ -115,15 +103,11 @@ class ItManagedCoherence {
115
103
@ BeforeAll
116
104
public static void init (@ Namespaces (3 ) List <String > namespaces ) {
117
105
logger = getLogger ();
118
- // create standard, reusable retry/backoff policy
119
- withStandardRetryPolicy = with ().pollDelay (2 , SECONDS )
120
- .and ().with ().pollInterval (10 , SECONDS )
121
- .atMost (5 , MINUTES ).await ();
122
106
123
- // get a unique Voyager namespace
124
- logger .info ("Get a unique namespace for Voyager " );
107
+ // get a unique Traefik namespace
108
+ logger .info ("Get a unique namespace for Traefik " );
125
109
assertNotNull (namespaces .get (0 ), "Namespace list is null" );
126
- String voyagerNamespace = namespaces .get (0 );
110
+ String traefikNamespace = namespaces .get (0 );
127
111
128
112
// get a new unique opNamespace
129
113
logger .info ("Assigning a unique namespace for Operator" );
@@ -135,10 +119,9 @@ public static void init(@Namespaces(3) List<String> namespaces) {
135
119
assertNotNull (namespaces .get (2 ), "Namespace list is null" );
136
120
domainNamespace = namespaces .get (2 );
137
121
138
- // install and verify Voyager if not running on OKD
122
+ // install and verify Traefik if not running on OKD
139
123
if (!OKD ) {
140
- voyagerHelmParams =
141
- installAndVerifyVoyager (voyagerNamespace , cloudProvider , enableValidatingWebhook );
124
+ traefikHelmParams = installAndVerifyTraefik (traefikNamespace , 0 , 0 );
142
125
}
143
126
144
127
// install and verify operator
@@ -165,7 +148,6 @@ public static void init(@Namespaces(3) List<String> namespaces) {
165
148
@ DisplayName ("Two cluster domain with a Coherence cluster and test interaction with cache data" )
166
149
void testMultiClusterCoherenceDomain () {
167
150
String ingressName = domainUid + "-ingress-host-routing" ;
168
- String ingressServiceName = VOYAGER_CHART_NAME + "-" + ingressName ;
169
151
String channelName = "tcp-80" ;
170
152
171
153
// create a DomainHomeInImage image using WebLogic Image Tool
@@ -187,34 +169,29 @@ void testMultiClusterCoherenceDomain() {
187
169
assertTrue (testCompletedSuccessfully , "Test Coherence cache failed" );
188
170
} else {
189
171
190
- // create Voyager ingress resource
191
172
Map <String , Integer > clusterNameMsPortMap = new HashMap <>();
192
173
for (int i = 1 ; i <= NUMBER_OF_CLUSTERS ; i ++) {
193
174
clusterNameMsPortMap .put (CLUSTER_NAME_PREFIX + i , MANAGED_SERVER_PORT );
194
175
}
176
+ // clusterNameMsPortMap.put(clusterName, managedServerPort);
177
+ logger .info ("Creating ingress for domain {0} in namespace {1}" , domainUid , domainNamespace );
178
+ createTraefikIngressForDomainAndVerify (domainUid , domainNamespace , 0 , clusterNameMsPortMap , true , null );
195
179
196
- // get hostnames
197
- List <String > hostNames =
198
- installVoyagerIngressAndVerify (domainUid , domainNamespace , ingressName , clusterNameMsPortMap );
199
-
180
+ String clusterHostname = domainUid + "." + domainNamespace + ".cluster-1.test" ;
200
181
// get ingress service Nodeport
182
+ String ingressServiceName = traefikHelmParams .getReleaseName ();
183
+ String traefikNamespace = traefikHelmParams .getNamespace ();
184
+
201
185
int ingressServiceNodePort = assertDoesNotThrow (()
202
- -> getServiceNodePort (domainNamespace , ingressServiceName , channelName ),
203
- "Getting admin server node port failed" );
186
+ -> getServiceNodePort (traefikNamespace , ingressServiceName , "web" ),
187
+ "Getting Ingress Service node port failed" );
204
188
logger .info ("Node port for {0} is: {1} :" , ingressServiceName , ingressServiceNodePort );
205
189
206
- // get hostname for each cluster
207
- for (String hostName : hostNames ) {
208
- if (hostName .contains ("cluster-1" )) {
209
- cluster1Hostname = hostName ;
210
- } else if (hostName .contains ("cluster-2" )) {
211
- cluster2Hostname = hostName ;
212
- }
213
- }
214
-
190
+ String hostAndPort = getHostAndPort (clusterHostname , ingressServiceNodePort );
191
+ assertTrue (checkCoheranceApp (clusterHostname , hostAndPort ), "Failed to access Coherance App cation" );
215
192
// test adding data to the cache and retrieving them from the cache
216
193
boolean testCompletedSuccessfully = assertDoesNotThrow (()
217
- -> coherenceCacheTest (cluster1Hostname , ingressServiceNodePort ), "Test Coherence cache failed" );
194
+ -> coherenceCacheTest (clusterHostname , ingressServiceNodePort ), "Test Coherence cache failed" );
218
195
assertTrue (testCompletedSuccessfully , "Test Coherence cache failed" );
219
196
}
220
197
}
@@ -241,8 +218,8 @@ private static void createAndVerifyDomain(String domImage) {
241
218
// create secret for admin credentials
242
219
logger .info ("Create secret for admin credentials" );
243
220
String adminSecretName = "weblogic-credentials" ;
244
- assertDoesNotThrow (() -> createSecretWithUsernamePassword (adminSecretName ,
245
- domainNamespace , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ),
221
+ assertDoesNotThrow (() -> createSecretWithUsernamePassword (adminSecretName , domainNamespace ,
222
+ ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ),
246
223
String .format ("create secret for admin credentials failed for %s" , adminSecretName ));
247
224
248
225
// create encryption secret
@@ -349,7 +326,7 @@ private boolean coherenceCacheTest(String hostName) {
349
326
private boolean coherenceCacheTest (String hostName , int ingressServiceNodePort ) {
350
327
logger .info ("Starting to test the cache" );
351
328
352
- String hostAndPort = ( OKD ) ? hostName : K8S_NODEPORT_HOST + ":" + ingressServiceNodePort ;
329
+ String hostAndPort = getHostAndPort ( hostName , ingressServiceNodePort ) ;
353
330
logger .info ("hostAndPort = {0} " , hostAndPort );
354
331
355
332
// add the data to cache
@@ -358,8 +335,8 @@ private boolean coherenceCacheTest(String hostName, int ingressServiceNodePort)
358
335
ExecResult result = null ;
359
336
for (int i = 0 ; i < firstNameList .length ; i ++) {
360
337
result = addDataToCache (firstNameList [i ], secondNameList [i ], hostName , hostAndPort );
361
- logger .info ("Data added to the cache " + result .stdout ());
362
338
assertTrue (result .stdout ().contains (firstNameList [i ]), "Did not add the expected record" );
339
+ logger .info ("Data added to the cache: {0}" , result .stdout ());
363
340
}
364
341
365
342
// check if cache size is 6
@@ -390,7 +367,6 @@ private ExecResult addDataToCache(String firstName,
390
367
String hostName ,
391
368
String hostAndPort ) {
392
369
logger .info ("Add initial data to cache" );
393
-
394
370
StringBuffer curlCmd = new StringBuffer ("curl --silent --show-error --noproxy '*' " );
395
371
curlCmd
396
372
.append ("-d 'action=add&first=" )
@@ -407,8 +383,7 @@ private ExecResult addDataToCache(String firstName,
407
383
.append ("/" )
408
384
.append (COHERENCE_APP_NAME );
409
385
logger .info ("Command to add initial data to cache {0} " , curlCmd .toString ());
410
-
411
- ExecResult result = assertDoesNotThrow (() -> ExecCommand .exec (curlCmd .toString (), true ),
386
+ ExecResult result = assertDoesNotThrow (() -> exec (curlCmd .toString (), true ),
412
387
String .format ("Failed to add initial data to cache by running command %s" , curlCmd ));
413
388
assertEquals (0 , result .exitValue (),
414
389
String .format ("Failed to add initial data to cache. Error is %s " , result .stderr ()));
@@ -432,7 +407,7 @@ private ExecResult getCacheSize(String hostName, String hostAndPort) {
432
407
.append (COHERENCE_APP_NAME );
433
408
logger .info ("Command to get the number of records in cache " + curlCmd .toString ());
434
409
435
- ExecResult result = assertDoesNotThrow (() -> ExecCommand . exec (curlCmd .toString (), true ),
410
+ ExecResult result = assertDoesNotThrow (() -> exec (curlCmd .toString (), true ),
436
411
String .format ("Failed to get the number of records in cache by running command %s" , curlCmd ));
437
412
assertEquals (0 , result .exitValue (),
438
413
String .format ("Failed to get the number of records in cache. Error is %s " , result .stderr ()));
@@ -456,7 +431,7 @@ private ExecResult getCacheContents(String hostName, String hostAndPort) {
456
431
.append (COHERENCE_APP_NAME );
457
432
logger .info ("Command to get the records from cache " + curlCmd .toString ());
458
433
459
- ExecResult result = assertDoesNotThrow (() -> ExecCommand . exec (curlCmd .toString (), true ),
434
+ ExecResult result = assertDoesNotThrow (() -> exec (curlCmd .toString (), true ),
460
435
String .format ("Failed to get the records from cache by running command %s" , curlCmd ));
461
436
assertEquals (0 , result .exitValue (),
462
437
String .format ("Failed to get the records from cache. Error is %s " , result .stderr ()));
@@ -480,11 +455,37 @@ private ExecResult clearCache(String hostName, String hostAndPort) {
480
455
.append (COHERENCE_APP_NAME );
481
456
logger .info ("Command to clean the cache " + curlCmd .toString ());
482
457
483
- ExecResult result = assertDoesNotThrow (() -> ExecCommand . exec (curlCmd .toString (), true ),
458
+ ExecResult result = assertDoesNotThrow (() -> exec (curlCmd .toString (), true ),
484
459
String .format ("Failed to clean the cache by running command %s" , curlCmd ));
485
460
assertEquals (0 , result .exitValue (),
486
461
String .format ("Failed to clean the cache. Error is %s " , result .stderr ()));
487
462
488
463
return result ;
489
464
}
465
+
466
+ private boolean checkCoheranceApp (String hostName , String hostAndPort ) {
467
+
468
+ StringBuffer curlCmd = new StringBuffer ("curl --silent --show-error --noproxy '*' " );
469
+ curlCmd
470
+ .append ("-d 'action=clear' " )
471
+ .append ("-X POST -H 'host: " )
472
+ .append (hostName )
473
+ .append ("' http://" )
474
+ .append (hostAndPort )
475
+ .append ("/" )
476
+ .append (COHERENCE_APP_NAME )
477
+ .append ("/" )
478
+ .append (COHERENCE_APP_NAME )
479
+ .append (" -o /dev/null" )
480
+ .append (" -w %{http_code};" )
481
+ .append ("echo ${status}" );
482
+ logger .info ("Command to check the Application {0} " , curlCmd .toString ());
483
+ testUntil (
484
+ assertDoesNotThrow (() -> () -> exec (new String (curlCmd ), true ).stdout ().contains ("200" )),
485
+ logger ,
486
+ "application to be ready {0}" ,
487
+ curlCmd );
488
+ return true ;
489
+ }
490
+
490
491
}
0 commit comments