diff --git a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesCrudDispatcher.java b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesCrudDispatcher.java index 1dd30de96af..fdc482a7c31 100644 --- a/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesCrudDispatcher.java +++ b/junit/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesCrudDispatcher.java @@ -214,6 +214,7 @@ private void processDelete(String path, AttributeSet pathAttributes, AttributeSe if (!resource.isMarkedForDeletion()) { // Mark the resource as deleted, but don't remove it yet (wait for finalizer-removal). resource.getMetadata().setDeletionTimestamp(LocalDateTime.now().toString()); + resource.getMetadata().setResourceVersion(String.valueOf(requestResourceVersion())); String updatedResource = Serialization.asJson(resource); processEvent(path, pathAttributes, oldAttributes, resource, updatedResource); return; diff --git a/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherFinalizerTest.java b/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherFinalizerTest.java index a52af3822ae..5625cff9f0f 100644 --- a/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherFinalizerTest.java +++ b/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherFinalizerTest.java @@ -60,8 +60,7 @@ void tearDown() { private Owl createOwlWithFinalizer(String owlName) { final Owl owl = new Owl(); owl.setMetadata(new ObjectMetaBuilder().withName(owlName).withFinalizers("test-finalizer").build()); - client.resources(Owl.class).resource(owl).create(); - return owl; + return client.resources(Owl.class).resource(owl).create(); } @Test @@ -96,6 +95,7 @@ void deleteResourceWithFinalizerTwiceSameDeletionTimestamp() { String deletionTimestamp1 = owl1.getMetadata().getDeletionTimestamp(); assertNotNull(deletionTimestamp1); assertDoesNotThrow(() -> DateTimeFormatter.ISO_DATE_TIME.parse(deletionTimestamp1)); + assertNotEquals(initialOwl.getMetadata().getResourceVersion(), owl1.getMetadata().getResourceVersion()); // When the owl is deleted a second time: client.resources(Owl.class).resource(owl1).delete();