Skip to content

Commit dfc4875

Browse files
authored
Merge pull request #582 from oracle/develop-feature-rolling-restart-tests
One more test for rolling restart
2 parents d760c99 + 3183549 commit dfc4875

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,16 @@ public abstract class BaseConfiguration {
4949
private String serverStartPolicy;
5050

5151
/**
52-
* Tells the operator whether the customer wants the to restart the pods. The value is a positive
53-
* integer that customer has to increment, it can be defined in domain, cluster or server.
54-
* Depending on where the value is incremented (domain, cluster or server) the pods assigned to
55-
* such will be restarted.
52+
* Tells the operator whether the customer wants the to restart the pods. The value can be any
53+
* String and it can be defined in domain, cluster or server to restart the different pods. After
54+
* the value is added, the corresponding pods will be terminated and created again, if customer
55+
* modify the value again after the pods were recreated, then pods will again be terminated and
56+
* recreated.
5657
*
5758
* @since 2.0
5859
*/
5960
@Description(
60-
"If preseent, every time this integer value is incremented the operator will restart"
61+
"If preseent, every time this value is updated the operator will restart"
6162
+ " the required servers")
6263
private String restartVersion;
6364

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import static org.hamcrest.Matchers.empty;
1515
import static org.hamcrest.Matchers.equalTo;
1616
import static org.hamcrest.Matchers.hasEntry;
17+
import static org.hamcrest.Matchers.hasKey;
1718
import static org.hamcrest.Matchers.not;
1819
import static org.hamcrest.junit.MatcherAssert.assertThat;
1920

@@ -205,6 +206,14 @@ public void whenExistingAdminPodSpecContainerHasWrongEnvFrom_replaceIt() {
205206
verifyAdminPodReplacedWhen((pod) -> getSpecContainer(pod).envFrom(Collections.emptyList()));
206207
}
207208

209+
@Test
210+
public void whenExistingAdminPodSpecContainerHasRestartVersion_replaceIt() {
211+
verifyAdminPodReplacedWhen(
212+
(pod) ->
213+
pod.getMetadata()
214+
.putLabelsItem(LabelConstants.SERVERRESTARTVERSION_LABEL, "adminRestartV1"));
215+
}
216+
208217
@Test
209218
public void whenAdminPodCreated_specHasPodNameAsHostName() {
210219
assertThat(getCreatedPod().getSpec().getHostname(), equalTo(getPodName()));
@@ -422,11 +431,12 @@ public void whenDomainAndAdminHasRestartVersion_createAdminPodWithRestartVersion
422431
getConfigurator()
423432
.withRestartVersion("domainRestartV1")
424433
.configureAdminServer((ADMIN_SERVER))
425-
.withRestartVersion("adminRestartV1");
434+
.withRestartVersion("adminRestartV1");
426435

427436
Map<String, String> podLabels = getCreatedPod().getMetadata().getLabels();
428437
assertThat(podLabels, hasEntry(LabelConstants.DOMAINRESTARTVERSION_LABEL, "domainRestartV1"));
429438
assertThat(podLabels, hasEntry(LabelConstants.SERVERRESTARTVERSION_LABEL, "adminRestartV1"));
439+
assertThat(podLabels, hasKey(not(LabelConstants.CLUSTERRESTARTVERSION_LABEL)));
430440
}
431441

432442
@Override

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import static org.hamcrest.Matchers.anEmptyMap;
1414
import static org.hamcrest.Matchers.contains;
1515
import static org.hamcrest.Matchers.hasEntry;
16+
import static org.hamcrest.Matchers.hasKey;
1617
import static org.hamcrest.Matchers.not;
1718
import static org.hamcrest.junit.MatcherAssert.assertThat;
1819

@@ -377,6 +378,8 @@ public void whenClusterHasRestartVersion_createManagedPodWithRestartVersionLabel
377378

378379
Map<String, String> podLabels = getCreatedPod().getMetadata().getLabels();
379380
assertThat(podLabels, hasEntry(LabelConstants.CLUSTERRESTARTVERSION_LABEL, "clusterRestartV1"));
381+
assertThat(podLabels, hasKey(not(LabelConstants.DOMAINRESTARTVERSION_LABEL)));
382+
assertThat(podLabels, hasKey(not(LabelConstants.SERVERRESTARTVERSION_LABEL)));
380383
}
381384

382385
@Test
@@ -386,6 +389,8 @@ public void whenDomainHasRestartVersion_createManagedPodWithRestartVersionLabel(
386389

387390
Map<String, String> podLabels = getCreatedPod().getMetadata().getLabels();
388391
assertThat(podLabels, hasEntry(LabelConstants.DOMAINRESTARTVERSION_LABEL, "domainRestartV1"));
392+
assertThat(podLabels, hasKey(not(LabelConstants.CLUSTERRESTARTVERSION_LABEL)));
393+
assertThat(podLabels, hasKey(not(LabelConstants.SERVERRESTARTVERSION_LABEL)));
389394
}
390395

391396
@Test
@@ -479,7 +484,6 @@ public void whenPodHasCustomLabelConflictWithInternal_createManagedPodWithIntern
479484
assertThat(podLabels, hasEntry(LabelConstants.CREATEDBYOPERATOR_LABEL, "true"));
480485
}
481486

482-
@SuppressWarnings("unchecked")
483487
private void verifyRollManagedPodWhen(PodMutator mutator) {
484488
Map<String, StepAndPacket> rolling = new HashMap<>();
485489
testSupport.addToPacket(SERVERS_TO_ROLL, rolling);

0 commit comments

Comments
 (0)