1414import static org .hamcrest .Matchers .empty ;
1515import static org .hamcrest .Matchers .equalTo ;
1616import static org .hamcrest .Matchers .not ;
17- import static org .hamcrest .Matchers .sameInstance ;
1817import static org .hamcrest .junit .MatcherAssert .assertThat ;
1918
2019import io .kubernetes .client .ApiException ;
@@ -77,7 +76,8 @@ private void verifyAdminPodReplacedWhen(PodMutator mutator) {
7776
7877 V1Pod existingPod = createPodModel ();
7978 mutator .mutate (existingPod );
80- expectReadPod (getPodName ()).returning (existingPod );
79+ initializeExistingPod (existingPod );
80+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
8181 expectDeletePod (getPodName ()).returning (new V1Status ());
8282 expectCreatePod (podWithName (getPodName ())).returning (createPodModel ());
8383
@@ -101,7 +101,8 @@ public void whenDeleteReportsNotFound_replaceAdminPod() {
101101 PodAwaiterStepFactory .class ,
102102 (pod , next ) -> terminalStep );
103103
104- expectReadPod (getPodName ()).returning (getIncompatiblePod ());
104+ initializeExistingPod (getIncompatiblePod ());
105+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
105106 expectDeletePod (getPodName ()).failingWithStatus (CallBuilder .NOT_FOUND );
106107 expectCreatePod (podWithName (getPodName ())).returning (createPodModel ());
107108
@@ -119,7 +120,8 @@ private V1Pod getIncompatiblePod() {
119120 @ Test
120121 public void whenAdminPodDeletionFails_retryOnFailure () {
121122 testSupport .addRetryStrategy (retryStrategy );
122- expectReadPod (getPodName ()).returning (getIncompatiblePod ());
123+ initializeExistingPod (getIncompatiblePod ());
124+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
123125 expectDeletePod (getPodName ()).failingWithStatus (401 );
124126 expectStepsAfterCreation ();
125127
@@ -128,13 +130,13 @@ public void whenAdminPodDeletionFails_retryOnFailure() {
128130 testSupport .runSteps (initialStep );
129131
130132 testSupport .verifyCompletionThrowable (ApiException .class );
131- assertThat (retryStrategy .getConflictStep (), sameInstance (initialStep ));
132133 }
133134
134135 @ Test
135136 public void whenAdminPodReplacementFails_retryOnFailure () {
136137 testSupport .addRetryStrategy (retryStrategy );
137- expectReadPod (getPodName ()).returning (getIncompatiblePod ());
138+ initializeExistingPod (getIncompatiblePod ());
139+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
138140 expectDeletePod (getPodName ()).returning (new V1Status ());
139141 expectCreatePod (podWithName (getPodName ())).failingWithStatus (401 );
140142 expectStepsAfterCreation ();
@@ -144,7 +146,6 @@ public void whenAdminPodReplacementFails_retryOnFailure() {
144146 testSupport .runSteps (initialStep );
145147
146148 testSupport .verifyCompletionThrowable (ApiException .class );
147- assertThat (retryStrategy .getConflictStep (), sameInstance (initialStep ));
148149 }
149150
150151 @ Test
@@ -209,11 +210,13 @@ public void whenExistingAdminPodSpecContainerHasWrongEnvFrom_replaceIt() {
209210
210211 @ Test
211212 public void whenAdminPodCreated_specHasPodNameAsHostName () {
213+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
212214 assertThat (getCreatedPod ().getSpec ().getHostname (), equalTo (getPodName ()));
213215 }
214216
215217 @ Test
216218 public void whenAdminPodCreated_containerHasStartServerCommand () {
219+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
217220 assertThat (
218221 getCreatedPodSpecContainer ().getCommand (),
219222 contains ("/weblogic-operator/scripts/startServer.sh" , UID , getServerName (), DOMAIN_NAME ));
@@ -222,6 +225,7 @@ public void whenAdminPodCreated_containerHasStartServerCommand() {
222225 @ Test
223226 public void whenAdminPodCreated_hasOperatorCertEnvVariable () {
224227 putTuningParameter (INTERNAL_OPERATOR_CERT_FILE_PARAM , CERTFILE );
228+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
225229 assertThat (
226230 getCreatedPodSpecContainer ().getEnv (),
227231 hasEnvVar (INTERNAL_OPERATOR_CERT_ENV_NAME , CERTFILE ));
@@ -231,6 +235,7 @@ public void whenAdminPodCreated_hasOperatorCertEnvVariable() {
231235 public void whenDomainPresenceHasNullEnvironmentItems_createAdminPodStartupWithDefaultItems () {
232236 domainPresenceInfo .getDomain ().getSpec ().setServerStartup (null );
233237
238+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
234239 assertThat (getCreatedPodSpecContainer ().getEnv (), not (empty ()));
235240 }
236241
@@ -245,6 +250,7 @@ public void whenDomainPresenceHasEnvironmentItems_createAdminPodStartupWithThem(
245250 .withVar ("item2" , "value2" )
246251 .build ());
247252
253+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
248254 assertThat (
249255 getCreatedPodSpecContainer ().getEnv (),
250256 allOf (hasEnvVar ("item1" , "value1" ), hasEnvVar ("item2" , "value2" )));
@@ -261,6 +267,7 @@ public void whenDomainPresenceHasEnvironmentItemsWithVariables_createAdminPodSta
261267 .withVar ("item2" , "$(SERVER_NAME) is $(ADMIN_NAME):$(ADMIN_PORT)" )
262268 .build ());
263269
270+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
264271 assertThat (
265272 getCreatedPodSpecContainer ().getEnv (),
266273 allOf (
@@ -287,6 +294,11 @@ List<ServerStartup> build() {
287294 }
288295 }
289296
297+ @ Override
298+ protected void onAdminExpectListPersistentVolume () {
299+ expectListPersistentVolume ().returning (createPersistentVolumeList ());
300+ }
301+
290302 @ Override
291303 V1Pod createPodModel () {
292304 return new V1Pod ().metadata (createPodMetadata ()).spec (createPodSpec ());
0 commit comments