Skip to content

Commit 3e3d66b

Browse files
sankarpnjshum2479
authored andcommitted
Fix for ItLBTwoDomainsNginx, ItEvictedPodsCycling and ItLBTwoDomainsTraefik nightly failures
1 parent 6887f05 commit 3e3d66b

File tree

4 files changed

+57
-30
lines changed

4 files changed

+57
-30
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItEvictedPodsCycling.java

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
55

66
import java.util.HashMap;
77
import java.util.List;
88
import java.util.Map;
9+
import java.util.concurrent.Callable;
910

11+
import io.kubernetes.client.openapi.ApiException;
12+
import io.kubernetes.client.openapi.models.CoreV1Event;
1013
import io.kubernetes.client.openapi.models.V1ResourceRequirements;
14+
import io.kubernetes.client.util.Yaml;
1115
import oracle.weblogic.domain.DomainResource;
16+
import oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes;
1217
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
1318
import oracle.weblogic.kubernetes.annotations.Namespaces;
1419
import oracle.weblogic.kubernetes.logging.LoggingFacade;
@@ -25,8 +30,9 @@
2530
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
2631
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
2732
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createDomainResource;
28-
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodEvictedStatus;
2933
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
34+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
35+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withLongRetryPolicy;
3036
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
3137
import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret;
3238
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
@@ -38,11 +44,11 @@
3844

3945
/**
4046
* Use Operator log to test WLS server pods were evicted due to Pod ephemeral local
41-
* storage usage exceeds the total limit of containers 50M and replaced.
47+
* storage usage exceeds the total limit of containers 25M and replaced.
4248
* 1. Install and start Operators
43-
* 2. Create and start the WebLogic domain with configuration of resource limit "ephemeral-storage=50M"
49+
* 2. Create and start the WebLogic domain with configuration of resource limit "ephemeral-storage=25M"
4450
* 3. Verify that WLS server pods were evicted due to Pod ephemeral local
45-
* storage usage exceeds the total limit of containers 50M and replaced.
51+
* storage usage exceeds the total limit of containers 25M and replaced.
4652
*/
4753
@DisplayName("Test WLS server pods were evicted due to Pod ephemeral storage usage exceeds the total limit")
4854
@IntegrationTest
@@ -63,13 +69,13 @@ class ItEvictedPodsCycling {
6369

6470
private static Map<String, String> resourceRequest = new HashMap<>();
6571
private static Map<String, String> resourceLimit = new HashMap<>();
66-
private static final String ephemeralStorage = "50M";
72+
private static final String ephemeralStorage = "25M";
6773

6874
private static LoggingFacade logger = null;
6975

7076
/**
7177
* Install Operator.
72-
* Config resource limit and set ephemeral-storage=50M
78+
* Config resource limit and set ephemeral-storage=25M
7379
* Create domain.
7480
*
7581
* @param namespaces list of namespaces created by the IntegrationTestWatcher by the
@@ -97,22 +103,29 @@ public static void init(@Namespaces(2) List<String> namespaces) {
97103
}
98104

99105
/**
100-
* Set domain resources limits tp 50M and then use Operator log to verify
106+
* Set domain resources limits to 25M and then use Operator log to verify
101107
* that WLS server pods were evicted due to Pod ephemeral local
102-
* storage usage exceeds the total limit of containers 50M and replaced.
108+
* storage usage exceeds the total limit of containers 25M and replaced.
103109
*/
104110
@Test
105111
@DisplayName("Use Operator log to verify that WLS server pods were evicted and replaced")
106-
void testEvictedPodReplaced() {
112+
void testEvictedPodReplaced() throws ApiException {
107113
resourceLimit.put("ephemeral-storage", ephemeralStorage);
108114
resourceRequest.put("cpu", "250m");
109115
resourceRequest.put("memory", "768Mi");
110116

111-
// patch domain with ephemeral-storage = 50M
117+
// patch domain with ephemeral-storage = 25M
118+
String reason = "Pod ephemeral local storage usage exceeds the total limit of containers";
119+
addServerPodResources(domainUid, domainNamespace, resourceLimit, resourceRequest);
120+
// verify that admin server pod evicted event is logged
121+
testUntil(withLongRetryPolicy,
122+
checkEvictionEvent(adminServerPodName, "Evicted", reason, "Warning"),
123+
logger,
124+
"domain event {0} to be logged in namespace {1}",
125+
reason,
126+
domainNamespace);
127+
resourceLimit.replace("ephemeral-storage", "250M");
112128
addServerPodResources(domainUid, domainNamespace, resourceLimit, resourceRequest);
113-
114-
// verify that admin server pod evicted status exists in Operator log
115-
checkPodEvictedStatus(opNamespace, adminServerPodName, ephemeralStorage);
116129

117130
// verify that evicted pods are replaced and started
118131
checkServerPodsAndServiceReady();
@@ -184,4 +197,22 @@ private static void checkServerPodsAndServiceReady() {
184197
checkPodReadyAndServiceExists(managedServerPodPrefix + i, domainUid, domainNamespace);
185198
}
186199
}
200+
201+
private Callable<Boolean> checkEvictionEvent(String adminServerpodName,
202+
String reason, String message, String type) throws ApiException {
203+
return (() -> {
204+
boolean gotEvent = false;
205+
List<CoreV1Event> events = Kubernetes.listNamespacedEvents(domainNamespace);
206+
for (CoreV1Event event : events) {
207+
if (event.getType().equals(type)
208+
&& event.getInvolvedObject().getName().equals(adminServerpodName)
209+
&& event.getReason().equals(reason)
210+
&& event.getMessage().contains(message)) {
211+
logger.info(Yaml.dump(event));
212+
gotEvent = true;
213+
}
214+
}
215+
return gotEvent;
216+
});
217+
}
187218
}

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItLBTwoDomainsNginx.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -46,6 +46,7 @@
4646
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.verifyAdminServerAccess;
4747
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.verifyClusterLoadbalancing;
4848
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.verifyHeadersInAdminServerLog;
49+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.formatIPv6Host;
4950
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getServiceExtIPAddrtOke;
5051
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
5152
import static oracle.weblogic.kubernetes.utils.LoadBalancerUtils.installAndVerifyNginx;
@@ -138,7 +139,7 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
138139

139140
String ingressServiceName = nginxHelmParams.getHelmParams().getReleaseName() + "-ingress-nginx-controller";
140141
ingressIP = getServiceExtIPAddrtOke(ingressServiceName, nginxNamespace) != null
141-
? getServiceExtIPAddrtOke(ingressServiceName, nginxNamespace) : K8S_NODEPORT_HOST;
142+
? getServiceExtIPAddrtOke(ingressServiceName, nginxNamespace) : formatIPv6Host(K8S_NODEPORT_HOST);
142143
}
143144

