Skip to content

Commit

Permalink
allow time for async things to finish in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lllamnyp committed Jun 25, 2024
1 parent 8d5a5e3 commit 384893c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
1 change: 1 addition & 0 deletions internal/controller/etcdcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (r *EtcdClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
if !state.endpointsFound {
if !state.stsExists {
// TODO: happy path for new cluster creation
log.Debug(ctx, "happy path for new cluster creation (not yet implemented)")
}
}

Expand Down
16 changes: 8 additions & 8 deletions internal/controller/observables.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ type etcdStatus struct {
// observables stores observations that the operator can make about
// states of objects in kubernetes
type observables struct {
statefulSet appsv1.StatefulSet
stsExists bool
endpointsFound bool
etcdStatuses []etcdStatus
clusterID uint64
endpointsReached int
pvcs []corev1.PersistentVolumeClaim
statefulSet appsv1.StatefulSet
stsExists bool
endpointsFound bool
etcdStatuses []etcdStatus
clusterID uint64
_ int
_ []corev1.PersistentVolumeClaim
}

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

// TODO: make a real function
func (o *observables) desiredReplicas() int {
func (o *observables) _() int {
if o.etcdStatuses != nil {
for i := range o.etcdStatuses {
if o.etcdStatuses[i].memberList != nil {
Expand Down
34 changes: 32 additions & 2 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"
"os/exec"
"sync"
"time"

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

Eventually(func() error {
cmd := exec.Command("kubectl", "get",
"statefulset/test",
"--namespace", namespace,
)
_, err = utils.Run(cmd)
return err
}, time.Second*20, time.Second*2).Should(Succeed())

By("wait for statefulset is ready", func() {
cmd := exec.Command("kubectl", "wait",
"statefulset/test",
Expand Down Expand Up @@ -144,6 +154,15 @@ var _ = Describe("etcd-operator", Ordered, func() {
ExpectWithOffset(1, err).NotTo(HaveOccurred())
})

Eventually(func() error {
cmd := exec.Command("kubectl", "get",
"statefulset/test",
"--namespace", namespace,
)
_, err = utils.Run(cmd)
return err
}, time.Second*20, time.Second*2).Should(Succeed())

By("wait for statefulset is ready", func() {
cmd := exec.Command("kubectl", "wait",
"statefulset/test",
Expand Down Expand Up @@ -192,6 +211,15 @@ var _ = Describe("etcd-operator", Ordered, func() {
ExpectWithOffset(1, err).NotTo(HaveOccurred())
})

Eventually(func() error {
cmd := exec.Command("kubectl", "get",
"statefulset/test",
"--namespace", namespace,
)
_, err = utils.Run(cmd)
return err
}, time.Second*20, time.Second*2).Should(Succeed())

By("wait for statefulset is ready", func() {
cmd := exec.Command("kubectl", "wait",
"statefulset/test",
Expand All @@ -217,8 +245,10 @@ var _ = Describe("etcd-operator", Ordered, func() {
auth := clientv3.NewAuth(client)

By("check root role is created", func() {
_, err = auth.RoleGet(ctx, "root")
Expect(err).NotTo(HaveOccurred())
Eventually(func() error {
_, err = auth.RoleGet(ctx, "root")
return err
}, time.Second*20, time.Second*2).Should(Succeed())
})

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

0 comments on commit 384893c

Please sign in to comment.