|
5 | 5 |
|
6 | 6 | import java.io.File;
|
7 | 7 | import java.io.FileOutputStream;
|
| 8 | +import java.io.IOException; |
8 | 9 | import java.net.http.HttpResponse;
|
9 | 10 | import java.nio.file.Path;
|
10 | 11 | import java.nio.file.Paths;
|
|
32 | 33 | import oracle.weblogic.kubernetes.annotations.Namespaces;
|
33 | 34 | import oracle.weblogic.kubernetes.logging.LoggingFacade;
|
34 | 35 | import oracle.weblogic.kubernetes.utils.BuildApplication;
|
| 36 | +import oracle.weblogic.kubernetes.utils.ExecCommand; |
| 37 | +import oracle.weblogic.kubernetes.utils.ExecResult; |
35 | 38 | import oracle.weblogic.kubernetes.utils.OracleHttpClient;
|
36 | 39 | import org.junit.jupiter.api.BeforeAll;
|
37 | 40 | import org.junit.jupiter.api.DisplayName;
|
|
46 | 49 | import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
|
47 | 50 | import static oracle.weblogic.kubernetes.TestConstants.IMAGE_PULL_POLICY;
|
48 | 51 | import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
|
| 52 | +import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI; |
49 | 53 | import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
|
| 54 | +import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER; |
50 | 55 | import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
|
51 | 56 | import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
|
52 | 57 | import static oracle.weblogic.kubernetes.actions.ActionConstants.APP_DIR;
|
|
81 | 86 | @DisplayName("Test T3 channel deployment")
|
82 | 87 | @IntegrationTest
|
83 | 88 | @Tag("olcne-mrg")
|
84 |
| -@Tag("oke-sequential") |
| 89 | +@Tag("oke-gate") |
85 | 90 | @Tag("kind-sequential")
|
86 | 91 | class ItT3Channel {
|
87 | 92 | // namespace constants
|
@@ -271,11 +276,21 @@ void testAdminServerT3Channel() {
|
271 | 276 |
|
272 | 277 | // deploy application and verify all servers functions normally
|
273 | 278 | //deploy clusterview application
|
274 |
| - logger.info("Deploying clusterview app {0} to cluster {1}", |
275 |
| - clusterViewAppPath, clusterName); |
276 |
| - deployUsingWlst(adminServerPodName, Integer.toString(t3ChannelPort), |
277 |
| - ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, adminServerName + "," + clusterName, clusterViewAppPath, |
278 |
| - domainNamespace); |
| 279 | + if (OKE_CLUSTER) { |
| 280 | + int adminPort = 7001; |
| 281 | + assertDoesNotThrow(() -> deployUsingWlst(adminServerPodName, |
| 282 | + String.valueOf(adminPort), |
| 283 | + ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, |
| 284 | + clusterName + "," + adminServerName, |
| 285 | + clusterViewAppPath, |
| 286 | + domainNamespace), "Deploying the application"); |
| 287 | + } else { |
| 288 | + logger.info("Deploying clusterview app {0} to cluster {1}", |
| 289 | + clusterViewAppPath, clusterName); |
| 290 | + deployUsingWlst(adminServerPodName, Integer.toString(t3ChannelPort), |
| 291 | + ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, adminServerName + "," + clusterName, |
| 292 | + clusterViewAppPath, domainNamespace); |
| 293 | + } |
279 | 294 |
|
280 | 295 | List<String> managedServerNames = new ArrayList<String>();
|
281 | 296 | for (int i = 1; i <= replicaCount; i++) {
|
@@ -316,41 +331,70 @@ void testAdminServerT3Channel() {
|
316 | 331 | }
|
317 | 332 |
|
318 | 333 | private static void verifyMemberHealth(String adminServerPodName, List<String> managedServerNames,
|
319 |
| - String user, String code) { |
320 |
| - |
| 334 | + String user, String code) { |
321 | 335 | logger.info("Checking the health of servers in cluster");
|
322 | 336 | testUntil(() -> {
|
323 |
| - logger.info("Getting node port for default channel"); |
324 |
| - int serviceNodePort = assertDoesNotThrow(() |
325 |
| - -> getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"), |
326 |
| - "Getting admin server node port failed"); |
327 |
| - String host = K8S_NODEPORT_HOST; |
328 |
| - String hostAndPort = host + ":" + serviceNodePort; |
329 |
| - Map<String, String> headers = null; |
330 |
| - if (TestConstants.KIND_CLUSTER |
331 |
| - && !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) { |
332 |
| - hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT; |
333 |
| - headers = new HashMap<>(); |
334 |
| - headers.put("host", hostHeader); |
335 |
| - } |
336 |
| - String url = "http://" + hostAndPort |
337 |
| - + "/clusterview/ClusterViewServlet?user=" + user + "&password=" + code; |
338 |
| - HttpResponse<String> response; |
339 |
| - response = OracleHttpClient.get(url, headers, true); |
340 |
| - |
341 |
| - boolean health = true; |
342 |
| - for (String managedServer : managedServerNames) { |
343 |
| - health = health && response.body().contains(managedServer + ":HEALTH_OK"); |
344 |
| - if (health) { |
345 |
| - logger.info(managedServer + " is healthy"); |
346 |
| - } else { |
347 |
| - logger.info(managedServer + " health is not OK or server not found"); |
| 337 | + if (OKE_CLUSTER) { |
| 338 | + // In internal OKE env, verifyMemberHealth in admin server pod |
| 339 | + int adminPort = 7001; |
| 340 | + final String command = KUBERNETES_CLI + " exec -n " |
| 341 | + + domainNamespace + " " + adminServerPodName + " -- curl http://" |
| 342 | + + adminServerPodName + ":" |
| 343 | + + adminPort + "/clusterview/ClusterViewServlet" |
| 344 | + + "\"?user=" + user |
| 345 | + + "&password=" + code + "\""; |
| 346 | + |
| 347 | + ExecResult result = null; |
| 348 | + try { |
| 349 | + result = ExecCommand.exec(command, true); |
| 350 | + } catch (IOException | InterruptedException ex) { |
| 351 | + logger.severe(ex.getMessage()); |
| 352 | + } |
| 353 | + |
| 354 | + String response = result.stdout().trim(); |
| 355 | + logger.info(response); |
| 356 | + boolean health = true; |
| 357 | + for (String managedServer : managedServerNames) { |
| 358 | + health = health && response.contains(managedServer + ":HEALTH_OK"); |
| 359 | + if (health) { |
| 360 | + logger.info(managedServer + " is healthy"); |
| 361 | + } else { |
| 362 | + logger.info(managedServer + " health is not OK or server not found"); |
| 363 | + } |
| 364 | + } |
| 365 | + return health; |
| 366 | + } else { |
| 367 | + logger.info("Getting node port for default channel"); |
| 368 | + int serviceNodePort = assertDoesNotThrow(() |
| 369 | + -> getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"), |
| 370 | + "Getting admin server node port failed"); |
| 371 | + String host = K8S_NODEPORT_HOST; |
| 372 | + String hostAndPort = host + ":" + serviceNodePort; |
| 373 | + Map<String, String> headers = null; |
| 374 | + if (TestConstants.KIND_CLUSTER |
| 375 | + && !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) { |
| 376 | + hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT; |
| 377 | + headers = new HashMap<>(); |
| 378 | + headers.put("host", hostHeader); |
348 | 379 | }
|
| 380 | + String url = "http://" + hostAndPort |
| 381 | + + "/clusterview/ClusterViewServlet?user=" + user + "&password=" + code; |
| 382 | + HttpResponse<String> response; |
| 383 | + response = OracleHttpClient.get(url, headers, true); |
| 384 | + |
| 385 | + boolean health = true; |
| 386 | + for (String managedServer : managedServerNames) { |
| 387 | + health = health && response.body().contains(managedServer + ":HEALTH_OK"); |
| 388 | + if (health) { |
| 389 | + logger.info(managedServer + " is healthy"); |
| 390 | + } else { |
| 391 | + logger.info(managedServer + " health is not OK or server not found"); |
| 392 | + } |
| 393 | + } |
| 394 | + return health; |
349 | 395 | }
|
350 |
| - return health; |
351 | 396 | },
|
352 | 397 | logger,
|
353 | 398 | "Verifying the health of all cluster members");
|
354 | 399 | }
|
355 |
| - |
356 | 400 | }
|
0 commit comments