|
12 | 12 | import io.fabric8.kubernetes.client.KubernetesClient;
|
13 | 13 | import io.fabric8.kubernetes.client.dsl.MixedOperation;
|
14 | 14 | import io.fabric8.kubernetes.client.dsl.Resource;
|
| 15 | +import io.strimzi.operator.common.Reconciliation; |
15 | 16 | import io.vertx.core.Vertx;
|
16 | 17 | import org.junit.jupiter.api.Test;
|
17 | 18 |
|
18 | 19 | import java.util.Collections;
|
| 20 | +import java.util.Map; |
19 | 21 |
|
20 | 22 | import static org.hamcrest.CoreMatchers.is;
|
21 | 23 | import static org.hamcrest.MatcherAssert.assertThat;
|
@@ -103,4 +105,34 @@ public void testRevertingImmutableFields() {
|
103 | 105 | assertThat(current.getSpec().getSelector(), is(desired.getSpec().getSelector()));
|
104 | 106 | assertThat(current.getSpec().getVolumeName(), is(desired.getSpec().getVolumeName()));
|
105 | 107 | }
|
| 108 | + |
| 109 | + @Test |
| 110 | + public void testIgnoredAnnotationsInDiff() { |
| 111 | + PersistentVolumeClaim pvcWithDefaultAnnos = new PersistentVolumeClaimBuilder(resource("my-pvc")) |
| 112 | + .editMetadata() |
| 113 | + .withAnnotations(Map.of("strimzi.io/delete-claim", "false")) |
| 114 | + .endMetadata() |
| 115 | + .build(); |
| 116 | + PersistentVolumeClaim pvcWithOtherAnnos = new PersistentVolumeClaimBuilder(pvcWithDefaultAnnos) |
| 117 | + .editMetadata() |
| 118 | + .withAnnotations(Map.of("strimzi.io/delete-claim", "false", |
| 119 | + "pv.kubernetes.io/bound-by-controller", "my-controller", |
| 120 | + "some.annotation.io/key", "value")) |
| 121 | + .endMetadata() |
| 122 | + .build(); |
| 123 | + PersistentVolumeClaim pvcWithIgnoredAnnos = new PersistentVolumeClaimBuilder(pvcWithDefaultAnnos) |
| 124 | + .editMetadata() |
| 125 | + .withAnnotations(Map.of("strimzi.io/delete-claim", "false", |
| 126 | + "pv.kubernetes.io/bound-by-controller", "my-controller", |
| 127 | + "volume.beta.kubernetes.io/storage-provisioner", "my-provisioner", |
| 128 | + "volume.kubernetes.io/storage-resizer", "my-resizer")) |
| 129 | + .endMetadata() |
| 130 | + .build(); |
| 131 | + |
| 132 | + PvcOperator op = createResourceOperations(vertx, mock(KubernetesClient.class)); |
| 133 | + |
| 134 | + assertThat(op.diff(Reconciliation.DUMMY_RECONCILIATION, "my-pvc", pvcWithDefaultAnnos, pvcWithDefaultAnnos).isEmpty(), is(true)); |
| 135 | + assertThat(op.diff(Reconciliation.DUMMY_RECONCILIATION, "my-pvc", pvcWithDefaultAnnos, pvcWithIgnoredAnnos).isEmpty(), is(true)); |
| 136 | + assertThat(op.diff(Reconciliation.DUMMY_RECONCILIATION, "my-pvc", pvcWithDefaultAnnos, pvcWithOtherAnnos).isEmpty(), is(false)); |
| 137 | + } |
106 | 138 | }
|
0 commit comments