Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9abcc92
initial commit
xiancao Aug 12, 2020
4b23c1b
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernet…
xiancao Aug 13, 2020
79569c6
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernet…
xiancao Aug 20, 2020
308501f
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernet…
xiancao Aug 21, 2020
bb195cb
apache lb
xiancao Aug 24, 2020
88d94c4
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernet…
xiancao Aug 24, 2020
6596ebe
add apache tests to ItTwoDomainsLoadBalancers
xiancao Aug 26, 2020
aab305c
fix apache-webtier chart imagePullSecret
xiancao Aug 26, 2020
1ca2582
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernet…
xiancao Aug 26, 2020
f9c5109
get the ItPodsShutdownOption from shutdown3 branch
xiancao Aug 26, 2020
f56c7d2
change imagePullPolicy to Always
xiancao Aug 27, 2020
eebad12
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernet…
xiancao Aug 27, 2020
75f26c1
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernet…
xiancao Aug 27, 2020
5c6d6bd
push the apache image to Kind repo
xiancao Aug 27, 2020
ac942b8
add debug info for REPO_REGISTRY etc in Kind new
xiancao Aug 27, 2020
e113b42
get the latest develop
xiancao Aug 27, 2020
5ab3b3d
remoe pull image from ocir and push to kind repo
xiancao Aug 27, 2020
16d5218
enable pull apache image from ocir and push to kind new
xiancao Aug 28, 2020
f1294ff
cleanup
xiancao Aug 28, 2020
9ad4a3b
move OCR login to test
vanajamukkara Aug 31, 2020
39e5e8f
address Vanaja's comments
xiancao Aug 31, 2020
fb94ffb
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernet…
xiancao Sep 1, 2020
69c7c22
address Pani's comments
xiancao Sep 1, 2020
485b2fa
address Vanaja's comments
xiancao Sep 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ spec:
- name: {{ template "apache.fullname" . }}
hostPath:
path: {{ .Values.volumePath | quote }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
- name: {{ (index .Values.imagePullSecrets 0).name }}
{{- end }}
containers:
- name: {{ template "apache.fullname" . }}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ public interface TestConstants {
public static final String VOYAGER_CHART_NAME = "voyager";
public static final String VOYAGER_CHART_VERSION = "12.0.0";

// ELK Stack and WebLogic Logging Exporter constants
// Apache constants
public static final String APACHE_IMAGE_NAME = "phx.ocir.io/weblogick8s/oracle/apache";
public static final String APACHE_IMAGE_VERSION = "12.2.1.3";
public static final String APACHE_IMAGE = APACHE_IMAGE_NAME + ":" + APACHE_IMAGE_VERSION;
public static final String APACHE_RELEASE_NAME = "apache-release" + BUILD_ID;
public static final String APACHE_SAMPLE_CHART_DIR = "../kubernetes/samples/charts/apache-webtier";

// ELK Stack and WebLogic logging exporter constants
public static final String ELASTICSEARCH_NAME = "elasticsearch";
public static final String ELK_STACK_VERSION = "7.8.1";
public static final String ELASTICSEARCH_IMAGE = ELASTICSEARCH_NAME + ":" + ELK_STACK_VERSION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import io.kubernetes.client.openapi.models.V1ServiceAccount;
import io.kubernetes.client.openapi.models.V1ServiceList;
import oracle.weblogic.domain.DomainList;
import oracle.weblogic.kubernetes.actions.impl.Apache;
import oracle.weblogic.kubernetes.actions.impl.ApacheParams;
import oracle.weblogic.kubernetes.actions.impl.AppBuilder;
import oracle.weblogic.kubernetes.actions.impl.AppParams;
import oracle.weblogic.kubernetes.actions.impl.ClusterRole;
Expand Down Expand Up @@ -385,6 +387,16 @@ public static boolean installTraefik(TraefikParams params) {
return Traefik.install(params);
}

/**
* Install Apache ingress controller.
*
* @param params the parameters to Helm install command, such as release name, namespace, repo url,
* repo name and chart name
* @return true on success, false otherwise
*/
public static boolean installApache(ApacheParams params) {
return Apache.install(params);
}

/**
* Upgrade NGINX release.
Expand All @@ -406,6 +418,16 @@ public static boolean upgradeVoyager(VoyagerParams params) {
return Voyager.upgrade(params);
}

/**
* Upgrade Apache release.
*
* @param params the parameters to Helm upgrade command, such as release name and http/https nodeport
* @return true on success, false otherwise
*/
public static boolean upgradeApache(ApacheParams params) {
return Apache.upgrade(params);
}

/**
* Uninstall the NGINX release.
*
Expand Down Expand Up @@ -436,6 +458,16 @@ public static boolean uninstallVoyager(HelmParams params) {
return Voyager.uninstall(params);
}

/**
* Uninstall the Apache release.
*
* @param params the parameters to Helm uninstall command, such as release name and namespace
* @return true on success, false otherwise
*/
public static boolean uninstallApache(HelmParams params) {
return Apache.uninstall(params);
}

/**
* Create an ingress for the WebLogic domain with domainUid in the specified domain namespace.
* The ingress host is set to 'domainUid.clusterName.test'.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2020, Oracle Corporation and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

package oracle.weblogic.kubernetes.actions.impl;

import oracle.weblogic.kubernetes.actions.impl.primitive.Helm;
import oracle.weblogic.kubernetes.actions.impl.primitive.HelmParams;

/**
* Utility class for Apache load balancer.
*/
public class Apache {

/**
* Install Apache Helm chart.
*
* @param params the parameters to Helm install command such as release name, namespace, repo url or chart dir,
* chart name and chart values
* @return true on success, false otherwise
*/
public static boolean install(ApacheParams params) {
return Helm.install(params.getHelmParams(), params.getValues());
}

/**
* Upgrade Apache Helm release.
*
* @param params the parameters to Helm upgrade command such as release name, namespace and chart values to override
* @return true on success, false otherwise
*/
public static boolean upgrade(ApacheParams params) {
return Helm.upgrade(params.getHelmParams(), params.getValues());
}

/**
* Uninstall Apache Helm release.
*
* @param params the parameters to Helm uninstall command such as release name and namespace
* @return true on success, false otherwise
*/
public static boolean uninstall(HelmParams params) {
return Helm.uninstall(params);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright (c) 2020, Oracle Corporation and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

package oracle.weblogic.kubernetes.actions.impl;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import oracle.weblogic.kubernetes.actions.impl.primitive.HelmParams;

/**
* All parameters needed to install Apache load balancer.
*/
public class ApacheParams {

// The default values can be found here:
// weblogic-kubernetes-operator/kubernetes/samples/charts/apache-webtier/values.yaml
private static final String IMAGE = "image";
private static final String IMAGE_PULL_POLICY = "imagePullPolicy";
private static final String IMAGE_PULL_SECRETS = "imagePullSecrets";
private static final String VOLUME_PATH = "volumePath";
private static final String HTTP_NODEPORT = "httpNodePort";
private static final String HTTPS_NODEPORT = "httpsNodePort";
private static final String VIRTUAL_HOSTNAME = "virtualHostName";
private static final String CUSTOM_CERT = "customCert";
private static final String CUSTOM_KEY = "customKey";
private static final String DOMAIN_UID = "domainUID";

private String image = null;
private String imagePullPolicy = null;
private Map<String, Object> imagePullSecrets = null;
private String volumePath = null;
private int httpNodePort = 0;
private int httpsNodePort = 0;
private String virtualHostName = null;
private String customCert = null;
private String customKey = null;
private String domainUID = null;
private HelmParams helmParams;

public ApacheParams image(String image) {
this.image = image;
return this;
}

public ApacheParams imagePullPolicy(String imagePullPolicy) {
this.imagePullPolicy = imagePullPolicy;
return this;
}

public ApacheParams imagePullSecrets(Map<String, Object> imagePullSecrets) {
this.imagePullSecrets = imagePullSecrets;
return this;
}

public ApacheParams volumePath(String volumePath) {
this.volumePath = volumePath;
return this;
}

public ApacheParams httpNodePort(int httpNodePort) {
this.httpNodePort = httpNodePort;
return this;
}

public ApacheParams httpsNodePort(int httpsNodePort) {
this.httpsNodePort = httpsNodePort;
return this;
}

public ApacheParams virtualHostName(String virtualHostName) {
this.virtualHostName = virtualHostName;
return this;
}

public ApacheParams customCert(String customCert) {
this.customCert = customCert;
return this;
}

public ApacheParams customKey(String customKey) {
this.customKey = customKey;
return this;
}

public ApacheParams domainUID(String domainUID) {
this.domainUID = domainUID;
return this;
}

public ApacheParams helmParams(HelmParams helmParams) {
this.helmParams = helmParams;
return this;
}

public HelmParams getHelmParams() {
return helmParams;
}

/**
* Loads Helm values into a value map.
*
* @return Map of values
*/
public Map<String, Object> getValues() {
Map<String, Object> values = new HashMap<>();

values.put(IMAGE, image);
values.put(IMAGE_PULL_POLICY, imagePullPolicy);
values.put(IMAGE_PULL_SECRETS, imagePullSecrets);
values.put(VOLUME_PATH, volumePath);

if (httpNodePort >= 0) {
values.put(HTTP_NODEPORT, httpNodePort);
}
if (httpsNodePort >= 0) {
values.put(HTTPS_NODEPORT, httpsNodePort);
}

values.put(VIRTUAL_HOSTNAME, virtualHostName);
values.put(CUSTOM_CERT, customCert);
values.put(CUSTOM_KEY, customKey);
values.put(DOMAIN_UID, domainUID);

values.values().removeIf(Objects::isNull);
return values;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import java.util.concurrent.Callable;

import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.models.V1Secret;
import oracle.weblogic.kubernetes.actions.impl.LoggingExporter;
import oracle.weblogic.kubernetes.assertions.impl.Apache;
import oracle.weblogic.kubernetes.assertions.impl.Application;
import oracle.weblogic.kubernetes.assertions.impl.ClusterRole;
import oracle.weblogic.kubernetes.assertions.impl.ClusterRoleBinding;
Expand All @@ -30,6 +32,8 @@
import oracle.weblogic.kubernetes.assertions.impl.WitAssertion;
import org.joda.time.DateTime;

import static oracle.weblogic.kubernetes.actions.TestActions.listSecrets;

/**
* General assertions needed by the tests to validate CRD, Domain, Pods etc.
*/
Expand Down Expand Up @@ -65,6 +69,16 @@ public static Callable<Boolean> isNginxReady(String namespace) {
return Nginx.isReady(namespace);
}

/**
* Check if there are ready Apache pods in the specified namespace.
*
* @param namespace in which to check if Apache pods are in the ready state
* @return true if there are ready Apache pods in the specified namespace , false otherwise
*/
public static Callable<Boolean> isApacheReady(String namespace) {
return Apache.isReady(namespace);
}

/**
* Check traefik controller pod is ready in the specified namespace.
*
Expand Down Expand Up @@ -630,4 +644,24 @@ public static boolean clusterRoleExists(String clusterRoleName) throws ApiExcept
public static boolean clusterRoleBindingExists(String clusterRoleBindingName) throws ApiException {
return ClusterRoleBinding.clusterRoleBindingExists(clusterRoleBindingName);
}

/**
* Check whether the secret exists in the specified namespace.
*
* @param secretName name of the secret
* @param namespace namespace in which the secret exists
* @return true if secret exists, false otherwise
*/
public static boolean secretExists(String secretName, String namespace) {
for (V1Secret secret : listSecrets(namespace).getItems()) {
if (secret.getMetadata() != null) {
String name = secret.getMetadata().getName();
if (name != null && name.equals(secretName)) {
return true;
}
}
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2020, Oracle Corporation and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

package oracle.weblogic.kubernetes.assertions.impl;

import java.util.concurrent.Callable;

/**
* Assertions for Apache load balancer.
*/
public class Apache {

/**
* Check if the Apache pod is running in the specified namespace.
*
* @param namespace in which to check if the Apache pod is running
* @return true if the Apache pod is running, false otherwise
*/
public static Callable<Boolean> isRunning(String namespace) {
return () -> Kubernetes.isApachePodRunning(namespace);
}

/**
* Check if the Apache pod is ready in the specified namespace.
*
* @param namespace in which to check the Apache pod is ready
* @return true if the Apache pod is in the ready state, false otherwise
*/
public static Callable<Boolean> isReady(String namespace) {
return () -> Kubernetes.isApachePodReady(namespace);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.joda.time.DateTime;

import static io.kubernetes.client.util.Yaml.dump;
import static oracle.weblogic.kubernetes.TestConstants.APACHE_RELEASE_NAME;
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_RELEASE_NAME;
import static oracle.weblogic.kubernetes.actions.TestActions.getPodRestartVersion;
import static oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes.getPodCreationTimestamp;
Expand Down Expand Up @@ -344,6 +345,34 @@ public static boolean isNginxPodReady(String namespace) throws ApiException {
return isPodReady(namespace, labelSelector, "nginx-ingress-controller");
}

/**
* Checks if a Apache pod is running in the specified namespace.
* The method assumes the Apache pod name contains "APACHE_RELEAE_NAME-namespace.substring(3)-apache-webtier".
*
* @param namespace in which to check if the Apache pod is running
* @return true if the pod is running, otherwise false
* @throws ApiException if Kubernetes client API call fails
*/
public static boolean isApachePodRunning(String namespace) throws ApiException {

return isPodRunning(namespace, null,
APACHE_RELEASE_NAME + "-" + namespace.substring(3) + "-apache-webtier");
}

/**
* Check whether the Apache pod is ready in the specified namespace.
* The method assumes the Apache pod name contains "APACHE_RELEASE_NAME-namespace.substring(3)-apache-webtier".
*
* @param namespace in which to check if the Apache pod is ready
* @return true if the pod is in the ready state, false otherwise
* @throws ApiException if Kubernetes client API call fails
*/
public static boolean isApachePodReady(String namespace) throws ApiException {
String labelSelector = null;
return isPodReady(namespace, labelSelector,
APACHE_RELEASE_NAME + "-" + namespace.substring(3) + "-apache-webtier");
}

/**
* Checks if traefik pod is running in the specified namespace.
*
Expand Down
Loading