Skip to content

Commit a98618a

Browse files
authored
Backport ServerStartup Policy tests, fixed domain events retrieval to 3.4 release (#2896)
* Backport ServerStartup Policy tests, fixed domain events retrieval to 3.4 release
1 parent d7c5841 commit a98618a

14 files changed

+1714
-1240
lines changed

integration-tests/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@
297297
<includes-failsafe>
298298
**/ItMultiDomainModels,
299299
**/ItServerStartPolicy,
300+
**/ItServerStartPolicyDynamicCluster,
301+
**/ItServerStartPolicyConfigCluster,
300302
**/ItMiiUpdateDomainConfig,
301303
**/ItIntrospectVersion,
302304
**/ItFmwDomainInPV,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import static oracle.weblogic.kubernetes.utils.ImageUtils.dockerLoginAndPushImageToRegistry;
5353
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
5454
import static oracle.weblogic.kubernetes.utils.OperatorUtils.upgradeAndVerifyOperator;
55-
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodInitializing;
55+
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodInitialized;
5656
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodReady;
5757
import static oracle.weblogic.kubernetes.utils.PodUtils.getPodCreationTime;
5858
import static oracle.weblogic.kubernetes.utils.PodUtils.setPodAntiAffinity;
@@ -415,7 +415,7 @@ private void createAndVerifyMiiDomain(String domainNamespace, String domainUid,
415415
createDomainAndVerify(domain, domainNamespace);
416416
String adminServerPodName = domainUid + adminServerPrefix;
417417
//check if pod in init state
418-
checkPodInitializing(adminServerPodName,domainUid, domainNamespace);
418+
checkPodInitialized(adminServerPodName,domainUid, domainNamespace);
419419

420420
// check that admin service exists and pod is ready in the domain namespace
421421
logger.info("Checking that admin service {0} exists in namespace {1}",
@@ -426,7 +426,7 @@ private void createAndVerifyMiiDomain(String domainNamespace, String domainUid,
426426
for (int i = 1; i <= replicaCount; i++) {
427427
String managedServerPodName = domainUid + managedServerPrefix + i;
428428
//check if pod in init state
429-
checkPodInitializing(managedServerPodName,domainUid, domainNamespace);
429+
checkPodInitialized(managedServerPodName,domainUid, domainNamespace);
430430
// check that the managed server service exists and pod is ready in the domain namespace
431431
logger.info("Checking that managed server service {0} exists in namespace {1}",
432432
managedServerPodName, domainNamespace);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class ItKubernetesEvents {
148148
final String cluster1Name = "mycluster";
149149
final String cluster2Name = "cl2";
150150
final String adminServerName = "admin-server";
151+
final String domainUid = "k8seventsdomain";
151152
final String adminServerPodName = domainUid + "-" + adminServerName;
152153
final String managedServerNameBase = "ms-";
153154
String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase;
@@ -156,7 +157,6 @@ class ItKubernetesEvents {
156157

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

162162
// create standard, reusable retry/backoff policy

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

Lines changed: 135 additions & 1186 deletions
Large diffs are not rendered by default.

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

Lines changed: 423 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 561 additions & 0 deletions
Large diffs are not rendered by default.

integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/TestAssertions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,15 @@ public static Callable<Boolean> podReady(String podName, String domainUid, Strin
286286
}
287287

288288
/**
289-
* Check if a Kubernetes pod is in initializing state.
289+
* Check if a Kubernetes pod is in initialized state.
290290
*
291291
* @param podName name of the pod to check for
292292
* @param domainUid WebLogic domain uid in which the pod belongs
293-
* @param namespace in which the pod is initializing
294-
* @return true if the pod is initializing otherwise false
293+
* @param namespace in which the pod is initialized
294+
* @return true if the pod is initialized otherwise false
295295
*/
296-
public static Callable<Boolean> podInitializing(String podName, String domainUid, String namespace) {
297-
return Pod.podInitializing(namespace, domainUid, podName);
296+
public static Callable<Boolean> podInitialized(String podName, String domainUid, String namespace) {
297+
return Pod.podInitialized(namespace, domainUid, podName);
298298
}
299299

300300
/**

integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/Kubernetes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ public static boolean isPodRunning(String namespace, String domainUid, String po
136136
}
137137

138138
/**
139-
* Checks if a pod exists in a given namespace and in Running state.
139+
* Checks if a pod exists in a given namespace and in Initialized state.
140140
* @param namespace in which to check for the pod running
141141
* @param domainUid the label the pod is decorated with
142142
* @param podName name of the pod to check for
143143
* @return true if pod exists and running otherwise false
144144
* @throws ApiException when there is error in querying the cluster
145145
*/
146-
public static boolean isPodInitializing(String namespace, String domainUid, String podName) throws ApiException {
146+
public static boolean isPodInitialized(String namespace, String domainUid, String podName) throws ApiException {
147147
final LoggingFacade logger = getLogger();
148148
boolean status = false;
149149
V1Pod pod = getPod(namespace, null, podName);

integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/Pod.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2022, 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.assertions.impl;
@@ -130,9 +130,9 @@ public static Callable<Boolean> podReady(String namespace, String domainUid, Str
130130
* @param podName name of the pod
131131
* @return true if pod is initializing otherwise false
132132
*/
133-
public static Callable<Boolean> podInitializing(String namespace, String domainUid, String podName) {
133+
public static Callable<Boolean> podInitialized(String namespace, String domainUid, String podName) {
134134
return () -> {
135-
return Kubernetes.isPodInitializing(namespace, domainUid, podName);
135+
return Kubernetes.isPodInitialized(namespace, domainUid, podName);
136136
};
137137
}
138138

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

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@
6969
*/
7070
public class CommonTestUtils {
7171

72-
public static ConditionFactory withStandardRetryPolicy =
73-
with().pollDelay(2, SECONDS)
74-
.and().with().pollInterval(10, SECONDS)
75-
.atMost(5, MINUTES).await();
7672

77-
public static ConditionFactory withQuickRetryPolicy = with().pollDelay(0, SECONDS)
78-
.and().with().pollInterval(3, SECONDS)
79-
.atMost(120, SECONDS).await();
73+
public static ConditionFactory withStandardRetryPolicy = createStandardRetryPolicyWithAtMost(10);
74+
public static ConditionFactory withLongRetryPolicy = createStandardRetryPolicyWithAtMost(15);
75+
public static ConditionFactory withQuickRetryPolicy = createStandardRetryPolicyWithAtMost(2);
76+
77+
private static ConditionFactory createStandardRetryPolicyWithAtMost(long minutes) {
78+
return with().pollDelay(2, SECONDS)
79+
.and().with().pollInterval(10, SECONDS)
80+
.atMost(minutes, MINUTES).await();
81+
}
8082

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

163+
/**
164+
* Check pod is ready and service exists in the specified namespace.
165+
*
166+
* @param conditionFactory Configuration for Awaitility condition factory
167+
* @param podName pod name to check
168+
* @param domainUid the label the pod is decorated with
169+
* @param namespace the namespace in which the pod exists
170+
*/
171+
public static void checkPodReadyAndServiceExists(ConditionFactory conditionFactory,
172+
String podName, String domainUid, String namespace) {
173+
LoggingFacade logger = getLogger();
174+
175+
logger.info("Check service {0} exists in namespace {1}", podName, namespace);
176+
checkServiceExists(conditionFactory, podName, namespace);
177+
178+
logger.info("Waiting for pod {0} to be ready in namespace {1}", podName, namespace);
179+
checkPodReady(conditionFactory, podName, domainUid, namespace);
180+
}
181+
161182
/**
162183
* Check service exists in the specified namespace.
163184
*
@@ -179,6 +200,25 @@ public static void checkServiceExists(String serviceName, String namespace) {
179200
serviceName, namespace)));
180201
}
181202

203+
/**
204+
* Check service exists in the specified namespace.
205+
*
206+
* @param conditionFactory Configuration for Awaitility condition factory
207+
* @param serviceName service name to check
208+
* @param namespace the namespace in which to check for the service
209+
*/
210+
public static void checkServiceExists(ConditionFactory conditionFactory,String serviceName, String namespace) {
211+
LoggingFacade logger = getLogger();
212+
testUntil(conditionFactory,
213+
assertDoesNotThrow(() -> serviceExists(serviceName, null, namespace),
214+
String.format("serviceExists failed with ApiException for service %s in namespace %s",
215+
serviceName, namespace)),
216+
logger,
217+
"service {0} to exist in namespace {1}",
218+
serviceName,
219+
namespace);
220+
}
221+
182222
/**
183223
* add security context constraints to the service account of db namespace.
184224
* @param serviceAccount - service account to add to scc

0 commit comments

Comments
 (0)