Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@
<includes-failsafe>
**/ItMultiDomainModels,
**/ItServerStartPolicy,
**/ItServerStartPolicyDynamicCluster,
**/ItServerStartPolicyConfigCluster,
**/ItMiiUpdateDomainConfig,
**/ItIntrospectVersion,
**/ItFmwDomainInPV,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import static oracle.weblogic.kubernetes.utils.ImageUtils.dockerLoginAndPushImageToRegistry;
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
import static oracle.weblogic.kubernetes.utils.OperatorUtils.upgradeAndVerifyOperator;
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodInitializing;
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodInitialized;
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodReady;
import static oracle.weblogic.kubernetes.utils.PodUtils.getPodCreationTime;
import static oracle.weblogic.kubernetes.utils.PodUtils.setPodAntiAffinity;
Expand Down Expand Up @@ -415,7 +415,7 @@ private void createAndVerifyMiiDomain(String domainNamespace, String domainUid,
createDomainAndVerify(domain, domainNamespace);
String adminServerPodName = domainUid + adminServerPrefix;
//check if pod in init state
checkPodInitializing(adminServerPodName,domainUid, domainNamespace);
checkPodInitialized(adminServerPodName,domainUid, domainNamespace);

// check that admin service exists and pod is ready in the domain namespace
logger.info("Checking that admin service {0} exists in namespace {1}",
Expand All @@ -426,7 +426,7 @@ private void createAndVerifyMiiDomain(String domainNamespace, String domainUid,
for (int i = 1; i <= replicaCount; i++) {
String managedServerPodName = domainUid + managedServerPrefix + i;
//check if pod in init state
checkPodInitializing(managedServerPodName,domainUid, domainNamespace);
checkPodInitialized(managedServerPodName,domainUid, domainNamespace);
// check that the managed server service exists and pod is ready in the domain namespace
logger.info("Checking that managed server service {0} exists in namespace {1}",
managedServerPodName, domainNamespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class ItKubernetesEvents {
final String cluster1Name = "mycluster";
final String cluster2Name = "cl2";
final String adminServerName = "admin-server";
final String domainUid = "k8seventsdomain";
final String adminServerPodName = domainUid + "-" + adminServerName;
final String managedServerNameBase = "ms-";
String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase;
Expand All @@ -156,7 +157,6 @@ class ItKubernetesEvents {

final String pvName = getUniquePvOrPvcName(domainUid + "-pv-");
final String pvcName = getUniquePvOrPvcName(domainUid + "-pvc-");
private static final String domainUid = "k8seventsdomain";
private final String wlSecretName = "weblogic-credentials";

// create standard, reusable retry/backoff policy
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ public static Callable<Boolean> podReady(String podName, String domainUid, Strin
}

/**
* Check if a Kubernetes pod is in initializing state.
* Check if a Kubernetes pod is in initialized state.
*
* @param podName name of the pod to check for
* @param domainUid WebLogic domain uid in which the pod belongs
* @param namespace in which the pod is initializing
* @return true if the pod is initializing otherwise false
* @param namespace in which the pod is initialized
* @return true if the pod is initialized otherwise false
*/
public static Callable<Boolean> podInitializing(String podName, String domainUid, String namespace) {
return Pod.podInitializing(namespace, domainUid, podName);
public static Callable<Boolean> podInitialized(String podName, String domainUid, String namespace) {
return Pod.podInitialized(namespace, domainUid, podName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ public static boolean isPodRunning(String namespace, String domainUid, String po
}

/**
* Checks if a pod exists in a given namespace and in Running state.
* Checks if a pod exists in a given namespace and in Initialized state.
* @param namespace in which to check for the pod running
* @param domainUid the label the pod is decorated with
* @param podName name of the pod to check for
* @return true if pod exists and running otherwise false
* @throws ApiException when there is error in querying the cluster
*/
public static boolean isPodInitializing(String namespace, String domainUid, String podName) throws ApiException {
public static boolean isPodInitialized(String namespace, String domainUid, String podName) throws ApiException {
final LoggingFacade logger = getLogger();
boolean status = false;
V1Pod pod = getPod(namespace, null, podName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020, 2021, Oracle and/or its affiliates.
// Copyright (c) 2020, 2022, Oracle 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;
Expand Down Expand Up @@ -130,9 +130,9 @@ public static Callable<Boolean> podReady(String namespace, String domainUid, Str
* @param podName name of the pod
* @return true if pod is initializing otherwise false
*/
public static Callable<Boolean> podInitializing(String namespace, String domainUid, String podName) {
public static Callable<Boolean> podInitialized(String namespace, String domainUid, String podName) {
return () -> {
return Kubernetes.isPodInitializing(namespace, domainUid, podName);
return Kubernetes.isPodInitialized(namespace, domainUid, podName);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@
*/
public class CommonTestUtils {

public static ConditionFactory withStandardRetryPolicy =
with().pollDelay(2, SECONDS)
.and().with().pollInterval(10, SECONDS)
.atMost(5, MINUTES).await();

public static ConditionFactory withQuickRetryPolicy = with().pollDelay(0, SECONDS)
.and().with().pollInterval(3, SECONDS)
.atMost(120, SECONDS).await();
public static ConditionFactory withStandardRetryPolicy = createStandardRetryPolicyWithAtMost(10);
public static ConditionFactory withLongRetryPolicy = createStandardRetryPolicyWithAtMost(15);
public static ConditionFactory withQuickRetryPolicy = createStandardRetryPolicyWithAtMost(2);

private static ConditionFactory createStandardRetryPolicyWithAtMost(long minutes) {
return with().pollDelay(2, SECONDS)
.and().with().pollInterval(10, SECONDS)
.atMost(minutes, MINUTES).await();
}

/**
* Test assertion using standard retry policy over time until it passes or the timeout expires.
Expand Down Expand Up @@ -158,6 +160,25 @@ public static void checkPodReadyAndServiceExists(String podName, String domainUi
checkPodReady(podName, domainUid, namespace);
}

/**
* Check pod is ready and service exists in the specified namespace.
*
* @param conditionFactory Configuration for Awaitility condition factory
* @param podName pod name to check
* @param domainUid the label the pod is decorated with
* @param namespace the namespace in which the pod exists
*/
public static void checkPodReadyAndServiceExists(ConditionFactory conditionFactory,
String podName, String domainUid, String namespace) {
LoggingFacade logger = getLogger();

logger.info("Check service {0} exists in namespace {1}", podName, namespace);
checkServiceExists(conditionFactory, podName, namespace);

logger.info("Waiting for pod {0} to be ready in namespace {1}", podName, namespace);
checkPodReady(conditionFactory, podName, domainUid, namespace);
}

/**
* Check service exists in the specified namespace.
*
Expand All @@ -179,6 +200,25 @@ public static void checkServiceExists(String serviceName, String namespace) {
serviceName, namespace)));
}

/**
* Check service exists in the specified namespace.
*
* @param conditionFactory Configuration for Awaitility condition factory
* @param serviceName service name to check
* @param namespace the namespace in which to check for the service
*/
public static void checkServiceExists(ConditionFactory conditionFactory,String serviceName, String namespace) {
LoggingFacade logger = getLogger();
testUntil(conditionFactory,
assertDoesNotThrow(() -> serviceExists(serviceName, null, namespace),
String.format("serviceExists failed with ApiException for service %s in namespace %s",
serviceName, namespace)),
logger,
"service {0} to exist in namespace {1}",
serviceName,
namespace);
}

/**
* add security context constraints to the service account of db namespace.
* @param serviceAccount - service account to add to scc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020, 2021, Oracle and/or its affiliates.
// Copyright (c) 2020, 2022, Oracle 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.utils;
Expand Down Expand Up @@ -166,6 +166,7 @@ && domainEventExists(opNamespace, opNamespace, null, STOP_MANAGING_NAMESPACE, ty
* @param reason event to check for Created, Changed, deleted, processing etc
* @param type type of event, Normal or Warning
* @param timestamp the timestamp after which to see events
* @return true if event exists otherwise false
*/
public static boolean domainEventExists(
String opNamespace, String domainNamespace, String domainUid, String reason,
Expand All @@ -174,7 +175,10 @@ public static boolean domainEventExists(
try {
List<CoreV1Event> events = Kubernetes.listNamespacedEvents(domainNamespace);
for (CoreV1Event event : events) {
if (event.getReason().equals(reason) && (isEqualOrAfter(timestamp, event))) {
if (((domainUid != null && (event.getMetadata().getLabels() != null
&& event.getMetadata().getLabels().containsValue(domainUid)))
|| domainUid == null)
&& (event.getReason().equals(reason) && (isEqualOrAfter(timestamp, event)))) {
logger.info(Yaml.dump(event));
verifyOperatorDetails(event, opNamespace, domainUid);
//verify type
Expand Down Expand Up @@ -274,7 +278,9 @@ public static Callable<Boolean> checkDomainEventWithCount(
try {
List<CoreV1Event> events = Kubernetes.listNamespacedEvents(domainNamespace);
for (CoreV1Event event : events) {
if (event.getReason().equals(reason) && (isEqualOrAfter(timestamp, event))) {
if (event.getReason().equals(reason) && (isEqualOrAfter(timestamp, event))
&& (event.getMetadata().getLabels() != null
&& event.getMetadata().getLabels().containsValue(domainUid))) {
logger.info(Yaml.dump(event));
verifyOperatorDetails(event, opNamespace, domainUid);
//verify type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020, 2021, Oracle and/or its affiliates.
// Copyright (c) 2020, 2022, Oracle 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.utils;
Expand Down Expand Up @@ -42,6 +42,7 @@
import static oracle.weblogic.kubernetes.actions.TestActions.getPodLog;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podDoesNotExist;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podReady;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
import static org.awaitility.Awaitility.with;
Expand Down Expand Up @@ -479,23 +480,21 @@ private static Callable<Boolean> podLogContainsString(String namespace, String p

/**
* Wait and check the pod log contains the expected string.
* @param namespace the namespace in which the pod exists
* @param podName the pod to get the log
*
* @param namespace the namespace in which the pod exists
* @param podName the pod to get the log
* @param expectedString the expected string to check in the pod log
*/
public static void checkPodLogContainsString(String namespace, String podName, String expectedString) {
public static void checkPodLogContainsString(String namespace, String podName, String expectedString) {

getLogger().info("Wait for string {0} existing in pod {1} in namespace {2}", expectedString, podName, namespace);
withStandardRetryPolicy
.conditionEvaluationListener(
condition -> getLogger().info("Waiting for string {0} existing in pod {1} in namespace {2} "
+ "(elapsed time {3}ms, remaining time {4}ms)",
expectedString,
podName,
namespace,
condition.getElapsedTimeInMS(),
condition.getRemainingTimeInMS()))
.until(assertDoesNotThrow(() -> podLogContainsString(namespace, podName, expectedString),
"podLogContainsString failed with IOException, ApiException or InterruptedException"));
testUntil(
assertDoesNotThrow(() -> podLogContainsString(namespace, podName, expectedString),
"podLogContainsString failed with IOException, ApiException or InterruptedException"),
getLogger(),
"string {0} existing in pod {1} in namespace {2}",
expectedString,
podName,
namespace);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021, Oracle and/or its affiliates.
// Copyright (c) 2021, 2022, Oracle 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.utils;
Expand All @@ -22,14 +22,16 @@
import oracle.weblogic.kubernetes.TestConstants;
import oracle.weblogic.kubernetes.actions.impl.Exec;
import oracle.weblogic.kubernetes.logging.LoggingFacade;
import org.awaitility.core.ConditionFactory;

import static oracle.weblogic.kubernetes.actions.TestActions.getPod;
import static oracle.weblogic.kubernetes.actions.TestActions.getPodCreationTimestamp;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.isPodRestarted;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podDoesNotExist;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podExists;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podInitializing;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podInitialized;
import static oracle.weblogic.kubernetes.assertions.TestAssertions.podReady;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
import static oracle.weblogic.kubernetes.utils.JobUtils.getIntrospectJobName;
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
Expand Down Expand Up @@ -108,25 +110,43 @@ public static void checkPodReady(String podName, String domainUid, String domain
}

/**
* Checks that pod is initializing.
* Check pod is ready.
*
* @param conditionFactory Configuration for Awaitility condition factory
* @param podName pod name to check
* @param domainUid the label the pod is decorated with
* @param domainNamespace the domain namespace in which the domain exists
*/
public static void checkPodInitializing(String podName, String domainUid, String domainNamespace) {
public static void checkPodReady(ConditionFactory conditionFactory, String podName,
String domainUid, String domainNamespace) {
LoggingFacade logger = getLogger();
withStandardRetryPolicy
.conditionEvaluationListener(
condition -> logger.info("Waiting for pod {0} to be initializing in namespace {1} "
+ "(elapsed time {2}ms, remaining time {3}ms)",
podName,
domainNamespace,
condition.getElapsedTimeInMS(),
condition.getRemainingTimeInMS()))
.until(assertDoesNotThrow(() -> podInitializing(podName, domainUid, domainNamespace),
String.format("podReady failed with ApiException for pod %s in namespace %s",
podName, domainNamespace)));
testUntil(conditionFactory,
assertDoesNotThrow(() -> podReady(podName, domainUid, domainNamespace),
String.format("podReady failed with ApiException for pod %s in namespace %s",
podName, domainNamespace)),
logger,
"pod {0} to be ready in namespace {1}",
podName,
domainNamespace);
}

/**
* Checks that pod is initialized.
*
* @param podName pod name to check
* @param domainUid the label the pod is decorated with
* @param domainNamespace the domain namespace in which the domain exists
*/
public static void checkPodInitialized(String podName, String domainUid, String domainNamespace) {
LoggingFacade logger = getLogger();
testUntil(
assertDoesNotThrow(() -> podInitialized(podName, domainUid, domainNamespace),
String.format("podInitialized failed with ApiException for pod %s in namespace %s",
podName, domainNamespace)),
logger,
"pod {0} to be initialized in namespace {1}",
podName,
domainNamespace);
}

/**
Expand Down
Loading