15
15
import io .kubernetes .client .openapi .models .V1LocalObjectReference ;
16
16
import oracle .weblogic .domain .ClusterResource ;
17
17
import oracle .weblogic .domain .DomainResource ;
18
+ import oracle .weblogic .kubernetes .actions .impl .TraefikParams ;
18
19
import oracle .weblogic .kubernetes .actions .impl .primitive .Command ;
19
20
import oracle .weblogic .kubernetes .actions .impl .primitive .CommandParams ;
21
+ import oracle .weblogic .kubernetes .actions .impl .primitive .HelmParams ;
20
22
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
21
23
import oracle .weblogic .kubernetes .annotations .Namespaces ;
22
24
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
41
43
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_APP_NAME ;
42
44
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
43
45
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
46
+ import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER_PRIVATEIP ;
44
47
import static oracle .weblogic .kubernetes .TestConstants .SKIP_CLEANUP ;
45
48
import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
46
- import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
47
49
import static oracle .weblogic .kubernetes .actions .ActionConstants .ITTESTS_DIR ;
48
50
import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
49
51
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
50
52
import static oracle .weblogic .kubernetes .actions .ActionConstants .WORK_DIR ;
51
53
import static oracle .weblogic .kubernetes .actions .TestActions .createDomainCustomResource ;
52
54
import static oracle .weblogic .kubernetes .actions .TestActions .execCommand ;
53
- import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
54
55
import static oracle .weblogic .kubernetes .actions .TestActions .patchDomainCustomResource ;
55
56
import static oracle .weblogic .kubernetes .actions .TestActions .scaleCluster ;
57
+ import static oracle .weblogic .kubernetes .actions .TestActions .uninstallTraefik ;
56
58
import static oracle .weblogic .kubernetes .actions .impl .primitive .Command .defaultCommandParams ;
57
59
import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainExists ;
58
60
import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterAndVerify ;
61
63
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .createDomainResourceWithLogHome ;
62
64
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .createDomainSecret ;
63
65
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .createJobToChangePermissionsOnPvHostPath ;
66
+ import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .readRuntimeResource ;
64
67
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
65
68
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
66
- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
67
69
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
68
70
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .runClientInsidePod ;
69
71
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .runJavacInsidePod ;
74
76
import static oracle .weblogic .kubernetes .utils .DbUtils .createRcuSchema ;
75
77
import static oracle .weblogic .kubernetes .utils .DbUtils .deleteOracleDB ;
76
78
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
77
- import static oracle .weblogic .kubernetes .utils .ExecCommand .exec ;
78
79
import static oracle .weblogic .kubernetes .utils .FileUtils .copyFileToPod ;
79
80
import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyDomainReady ;
80
81
import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyEMconsoleAccess ;
81
82
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
82
83
import static oracle .weblogic .kubernetes .utils .ImageUtils .createMiiImageAndVerify ;
83
84
import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
84
85
import static oracle .weblogic .kubernetes .utils .ImageUtils .imageRepoLoginAndPushImageToRegistry ;
86
+ import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .installAndVerifyTraefik ;
85
87
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
86
88
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
87
89
import static oracle .weblogic .kubernetes .utils .PatchDomainUtils .patchDomainResourceServerStartPolicy ;
93
95
import static oracle .weblogic .kubernetes .utils .SecretUtils .createOpsswalletpasswordSecret ;
94
96
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
95
97
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
98
+ import static org .assertj .core .api .Assertions .assertThat ;
96
99
import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
97
100
import static org .junit .jupiter .api .Assertions .assertEquals ;
98
101
import static org .junit .jupiter .api .Assertions .assertNotNull ;
106
109
@ DisplayName ("Test to create FMW model in image domain and WebLogic domain using Oracle "
107
110
+ "database created using Oracle Database Operator" )
108
111
@ IntegrationTest
109
- @ Tag ("oke-sequential " )
112
+ @ Tag ("oke-gate " )
110
113
@ Tag ("kind-parallel" )
111
114
class ItDBOperator {
112
115
113
116
private static String dbNamespace = null ;
114
117
private static String opNamespace = null ;
115
118
private static String fmwDomainNamespace = null ;
116
119
private static String wlsDomainNamespace = null ;
120
+ private static String traefikNamespace = null ;
117
121
private static String fmwMiiImage = null ;
118
122
119
123
private static final String RCUSCHEMAPREFIX = "FMWDOMAINMII" ;
@@ -124,6 +128,7 @@ class ItDBOperator {
124
128
private static String dbUrl = null ;
125
129
private static String dbName = "my-oracle-sidb" ;
126
130
private static LoggingFacade logger = null ;
131
+ private static HelmParams traefikHelmParams ;
127
132
128
133
private String fmwDomainUid = "fmwdomain-mii-db" ;
129
134
private String adminServerName = "admin-server" ;
@@ -153,6 +158,7 @@ class ItDBOperator {
153
158
private final String wlsClusterResName = wlsDomainUid + "-" + clusterName ;
154
159
155
160
private static String hostHeader ;
161
+ private static TraefikParams traefikParams ;
156
162
157
163
/**
158
164
* Start DB service and create RCU schema.
@@ -162,7 +168,7 @@ class ItDBOperator {
162
168
* @param namespaces injected by JUnit
163
169
*/
164
170
@ BeforeAll
165
- public static void initAll (@ Namespaces (4 ) List <String > namespaces ) {
171
+ public static void initAll (@ Namespaces (5 ) List <String > namespaces ) {
166
172
167
173
logger = getLogger ();
168
174
logger .info ("Assign a unique namespace for DB and RCU" );
@@ -181,6 +187,18 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
181
187
assertNotNull (namespaces .get (3 ), "Namespace is null" );
182
188
wlsDomainNamespace = namespaces .get (3 );
183
189
190
+ // get a unique Traefik namespace
191
+ logger .info ("Get a unique namespace for Traefik" );
192
+ assertNotNull (namespaces .get (4 ), "Namespace list is null" );
193
+ traefikNamespace = namespaces .get (4 );
194
+
195
+ // install and verify Traefik
196
+ if (OKE_CLUSTER_PRIVATEIP ) {
197
+ traefikParams =
198
+ installAndVerifyTraefik (traefikNamespace , 0 , 0 );
199
+ traefikHelmParams = traefikParams .getHelmParams ();
200
+ }
201
+
184
202
// Create the repo secret to pull the image
185
203
// this secret is used only for non-kind cluster
186
204
createBaseRepoSecret (fmwDomainNamespace );
@@ -199,6 +217,17 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
199
217
installAndVerifyOperator (opNamespace , fmwDomainNamespace , wlsDomainNamespace );
200
218
}
201
219
220
+ @ AfterAll
221
+ void tearDown () {
222
+ // uninstall Traefik
223
+ if (traefikHelmParams != null ) {
224
+ assertThat (uninstallTraefik (traefikHelmParams ))
225
+ .as ("Test uninstallTraefik returns true" )
226
+ .withFailMessage ("uninstallTraefik() did not return true" )
227
+ .isTrue ();
228
+ }
229
+ }
230
+
202
231
/**
203
232
* Create a basic FMW model in image domain using the database created by DB Operator. Verify Pod is ready and service
204
233
* exists for both admin server and managed servers. Verify EM console is accessible.
@@ -553,34 +582,28 @@ private void runJmsClientOnAdminPod(String action, String queue) {
553
582
* @returns true if MBean is found otherwise false
554
583
**/
555
584
private boolean checkJmsServerRuntime (String jmsServer , String managedServer ) {
556
- ExecResult result = null ;
557
- int adminServiceNodePort
558
- = getServiceNodePort (wlsDomainNamespace , getExternalServicePodName (wlsAdminServerPodName ), "default" );
559
- String hostAndPort = getHostAndPort (adminSvcExtRouteHost , adminServiceNodePort );
560
- StringBuffer curlString = new StringBuffer ("status=$(curl --user "
561
- + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + " " );
562
- if (TestConstants .KIND_CLUSTER
563
- && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
564
- hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT ;
565
- curlString .append (" -H 'host: " + hostHeader + "' " );
566
- }
567
- curlString .append ("http://" + hostAndPort )
568
- .append ("/management/weblogic/latest/domainRuntime/serverRuntimes/" )
569
- .append (managedServer )
570
- .append ("/JMSRuntime/JMSServers/" )
571
- .append (jmsServer )
572
- .append (" --silent --show-error " )
573
- .append (" -o /dev/null" )
574
- .append (" -w %{http_code});" )
575
- .append ("echo ${status}" );
576
- logger .info ("checkJmsServerRuntime: curl command {0}" , new String (curlString ));
577
585
testUntil (
578
- assertDoesNotThrow (() -> () -> exec (curlString .toString (), true ).stdout ().contains ("200" )),
586
+ assertDoesNotThrow (() -> () -> getJMSRunTimeOutput (jmsServer ,
587
+ managedServer ).contains ("destinationsCurrentCount" )),
579
588
logger ,
580
589
"JMS Server Service to migrate" );
581
590
return true ;
582
591
}
583
592
593
+ private String getJMSRunTimeOutput (String jmsServer , String managedServer ) {
594
+ String output = readRuntimeResource (
595
+ adminSvcExtHost ,
596
+ wlsDomainNamespace ,
597
+ wlsAdminServerPodName ,
598
+ "/management/weblogic/latest/domainRuntime/serverRuntimes/"
599
+ + managedServer
600
+ + "/JMSRuntime/JMSServers/"
601
+ + jmsServer ,
602
+ "checkJmsServerRuntime" );
603
+ logger .info ("Got output " + output );
604
+ return output ;
605
+ }
606
+
584
607
/*
585
608
* Verify the Persistent Store Runtimes through REST API.
586
609
* Get the specific Persistent Store Runtime on specified managed server.
@@ -589,31 +612,19 @@ private boolean checkJmsServerRuntime(String jmsServer, String managedServer) {
589
612
* @returns true if MBean is found otherwise false
590
613
**/
591
614
private boolean checkStoreRuntime (String storeName , String managedServer ) {
592
- ExecResult result = null ;
593
- int adminServiceNodePort
594
- = getServiceNodePort (wlsDomainNamespace , getExternalServicePodName (wlsAdminServerPodName ), "default" );
595
- String hostAndPort = getHostAndPort (adminSvcExtRouteHost , adminServiceNodePort );
596
- StringBuffer curlString = new StringBuffer ("status=$(curl --user "
597
- + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + " " );
598
- if (TestConstants .KIND_CLUSTER
599
- && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
600
- hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT ;
601
- curlString .append (" -H 'host: " + hostHeader + "' " );
602
- }
603
- curlString .append ("http://" + hostAndPort )
604
- .append ("/management/weblogic/latest/domainRuntime/serverRuntimes/" )
605
- .append (managedServer )
606
- .append ("/persistentStoreRuntimes/" )
607
- .append (storeName )
608
- .append (" --silent --show-error " )
609
- .append (" -o /dev/null" )
610
- .append (" -w %{http_code});" )
611
- .append ("echo ${status}" );
612
- logger .info ("checkStoreRuntime: curl command {0}" , new String (curlString ));
613
615
testUntil (
614
- assertDoesNotThrow (() -> () -> exec (curlString .toString (), true ).stdout ().contains ("200" )),
616
+ assertDoesNotThrow (() -> () -> readRuntimeResource (
617
+ adminSvcExtHost ,
618
+ wlsDomainNamespace ,
619
+ wlsAdminServerPodName ,
620
+ "/management/weblogic/latest/domainRuntime/serverRuntimes/"
621
+ + managedServer
622
+ + "/persistentStoreRuntimes/"
623
+ + storeName ,
624
+ "checkPersistentStoreRuntime" ).contains ("PersistentStoreRuntime" )),
615
625
logger ,
616
626
"PersistentStoreRuntimes Service to migrate" );
627
+
617
628
return true ;
618
629
}
619
630
@@ -627,28 +638,16 @@ private boolean checkStoreRuntime(String storeName, String managedServer) {
627
638
* @returns true if MBean is found otherwise false
628
639
**/
629
640
private boolean checkJtaRecoveryServiceRuntime (String managedServer , String recoveryService , String active ) {
630
- ExecResult result = null ;
631
- int adminServiceNodePort
632
- = getServiceNodePort (wlsDomainNamespace , getExternalServicePodName (wlsAdminServerPodName ), "default" );
633
- String hostAndPort = getHostAndPort (adminSvcExtRouteHost , adminServiceNodePort );
634
- StringBuffer curlString = new StringBuffer ("curl --user "
635
- + ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT + " " );
636
- if (TestConstants .KIND_CLUSTER
637
- && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
638
- hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT ;
639
- curlString .append (" -H 'host: " + hostHeader + "' " );
640
- }
641
- curlString .append ("\" http://" + hostAndPort )
642
- .append ("/management/weblogic/latest/domainRuntime/serverRuntimes/" )
643
- .append (managedServer )
644
- .append ("/JTARuntime/recoveryRuntimeMBeans/" )
645
- .append (recoveryService )
646
- .append ("?fields=active&links=none\" " )
647
- .append (" --show-error " );
648
- logger .info ("checkJtaRecoveryServiceRuntime: curl command {0}" , new String (curlString ));
649
641
testUntil (
650
- assertDoesNotThrow (() -> () -> exec (curlString .toString (), true )
651
- .stdout ().contains ("\" active\" : " + active )),
642
+ assertDoesNotThrow (() -> () -> readRuntimeResource (
643
+ adminSvcExtHost ,
644
+ wlsDomainNamespace ,
645
+ wlsAdminServerPodName ,
646
+ "/management/weblogic/latest/domainRuntime/serverRuntimes/"
647
+ + managedServer
648
+ + "/JTARuntime/recoveryRuntimeMBeans/"
649
+ + recoveryService ,
650
+ "checkRecoveryServiceRuntime" ).contains ("\" active\" : " + active )),
652
651
logger ,
653
652
"JTA Recovery Service to migrate" );
654
653
return true ;
0 commit comments