From d89e1293a2455b7b413e42d7b42f028865fbad19 Mon Sep 17 00:00:00 2001 From: Marek Biskup Date: Thu, 11 Jun 2015 19:29:41 +0200 Subject: [PATCH] skip not ready nodes in networking test --- test/e2e/networking.go | 8 ++++++++ test/e2e/util.go | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/test/e2e/networking.go b/test/e2e/networking.go index 10465df6923..2fec16512bc 100644 --- a/test/e2e/networking.go +++ b/test/e2e/networking.go @@ -116,6 +116,14 @@ var _ = Describe("Networking", func() { if err != nil { Failf("Failed to list nodes: %v", err) } + // previous tests may have cause failures of some nodes. Let's skip + // 'Not Ready' nodes, just in case (there is no need to fail the test). + filterNodes(nodes, func(node api.Node) bool { + return isNodeReadySetAsExpected(&node, true) + }) + if len(nodes.Items) < 2 { + Failf("Less than two nodes were found Ready.") + } podNames := LaunchNetTestPodPerNode(f, nodes, svcname, "1.4") diff --git a/test/e2e/util.go b/test/e2e/util.go index 061f4e63fa5..44d2a88e849 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -1145,6 +1145,21 @@ func waitForNodeToBeNotReady(c *client.Client, name string, timeout time.Duratio return waitForNodeToBe(c, name, false, timeout) } +func isNodeReadySetAsExpected(node *api.Node, wantReady bool) bool { + // Check the node readiness condition (logging all). + for i, cond := range node.Status.Conditions { + Logf("Node %s condition %d/%d: type: %v, status: %v", + node.Name, i+1, len(node.Status.Conditions), cond.Type, cond.Status) + // Ensure that the condition type is readiness and the status + // matches as desired. + if cond.Type == api.NodeReady && (cond.Status == api.ConditionTrue) == wantReady { + Logf("Successfully found node %s readiness to be %t", node.Name, wantReady) + return true + } + } + return false +} + // waitForNodeToBe returns whether node name's readiness state matches wantReady // within timeout. If wantReady is true, it will ensure the node is ready; if // it's false, it ensures the node is in any state other than ready (e.g. not @@ -1158,22 +1173,28 @@ func waitForNodeToBe(c *client.Client, name string, wantReady bool, timeout time continue } - // Check the node readiness condition (logging all). - for i, cond := range node.Status.Conditions { - Logf("Node %s condition %d/%d: type: %v, status: %v", - name, i+1, len(node.Status.Conditions), cond.Type, cond.Status) - // Ensure that the condition type is readiness and the status - // matches as desired. - if cond.Type == api.NodeReady && (cond.Status == api.ConditionTrue) == wantReady { - Logf("Successfully found node %s readiness to be %t", name, wantReady) - return true - } + if isNodeReadySetAsExpected(node, wantReady) { + return true } } Logf("Node %s didn't reach desired readiness (%t) within %v", name, wantReady, timeout) return false } +// Filters nodes in NodeList in place, removing nodes that do not +// satisfy the given condition +// TODO: consider merging with pkg/client/cache.NodeLister +func filterNodes(nodeList *api.NodeList, fn func(node api.Node) bool) { + var l []api.Node + + for _, node := range nodeList.Items { + if fn(node) { + l = append(l, node) + } + } + nodeList.Items = l +} + // LatencyMetrics stores data about request latency at a given quantile // broken down by verb (e.g. GET, PUT, LIST) and resource (e.g. pods, services). type LatencyMetric struct {