use of io.fabric8.kubernetes.api.model.DeletionPropagation in project strimzi by strimzi.
the class StatefulSetOperatorTest method testNonCascadingDeleteAsync.
@Test
public void testNonCascadingDeleteAsync(VertxTestContext context) {
Deletable mockDeletable = mock(Deletable.class);
when(mockDeletable.delete()).thenReturn(Boolean.TRUE);
Resource mockERPD = mock(resourceType());
when(mockERPD.withPropagationPolicy(any(DeletionPropagation.class))).thenReturn(mockDeletable);
when(mockERPD.withGracePeriod(anyLong())).thenReturn(mockDeletable);
RollableScalableResource mockRSR = mock(RollableScalableResource.class);
ArgumentCaptor<DeletionPropagation> cascadingCaptor = ArgumentCaptor.forClass(DeletionPropagation.class);
when(mockRSR.withPropagationPolicy(cascadingCaptor.capture())).thenReturn(mockERPD);
ArgumentCaptor<Watcher> watcherCaptor = ArgumentCaptor.forClass(Watcher.class);
when(mockRSR.watch(watcherCaptor.capture())).thenReturn(mock(Watch.class));
NonNamespaceOperation mockNameable = mock(NonNamespaceOperation.class);
when(mockNameable.withName(matches(RESOURCE_NAME))).thenReturn(mockRSR);
MixedOperation mockCms = mock(MixedOperation.class);
when(mockCms.inNamespace(matches(NAMESPACE))).thenReturn(mockNameable);
PodOperator podOperator = mock(PodOperator.class);
PvcOperator pvcOperator = mock(PvcOperator.class);
KubernetesClient mockClient = mock(KubernetesClient.class);
mocker(mockClient, mockCms);
StatefulSetOperator op = new StatefulSetOperator(AbstractResourceOperatorTest.vertx, mockClient, 5_000L, podOperator, pvcOperator) {
@Override
protected boolean shouldIncrementGeneration(Reconciliation reconciliation, StatefulSetDiff diff) {
return true;
}
};
Checkpoint a = context.checkpoint();
op.deleteAsync(new Reconciliation("test", "kind", "namespace", "name"), NAMESPACE, RESOURCE_NAME, false).onComplete(context.succeeding(v -> context.verify(() -> {
assertThat(cascadingCaptor.getValue(), is(DeletionPropagation.ORPHAN));
a.flag();
})));
}
use of io.fabric8.kubernetes.api.model.DeletionPropagation in project strimzi-kafka-operator by strimzi.
the class StatefulSetOperatorTest method testNonCascadingDeleteAsync.
@Test
public void testNonCascadingDeleteAsync(VertxTestContext context) {
Deletable mockDeletable = mock(Deletable.class);
when(mockDeletable.delete()).thenReturn(Boolean.TRUE);
Resource mockERPD = mock(resourceType());
when(mockERPD.withPropagationPolicy(any(DeletionPropagation.class))).thenReturn(mockDeletable);
when(mockERPD.withGracePeriod(anyLong())).thenReturn(mockDeletable);
RollableScalableResource mockRSR = mock(RollableScalableResource.class);
ArgumentCaptor<DeletionPropagation> cascadingCaptor = ArgumentCaptor.forClass(DeletionPropagation.class);
when(mockRSR.withPropagationPolicy(cascadingCaptor.capture())).thenReturn(mockERPD);
ArgumentCaptor<Watcher> watcherCaptor = ArgumentCaptor.forClass(Watcher.class);
when(mockRSR.watch(watcherCaptor.capture())).thenReturn(mock(Watch.class));
NonNamespaceOperation mockNameable = mock(NonNamespaceOperation.class);
when(mockNameable.withName(matches(RESOURCE_NAME))).thenReturn(mockRSR);
MixedOperation mockCms = mock(MixedOperation.class);
when(mockCms.inNamespace(matches(NAMESPACE))).thenReturn(mockNameable);
PodOperator podOperator = mock(PodOperator.class);
PvcOperator pvcOperator = mock(PvcOperator.class);
KubernetesClient mockClient = mock(KubernetesClient.class);
mocker(mockClient, mockCms);
StatefulSetOperator op = new StatefulSetOperator(AbstractResourceOperatorTest.vertx, mockClient, 5_000L, podOperator, pvcOperator) {
@Override
protected boolean shouldIncrementGeneration(Reconciliation reconciliation, StatefulSetDiff diff) {
return true;
}
};
Checkpoint a = context.checkpoint();
op.deleteAsync(new Reconciliation("test", "kind", "namespace", "name"), NAMESPACE, RESOURCE_NAME, false).onComplete(context.succeeding(v -> context.verify(() -> {
assertThat(cascadingCaptor.getValue(), is(DeletionPropagation.ORPHAN));
a.flag();
})));
}
use of io.fabric8.kubernetes.api.model.DeletionPropagation in project strimzi by strimzi.
the class StatefulSetOperatorTest method testCascadingDeleteAsync.
@Test
public void testCascadingDeleteAsync(VertxTestContext context) {
Deletable mockDeletable = mock(Deletable.class);
when(mockDeletable.delete()).thenReturn(Boolean.TRUE);
Resource mockERPD = mock(resourceType());
when(mockERPD.withPropagationPolicy(any(DeletionPropagation.class))).thenReturn(mockDeletable);
when(mockERPD.withGracePeriod(anyLong())).thenReturn(mockDeletable);
RollableScalableResource mockRSR = mock(RollableScalableResource.class);
ArgumentCaptor<DeletionPropagation> cascadingCaptor = ArgumentCaptor.forClass(DeletionPropagation.class);
when(mockRSR.withPropagationPolicy(cascadingCaptor.capture())).thenReturn(mockERPD);
ArgumentCaptor<Watcher> watcherCaptor = ArgumentCaptor.forClass(Watcher.class);
when(mockRSR.watch(watcherCaptor.capture())).thenReturn(mock(Watch.class));
NonNamespaceOperation mockNameable = mock(NonNamespaceOperation.class);
when(mockNameable.withName(matches(RESOURCE_NAME))).thenReturn(mockRSR);
MixedOperation mockCms = mock(MixedOperation.class);
when(mockCms.inNamespace(matches(NAMESPACE))).thenReturn(mockNameable);
PodOperator podOperator = mock(PodOperator.class);
PvcOperator pvcOperator = mock(PvcOperator.class);
KubernetesClient mockClient = mock(KubernetesClient.class);
mocker(mockClient, mockCms);
StatefulSetOperator op = new StatefulSetOperator(AbstractResourceOperatorTest.vertx, mockClient, 5_000L, podOperator, pvcOperator) {
@Override
protected boolean shouldIncrementGeneration(Reconciliation reconciliation, StatefulSetDiff diff) {
return true;
}
};
Checkpoint async = context.checkpoint();
op.deleteAsync(new Reconciliation("test", "kind", "namespace", "name"), NAMESPACE, RESOURCE_NAME, true).onComplete(context.succeeding(v -> context.verify(() -> {
assertThat(cascadingCaptor.getValue(), is(DeletionPropagation.FOREGROUND));
async.flag();
})));
}
use of io.fabric8.kubernetes.api.model.DeletionPropagation in project strimzi-kafka-operator by strimzi.
the class StatefulSetOperatorTest method testCascadingDeleteAsync.
@Test
public void testCascadingDeleteAsync(VertxTestContext context) {
Deletable mockDeletable = mock(Deletable.class);
when(mockDeletable.delete()).thenReturn(Boolean.TRUE);
Resource mockERPD = mock(resourceType());
when(mockERPD.withPropagationPolicy(any(DeletionPropagation.class))).thenReturn(mockDeletable);
when(mockERPD.withGracePeriod(anyLong())).thenReturn(mockDeletable);
RollableScalableResource mockRSR = mock(RollableScalableResource.class);
ArgumentCaptor<DeletionPropagation> cascadingCaptor = ArgumentCaptor.forClass(DeletionPropagation.class);
when(mockRSR.withPropagationPolicy(cascadingCaptor.capture())).thenReturn(mockERPD);
ArgumentCaptor<Watcher> watcherCaptor = ArgumentCaptor.forClass(Watcher.class);
when(mockRSR.watch(watcherCaptor.capture())).thenReturn(mock(Watch.class));
NonNamespaceOperation mockNameable = mock(NonNamespaceOperation.class);
when(mockNameable.withName(matches(RESOURCE_NAME))).thenReturn(mockRSR);
MixedOperation mockCms = mock(MixedOperation.class);
when(mockCms.inNamespace(matches(NAMESPACE))).thenReturn(mockNameable);
PodOperator podOperator = mock(PodOperator.class);
PvcOperator pvcOperator = mock(PvcOperator.class);
KubernetesClient mockClient = mock(KubernetesClient.class);
mocker(mockClient, mockCms);
StatefulSetOperator op = new StatefulSetOperator(AbstractResourceOperatorTest.vertx, mockClient, 5_000L, podOperator, pvcOperator) {
@Override
protected boolean shouldIncrementGeneration(Reconciliation reconciliation, StatefulSetDiff diff) {
return true;
}
};
Checkpoint async = context.checkpoint();
op.deleteAsync(new Reconciliation("test", "kind", "namespace", "name"), NAMESPACE, RESOURCE_NAME, true).onComplete(context.succeeding(v -> context.verify(() -> {
assertThat(cascadingCaptor.getValue(), is(DeletionPropagation.FOREGROUND));
async.flag();
})));
}
Aggregations