144145
/**

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonLBTestUtils.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -842,24 +842,18 @@ public static void verifyClusterLoadbalancing(String domainUid,
842842
// access application in managed servers through load balancer
843843
getLogger().info("Accessing the clusterview app through load balancer to verify all servers in cluster");
844844
String curlRequest;
845+
String uri = "clusterview/ClusterViewServlet" + "\"?user=" + ADMIN_USERNAME_DEFAULT
846+
+ "&password=" + ADMIN_PASSWORD_DEFAULT + (host.contains(":") ? "&ipv6=true" : "&ipv6=false") + "\"";
845847
if (hostRouting) {
846848
curlRequest = OKE_CLUSTER_PRIVATEIP ? String.format("curl -g --show-error -ks --noproxy '*' "
847-
+ "-H 'host: %s' %s://%s/clusterview/ClusterViewServlet"
848-
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
849-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"", ingressHostName, protocol, host)
850-
: String.format("curl --show-error -ks --noproxy '*' "
851-
+ "-H 'host: %s' %s://%s:%s/clusterview/ClusterViewServlet"
852-
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
853-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"", ingressHostName, protocol, host, lbPort);
849+
+ "-H 'host: %s' %s://%s/" + uri, ingressHostName, protocol, host)
850+
: String.format("curl -g --show-error -ks --noproxy '*' "
851+
+ "-H 'host: %s' %s://%s:%s/" + uri, ingressHostName, protocol, host, lbPort);
854852
} else {
855853
curlRequest = OKE_CLUSTER_PRIVATEIP ? String.format("curl -g --show-error -ks --noproxy '*' "
856-
+ "%s://%s" + locationString + "/clusterview/ClusterViewServlet"
857-
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
858-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"", protocol, host)
859-
: String.format("curl --show-error -ks --noproxy '*' "
860-
+ "%s://%s:%s" + locationString + "/clusterview/ClusterViewServlet"
861-
+ "\"?user=" + ADMIN_USERNAME_DEFAULT
862-
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "\"", protocol, host, lbPort);
854+
+ "%s://%s" + locationString + "/" + uri, protocol, host)
855+
: String.format("curl -g --show-error -ks --noproxy '*' "
856+
+ "%s://%s:%s" + locationString + "/" + uri, protocol, host, lbPort);
863857
}
864858

865859
List<String> managedServers = new ArrayList<>();

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonTestUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ public static void verifyServerCommunication(String curlRequest, List<String> ma
10931093
// check the response contains managed server name
10941094
ExecResult result = null;
10951095
try {
1096+
logger.info("Sending request {0}", curlRequest);
10961097
result = ExecCommand.exec(curlRequest, true);
10971098
} catch (IOException | InterruptedException ex) {
10981099
logger.severe(ex.getMessage());

0 commit comments

Comments
 (0)