33
44package oracle .weblogic .kubernetes ;
55
6+ import java .net .InetAddress ;
7+ import java .net .UnknownHostException ;
68import java .nio .file .Path ;
79import java .nio .file .Paths ;
810import java .util .HashMap ;
3133import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
3234import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
3335import static oracle .weblogic .kubernetes .TestConstants .IMAGE_PULL_POLICY ;
36+ import static oracle .weblogic .kubernetes .TestConstants .ISTIO_HTTPS_HOSTPORT ;
37+ import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
3438import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
3539import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
40+ import static oracle .weblogic .kubernetes .TestConstants .OCNE ;
3641import static oracle .weblogic .kubernetes .TestConstants .SSL_PROPERTIES ;
3742import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
3843import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
3944import static oracle .weblogic .kubernetes .actions .TestActions .addLabelsToNamespace ;
4045import static oracle .weblogic .kubernetes .actions .TestActions .createConfigMap ;
46+ import static oracle .weblogic .kubernetes .utils .ApplicationUtils .checkAppUsingHostHeader ;
4147import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
48+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .formatIPv6Host ;
49+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getServiceExtIPAddrtOke ;
50+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
4251import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
4352import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
4453import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
4554import static oracle .weblogic .kubernetes .utils .IstioUtils .createAdminServer ;
4655import static oracle .weblogic .kubernetes .utils .IstioUtils .deployHttpIstioGatewayAndVirtualservice ;
47- import static oracle .weblogic .kubernetes .utils .IstioUtils .deployIstioDestinationRule ;
4856import static oracle .weblogic .kubernetes .utils .IstioUtils .getIstioHttpIngressPort ;
4957import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
5058import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
@@ -71,6 +79,8 @@ class ItIstioProductionSecureMode {
7179 private final String adminServerPodName = domainUid + "-admin-server" ;
7280 private final String managedServerPrefix = domainUid + "-managed-server" ;
7381 private final int replicaCount = 1 ;
82+ private static final String istioNamespace = "istio-system" ;
83+ private static final String istioIngressServiceName = "istio-ingressgateway" ;
7484 private static LoggingFacade logger = null ;
7585
7686 /**
@@ -115,7 +125,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
115125 */
116126 @ Test
117127 @ DisplayName ("Create WebLogic SecureMode Domain with mii model with istio" )
118- void testIstioModelInImageSecureModeDomain () {
128+ void testIstioModelInImageSecureModeDomain () throws UnknownHostException {
119129
120130 // Create the repo secret to pull the image
121131 // this secret is used only for non-kind cluster
@@ -178,34 +188,36 @@ void testIstioModelInImageSecureModeDomain() {
178188 checkPodReadyAndServiceExists (managedServerPrefix + i , domainUid , domainNamespace );
179189 }
180190
181- String clusterService = domainUid + "-cluster-" + clusterName + "." + domainNamespace + ".svc.cluster.local" ;
182-
183- Map <String , String > templateMap = new HashMap <>();
191+ Map <String , String > templateMap = new HashMap <>();
184192 templateMap .put ("NAMESPACE" , domainNamespace );
185- templateMap .put ("DUID" , domainUid );
186- templateMap .put ("ADMIN_SERVICE" ,adminServerPodName );
187- templateMap .put ("CLUSTER_SERVICE" , clusterService );
188193
189- Path srcHttpFile = Paths .get (RESOURCE_DIR , "istio" , "istio-http-template .yaml" );
194+ Path srcHttpFile = Paths .get (RESOURCE_DIR , "istio" , "istio-productionsecure-tls-mode .yaml" );
190195 Path targetHttpFile = assertDoesNotThrow (
191- () -> generateFileFromTemplate (srcHttpFile .toString (), "istio-http .yaml" , templateMap ));
196+ () -> generateFileFromTemplate (srcHttpFile .toString (), "istio-productionsecure-tls-mode .yaml" , templateMap ));
192197 logger .info ("Generated Http VS/Gateway file path is {0}" , targetHttpFile );
193198
194199 boolean deployRes = assertDoesNotThrow (
195200 () -> deployHttpIstioGatewayAndVirtualservice (targetHttpFile ));
196201 assertTrue (deployRes , "Failed to deploy Http Istio Gateway/VirtualService" );
197-
198- Path srcDrFile = Paths .get (RESOURCE_DIR , "istio" , "istio-dr-template.yaml" );
199- Path targetDrFile = assertDoesNotThrow (
200- () -> generateFileFromTemplate (srcDrFile .toString (), "istio-dr.yaml" , templateMap ));
201- logger .info ("Generated DestinationRule file path is {0}" , targetDrFile );
202-
203- deployRes = assertDoesNotThrow (
204- () -> deployIstioDestinationRule (targetDrFile ));
205- assertTrue (deployRes , "Failed to deploy Istio DestinationRule" );
206-
207- int istioIngressPort = getIstioHttpIngressPort ();
202+
203+ String host = formatIPv6Host (K8S_NODEPORT_HOST );
204+ int istioIngressPort = getIstioHttpIngressPort ("https" );
208205 logger .info ("Istio Ingress Port is {0}" , istioIngressPort );
206+ logger .info ("host {0}" , host );
207+ String hostAndPort = getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) != null
208+ ? getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) : host + ":" + istioIngressPort ;
209+
210+ if (!TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT ) && !OCNE ) {
211+ istioIngressPort = ISTIO_HTTPS_HOSTPORT ;
212+ hostAndPort = InetAddress .getLocalHost ().getHostAddress () + ":" + istioIngressPort ;
213+ }
214+ String url = "https://" + hostAndPort + "/weblogic/ready" ;
215+ testUntil (
216+ () -> checkAppUsingHostHeader (url ,
217+ "istio-mii-securemode-admin-server.NAMESPACE.svc.cluster.local" .replace ("NAMESPACE" , domainNamespace )),
218+ logger ,
219+ "application to be ready {0}" ,
220+ url );
209221
210222 }
211223
0 commit comments