mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Check whether all nodes are healthy in e2e framework
This commit is contained in:
parent
73cb04ad6b
commit
54f2305dec
@ -85,6 +85,11 @@ func (f *Framework) afterEach() {
|
|||||||
// you may or may not see the killing/deletion/cleanup events.
|
// you may or may not see the killing/deletion/cleanup events.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check whether all nodes are ready after the test.
|
||||||
|
if err := allNodesReady(f.Client); err != nil {
|
||||||
|
Failf("All nodes should be ready after test, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
By(fmt.Sprintf("Destroying namespace %q for this suite.", f.Namespace.Name))
|
By(fmt.Sprintf("Destroying namespace %q for this suite.", f.Namespace.Name))
|
||||||
if err := f.Client.Namespaces().Delete(f.Namespace.Name); err != nil {
|
if err := f.Client.Namespaces().Delete(f.Namespace.Name); err != nil {
|
||||||
Failf("Couldn't delete ns %q: %s", f.Namespace.Name, err)
|
Failf("Couldn't delete ns %q: %s", f.Namespace.Name, err)
|
||||||
|
@ -412,6 +412,10 @@ var _ = Describe("Nodes", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
By("checking whether all nodes are healthy")
|
||||||
|
if err := allNodesReady(c); err != nil {
|
||||||
|
Failf("Not all nodes are ready: %v", err)
|
||||||
|
}
|
||||||
By(fmt.Sprintf("destroying namespace for this suite %s", ns))
|
By(fmt.Sprintf("destroying namespace for this suite %s", ns))
|
||||||
if err := c.Namespaces().Delete(ns); err != nil {
|
if err := c.Namespaces().Delete(ns); err != nil {
|
||||||
Failf("Couldn't delete namespace '%s', %v", ns, err)
|
Failf("Couldn't delete namespace '%s', %v", ns, err)
|
||||||
|
@ -1461,6 +1461,22 @@ func waitForNodeToBe(c *client.Client, name string, wantReady bool, timeout time
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checks whether all registered nodes are ready
|
||||||
|
func allNodesReady(c *client.Client) error {
|
||||||
|
nodes, err := c.Nodes().List(labels.Everything(), fields.Everything())
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
var notReady []api.Node
|
||||||
|
for _, node := range nodes.Items {
|
||||||
|
if isNodeReadySetAsExpected(&node, false) {
|
||||||
|
notReady = append(notReady, node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(notReady) > 0 {
|
||||||
|
return fmt.Errorf("Not ready nodes: %v", notReady)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Filters nodes in NodeList in place, removing nodes that do not
|
// Filters nodes in NodeList in place, removing nodes that do not
|
||||||
// satisfy the given condition
|
// satisfy the given condition
|
||||||
// TODO: consider merging with pkg/client/cache.NodeLister
|
// TODO: consider merging with pkg/client/cache.NodeLister
|
||||||
|
Loading…
Reference in New Issue
Block a user