mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Wait for node ready before the node e2e test started.
This commit is contained in:
parent
1de858290d
commit
cb760a6ed4
@ -31,6 +31,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
commontest "k8s.io/kubernetes/test/e2e/common"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
|
||||
@ -118,6 +120,9 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
||||
glog.Infof("Running tests without starting services.")
|
||||
}
|
||||
|
||||
glog.Infof("Wait for the node to be ready")
|
||||
waitForNodeReady()
|
||||
|
||||
// Reference common test to make the import valid.
|
||||
commontest.CurrentSuite = commontest.NodeE2E
|
||||
|
||||
@ -160,3 +165,32 @@ func maskLocksmithdOnCoreos() {
|
||||
glog.Infof("Locksmithd is masked successfully")
|
||||
}
|
||||
}
|
||||
|
||||
func waitForNodeReady() {
|
||||
const (
|
||||
// nodeReadyTimeout is the time to wait for node to become ready.
|
||||
nodeReadyTimeout = 2 * time.Minute
|
||||
// nodeReadyPollInterval is the interval to check node ready.
|
||||
nodeReadyPollInterval = 1 * time.Second
|
||||
)
|
||||
config, err := framework.LoadConfig()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
client, err := clientset.NewForConfig(config)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Eventually(func() error {
|
||||
nodes, err := client.Nodes().List(api.ListOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
if nodes == nil {
|
||||
return fmt.Errorf("the node list is nil.")
|
||||
}
|
||||
Expect(len(nodes.Items) > 1).NotTo(BeTrue())
|
||||
if len(nodes.Items) == 0 {
|
||||
return fmt.Errorf("empty node list: %+v", nodes)
|
||||
}
|
||||
node := nodes.Items[0]
|
||||
if !api.IsNodeReady(&node) {
|
||||
return fmt.Errorf("node is not ready: %+v", node)
|
||||
}
|
||||
return nil
|
||||
}, nodeReadyTimeout, nodeReadyPollInterval).Should(Succeed())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user