|
5 | 5 |
|
6 | 6 | import java.io.File; |
7 | 7 | import java.io.FileOutputStream; |
8 | | -import java.io.IOException; |
9 | 8 | import java.net.InetAddress; |
10 | | -import java.net.http.HttpResponse; |
11 | 9 | import java.nio.file.Files; |
12 | 10 | import java.nio.file.Path; |
13 | 11 | import java.nio.file.Paths; |
|
53 | 51 | import oracle.weblogic.kubernetes.logging.LoggingFacade; |
54 | 52 | import oracle.weblogic.kubernetes.utils.BuildApplication; |
55 | 53 | import oracle.weblogic.kubernetes.utils.CommonTestUtils; |
56 | | -import oracle.weblogic.kubernetes.utils.ExecCommand; |
57 | 54 | import oracle.weblogic.kubernetes.utils.ExecResult; |
58 | | -import oracle.weblogic.kubernetes.utils.OracleHttpClient; |
59 | 55 | import org.junit.jupiter.api.BeforeAll; |
60 | 56 | import org.junit.jupiter.api.DisplayName; |
61 | 57 | import org.junit.jupiter.api.MethodOrderer; |
|
122 | 118 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting; |
123 | 119 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.formatIPv6Host; |
124 | 120 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.generateNewModelFileWithUpdatedDomainUid; |
125 | | -import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort; |
126 | 121 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort; |
127 | 122 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName; |
128 | 123 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil; |
@@ -396,10 +391,6 @@ void testDomainIntrospectVersionNotRolling() { |
396 | 391 | for (int i = 1; i <= cluster1ReplicaCount + 1; i++) { |
397 | 392 | managedServerNames.add(cluster1ManagedServerNameBase + i); |
398 | 393 | } |
399 | | - |
400 | | - //verify admin server accessibility and the health of cluster members |
401 | | - verifyMemberHealth(adminServerPodName, managedServerNames, wlsUserName, wlsPassword); |
402 | | - |
403 | 394 | // verify each managed server can see other member in the cluster |
404 | 395 | for (String managedServerName : managedServerNames) { |
405 | 396 | verifyConnectionBetweenClusterMembers(managedServerName, managedServerNames); |
@@ -525,11 +516,6 @@ void testDomainIntrospectVersionRolling() throws ApiException { |
525 | 516 | && !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) { |
526 | 517 | updateIngressBackendServicePort(newAdminPort); |
527 | 518 | } |
528 | | - |
529 | | - //verify admin server accessibility and the health of cluster members |
530 | | - verifyMemberHealth(adminServerPodName, managedServerNames, |
531 | | - ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT); |
532 | | - |
533 | 519 | // verify each managed server can see other member in the cluster |
534 | 520 | for (String managedServerName : managedServerNames) { |
535 | 521 | verifyConnectionBetweenClusterMembers(managedServerName, managedServerNames); |
@@ -666,10 +652,6 @@ void testCredentialChange() { |
666 | 652 | for (int i = 1; i <= cluster1ReplicaCount; i++) { |
667 | 653 | managedServerNames.add(cluster1ManagedServerNameBase + i); |
668 | 654 | } |
669 | | - |
670 | | - //verify admin server accessibility and the health of cluster members |
671 | | - verifyMemberHealth(adminServerPodName, managedServerNames, ADMIN_USERNAME_PATCH, ADMIN_PASSWORD_PATCH); |
672 | | - |
673 | 655 | // verify when the spec.introspectVersion is changed, |
674 | 656 | // all running server pods' weblogic.introspectVersion label is updated to the new value. |
675 | 657 | verifyIntrospectVersionLabelInPod(); |
@@ -751,10 +733,6 @@ void testCreateNewCluster() { |
751 | 733 | for (int i = 1; i <= cluster2ReplicaCount; i++) { |
752 | 734 | managedServerNames.add(cluster2ManagedServerNameBase + i); |
753 | 735 | } |
754 | | - |
755 | | - //verify admin server accessibility and the health of cluster members |
756 | | - verifyMemberHealth(adminServerPodName, managedServerNames, wlsUserName, wlsPassword); |
757 | | - |
758 | 736 | // set the cluster2Created flag to true. |
759 | 737 | cluster2Created = true; |
760 | 738 | } |
@@ -861,13 +839,6 @@ void testUpdateImageName() { |
861 | 839 | checkPodReadyAndServiceExists(cluster2ManagedServerPodNamePrefix + i, domainUid, introDomainNamespace); |
862 | 840 | } |
863 | 841 | } |
864 | | - |
865 | | - //verify admin server accessibility and the health of cluster1 members |
866 | | - verifyMemberHealth(adminServerPodName, cluster1ManagedServerNames, wlsUserName, wlsPassword); |
867 | | - if (cluster2Created) { |
868 | | - //verify admin server accessibility and the health of cluster2 members |
869 | | - verifyMemberHealth(adminServerPodName, cluster2ManagedServerNames, wlsUserName, wlsPassword); |
870 | | - } |
871 | 842 | } |
872 | 843 |
|
873 | 844 | /** |
@@ -1263,99 +1234,9 @@ private static void createDomain() { |
1263 | 1234 | hostHeader = createIngressHostRouting(introDomainNamespace, domainUid, adminServerName, adminPort); |
1264 | 1235 | assertDoesNotThrow(() -> verifyAdminServerRESTAccess(formatIPv6Host(InetAddress.getLocalHost().getHostAddress()), |
1265 | 1236 | TRAEFIK_INGRESS_HTTP_HOSTPORT, false, hostHeader)); |
1266 | | - } |
1267 | | - |
1268 | | - //verify admin server accessibility and the health of cluster members |
1269 | | - verifyMemberHealth(adminServerPodName, managedServerNames, wlsUserName, wlsPassword); |
1270 | | - } |
1271 | | - |
1272 | | - private static void verifyMemberHealth(String adminServerPodName, List<String> managedServerNames, |
1273 | | - String user, String code) { |
1274 | | - |
1275 | | - logger.info("Checking the health of servers in cluster"); |
1276 | | - boolean ipv6 = K8S_NODEPORT_HOST.contains(":"); |
1277 | | - |
1278 | | - testUntil(() -> { |
1279 | | - if (OKE_CLUSTER) { |
1280 | | - // In internal OKE env, verifyMemberHealth in admin server pod |
1281 | | - int servicePort = getServicePort(introDomainNamespace, |
1282 | | - getExternalServicePodName(adminServerPodName), "default"); |
1283 | | - final String command = KUBERNETES_CLI + " exec -n " |
1284 | | - + introDomainNamespace + " " + adminServerPodName + " -- curl http://" |
1285 | | - + adminServerPodName + ":" |
1286 | | - + servicePort + "/clusterview/ClusterViewServlet" |
1287 | | - + "\"?user=" + user |
1288 | | - + "&password=" + code + "&ipv6=" + ipv6 + "\""; |
1289 | | - |
1290 | | - ExecResult result = null; |
1291 | | - try { |
1292 | | - result = ExecCommand.exec(command, true); |
1293 | | - } catch (IOException | InterruptedException ex) { |
1294 | | - logger.severe(ex.getMessage()); |
1295 | | - } |
1296 | | - assertNotNull(result, "result is null"); |
1297 | | - String response = result.stdout().trim(); |
1298 | | - logger.info(response); |
1299 | | - logger.info(result.stderr()); |
1300 | | - logger.info("{0}", result.exitValue()); |
1301 | | - boolean health = true; |
1302 | | - for (String managedServer : managedServerNames) { |
1303 | | - health = health && response.contains(managedServer + ":HEALTH_OK"); |
1304 | | - if (health) { |
1305 | | - logger.info(managedServer + " is healthy"); |
1306 | | - } else { |
1307 | | - logger.info(managedServer + " health is not OK or server not found"); |
1308 | | - } |
1309 | | - } |
1310 | | - return health; |
1311 | | - } else { |
1312 | | - // In non-internal OKE env, verifyMemberHealth using adminSvcExtHost by sending HTTP request from local VM |
1313 | | - |
1314 | | - String extSvcPodName = getExternalServicePodName(adminServerPodName); |
1315 | | - logger.info("**** adminServerPodName={0}", adminServerPodName); |
1316 | | - logger.info("**** extSvcPodName={0}", extSvcPodName); |
1317 | | - |
1318 | | - adminSvcExtHost = createRouteForOKD(extSvcPodName, introDomainNamespace); |
1319 | | - logger.info("**** adminSvcExtHost={0}", adminSvcExtHost); |
1320 | | - logger.info("admin svc host = {0}", adminSvcExtHost); |
1321 | | - |
1322 | | - logger.info("Getting node port for default channel"); |
1323 | | - int serviceNodePort = assertDoesNotThrow(() |
1324 | | - -> getServiceNodePort(introDomainNamespace, getExternalServicePodName(adminServerPodName), "default"), |
1325 | | - "Getting admin server node port failed"); |
1326 | | - String hostAndPort = getHostAndPort(adminSvcExtHost, serviceNodePort); |
1327 | | - |
1328 | | - Map<String, String> headers = null; |
1329 | | - if (TestConstants.KIND_CLUSTER |
1330 | | - && !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) { |
1331 | | - hostAndPort = formatIPv6Host(InetAddress.getLocalHost().getHostAddress()) |
1332 | | - + ":" + TRAEFIK_INGRESS_HTTP_HOSTPORT; |
1333 | | - headers = new HashMap<>(); |
1334 | | - headers.put("host", hostHeader); |
1335 | | - } |
1336 | | - |
1337 | | - String url = "http://" + hostAndPort |
1338 | | - + "/clusterview/ClusterViewServlet?user=" + user + "&password=" + code + "&ipv6=" + ipv6; |
1339 | | - HttpResponse<String> response; |
1340 | | - response = OracleHttpClient.get(url, headers, true); |
1341 | | - |
1342 | | - boolean health = true; |
1343 | | - for (String managedServer : managedServerNames) { |
1344 | | - health = health && response.body().contains(managedServer + ":HEALTH_OK"); |
1345 | | - if (health) { |
1346 | | - logger.info(managedServer + " is healthy"); |
1347 | | - } else { |
1348 | | - logger.info(managedServer + " health is not OK or server not found"); |
1349 | | - } |
1350 | | - } |
1351 | | - return health; |
1352 | | - } |
1353 | | - }, |
1354 | | - logger, |
1355 | | - "Verifying the health of all cluster members"); |
| 1237 | + } |
1356 | 1238 | } |
1357 | 1239 |
|
1358 | | - |
1359 | 1240 | private void verifyConnectionBetweenClusterMembers(String serverName, List<String> managedServerNames) { |
1360 | 1241 | String podName = domainUid + "-" + serverName; |
1361 | 1242 | boolean ipv6 = K8S_NODEPORT_HOST.contains(":"); |
|
0 commit comments