3
3
4
4
package oracle .weblogic .kubernetes ;
5
5
6
- import java .io .IOException ;
7
6
import java .net .InetAddress ;
8
7
import java .net .UnknownHostException ;
9
8
import java .net .http .HttpResponse ;
12
11
import java .nio .file .Paths ;
13
12
import java .util .ArrayList ;
14
13
import java .util .Arrays ;
15
- import java .util .Collections ;
16
14
import java .util .HashMap ;
17
15
import java .util .List ;
18
16
import java .util .Map ;
37
35
import oracle .weblogic .kubernetes .annotations .Namespaces ;
38
36
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
39
37
import oracle .weblogic .kubernetes .utils .ExecResult ;
40
- import oracle .weblogic .kubernetes .utils .FmwUtils ;
41
38
import oracle .weblogic .kubernetes .utils .OracleHttpClient ;
42
39
import org .junit .jupiter .api .AfterAll ;
43
40
import org .junit .jupiter .api .BeforeAll ;
53
50
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_VERSION ;
54
51
import static oracle .weblogic .kubernetes .TestConstants .ENCRYPION_PASSWORD_DEFAULT ;
55
52
import 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 ;
59
53
import static oracle .weblogic .kubernetes .TestConstants .IMAGE_PULL_POLICY ;
60
54
import 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 ;
63
55
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
64
56
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
65
57
import static oracle .weblogic .kubernetes .TestConstants .SKIP_CLEANUP ;
66
58
import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
67
- import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TAG ;
68
59
import static oracle .weblogic .kubernetes .actions .ActionConstants .ITTESTS_DIR ;
69
60
import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
70
61
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
84
75
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .formatIPv6Host ;
85
76
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
86
77
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
87
- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .isWebLogicPsuPatchApplied ;
88
78
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .runClientInsidePod ;
89
79
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .runJavacInsidePod ;
90
80
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
91
81
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapAndVerify ;
92
82
import 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 ;
95
83
import static oracle .weblogic .kubernetes .utils .DbUtils .deleteOracleDB ;
96
84
import static oracle .weblogic .kubernetes .utils .DbUtils .installDBOperator ;
97
85
import 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 ;
100
86
import static oracle .weblogic .kubernetes .utils .FileUtils .copyFileToPod ;
101
87
import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
102
- import static oracle .weblogic .kubernetes .utils .FmwUtils .verifyDomainReady ;
103
88
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
104
- import static oracle .weblogic .kubernetes .utils .ImageUtils .createMiiImageAndVerify ;
105
89
import static oracle .weblogic .kubernetes .utils .ImageUtils .createTestRepoSecret ;
106
- import static oracle .weblogic .kubernetes .utils .ImageUtils .imageRepoLoginAndPushImageToRegistry ;
107
90
import static oracle .weblogic .kubernetes .utils .IstioUtils .deployHttpIstioGatewayAndVirtualservice ;
108
91
import static oracle .weblogic .kubernetes .utils .IstioUtils .deployIstioDestinationRule ;
109
92
import static oracle .weblogic .kubernetes .utils .IstioUtils .getIstioHttpIngressPort ;
114
97
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
115
98
import static oracle .weblogic .kubernetes .utils .PodUtils .getExternalServicePodName ;
116
99
import 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 ;
119
100
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
120
101
import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
121
102
import static org .junit .jupiter .api .Assertions .assertEquals ;
@@ -132,38 +113,23 @@ class ItIstioDBOperator {
132
113
133
114
private static String dbNamespace = null ;
134
115
private static String opNamespace = null ;
135
- private static String fmwDomainNamespace = null ;
136
116
private static String wlsDomainNamespace = null ;
137
- private static String fmwMiiImage = null ;
138
117
139
- private static final String RCUSCHEMAPREFIX = "FMWDOMAINMII" ;
140
118
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" ;
143
119
144
120
private static String dbUrl = null ;
145
121
private static String dbName = "istio-oracle-sidb" ;
146
122
private static LoggingFacade logger = null ;
147
123
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" ;
152
125
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 ;
159
126
160
127
private static final String wlsDomainUid = "mii-jms-istio-db" ;
161
128
private static final String pvName = getUniqueName (wlsDomainUid + "-pv-" );
162
129
private static final String pvcName = getUniqueName (wlsDomainUid + "-pvc-" );
163
130
private static final String wlsAdminServerPodName = wlsDomainUid + "-admin-server" ;
164
131
private static final String wlsManagedServerPrefix = wlsDomainUid + "-managed-server" ;
165
132
private static int wlDomainIstioIngressPort ;
166
- private String configMapName = "dynamicupdate-istio-configmap" ;
167
133
private static String cpUrl ;
168
134
private static String adminSvcExtRouteHost = null ;
169
135
@@ -194,17 +160,12 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
194
160
assertNotNull (namespaces .get (1 ), "Namespace is null" );
195
161
opNamespace = namespaces .get (1 );
196
162
197
- logger .info ("Assign a unique namespace for FMW domain" );
198
- assertNotNull (namespaces .get (2 ), "Namespace is null" );
199
- fmwDomainNamespace = namespaces .get (2 );
200
-
201
163
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 );
204
166
205
167
// Create the repo secret to pull the image
206
168
// this secret is used only for non-kind cluster
207
- createBaseRepoSecret (fmwDomainNamespace );
208
169
createBaseRepoSecret (wlsDomainNamespace );
209
170
createTestRepoSecret (wlsDomainNamespace );
210
171
// create PV, PVC for logs/data
@@ -217,7 +178,6 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
217
178
// Label the domain/operator namespace with istio-injection=enabled
218
179
Map <String , String > labelMap = new HashMap <>();
219
180
labelMap .put ("istio-injection" , "enabled" );
220
- assertDoesNotThrow (() -> addLabelsToNamespace (fmwDomainNamespace , labelMap ));
221
181
assertDoesNotThrow (() -> addLabelsToNamespace (wlsDomainNamespace , labelMap ));
222
182
assertDoesNotThrow (() -> addLabelsToNamespace (opNamespace , labelMap ));
223
183
@@ -226,148 +186,12 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
226
186
227
187
logger .info ("Create Oracle DB in namespace: {0} " , dbNamespace );
228
188
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
+
235
190
// create testwebapp.war
236
191
testWebAppWarLoc = createTestWebAppWarFile (wlsDomainNamespace );
237
192
238
193
// 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 );
371
195
}
372
196
373
197
/**
@@ -648,7 +472,7 @@ private boolean checkJtaRecoveryServiceRuntime(String managedServer,
648
472
logger .info ("JTA Recovery Service to migrate" );
649
473
String url = "http://" + hostAndPort + "/management/weblogic/latest/domainRuntime/serverRuntimes/"
650
474
+ managedServer + "/JTARuntime/recoveryRuntimeMBeans/" + recoveryService + "?fields=active&links=none" ;
651
- checkApp (url , httpHeaders , "{ \" active\" : " + active + "}" );
475
+ checkApp (url , httpHeaders , "\" active\" : " + active );
652
476
return true ;
653
477
}
654
478
0 commit comments