33
33
import oracle .weblogic .kubernetes .assertions .TestAssertions ;
34
34
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
35
35
import oracle .weblogic .kubernetes .utils .ExecResult ;
36
- import org .awaitility .core .ConditionFactory ;
37
36
import org .junit .jupiter .api .BeforeAll ;
37
+ import org .junit .jupiter .api .BeforeEach ;
38
38
import org .junit .jupiter .api .DisplayName ;
39
- import org .junit .jupiter .api .MethodOrderer ;
40
- import org .junit .jupiter .api .Order ;
41
39
import org .junit .jupiter .api .Test ;
42
- import org .junit .jupiter .api .TestMethodOrder ;
43
40
44
41
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
45
42
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
46
43
import static oracle .weblogic .kubernetes .TestConstants .DB_IMAGE_TO_USE_IN_SPEC ;
47
44
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
48
45
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_VERSION ;
49
- import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
50
46
import static oracle .weblogic .kubernetes .TestConstants .OCIR_SECRET_NAME ;
51
47
import static oracle .weblogic .kubernetes .TestConstants .RESULTS_ROOT ;
52
48
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_SLIM ;
53
49
import static oracle .weblogic .kubernetes .actions .ActionConstants .APP_DIR ;
54
50
import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
51
+ import static oracle .weblogic .kubernetes .actions .ActionConstants .WORK_DIR ;
55
52
import static oracle .weblogic .kubernetes .actions .TestActions .createDomainCustomResource ;
56
53
import static oracle .weblogic .kubernetes .actions .TestActions .getPodIP ;
57
54
import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
58
55
import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainExists ;
59
56
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .checkAppIsActive ;
60
57
import static oracle .weblogic .kubernetes .utils .BuildApplication .buildApplication ;
61
- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
58
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
62
59
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
63
60
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
64
61
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
73
70
import static oracle .weblogic .kubernetes .utils .ImageUtils .dockerLoginAndPushImageToRegistry ;
74
71
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
75
72
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
76
- import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodExists ;
77
- import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodReady ;
78
73
import static oracle .weblogic .kubernetes .utils .PodUtils .getExternalServicePodName ;
79
74
import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
80
75
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
87
82
/**
88
83
* Cross domain transaction tests.
89
84
*/
90
- @ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
91
85
@ DisplayName ("Verify cross domain transaction is successful" )
92
86
@ IntegrationTest
93
87
class ItCrossDomainTransaction {
@@ -107,7 +101,6 @@ class ItCrossDomainTransaction {
107
101
private static String opNamespace = null ;
108
102
private static String domain1Namespace = null ;
109
103
private static String domain2Namespace = null ;
110
- private static ConditionFactory withStandardRetryPolicy = null ;
111
104
private static String domainUid1 = "domain1" ;
112
105
private static String domainUid2 = "domain2" ;
113
106
private static int domain1AdminServiceNodePort = -1 ;
@@ -126,6 +119,7 @@ class ItCrossDomainTransaction {
126
119
private static String adminExtSvcRouteHost = null ;
127
120
private static String hostAndPort = null ;
128
121
private static String dbPodIP = null ;
122
+ private static int dbPort = 1521 ;
129
123
130
124
/**
131
125
* Install Operator.
@@ -181,6 +175,23 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
181
175
buildApplicationsAndDomains ();
182
176
}
183
177
178
+ /**
179
+ * Verify all server pods are running.
180
+ * Verify k8s services for all servers are created.
181
+ */
182
+ @ BeforeEach
183
+ public void beforeEach () {
184
+ int replicaCount = 2 ;
185
+ for (int i = 1 ; i <= replicaCount ; i ++) {
186
+ checkPodReadyAndServiceExists (domain2ManagedServerPrefix + i ,
187
+ domainUid2 , domain2Namespace );
188
+ }
189
+ for (int i = 1 ; i <= replicaCount ; i ++) {
190
+ checkPodReadyAndServiceExists (domain1ManagedServerPrefix + i ,
191
+ domainUid1 , domain1Namespace );
192
+ }
193
+ }
194
+
184
195
private static void updatePropertyFile () {
185
196
//create a temporary directory to copy and update the properties file
186
197
Path target = Paths .get (PROPS_TEMP_DIR );
@@ -214,17 +225,20 @@ private static void addToPropertyFile(String propFileName, String domainNamespac
214
225
215
226
FileOutputStream out = new FileOutputStream (PROPS_TEMP_DIR + "/" + propFileName );
216
227
props .setProperty ("NAMESPACE" , domainNamespace );
217
- props .setProperty ("K8S_NODEPORT_HOST" , K8S_NODEPORT_HOST );
218
- props .setProperty ("DBPORT" , Integer .toString (dbNodePort ));
228
+ props .setProperty ("K8S_NODEPORT_HOST" , dbPodIP );
229
+ props .setProperty ("DBPORT" , Integer .toString (dbPort ));
219
230
props .store (out , null );
220
231
out .close ();
221
232
}
222
233
223
234
private static void buildApplicationsAndDomains () {
224
235
225
236
//build application archive
237
+
238
+ Path targetDir = Paths .get (WORK_DIR ,
239
+ ItCrossDomainTransaction .class .getName () + "/txforward" );
226
240
Path distDir = buildApplication (Paths .get (APP_DIR , "txforward" ), null , null ,
227
- "build" , domain1Namespace );
241
+ "build" , domain1Namespace , targetDir );
228
242
logger .info ("distDir is {0}" , distDir .toString ());
229
243
assertTrue (Paths .get (distDir .toString (),
230
244
"txforward.ear" ).toFile ().exists (),
@@ -233,8 +247,10 @@ private static void buildApplicationsAndDomains() {
233
247
logger .info ("Application is in {0}" , appSource );
234
248
235
249
//build application archive
250
+ targetDir = Paths .get (WORK_DIR ,
251
+ ItCrossDomainTransaction .class .getName () + "/cdtservlet" );
236
252
distDir = buildApplication (Paths .get (APP_DIR , "cdtservlet" ), null , null ,
237
- "build" , domain1Namespace );
253
+ "build" , domain1Namespace , targetDir );
238
254
logger .info ("distDir is {0}" , distDir .toString ());
239
255
assertTrue (Paths .get (distDir .toString (),
240
256
"cdttxservlet.war" ).toFile ().exists (),
@@ -243,8 +259,10 @@ private static void buildApplicationsAndDomains() {
243
259
logger .info ("Application is in {0}" , appSource1 );
244
260
245
261
//build application archive for JMS Send/Receive
262
+ targetDir = Paths .get (WORK_DIR ,
263
+ ItCrossDomainTransaction .class .getName () + "/jmsservlet" );
246
264
distDir = buildApplication (Paths .get (APP_DIR , "jmsservlet" ), null , null ,
247
- "build" , domain1Namespace );
265
+ "build" , domain1Namespace , targetDir );
248
266
logger .info ("distDir is {0}" , distDir .toString ());
249
267
assertTrue (Paths .get (distDir .toString (),
250
268
"jmsservlet.war" ).toFile ().exists (),
@@ -269,8 +287,10 @@ private static void buildApplicationsAndDomains() {
269
287
"Could not modify the domain2Namespace in MDB Template file" );
270
288
271
289
//build application archive for MDB
290
+ targetDir = Paths .get (WORK_DIR ,
291
+ ItCrossDomainTransaction .class .getName () + "/mdbtopic" );
272
292
distDir = buildApplication (Paths .get (PROPS_TEMP_DIR , "mdbtopic" ), null , null ,
273
- "build" , domain1Namespace );
293
+ "build" , domain1Namespace , targetDir );
274
294
logger .info ("distDir is {0}" , distDir .toString ());
275
295
assertTrue (Paths .get (distDir .toString (),
276
296
"mdbtopic.jar" ).toFile ().exists (),
@@ -394,7 +414,6 @@ void testCrossDomainTransaction() {
394
414
* domain2 and the transaction should commit.
395
415
*
396
416
*/
397
- @ Order (2 )
398
417
@ Test
399
418
@ DisplayName ("Check cross domain transaction with TMAfterTLogBeforeCommitExit property commits" )
400
419
void testCrossDomainTransactionWithFailInjection () {
@@ -431,7 +450,6 @@ void testCrossDomainTransactionWithFailInjection() {
431
450
* targeted to a cluster of two servers, onMessage() will be triggered
432
451
* for both instance of MDB for a message sent to Distributed Topic
433
452
*/
434
- @ Order (3 )
435
453
@ Test
436
454
@ DisplayName ("Check cross domain transcated MDB communication " )
437
455
void testCrossDomainTranscatedMDB () {
@@ -467,27 +485,19 @@ void testCrossDomainTranscatedMDB() {
467
485
"Expected number of message not found in Accounting Queue" );
468
486
}
469
487
470
-
471
488
private boolean checkLocalQueue () {
472
489
String curlString = String .format ("curl -v --show-error --noproxy '*' "
473
- + "\" http://%s:%s /jmsservlet/jmstest?"
490
+ + "\" http://%s/jmsservlet/jmstest?"
474
491
+ "url=t3://localhost:7001&"
475
492
+ "action=receive&dest=jms.testAccountingQueue\" " ,
476
- K8S_NODEPORT_HOST , domain1AdminServiceNodePort );
493
+ hostAndPort );
477
494
478
495
logger .info ("curl command {0}" , curlString );
479
496
480
- withStandardRetryPolicy
481
- .conditionEvaluationListener (
482
- condition -> logger .info ("Waiting for local queue to be updated "
483
- + "(elapsed time {0} ms, remaining time {1} ms)" ,
484
- condition .getElapsedTimeInMS (),
485
- condition .getRemainingTimeInMS ()))
486
- .until (assertDoesNotThrow (() -> {
487
- return () -> {
488
- return exec (new String (curlString ), true ).stdout ().contains ("Messages are distributed" );
489
- };
490
- }));
497
+ testUntil (
498
+ () -> exec (new String (curlString ), true ).stdout ().contains ("Messages are distributed" ),
499
+ logger ,
500
+ "local queue to be updated" );
491
501
return true ;
492
502
}
493
503
@@ -507,55 +517,34 @@ private static void createDomain(String domainUid, String domainNamespace, Strin
507
517
replicaCount , domainImage );
508
518
509
519
// wait for the domain to exist
510
- logger .info ("Checking for domain custom resource in namespace {0}" , domainNamespace );
520
+ logger .info ("Check for domain custom resource in namespace {0}" , domainNamespace );
511
521
testUntil (
512
522
domainExists (domainUid , DOMAIN_VERSION , domainNamespace ),
513
523
logger ,
514
524
"domain {0} to be created in namespace {1}" ,
515
525
domainUid ,
516
- domainNamespace );
526
+ domainNamespace
527
+ );
517
528
518
529
// check admin server pod exists
530
+ // check admin server services created
519
531
logger .info ("Check for admin server pod {0} existence in namespace {1}" ,
520
532
adminServerPodName , domainNamespace );
521
- checkPodExists (adminServerPodName , domainUid , domainNamespace );
522
-
533
+ checkPodReadyAndServiceExists (adminServerPodName , domainUid , domainNamespace );
523
534
// check managed server pods exist
524
- for (int i = 1 ; i <= replicaCount ; i ++) {
525
- logger .info ("Check for managed server pod {0} existence in namespace {1}" ,
526
- managedServerPrefix + i , domainNamespace );
527
- checkPodExists (managedServerPrefix + i , domainUid , domainNamespace );
528
- }
529
-
530
- // check admin server pod is ready
531
- logger .info ("Wait for admin server pod {0} to be ready in namespace {1}" ,
532
- adminServerPodName , domainNamespace );
533
- checkPodReady (adminServerPodName , domainUid , domainNamespace );
534
-
535
- // check managed server pods are ready
536
- for (int i = 1 ; i <= replicaCount ; i ++) {
537
- logger .info ("Wait for managed server pod {0} to be ready in namespace {1}" ,
538
- managedServerPrefix + i , domainNamespace );
539
- checkPodReady (managedServerPrefix + i , domainUid , domainNamespace );
540
- }
541
-
542
- logger .info ("Check admin service {0} is created in namespace {1}" ,
543
- adminServerPodName , domainNamespace );
544
- checkServiceExists (adminServerPodName , domainNamespace );
545
-
546
535
// check managed server services created
547
536
for (int i = 1 ; i <= replicaCount ; i ++) {
548
- logger .info ("Check managed server service {0} is created in namespace {1}" ,
537
+ logger .info ("Check for managed server pod {0} existence in namespace {1}" ,
549
538
managedServerPrefix + i , domainNamespace );
550
- checkServiceExists (managedServerPrefix + i , domainNamespace );
539
+ checkPodReadyAndServiceExists (managedServerPrefix + i , domainUid , domainNamespace );
551
540
}
552
541
553
542
adminExtSvcRouteHost = createRouteForOKD (getExternalServicePodName (adminServerPodName ), domainNamespace );
554
543
// The fail inject test case, the response to the curl command takes longer than the default timeout of 30s
555
544
// So, have to increase the proxy timeout for the route
556
- String command = "oc -n " + domainNamespace + " annotate route "
557
- + getExternalServicePodName (adminServerPodName )
558
- + " --overwrite haproxy.router.openshift.io/timeout=600s" ;
545
+ String command = "oc -n " + domainNamespace + " annotate route "
546
+ + getExternalServicePodName (adminServerPodName )
547
+ + " --overwrite haproxy.router.openshift.io/timeout=600s" ;
559
548
logger .info ("command to set timeout = {0}" , command );
560
549
assertDoesNotThrow (
561
550
() -> exec (command , true ));
0 commit comments