-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make StatefulSet updateStrategy configurable (#845)
* Make updateStrategy configurable * Update docs --------- Co-authored-by: Yevhen Ivantsov <[email protected]>
- Loading branch information
Showing
24 changed files
with
185 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package test; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.TestInfo; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
import test.helm.Helm; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import test.model.Product; | ||
import test.model.StatefulSet; | ||
|
||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static test.jackson.JsonNodeAssert.assertThat; | ||
|
||
public class StatefulSetUpdateTest { | ||
|
||
private Helm helm; | ||
|
||
@BeforeEach | ||
void initHelm(TestInfo testInfo) { | ||
helm = new Helm(testInfo); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE) | ||
void sts_on_delete_update(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( | ||
"statefulSet.updateStrategy.type", "OnDelete" | ||
)); | ||
StatefulSet sts = resources.getStatefulSet(product.getHelmReleaseName()); | ||
JsonNode updateStrategy = sts.getSpec().path("updateStrategy").path("type"); | ||
assertEquals("OnDelete", updateStrategy.asText()); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE) | ||
void sts_on_not_set(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of()); | ||
StatefulSet sts = resources.getStatefulSet(product.getHelmReleaseName()); | ||
JsonNode updateStrategy = sts.getSpec().path("updateStrategy").path("type"); | ||
assertThat(updateStrategy).isEmpty(); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"confluence"}, mode = EnumSource.Mode.INCLUDE) | ||
void sts_on_delete_update_synchrony(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( | ||
"statefulSet.updateStrategy.type", "OnDelete", | ||
"synchrony.enabled", "true" | ||
)); | ||
StatefulSet sts = resources.getStatefulSet(product.getHelmReleaseName() + "-synchrony"); | ||
JsonNode updateStrategy = sts.getSpec().path("updateStrategy").path("type"); | ||
assertEquals("OnDelete", updateStrategy.asText()); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"confluence"}, mode = EnumSource.Mode.INCLUDE) | ||
void sts_on_not_set_synchrony(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( | ||
"synchrony.enabled", "true" | ||
)); | ||
StatefulSet sts = resources.getStatefulSet(product.getHelmReleaseName() + "-synchrony"); | ||
JsonNode updateStrategy = sts.getSpec().path("updateStrategy").path("type"); | ||
assertThat(updateStrategy).isEmpty(); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"bitbucket"}, mode = EnumSource.Mode.INCLUDE) | ||
void sts_on_delete_update_mesh(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( | ||
"statefulSet.updateStrategy.type", "OnDelete", | ||
"bitbucket.mesh.enabled", "true" | ||
)); | ||
StatefulSet sts = resources.getStatefulSet(product.getHelmReleaseName() + "-mesh"); | ||
JsonNode updateStrategy = sts.getSpec().path("updateStrategy").path("type"); | ||
assertEquals("OnDelete", updateStrategy.asText()); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = Product.class, names = {"bitbucket"}, mode = EnumSource.Mode.INCLUDE) | ||
void sts_on_not_set_mesh(Product product) throws Exception { | ||
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( | ||
"bitbucket.mesh.enabled", "true" | ||
)); | ||
StatefulSet sts = resources.getStatefulSet(product.getHelmReleaseName() + "-mesh"); | ||
JsonNode updateStrategy = sts.getSpec().path("updateStrategy").path("type"); | ||
assertThat(updateStrategy).isEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.