Skip to content

Commit

Permalink
e2e test for etcd cluster with empydir storage
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Bortnikov <[email protected]>
  • Loading branch information
aobort committed Jun 20, 2024
1 parent 2ef99ee commit a5f7cb9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
10 changes: 10 additions & 0 deletions examples/manifests/etcdcluster-emptydir.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: etcd.aenix.io/v1alpha1
kind: EtcdCluster
metadata:
name: test
spec:
storage:
emptyDir:
sizeLimit: 1Gi
replicas: 3
51 changes: 50 additions & 1 deletion test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var _ = Describe("etcd-operator", Ordered, func() {

})

if os.Getenv("DO_NOT_CLEANUP_AFTER_E2E") == "true" {
if os.Getenv("DO_CLEANUP_AFTER_E2E") == "true" {
AfterAll(func() {
By("Delete kind environment", func() {
cmd := exec.Command("make", "kind-delete")
Expand Down Expand Up @@ -120,6 +120,55 @@ var _ = Describe("etcd-operator", Ordered, func() {
})
})

Context("With emptyDir", func() {
It("should deploy etcd cluster", func() {
var err error
const namespace = "test-emtydir-etcd-cluster"
var wg sync.WaitGroup
wg.Add(1)

By("create namespace", func() {
cmd := exec.Command("sh", "-c",
fmt.Sprintf("kubectl create namespace %s --dry-run=client -o yaml | kubectl apply -f -", namespace)) // nolint:lll
_, err = utils.Run(cmd)
ExpectWithOffset(1, err).NotTo(HaveOccurred())
})

By("apply etcd cluster with emptydir manifest", func() {
dir, _ := utils.GetProjectDir()
cmd := exec.Command("kubectl", "apply",
"--filename", dir+"/examples/manifests/etcdcluster-emptydir.yaml",
"--namespace", namespace,
)
_, err = utils.Run(cmd)
ExpectWithOffset(1, err).NotTo(HaveOccurred())
})

By("wait for statefulset is ready", func() {
cmd := exec.Command("kubectl", "wait",
"statefulset/test",
"--for", "jsonpath={.status.readyReplicas}=3",
"--namespace", namespace,
"--timeout", "5m",
)
_, err = utils.Run(cmd)
ExpectWithOffset(1, err).NotTo(HaveOccurred())
})

client, err := utils.GetEtcdClient(ctx, client.ObjectKey{Namespace: namespace, Name: "test"})
Expect(err).NotTo(HaveOccurred())
defer func() {
err := client.Close()
Expect(err).NotTo(HaveOccurred())
}()

By("check etcd cluster is healthy", func() {
Expect(utils.IsEtcdClusterHealthy(ctx, client)).To(BeTrue())
})

})
})

Context("TLS and enabled auth", func() {
It("should deploy etcd cluster with auth", func() {
var err error
Expand Down

0 comments on commit a5f7cb9

Please sign in to comment.