33
44package oracle .weblogic .kubernetes ;
55
6- import java .io .IOException ;
76import java .net .InetAddress ;
87import java .net .UnknownHostException ;
98import java .net .http .HttpResponse ;
1211import java .nio .file .Paths ;
1312import java .util .ArrayList ;
1413import java .util .Arrays ;
15- import java .util .Collections ;
1614import java .util .HashMap ;
1715import java .util .List ;
1816import java .util .Map ;
3735import oracle .weblogic .kubernetes .annotations .Namespaces ;
3836import oracle .weblogic .kubernetes .logging .LoggingFacade ;
3937import oracle .weblogic .kubernetes .utils .ExecResult ;
40- import oracle .weblogic .kubernetes .utils .FmwUtils ;
4138import oracle .weblogic .kubernetes .utils .OracleHttpClient ;
4239import org .junit .jupiter .api .AfterAll ;
4340import org .junit .jupiter .api .BeforeAll ;
5350import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_VERSION ;
5451import static oracle .weblogic .kubernetes .TestConstants .ENCRYPION_PASSWORD_DEFAULT ;
5552import static oracle .weblogic .kubernetes .TestConstants .ENCRYPION_USERNAME_DEFAULT ;
56- import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_NAME ;
57- import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_TAG ;
58- import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_TO_USE_IN_SPEC ;
5953import static oracle .weblogic .kubernetes .TestConstants .IMAGE_PULL_POLICY ;
6054import static oracle .weblogic .kubernetes .TestConstants .ISTIO_HTTP_HOSTPORT ;
61- import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
62- import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_APP_NAME ;
6355import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
6456import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
6557import static oracle .weblogic .kubernetes .TestConstants .SKIP_CLEANUP ;
6658import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
67- import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TAG ;
6859import static oracle .weblogic .kubernetes .actions .ActionConstants .ITTESTS_DIR ;
6960import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
7061import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
8475import static oracle .weblogic .kubernetes .utils .CommonTestUtils .formatIPv6Host ;
8576import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
8677import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
87- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .isWebLogicPsuPatchApplied ;
8878import static oracle .weblogic .kubernetes .utils .CommonTestUtils .runClientInsidePod ;
8979import static oracle .weblogic .kubernetes .utils .CommonTestUtils .runJavacInsidePod ;
9080import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
9181import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapAndVerify ;
9282import static oracle .weblogic .kubernetes .utils .DbUtils .createOracleDBUsingOperator ;
93- import static oracle .weblogic .kubernetes .utils .DbUtils .createRcuAccessSecret ;
94- import static oracle .weblogic .kubernetes .utils .DbUtils .createRcuSchema ;
9583import static oracle .weblogic .kubernetes .utils .DbUtils .deleteOracleDB ;
9684import static oracle .weblogic .kubernetes .utils .DbUtils .installDBOperator ;
9785import static oracle .weblogic .kubernetes .utils .DbUtils .uninstallDBOperator ;
98- import static oracle .weblogic .kubernetes .utils .DeployUtil .deployToClusterUsingRest ;
99- import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
10086import static oracle .weblogic .kubernetes .utils .FileUtils .copyFileToPod ;
10187import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
102- import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyDomainReady ;
10388import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
104- import static oracle .weblogic .kubernetes .utils .ImageUtils .createMiiImageAndVerify ;
10589import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
106- import static oracle .weblogic .kubernetes .utils .ImageUtils .imageRepoLoginAndPushImageToRegistry ;
10790import static oracle .weblogic .kubernetes .utils .IstioUtils .deployHttpIstioGatewayAndVirtualservice ;
10891import static oracle .weblogic .kubernetes .utils .IstioUtils .deployIstioDestinationRule ;
10992import static oracle .weblogic .kubernetes .utils .IstioUtils .getIstioHttpIngressPort ;
11497import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
11598import static oracle .weblogic .kubernetes .utils .PodUtils .getExternalServicePodName ;
11699import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
117- import static oracle .weblogic .kubernetes .utils .SecretUtils .createOpsswalletpasswordSecret ;
118- import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
119100import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
120101import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
121102import static org .junit .jupiter .api .Assertions .assertEquals ;
@@ -132,38 +113,23 @@ class ItIstioDBOperator {
132113
133114 private static String dbNamespace = null ;
134115 private static String opNamespace = null ;
135- private static String fmwDomainNamespace = null ;
136116 private static String wlsDomainNamespace = null ;
137- private static String fmwMiiImage = null ;
138117
139- private static final String RCUSCHEMAPREFIX = "FMWDOMAINMII" ;
140118 private static final String RCUSYSPASSWORD = "Oradoc_db1" ;
141- private static final String RCUSCHEMAPASSWORD = "Oradoc_db1" ;
142- private static final String modelFile = "model-singleclusterdomain-sampleapp-jrf.yaml" ;
143119
144120 private static String dbUrl = null ;
145121 private static String dbName = "istio-oracle-sidb" ;
146122 private static LoggingFacade logger = null ;
147123
148- private String fmwDomainUid = "jrf-istio-db" ;
149- private String fmwAdminServerPodName = fmwDomainUid + "-admin-server" ;
150- private String fmwManagedServerPrefix = fmwDomainUid + "-managed-server" ;
151- private String clusterName = "cluster-1" ;
124+ private String clusterName = "cluster-1" ;
152125 private int replicaCount = 2 ;
153- private String fmwAminSecretName = fmwDomainUid + "-weblogic-credentials" ;
154- private String fmwEncryptionSecretName = fmwDomainUid + "-encryptionsecret" ;
155- private String rcuaccessSecretName = fmwDomainUid + "-rcu-access" ;
156- private String opsswalletpassSecretName = fmwDomainUid + "-opss-wallet-password-secret" ;
157- private String opsswalletfileSecretName = fmwDomainUid + "opss-wallet-file-secret" ;
158- private String adminSvcExtHost = null ;
159126
160127 private static final String wlsDomainUid = "mii-jms-istio-db" ;
161128 private static final String pvName = getUniqueName (wlsDomainUid + "-pv-" );
162129 private static final String pvcName = getUniqueName (wlsDomainUid + "-pvc-" );
163130 private static final String wlsAdminServerPodName = wlsDomainUid + "-admin-server" ;
164131 private static final String wlsManagedServerPrefix = wlsDomainUid + "-managed-server" ;
165132 private static int wlDomainIstioIngressPort ;
166- private String configMapName = "dynamicupdate-istio-configmap" ;
167133 private static String cpUrl ;
168134 private static String adminSvcExtRouteHost = null ;
169135
@@ -194,17 +160,12 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
194160 assertNotNull (namespaces .get (1 ), "Namespace is null" );
195161 opNamespace = namespaces .get (1 );
196162
197- logger .info ("Assign a unique namespace for FMW domain" );
198- assertNotNull (namespaces .get (2 ), "Namespace is null" );
199- fmwDomainNamespace = namespaces .get (2 );
200-
201163 logger .info ("Assign a unique namespace for WLS domain" );
202- assertNotNull (namespaces .get (3 ), "Namespace is null" );
203- wlsDomainNamespace = namespaces .get (3 );
164+ assertNotNull (namespaces .get (2 ), "Namespace is null" );
165+ wlsDomainNamespace = namespaces .get (2 );
204166
205167 // Create the repo secret to pull the image
206168 // this secret is used only for non-kind cluster
207- createBaseRepoSecret (fmwDomainNamespace );
208169 createBaseRepoSecret (wlsDomainNamespace );
209170 createTestRepoSecret (wlsDomainNamespace );
210171 // create PV, PVC for logs/data
@@ -217,7 +178,6 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
217178 // Label the domain/operator namespace with istio-injection=enabled
218179 Map <String , String > labelMap = new HashMap <>();
219180 labelMap .put ("istio-injection" , "enabled" );
220- assertDoesNotThrow (() -> addLabelsToNamespace (fmwDomainNamespace , labelMap ));
221181 assertDoesNotThrow (() -> addLabelsToNamespace (wlsDomainNamespace , labelMap ));
222182 assertDoesNotThrow (() -> addLabelsToNamespace (opNamespace , labelMap ));
223183
@@ -226,148 +186,12 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
226186
227187 logger .info ("Create Oracle DB in namespace: {0} " , dbNamespace );
228188 dbUrl = assertDoesNotThrow (() -> createOracleDBUsingOperator (dbName , RCUSYSPASSWORD , dbNamespace ));
229-
230- logger .info ("Create RCU schema with fmwImage: {0}, rcuSchemaPrefix: {1}, dbUrl: {2}, "
231- + " dbNamespace: {3}" , FMWINFRA_IMAGE_TO_USE_IN_SPEC , RCUSCHEMAPREFIX , dbUrl , dbNamespace );
232- assertDoesNotThrow (() -> createRcuSchema (FMWINFRA_IMAGE_TO_USE_IN_SPEC , RCUSCHEMAPREFIX ,
233- dbUrl , dbNamespace ));
234-
189+
235190 // create testwebapp.war
236191 testWebAppWarLoc = createTestWebAppWarFile (wlsDomainNamespace );
237192
238193 // install operator and verify its running in ready state
239- installAndVerifyOperator (opNamespace , fmwDomainNamespace , wlsDomainNamespace );
240- }
241-
242- /**
243- * Create a basic istio enabled FMW model in image domain using the database created by DB Operator.
244- * Verify Pod is ready and service exists for both admin server and managed servers.
245- */
246- @ Test
247- @ DisplayName ("Create Istio enabled FMW Domain model in image domain" )
248- void testIstioEnabledFmwModelInImageWithDbOperator () throws IOException , InterruptedException {
249-
250- // Create the repo secret to pull the image
251- // this secret is used only for non-kind cluster
252- createTestRepoSecret (fmwDomainNamespace );
253-
254- // create secret for admin credentials
255- logger .info ("Create secret for admin credentials" );
256- assertDoesNotThrow (() -> createSecretWithUsernamePassword (fmwAminSecretName ,
257- fmwDomainNamespace ,
258- ADMIN_USERNAME_DEFAULT ,
259- ADMIN_PASSWORD_DEFAULT ),
260- String .format ("createSecret failed for %s" , fmwAminSecretName ));
261-
262- // create encryption secret
263- logger .info ("Create encryption secret" );
264- assertDoesNotThrow (() -> createSecretWithUsernamePassword (fmwEncryptionSecretName ,
265- fmwDomainNamespace ,
266- ENCRYPION_USERNAME_DEFAULT ,
267- ENCRYPION_PASSWORD_DEFAULT ),
268- String .format ("createSecret failed for %s" , fmwEncryptionSecretName ));
269-
270- // create RCU access secret
271- logger .info ("Creating RCU access secret: {0}, with prefix: {1}, dbUrl: {2}, schemapassword: {3})" ,
272- rcuaccessSecretName , RCUSCHEMAPREFIX , dbUrl , RCUSCHEMAPASSWORD );
273- assertDoesNotThrow (() -> createRcuAccessSecret (
274- rcuaccessSecretName ,
275- fmwDomainNamespace ,
276- RCUSCHEMAPREFIX ,
277- RCUSCHEMAPASSWORD ,
278- dbUrl ),
279- String .format ("createSecret failed for %s" , rcuaccessSecretName ));
280-
281- logger .info ("Create OPSS wallet password secret" );
282- assertDoesNotThrow (() -> createOpsswalletpasswordSecret (
283- opsswalletpassSecretName ,
284- fmwDomainNamespace ,
285- ADMIN_PASSWORD_DEFAULT ),
286- String .format ("createSecret failed for %s" , opsswalletpassSecretName ));
287-
288- logger .info ("Create an image with jrf model file" );
289- final List <String > modelList = Collections .singletonList (MODEL_DIR + "/" + modelFile );
290- fmwMiiImage = createMiiImageAndVerify (
291- "jrf-mii-image" ,
292- modelList ,
293- Collections .singletonList (MII_BASIC_APP_NAME ),
294- FMWINFRA_IMAGE_NAME ,
295- FMWINFRA_IMAGE_TAG ,
296- "JRF" ,
297- false );
298-
299- // push the image to a registry to make it accessible in multi-node cluster
300- imageRepoLoginAndPushImageToRegistry (fmwMiiImage );
301-
302- // create WDT config map without any files
303- createConfigMapAndVerify (configMapName , fmwDomainUid , fmwDomainNamespace , Collections .emptyList ());
304-
305- // create the domain object
306- DomainResource domain = FmwUtils .createIstioDomainResource (fmwDomainUid ,
307- fmwDomainNamespace ,
308- fmwAminSecretName ,
309- TEST_IMAGES_REPO_SECRET_NAME ,
310- fmwEncryptionSecretName ,
311- rcuaccessSecretName ,
312- opsswalletpassSecretName ,
313- replicaCount ,
314- fmwMiiImage ,
315- configMapName
316- );
317-
318- // create cluster object
319- String clusterResName = fmwDomainUid + "-" + clusterName ;
320- ClusterResource cluster = createClusterResource (clusterResName , clusterName , fmwDomainNamespace , replicaCount );
321- logger .info ("Creating cluster resource {0} in namespace {1}" , clusterName , fmwDomainNamespace );
322- createClusterAndVerify (cluster );
323- // set cluster references
324- domain .getSpec ().withCluster (new V1LocalObjectReference ().name (clusterResName ));
325-
326- createDomainAndVerify (domain , fmwDomainNamespace );
327-
328- verifyDomainReady (fmwDomainNamespace , fmwDomainUid , replicaCount );
329-
330- String clusterName = "cluster-1" ;
331- int istioIngressPort = enableIstio (clusterName , fmwDomainUid , fmwDomainNamespace , fmwAdminServerPodName );
332- logger .info ("Istio Ingress Port is {0}" , istioIngressPort );
333-
334- String host = formatIPv6Host (K8S_NODEPORT_HOST );
335- String hostAndPort = host + ":" + istioIngressPort ;
336-
337- httpHeaders = new HashMap <>();
338- httpHeaders .put ("host" , fmwDomainNamespace + ".org" );
339- httpHeaders .put ("Authorization" , ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT );
340-
341- if (!TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
342- istioIngressPort = ISTIO_HTTP_HOSTPORT ;
343- host = formatIPv6Host (InetAddress .getLocalHost ().getHostAddress ());
344- hostAndPort = host + ":" + istioIngressPort ;
345- }
346-
347- String url = "http://" + hostAndPort + "/management/tenant-monitoring/servers/" ;
348- checkApp (url , httpHeaders , "RUNNING" );
349-
350- if (isWebLogicPsuPatchApplied ()) {
351- url = "http://" + hostAndPort + "/management/weblogic/latest/domainRuntime/domainSecurityRuntime?link=none" ;
352- checkApp (url , httpHeaders , "SecurityValidationWarnings" );
353- } else {
354- logger .info ("Skipping Security warning check, since Security Warning tool "
355- + " is not available in the WLS Release {0}" , WEBLOGIC_IMAGE_TAG );
356- }
357-
358- Path archivePath = Paths .get (testWebAppWarLoc );
359- ExecResult result = null ;
360-
361- result = deployToClusterUsingRest (host , String .valueOf (istioIngressPort ),
362- ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ,
363- clusterName , archivePath , fmwDomainNamespace + ".org" , "testwebapp" );
364- assertNotNull (result , "Application deployment failed" );
365- logger .info ("Application deployment returned {0}" , result .toString ());
366- assertEquals ("202" , result .stdout (), "Deployment didn't return HTTP status code 202" );
367-
368- url = "http://" + hostAndPort + "/testwebapp/index.jsp" ;
369- logger .info ("Application Access URL {0}" , url );
370- checkApp (url , httpHeaders );
194+ installAndVerifyOperator (opNamespace , wlsDomainNamespace );
371195 }
372196
373197 /**
@@ -648,7 +472,7 @@ private boolean checkJtaRecoveryServiceRuntime(String managedServer,
648472 logger .info ("JTA Recovery Service to migrate" );
649473 String url = "http://" + hostAndPort + "/management/weblogic/latest/domainRuntime/serverRuntimes/"
650474 + managedServer + "/JTARuntime/recoveryRuntimeMBeans/" + recoveryService + "?fields=active&links=none" ;
651- checkApp (url , httpHeaders , "{ \" active\" : " + active + "}" );
475+ checkApp (url , httpHeaders , "\" active\" : " + active );
652476 return true ;
653477 }
654478
0 commit comments