Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Add more descriptions to wait loops #383

Merged
merged 1 commit into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/integration/harness/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ func (h *TestHarness) WaitForHasLeader(nodes ...*TestHarnessNode) {

func (h *TestHarness) WaitForVersion(timeout time.Duration, expectedVersion string, nodes ...*TestHarnessNode) {
for _, n := range nodes {
h.WaitFor(timeout, func() error {
description := fmt.Sprintf("wait for node %s to have version %q", n.Address, expectedVersion)
h.WaitFor(timeout, description, func() error {
client, err := n.NewClient()
if err != nil {
return fmt.Errorf("error building etcd client: %v", err)
Expand Down
9 changes: 6 additions & 3 deletions test/integration/harness/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (n *TestHarnessNode) WaitForListMembers(timeout time.Duration) {
}
}

func (h *TestHarness) WaitFor(timeout time.Duration, f func() error) {
func (h *TestHarness) WaitFor(timeout time.Duration, description string, f func() error) {
t := h.T

deadline := time.Now().Add(timeout)
Expand All @@ -120,10 +120,13 @@ func (h *TestHarness) WaitFor(timeout time.Duration, f func() error) {
return
}

// We also log to klog, so that it appears in the test output.
if time.Now().After(deadline) {
t.Fatalf("time out waiting for condition: %v", err)
klog.Errorf("time out waiting for condition %q: %v", description, err)
t.Fatalf("time out waiting for condition %q: %v", description, err)
} else {
t.Logf("waiting for condition: %v", err)
klog.Infof("waiting for condition %q: %v", description, err)
t.Logf("waiting for condition %q: %v", description, err)
}

time.Sleep(time.Second)
Expand Down
6 changes: 4 additions & 2 deletions test/integration/harness/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ func (n *TestHarnessNode) AssertVersion(t *testing.T, version string) {
}

func (n *TestHarnessNode) WaitForHealthy(timeout time.Duration) {
n.TestHarness.WaitFor(timeout, func() error {
description := fmt.Sprintf("wait for node %s to be healthy", n.Address)
n.TestHarness.WaitFor(timeout, description, func() error {
client, err := n.NewClient()
if err != nil {
return fmt.Errorf("error building etcd client: %v", err)
Expand All @@ -302,7 +303,8 @@ func (n *TestHarnessNode) WaitForHealthy(timeout time.Duration) {
}

func (n *TestHarnessNode) WaitForHasLeader(timeout time.Duration) {
n.TestHarness.WaitFor(timeout, func() error {
description := fmt.Sprintf("wait for node %s to have a leader", n.Address)
n.TestHarness.WaitFor(timeout, description, func() error {
client, err := n.NewClient()
if err != nil {
return fmt.Errorf("error building etcd client: %v", err)
Expand Down
3 changes: 2 additions & 1 deletion test/integration/secure_transitions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ func TestEnableTLS(t *testing.T) {
h.WaitForHealthy(nodes[0])

for i, n := range nodes {
h.WaitFor(120*time.Second, func() error {
description := fmt.Sprintf("wait for node %s to restart and settle", n.Address)
h.WaitFor(120*time.Second, description, func() error {
members, err := n.ListMembers(ctx)
if err != nil {
return fmt.Errorf("error doing etcd ListMembers: %v", err)
Expand Down