Skip to content

Commit a5f7cb9

Browse files
committed
e2e test for etcd cluster with empydir storage
Signed-off-by: Artem Bortnikov <[email protected]>
1 parent 2ef99ee commit a5f7cb9

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
apiVersion: etcd.aenix.io/v1alpha1
3+
kind: EtcdCluster
4+
metadata:
5+
name: test
6+
spec:
7+
storage:
8+
emptyDir:
9+
sizeLimit: 1Gi
10+
replicas: 3

test/e2e/e2e_test.go

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var _ = Describe("etcd-operator", Ordered, func() {
6262

6363
})
6464

65-
if os.Getenv("DO_NOT_CLEANUP_AFTER_E2E") == "true" {
65+
if os.Getenv("DO_CLEANUP_AFTER_E2E") == "true" {
6666
AfterAll(func() {
6767
By("Delete kind environment", func() {
6868
cmd := exec.Command("make", "kind-delete")
@@ -120,6 +120,55 @@ var _ = Describe("etcd-operator", Ordered, func() {
120120
})
121121
})
122122

123+
Context("With emptyDir", func() {
124+
It("should deploy etcd cluster", func() {
125+
var err error
126+
const namespace = "test-emtydir-etcd-cluster"
127+
var wg sync.WaitGroup
128+
wg.Add(1)
129+
130+
By("create namespace", func() {
131+
cmd := exec.Command("sh", "-c",
132+
fmt.Sprintf("kubectl create namespace %s --dry-run=client -o yaml | kubectl apply -f -", namespace)) // nolint:lll
133+
_, err = utils.Run(cmd)
134+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
135+
})
136+
137+
By("apply etcd cluster with emptydir manifest", func() {
138+
dir, _ := utils.GetProjectDir()
139+
cmd := exec.Command("kubectl", "apply",
140+
"--filename", dir+"/examples/manifests/etcdcluster-emptydir.yaml",
141+
"--namespace", namespace,
142+
)
143+
_, err = utils.Run(cmd)
144+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
145+
})
146+
147+
By("wait for statefulset is ready", func() {
148+
cmd := exec.Command("kubectl", "wait",
149+
"statefulset/test",
150+
"--for", "jsonpath={.status.readyReplicas}=3",
151+
"--namespace", namespace,
152+
"--timeout", "5m",
153+
)
154+
_, err = utils.Run(cmd)
155+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
156+
})
157+
158+
client, err := utils.GetEtcdClient(ctx, client.ObjectKey{Namespace: namespace, Name: "test"})
159+
Expect(err).NotTo(HaveOccurred())
160+
defer func() {
161+
err := client.Close()
162+
Expect(err).NotTo(HaveOccurred())
163+
}()
164+
165+
By("check etcd cluster is healthy", func() {
166+
Expect(utils.IsEtcdClusterHealthy(ctx, client)).To(BeTrue())
167+
})
168+
169+
})
170+
})
171+
123172
Context("TLS and enabled auth", func() {
124173
It("should deploy etcd cluster with auth", func() {
125174
var err error

0 commit comments

Comments
 (0)