Skip to content

Commit

Permalink
Add pvc template update e2e tests.
Browse files Browse the repository at this point in the history
Signed-off-by: d-kuro <[email protected]>
  • Loading branch information
d-kuro committed Aug 14, 2024
1 parent 61123fc commit ddae9eb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
36 changes: 36 additions & 0 deletions e2e/partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ var forceRollingUpdateApplyYAML string
//go:embed testdata/partition_image_pull_backoff.yaml
var imagePullBackoffApplyYAML string

//go:embed testdata/partition_volume_template.yaml
var volumeTemplateApplyYAML string

var _ = Context("partition_test", func() {
if doUpgrade {
return
Expand Down Expand Up @@ -160,6 +163,39 @@ var _ = Context("partition_test", func() {
Expect(updatedReplicasMetric.GetGauge().GetValue()).To(BeNumerically(">", 0))
})

It("should volume template change succeed", func() {
// add label for pvc
kubectlSafe(fillTemplate(volumeTemplateApplyYAML), "apply", "-f", "-")
Eventually(func() error {
cluster, err := getCluster("partition", "test")
if err != nil {
return err
}
for _, cond := range cluster.Status.Conditions {
if cond.Type != mocov1beta2.ConditionHealthy {
continue
}
if cond.Status == metav1.ConditionTrue {
return nil
}
return fmt.Errorf("cluster is not healthy: %s", cond.Status)
}

return errors.New("no health condition")
}).WithTimeout(time.Minute * 10).Should(Succeed())
})

It("should recreate statefulset", func() {
out, err := kubectl(nil, "get", "-n", "partition", "statefulset", "moco-test", "-o", "json")
Expect(err).NotTo(HaveOccurred())
sts := &appsv1.StatefulSet{}
err = json.Unmarshal(out, sts)
Expect(err).NotTo(HaveOccurred())
Expect(sts.Spec.UpdateStrategy.RollingUpdate).NotTo(BeNil())
Expect(*sts.Spec.UpdateStrategy.RollingUpdate.Partition).To(Equal(int32(0)))
Expect(sts.Spec.VolumeClaimTemplates[0].Labels["foo"]).To(Equal("bar"))
})

It("should image pull backoff", func() {
kubectlSafe(fillTemplate(imagePullBackoffApplyYAML), "apply", "-f", "-")
Eventually(func() error {
Expand Down
25 changes: 25 additions & 0 deletions e2e/testdata/partition_volume_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: moco.cybozu.com/v1beta2
kind: MySQLCluster
metadata:
namespace: partition
name: test
spec:
replicas: 3
podTemplate:
spec:
containers:
- name: mysqld
image: ghcr.io/cybozu-go/moco/mysql:{{ . }}
resources:
requests:
cpu: 1m
volumeClaimTemplates:
- metadata:
name: mysql-data
labels:
foo: bar
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi

0 comments on commit ddae9eb

Please sign in to comment.