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
123
+ private static String hostAndPort = null ;
124
+
119
125
private static final String RCUSCHEMAPREFIX = "FMWDOMAINMII" ;
120
126
private static final String RCUSYSPASSWORD = "Oradoc_db1" ;
121
127
private static final String RCUSCHEMAPASSWORD = "Oradoc_db1" ;
@@ -124,6 +130,7 @@ class ItDBOperator {
124
130
private static String dbUrl = null ;
125
131
private static String dbName = "my-oracle-sidb" ;
126
132
private static LoggingFacade logger = null ;
133
+ private static HelmParams traefikHelmParams ;
127
134
128
135
private String fmwDomainUid = "fmwdomain-mii-db" ;
129
136
private String adminServerName = "admin-server" ;
@@ -153,6 +160,9 @@ class ItDBOperator {
153
160
private final String wlsClusterResName = wlsDomainUid + "-" + clusterName ;
154
161
155
162
private static String hostHeader ;
163
+ private String ingressIP ;
164
+ private static TraefikParams traefikParams ;
165
+ private String ingressClassName ;
156
166
157
167
/**
158
168
* Start DB service and create RCU schema.
@@ -162,7 +172,7 @@ class ItDBOperator {
162
172
* @param namespaces injected by JUnit
163
173
*/
164
174
@ BeforeAll
165
- public static void initAll (@ Namespaces (4 ) List <String > namespaces ) {
175
+ public static void initAll (@ Namespaces (5 ) List <String > namespaces ) {
166
176
167
177
logger = getLogger ();
168
178
logger .info ("Assign a unique namespace for DB and RCU" );
@@ -181,6 +191,19 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
181
191
assertNotNull (namespaces .get (3 ), "Namespace is null" );
182
192
wlsDomainNamespace = namespaces .get (3 );
183
193
194
+ // get a unique Traefik namespace
195
+ logger .info ("Get a unique namespace for Traefik" );
196
+ assertNotNull (namespaces .get (4 ), "Namespace list is null" );
197
+ traefikNamespace = namespaces .get (4 );
198
+
199
+ // install and verify Traefik
200
+ if (OKE_CLUSTER_PRIVATEIP ) {
201
+ traefikParams =
202
+ installAndVerifyTraefik (traefikNamespace , 0 , 0 );
203
+ traefikHelmParams = traefikParams .getHelmParams ();
204
+ }
205
+
206
+
184
207
// Create the repo secret to pull the image
185
208
// this secret is used only for non-kind cluster
186
209
createBaseRepoSecret (fmwDomainNamespace );
@@ -199,6 +222,17 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
199
222
installAndVerifyOperator (opNamespace , fmwDomainNamespace , wlsDomainNamespace );
200
223
}
201
224
225
+ @ AfterAll
226
+ void tearDown () {
227
+ // uninstall Traefik
228
+ if (traefikHelmParams != null ) {
229
+ assertThat (uninstallTraefik (traefikHelmParams ))
230
+ .as ("Test uninstallTraefik returns true" )
231
+ .withFailMessage ("uninstallTraefik() did not return true" )
232
+ .isTrue ();
233
+ }
234
+ }
235
+
202
236
/**
203
237
* Create a basic FMW model in image domain using the database created by DB Operator. Verify Pod is ready and service
204
238
* exists for both admin server and managed servers. Verify EM console is accessible.
@@ -553,34 +587,28 @@ private void runJmsClientOnAdminPod(String action, String queue) {
553
587
* @returns true if MBean is found otherwise false
554
588
**/
555
589
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
590
testUntil (
578
- assertDoesNotThrow (() -> () -> exec (curlString .toString (), true ).stdout ().contains ("200" )),
591
+ assertDoesNotThrow (() -> () -> getJMSRunTimeOutput (jmsServer ,
592
+ managedServer ).contains ("destinationsCurrentCount" )),
579
593
logger ,
580
594
"JMS Server Service to migrate" );
581
595
return true ;
582
596
}
583
597
598
+ private String getJMSRunTimeOutput (String jmsServer , String managedServer ) {
599
+ String output = readRuntimeResource (
600
+ adminSvcExtHost ,
601
+ wlsDomainNamespace ,
602
+ wlsAdminServerPodName ,
603
+ "/management/weblogic/latest/domainRuntime/serverRuntimes/"
604
+ + managedServer
605
+ + "/JMSRuntime/JMSServers/"
606
+ + jmsServer ,
607
+ "checkJmsServerRuntime" );
608
+ logger .info ("Got output " + output );
609
+ return output ;
610
+ }
611
+
584
612
/*
585
613
* Verify the Persistent Store Runtimes through REST API.
586
614
* Get the specific Persistent Store Runtime on specified managed server.
@@ -589,31 +617,19 @@ private boolean checkJmsServerRuntime(String jmsServer, String managedServer) {
589
617
* @returns true if MBean is found otherwise false
590
618
**/
591
619
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
620
testUntil (
614
- assertDoesNotThrow (() -> () -> exec (curlString .toString (), true ).stdout ().contains ("200" )),
621
+ assertDoesNotThrow (() -> () -> readRuntimeResource (
622
+ adminSvcExtHost ,
623
+ wlsDomainNamespace ,
624
+ wlsAdminServerPodName ,
625
+ "/management/weblogic/latest/domainRuntime/serverRuntimes/"
626
+ + managedServer
627
+ + "/persistentStoreRuntimes/"
628
+ + storeName ,
629
+ "checkPersistentStoreRuntime" ).contains ("PersistentStoreRuntime" )),
615
630
logger ,
616
631
"PersistentStoreRuntimes Service to migrate" );
632
+
617
633
return true ;
618
634
}
619
635
@@ -627,28 +643,16 @@ private boolean checkStoreRuntime(String storeName, String managedServer) {
627
643
* @returns true if MBean is found otherwise false
628
644
**/
629
645
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
646
testUntil (
650
- assertDoesNotThrow (() -> () -> exec (curlString .toString (), true )
651
- .stdout ().contains ("\" active\" : " + active )),
647
+ assertDoesNotThrow (() -> () -> readRuntimeResource (
648
+ adminSvcExtHost ,
649
+ wlsDomainNamespace ,
650
+ wlsAdminServerPodName ,
651
+ "/management/weblogic/latest/domainRuntime/serverRuntimes/"
652
+ + managedServer
653
+ + "/JTARuntime/recoveryRuntimeMBeans/"
654
+ + recoveryService ,
655
+ "checkRecoveryServiceRuntime" ).contains ("\" active\" : " + active )),
652
656
logger ,
653
657
"JTA Recovery Service to migrate" );
654
658
return true ;
0 commit comments