|
1 |
| -// Copyright (c) 2020, 2021, Oracle and/or its affiliates. |
| 1 | +// Copyright (c) 2020, 2023, Oracle and/or its affiliates. |
2 | 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
3 | 3 |
|
4 | 4 | package oracle.weblogic.kubernetes.utils;
|
@@ -238,24 +238,26 @@ public static synchronized void startOracleDB(String dbBaseImageName, int dbPort
|
238 | 238 | }
|
239 | 239 |
|
240 | 240 | // 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); |
245 | 241 | testUntil(
|
246 |
| - assertDoesNotThrow(() -> podIsReady(dbNamespace, "app=database", dbPodName), |
| 242 | + assertDoesNotThrow(() -> checkDBPodReady(dbNamespace, dbPodNamePrefix), |
247 | 243 | "oracleDBService podReady failed with ApiException"),
|
248 | 244 | 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), |
250 | 247 | dbNamespace);
|
251 | 248 |
|
252 | 249 | // 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 | + } |
259 | 261 | }
|
260 | 262 |
|
261 | 263 | /**
|
@@ -721,4 +723,10 @@ public static void updateRcuAccessSecret(String secretName, String namespace,
|
721 | 723 |
|
722 | 724 | }
|
723 | 725 |
|
| 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 | + } |
724 | 732 | }
|
0 commit comments