3
3
4
4
package oracle .weblogic .kubernetes ;
5
5
6
+ import java .net .InetAddress ;
7
+ import java .net .UnknownHostException ;
6
8
import java .nio .file .Path ;
7
9
import java .nio .file .Paths ;
8
10
import java .util .HashMap ;
31
33
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
32
34
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
33
35
import 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 ;
34
38
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
35
39
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
40
+ import static oracle .weblogic .kubernetes .TestConstants .OCNE ;
36
41
import static oracle .weblogic .kubernetes .TestConstants .SSL_PROPERTIES ;
37
42
import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
38
43
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
39
44
import static oracle .weblogic .kubernetes .actions .TestActions .addLabelsToNamespace ;
40
45
import static oracle .weblogic .kubernetes .actions .TestActions .createConfigMap ;
46
+ import static oracle .weblogic .kubernetes .utils .ApplicationUtils .checkAppUsingHostHeader ;
41
47
import 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 ;
42
51
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
43
52
import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
44
53
import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
45
54
import static oracle .weblogic .kubernetes .utils .IstioUtils .createAdminServer ;
46
55
import static oracle .weblogic .kubernetes .utils .IstioUtils .deployHttpIstioGatewayAndVirtualservice ;
47
- import static oracle .weblogic .kubernetes .utils .IstioUtils .deployIstioDestinationRule ;
48
56
import static oracle .weblogic .kubernetes .utils .IstioUtils .getIstioHttpIngressPort ;
49
57
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
50
58
import static oracle .weblogic .kubernetes .utils .PodUtils .setPodAntiAffinity ;
@@ -71,6 +79,8 @@ class ItIstioProductionSecureMode {
71
79
private final String adminServerPodName = domainUid + "-admin-server" ;
72
80
private final String managedServerPrefix = domainUid + "-managed-server" ;
73
81
private final int replicaCount = 1 ;
82
+ private static final String istioNamespace = "istio-system" ;
83
+ private static final String istioIngressServiceName = "istio-ingressgateway" ;
74
84
private static LoggingFacade logger = null ;
75
85
76
86
/**
@@ -115,7 +125,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
115
125
*/
116
126
@ Test
117
127
@ DisplayName ("Create WebLogic SecureMode Domain with mii model with istio" )
118
- void testIstioModelInImageSecureModeDomain () {
128
+ void testIstioModelInImageSecureModeDomain () throws UnknownHostException {
119
129
120
130
// Create the repo secret to pull the image
121
131
// this secret is used only for non-kind cluster
@@ -178,34 +188,36 @@ void testIstioModelInImageSecureModeDomain() {
178
188
checkPodReadyAndServiceExists (managedServerPrefix + i , domainUid , domainNamespace );
179
189
}
180
190
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 <>();
184
192
templateMap .put ("NAMESPACE" , domainNamespace );
185
- templateMap .put ("DUID" , domainUid );
186
- templateMap .put ("ADMIN_SERVICE" ,adminServerPodName );
187
- templateMap .put ("CLUSTER_SERVICE" , clusterService );
188
193
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" );
190
195
Path targetHttpFile = assertDoesNotThrow (
191
- () -> generateFileFromTemplate (srcHttpFile .toString (), "istio-http .yaml" , templateMap ));
196
+ () -> generateFileFromTemplate (srcHttpFile .toString (), "istio-productionsecure-tls-mode .yaml" , templateMap ));
192
197
logger .info ("Generated Http VS/Gateway file path is {0}" , targetHttpFile );
193
198
194
199
boolean deployRes = assertDoesNotThrow (
195
200
() -> deployHttpIstioGatewayAndVirtualservice (targetHttpFile ));
196
201
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" );
208
205
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 );
209
221
210
222
}
211
223
0 commit comments