Skip to content

Commit

Permalink
Merge branch 'foroke' into 'main'
Browse files Browse the repository at this point in the history
forward changes from 4.2. to main for Load Balancer tests

See merge request weblogic-cloud/weblogic-kubernetes-operator!4883
  • Loading branch information
rjeberhard committed Nov 26, 2024
2 parents f870072 + 954c087 commit ef2a105
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile.oke
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
//

CRON_SETTINGS = '''H 3 * * 6 % MAVEN_PROFILE_NAME=oke-weekly-sequential;CLUSTER_NAME=seqweek;PARALLEL_RUN=false
CRON_SETTINGS = '''H 3 * * 5 % MAVEN_PROFILE_NAME=oke-weekly-sequential;CLUSTER_NAME=seqweek;PARALLEL_RUN=false
H 18 * * 0-4 % MAVEN_PROFILE_NAME=oke-sequential;CLUSTER_NAME=seqone;PARALLEL_RUN=false
H 12 * * 0-4 % MAVEN_PROFILE_NAME=oke-parallel;CLUSTER_NAME=parone;PARALLEL_RUN=true'''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import oracle.weblogic.kubernetes.logging.LoggingFacade;
import oracle.weblogic.kubernetes.utils.ExecResult;
import oracle.weblogic.kubernetes.utils.OracleHttpClient;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -67,6 +68,7 @@
import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource;
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
import static oracle.weblogic.kubernetes.actions.TestActions.listIngresses;
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallNginx;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.checkAppIsActive;
Expand Down Expand Up @@ -224,6 +226,17 @@ public void beforeEach() {
}
}

@AfterAll
public void tearDownAll() {

if (nginxHelmParams != null && OKE_CLUSTER) {
assertThat(uninstallNginx(nginxHelmParams.getHelmParams()))
.as("Test uninstallNginx returns true")
.withFailMessage("uninstallNginx() did not return true")
.isTrue();
}
}

private static void updatePropertyFile() {
//create a temporary directory to copy and update the properties file
Path target = Paths.get(PROPS_TEMP_DIR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
@DisplayName("Test to a create MII domain and test autoscaling using HPA and"
+ "custom metrics provided via use of monitoring exporter and prometheus and prometheus adapter")
@IntegrationTest
@Tag("oke-sequential")
@Tag("oke-weekly-sequential")
@Tag("kind-parallel")
public class ItHorizontalPodAutoscalerCustomMetrics {
private static final String MONEXP_MODEL_FILE = "model.monexp.custommetrics.yaml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import static oracle.weblogic.kubernetes.actions.TestActions.deletePersistentVolumeClaim;
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
import static oracle.weblogic.kubernetes.actions.TestActions.listIngresses;
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallNginx;
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.buildAndDeployClusterviewApp;
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.checkIngressReady;
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.createMultipleDomainsSharingPVUsingWlstAndVerify;
Expand Down Expand Up @@ -266,6 +267,12 @@ public void tearDownAll() throws ApiException {
deletePersistentVolume(pvPvcNamePair.get(0));
}
}
if (nginxHelmParams != null && OKE_CLUSTER) {
assertThat(uninstallNginx(nginxHelmParams.getHelmParams()))
.as("Test uninstallNginx returns true")
.withFailMessage("uninstallNginx() did not return true")
.isTrue();
}
}

private static void createCertKeyFiles(String cn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static oracle.weblogic.kubernetes.TestConstants.KIND_CLUSTER;
import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI;
import static oracle.weblogic.kubernetes.TestConstants.OCNE;
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_TEMPFILE_DIR;
import static oracle.weblogic.kubernetes.TestConstants.SKIP_CLEANUP;
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTPS_HOSTPORT;
Expand All @@ -43,6 +44,7 @@
import static oracle.weblogic.kubernetes.actions.TestActions.deletePersistentVolume;
import static oracle.weblogic.kubernetes.actions.TestActions.deletePersistentVolumeClaim;
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallTraefik;
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.buildAndDeployClusterviewApp;
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.createMultipleDomainsSharingPVUsingWlstAndVerify;
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.verifyAdminServerAccess;
Expand All @@ -53,6 +55,7 @@
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithTLSCertKey;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -65,7 +68,7 @@
@IntegrationTest
@Tag("olcne-mrg")
@Tag("kind-parallel")
@Tag("oke-sequential")
@Tag("oke-weekly-sequential")
class ItLBTwoDomainsTraefik {

private static final int numberOfDomains = 2;
Expand Down Expand Up @@ -219,6 +222,13 @@ public void tearDownAll() throws ApiException {
deletePersistentVolume(pvPvcNamePair.get(0));
}
}
if (traefikHelmParams != null && OKE_CLUSTER) {

assertThat(uninstallTraefik(traefikHelmParams))
.as("Test uninstallTraefik returns true")
.withFailMessage("uninstallTraefik did not return true")
.isTrue();
}
}

private static void createCertKeyFiles(String cn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
+ "MonitoringExporter Side Car via Prometheus and Grafana")
@IntegrationTest
@Tag("olcne-mrg")
@Tag("oke-sequential")
@Tag("oke-weekly-sequential")
@Tag("kind-parallel")
@Tag("okd-wls-mrg")
class ItMonitoringExporterSideCar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
import static oracle.weblogic.kubernetes.actions.TestActions.installWlsRemoteConsole;
import static oracle.weblogic.kubernetes.actions.TestActions.listIngresses;
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallNginx;
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallTraefik;
import static oracle.weblogic.kubernetes.actions.impl.Service.getServiceNodePort;
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReturnedCode;
Expand Down Expand Up @@ -96,7 +98,7 @@
@DisabledOnSlimImage
@Tag("olcne-mrg")
@Tag("kind-parallel")
@Tag("oke-parallel")
@Tag("oke-weekly-sequential")
class ItRemoteConsole {

private static String domainNamespace = null;
Expand Down Expand Up @@ -311,6 +313,19 @@ public void tearDownAll() {
if (!SKIP_CLEANUP) {
assertTrue(shutdownWlsRemoteConsole(), "Remote Console shutdown failed");
}
if (traefikHelmParams != null && OKE_CLUSTER) {

assertThat(uninstallTraefik(traefikHelmParams))
.as("Test uninstallTraefik returns true")
.withFailMessage("uninstallTraefik did not return true")
.isTrue();
}
if (nginxHelmParams != null && OKE_CLUSTER) {
assertThat(uninstallNginx(nginxHelmParams.getHelmParams()))
.as("Test uninstallNginx returns true")
.withFailMessage("uninstallNginx() did not return true")
.isTrue();
}
}

private static void createTraefikIngressRoutingRules(String domainNamespace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,12 +784,12 @@ public static void verifyClusterLoadbalancing(String domainUid,
+ "&password=" + ADMIN_PASSWORD_DEFAULT
+ ((host != null) && host.contains(":") ? "&ipv6=true" : "&ipv6=false") + "\"";
if (hostRouting) {
curlRequest = OKE_CLUSTER_PRIVATEIP ? String.format("curl -g --show-error -ks --noproxy '*' "
curlRequest = OKE_CLUSTER_PRIVATEIP ? String.format("curl -g --show-error -ks --noproxy '*' -v "
+ "-H 'host: %s' %s://%s/" + uri, ingressHostName, protocol, host)
: String.format("curl -g --show-error -ks --noproxy '*' "
+ "-H 'host: %s' %s://%s/" + uri, ingressHostName, protocol, getHostAndPort(host, lbPort));
} else {
curlRequest = OKE_CLUSTER_PRIVATEIP ? String.format("curl -g --show-error -ks --noproxy '*' "
curlRequest = OKE_CLUSTER_PRIVATEIP ? String.format("curl -g --show-error -ks --noproxy '*' -v "
+ "%s://%s" + locationString + "/" + uri, protocol, host)
: String.format("curl -g --show-error -ks --noproxy '*' "
+ "%s://%s" + locationString + "/" + uri, protocol, getHostAndPort(host, lbPort));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,29 @@ public static String getLoadBalancerIP(String namespace, String lbName, boolean
return null;
}

private static boolean checkLoadBalancerHealthy(String namespace, String lbServiceName) {
/**
* Update NO_PROXY var with Load Balancer IP address.
*
* @param newEntry value to add for NO_PROXY
* @throws Exception throws exception if failed to update
*/
public static void addNoProxyEntry(String newEntry) {
String currentNoProxy = System.getenv("NO_PROXY");
getLogger().info("Current NO_PROXY value is :" + currentNoProxy);

String updatedNoProxy = (currentNoProxy == null || currentNoProxy.isEmpty())
? newEntry
: currentNoProxy + ",10.196.0.0/24,10.196.1.0/24," + newEntry;

System.setProperty("NO_PROXY", updatedNoProxy);
getLogger().info("Updated NO_PROXY: " + System.getProperty("NO_PROXY"));
}

private static synchronized boolean checkLoadBalancerHealthy(String namespace, String lbServiceName) {

String lbPublicIP = assertDoesNotThrow(() -> getLoadBalancerIP(namespace, lbServiceName));
InitializationTasks.registerLoadBalancerExternalIP(lbPublicIP);
assertDoesNotThrow(() -> addNoProxyEntry(lbPublicIP));
LoggingFacade logger = getLogger();
String testcompartmentid = System.getProperty("wko.it.oci.compartment.ocid");
logger.info("wko.it.oci.compartment.ocid property " + testcompartmentid);
Expand Down Expand Up @@ -453,9 +472,21 @@ private static boolean checkLoadBalancerHealthy(String namespace, String lbServi
if (result == null || result.exitValue() != 0 || result.stdout() == null) {
return false;
}
return (result.stdout().contains("OK") && isBackendHealthy(result.stdout()));
}

return result.stdout().contains("OK");

private static boolean isBackendHealthy(String jsonResponse) {
LoggingFacade logger = getLogger();
// Check for any non-empty backend set names indicating a failure
if (jsonResponse.contains("\"critical-state-backend-set-names\": []")
&& jsonResponse.contains("\"unknown-state-backend-set-names\": []")
&& jsonResponse.contains("\"warning-state-backend-set-names\": []")) {
logger.info("All backends are healthy.");
return true; // Healthy
} else {
logger.severe("Failure: There are issues with the backend(s)." + jsonResponse);
return false; // Unhealthy
}
}

@Nullable
Expand Down Expand Up @@ -675,7 +706,8 @@ public static List<String> createIngressForDomainAndVerify(String domainUid,
if (host.contains(":")) {
host = "[" + host + "]";
}
String curlCmd = "curl -g --silent --show-error --noproxy '*' -H 'host: " + ingressHost
String curlCmd = "curl -g --silent --show-error --noproxy '*' "
+ " -v --max-time 60 -H 'host: " + ingressHost
+ "' http://" + getHostAndPort(host, nodeport)
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";

Expand Down Expand Up @@ -803,7 +835,8 @@ public static List<String> createTraefikIngressForDomainAndVerify(
if (host.contains(":")) {
host = "[" + host + "]";
}
String curlCmd = "curl -g --silent --show-error --noproxy '*' -H 'host: " + ingressHost
String curlCmd = "curl -g --silent --show-error --noproxy '*' "
+ " -v --max-time 60 -H 'host: " + ingressHost
+ "' http://" + host + ":" + nodeport
+ "/weblogic/ready --write-out %{http_code} -o /dev/null";

Expand Down

0 comments on commit ef2a105

Please sign in to comment.