Skip to content

Commit 384893c

Browse files
committed
allow time for async things to finish in e2e tests
1 parent 8d5a5e3 commit 384893c

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

internal/controller/etcdcluster_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func (r *EtcdClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
111111
if !state.endpointsFound {
112112
if !state.stsExists {
113113
// TODO: happy path for new cluster creation
114+
log.Debug(ctx, "happy path for new cluster creation (not yet implemented)")
114115
}
115116
}
116117

internal/controller/observables.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ type etcdStatus struct {
2222
// observables stores observations that the operator can make about
2323
// states of objects in kubernetes
2424
type observables struct {
25-
statefulSet appsv1.StatefulSet
26-
stsExists bool
27-
endpointsFound bool
28-
etcdStatuses []etcdStatus
29-
clusterID uint64
30-
endpointsReached int
31-
pvcs []corev1.PersistentVolumeClaim
25+
statefulSet appsv1.StatefulSet
26+
stsExists bool
27+
endpointsFound bool
28+
etcdStatuses []etcdStatus
29+
clusterID uint64
30+
_ int
31+
_ []corev1.PersistentVolumeClaim
3232
}
3333

3434
// setClusterID populates the clusterID field based on etcdStatuses
@@ -68,7 +68,7 @@ func (s *etcdStatus) fill(ctx context.Context, c *clientv3.Client) {
6868
}
6969

7070
// TODO: make a real function
71-
func (o *observables) desiredReplicas() int {
71+
func (o *observables) _() int {
7272
if o.etcdStatuses != nil {
7373
for i := range o.etcdStatuses {
7474
if o.etcdStatuses[i].memberList != nil {

test/e2e/e2e_test.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"os"
2222
"os/exec"
2323
"sync"
24+
"time"
2425

2526
. "github.com/onsi/ginkgo/v2"
2627
. "github.com/onsi/gomega"
@@ -95,6 +96,15 @@ var _ = Describe("etcd-operator", Ordered, func() {
9596
ExpectWithOffset(1, err).NotTo(HaveOccurred())
9697
})
9798

99+
Eventually(func() error {
100+
cmd := exec.Command("kubectl", "get",
101+
"statefulset/test",
102+
"--namespace", namespace,
103+
)
104+
_, err = utils.Run(cmd)
105+
return err
106+
}, time.Second*20, time.Second*2).Should(Succeed())
107+
98108
By("wait for statefulset is ready", func() {
99109
cmd := exec.Command("kubectl", "wait",
100110
"statefulset/test",
@@ -144,6 +154,15 @@ var _ = Describe("etcd-operator", Ordered, func() {
144154
ExpectWithOffset(1, err).NotTo(HaveOccurred())
145155
})
146156

157+
Eventually(func() error {
158+
cmd := exec.Command("kubectl", "get",
159+
"statefulset/test",
160+
"--namespace", namespace,
161+
)
162+
_, err = utils.Run(cmd)
163+
return err
164+
}, time.Second*20, time.Second*2).Should(Succeed())
165+
147166
By("wait for statefulset is ready", func() {
148167
cmd := exec.Command("kubectl", "wait",
149168
"statefulset/test",
@@ -192,6 +211,15 @@ var _ = Describe("etcd-operator", Ordered, func() {
192211
ExpectWithOffset(1, err).NotTo(HaveOccurred())
193212
})
194213

214+
Eventually(func() error {
215+
cmd := exec.Command("kubectl", "get",
216+
"statefulset/test",
217+
"--namespace", namespace,
218+
)
219+
_, err = utils.Run(cmd)
220+
return err
221+
}, time.Second*20, time.Second*2).Should(Succeed())
222+
195223
By("wait for statefulset is ready", func() {
196224
cmd := exec.Command("kubectl", "wait",
197225
"statefulset/test",
@@ -217,8 +245,10 @@ var _ = Describe("etcd-operator", Ordered, func() {
217245
auth := clientv3.NewAuth(client)
218246

219247
By("check root role is created", func() {
220-
_, err = auth.RoleGet(ctx, "root")
221-
Expect(err).NotTo(HaveOccurred())
248+
Eventually(func() error {
249+
_, err = auth.RoleGet(ctx, "root")
250+
return err
251+
}, time.Second*20, time.Second*2).Should(Succeed())
222252
})
223253

224254
By("check root user is created and has root role", func() {

0 commit comments

Comments
 (0)