Skip to content

Commit 6d73da5

Browse files
committed
Merge branch 'xc-108118-orahub' into 'release/3.4'
Fix NullPointerException in ItFmwBigCMMiiDomain when getting DB pod name See merge request weblogic-cloud/weblogic-kubernetes-operator!4192
2 parents aabb602 + 1d3dd75 commit 6d73da5

File tree

1 file changed

+21
-13
lines changed
  • integration-tests/src/test/java/oracle/weblogic/kubernetes/utils

1 file changed

+21
-13
lines changed

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

Lines changed: 21 additions & 13 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, 2023, 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.utils;
@@ -238,24 +238,26 @@ public static synchronized void startOracleDB(String dbBaseImageName, int dbPort
238238
}
239239

240240
// wait for the Oracle DB pod to be ready
241-
String dbPodName = assertDoesNotThrow(() -> getPodNameOfDb(dbNamespace, dbPodNamePrefix),
242-
String.format("Get Oracle DB pod name failed with ApiException for oracleDBService in namespace %s",
243-
dbNamespace));
244-
logger.info("Wait for the oracle Db pod: {0} ready in namespace {1}", dbPodName, dbNamespace);
245241
testUntil(
246-
assertDoesNotThrow(() -> podIsReady(dbNamespace, "app=database", dbPodName),
242+
assertDoesNotThrow(() -> checkDBPodReady(dbNamespace, dbPodNamePrefix),
247243
"oracleDBService podReady failed with ApiException"),
248244
logger,
249-
"Oracle DB to be ready in namespace {0}",
245+
"Oracle DB pod {0} to be ready in namespace {1}",
246+
getPodNameOfDb(dbNamespace, dbPodNamePrefix),
250247
dbNamespace);
251248

252249
// check if DB is ready to be used by searching pod log
253-
logger.info("Check for DB pod {0} log contains ready message in namespace {1}",
254-
dbPodName, dbNamespace);
255-
String msg = "The database is ready for use";
256-
checkDbReady(msg, dbPodName, dbNamespace);
257-
258-
dbMap.put(dbNamespace, dbPodName);
250+
String dbPodName = getPodNameOfDb(dbNamespace, dbPodNamePrefix);
251+
if (dbPodName != null) {
252+
logger.info("Check for DB pod {0} log contains ready message in namespace {1}",
253+
dbPodName, dbNamespace);
254+
String msg = "The database is ready for use";
255+
checkDbReady(msg, dbPodName, dbNamespace);
256+
257+
dbMap.put(dbNamespace, dbPodName);
258+
} else {
259+
logger.info("db pod name is null");
260+
}
259261
}
260262

261263
/**
@@ -721,4 +723,10 @@ public static void updateRcuAccessSecret(String secretName, String namespace,
721723

722724
}
723725

726+
private static Callable<Boolean> checkDBPodReady(String dbNamespace, String dbPodNamePrefix) {
727+
String dbPodName = assertDoesNotThrow(() -> getPodNameOfDb(dbNamespace, dbPodNamePrefix),
728+
String.format("Get Oracle DB pod name failed with ApiException for oracleDBService in namespace %s",
729+
dbNamespace));
730+
return () -> dbPodName != null && isPodReady(dbNamespace, "app=database", dbPodName);
731+
}
724732
}

0 commit comments

Comments
 (0)