Skip to content

Commit dfc5397

Browse files
committed
Added oracle.kubernetes.weblogic.domain.v2.Cluster#fillInFrom; Added tests related to replacing a service if its label/annotation changes.
1 parent 60c094c commit dfc5397

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/Cluster.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ void setMaxUnavailable(Integer maxUnavailable) {
127127
this.maxUnavailable = maxUnavailable;
128128
}
129129

130+
void fillInFrom(Cluster other) {
131+
if (other == null) {
132+
return;
133+
}
134+
super.fillInFrom(other);
135+
clusterService.fillInFrom(other.clusterService);
136+
}
137+
130138
@Override
131139
public String toString() {
132140
return new ToStringBuilder(this)

operator/src/test/java/oracle/kubernetes/operator/helpers/ServiceHelperTest.java

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,45 @@ public void onClusterStepRunWithServiceWithBadPort_replaceIt() {
291291
verifyClusterServiceReplaced(this::withBadPort);
292292
}
293293

294-
// TODO: oracle.kubernetes.weblogic.domain.v2.Cluster.getConfiguration is broken. Doesn't fill in
295-
// Cluster#clusterService.
296-
// @Test
294+
@Test
297295
public void onClusterStepRunWithServiceWithLabelAdded_replaceIt() {
298296
configureClusterWithLabel("anyLabel", "anyValue");
299297
verifyClusterServiceReplaced(createClusterService(), withLabel(createClusterService()));
300298
}
301299

300+
@Test
301+
public void onClusterStepRunWithServiceWithLabelValueChanged_replaceIt() {
302+
final String newLabelValue = "newValue";
303+
configureClusterWithLabel("anyLabel", newLabelValue);
304+
verifyClusterServiceReplaced(
305+
withLabel(createClusterService()), withLabel(createClusterService(), newLabelValue));
306+
}
307+
308+
@Test
309+
public void onClusterStepRunWithServiceWithLabelRemoved_replaceIt() {
310+
verifyClusterServiceReplaced(this::withLabel);
311+
}
312+
313+
@Test
314+
public void onClusterStepRunWithServiceWithAnnotationAdded_replaceIt() {
315+
configureClusterWithAnnotation("anyAnnotation", "anyValue");
316+
verifyClusterServiceReplaced(createClusterService(), withAnnotation(createClusterService()));
317+
}
318+
319+
@Test
320+
public void onClusterStepRunWithServiceWithAnnotationValueChanged_replaceIt() {
321+
final String newAnnotationValue = "newValue";
322+
configureClusterWithAnnotation("anyAnnotation", newAnnotationValue);
323+
verifyClusterServiceReplaced(
324+
withAnnotation(createClusterService()),
325+
withAnnotation(createClusterService(), newAnnotationValue));
326+
}
327+
328+
@Test
329+
public void onClusterStepRunWithServiceWithAnnotationRemoved_replaceIt() {
330+
verifyClusterServiceReplaced(this::withAnnotation);
331+
}
332+
302333
@Test
303334
public void whenAttemptToReplaceBadClusterServiceFailsOnDelete_reportCompletionFailure() {
304335
V1Service existingService = createClusterServiceWithBadPort();
@@ -759,6 +790,10 @@ private void configureClusterWithLabel(String label, String value) {
759790
configureDomain().configureCluster(TEST_CLUSTER).withServiceLabel(label, value);
760791
}
761792

793+
private void configureClusterWithAnnotation(String annotation, String value) {
794+
configureDomain().configureCluster(TEST_CLUSTER).withServiceAnnotation(annotation, value);
795+
}
796+
762797
private void configureManagedServerWithLabel(String label, String value) {
763798
configureDomain().configureServer(TEST_SERVER_NAME).withServiceLabel(label, value);
764799
}

0 commit comments

Comments
 (0)