From 2777c8ddc699190f0edc2b5864337487ffd94d3c Mon Sep 17 00:00:00 2001 From: Wojciech Tyczynski Date: Wed, 8 Jun 2016 15:00:08 +0200 Subject: [PATCH] Extend logging for UnschedulableNodes --- test/integration/scheduler_test.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/test/integration/scheduler_test.go b/test/integration/scheduler_test.go index 1daee74117f..ff7b64b44e9 100644 --- a/test/integration/scheduler_test.go +++ b/test/integration/scheduler_test.go @@ -103,13 +103,23 @@ func podScheduled(c *client.Client, podNamespace, podName string) wait.Condition // Wait till the passFunc confirms that the object it expects to see is in the store. // Used to observe reflected events. -func waitForReflection(s cache.Store, key string, passFunc func(n interface{}) bool) error { - return wait.Poll(time.Millisecond*10, time.Second*20, func() (bool, error) { +func waitForReflection(t *testing.T, s cache.Store, key string, passFunc func(n interface{}) bool) error { + nodes := []*api.Node{} + err := wait.Poll(time.Millisecond*100, wait.ForeverTestTimeout, func() (bool, error) { if n, _, err := s.GetByKey(key); err == nil && passFunc(n) { return true, nil + } else { + nodes = append(nodes, n.(*api.Node)) + return false, nil } - return false, nil }) + if err != nil { + t.Logf("Logging consecutive node versions received from store:") + for i, n := range nodes { + t.Logf("%d: %#v", i, n) + } + } + return err } func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore cache.Store) { @@ -159,7 +169,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore if _, err := c.Nodes().Update(n); err != nil { t.Fatalf("Failed to update node with unschedulable=true: %v", err) } - err = waitForReflection(s, nodeKey, func(node interface{}) bool { + err = waitForReflection(t, s, nodeKey, func(node interface{}) bool { // An unschedulable node should get deleted from the store return node == nil }) @@ -172,7 +182,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore if _, err := c.Nodes().Update(n); err != nil { t.Fatalf("Failed to update node with unschedulable=false: %v", err) } - err = waitForReflection(s, nodeKey, func(node interface{}) bool { + err = waitForReflection(t, s, nodeKey, func(node interface{}) bool { return node != nil && node.(*api.Node).Spec.Unschedulable == false }) if err != nil { @@ -192,7 +202,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore if _, err = c.Nodes().UpdateStatus(n); err != nil { t.Fatalf("Failed to update node with bad status condition: %v", err) } - err = waitForReflection(s, nodeKey, func(node interface{}) bool { + err = waitForReflection(t, s, nodeKey, func(node interface{}) bool { return node != nil && node.(*api.Node).Status.Conditions[0].Status == api.ConditionUnknown }) if err != nil { @@ -209,7 +219,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore if _, err = c.Nodes().UpdateStatus(n); err != nil { t.Fatalf("Failed to update node with healthy status condition: %v", err) } - waitForReflection(s, nodeKey, func(node interface{}) bool { + err = waitForReflection(t, s, nodeKey, func(node interface{}) bool { return node != nil && node.(*api.Node).Status.Conditions[0].Status == api.ConditionTrue }) if err != nil {