Merge pull request #27561 from nikhiljindal/fixFedTest

Automatic merge from submit-queue

Adding a wait for federation apiserver to be ready in e2e tests

Ref #26762

@kubernetes/sig-cluster-federation @mml
This commit is contained in:
k8s-merge-robot 2016-06-16 17:10:05 -07:00 committed by GitHub
commit d82f3bf305
2 changed files with 16 additions and 0 deletions

View File

@ -177,6 +177,10 @@ func (f *Framework) BeforeEach() {
f.FederationClientset_1_3, err = LoadFederationClientset_1_3()
Expect(err).NotTo(HaveOccurred())
}
By("Waiting for federation-apiserver to be ready")
err := WaitForFederationApiserverReady(f.FederationClientset)
Expect(err).NotTo(HaveOccurred())
By("federation-apiserver is ready")
}
By("Building a namespace api object")

View File

@ -837,6 +837,18 @@ func WaitForDefaultServiceAccountInNamespace(c *client.Client, namespace string)
return waitForServiceAccountInNamespace(c, namespace, "default", ServiceAccountProvisionTimeout)
}
// WaitForFederationApiserverReady waits for the federation apiserver to be ready.
// It tests the readiness by sending a GET request and expecting a non error response.
func WaitForFederationApiserverReady(c *federation_internalclientset.Clientset) error {
return wait.PollImmediate(time.Second, 1*time.Minute, func() (bool, error) {
_, err := c.Federation().Clusters().List(api.ListOptions{})
if err != nil {
return false, nil
}
return true, nil
})
}
// WaitForPersistentVolumePhase waits for a PersistentVolume to be in a specific phase or until timeout occurs, whichever comes first.
func WaitForPersistentVolumePhase(phase api.PersistentVolumePhase, c *client.Client, pvName string, Poll, timeout time.Duration) error {
Logf("Waiting up to %v for PersistentVolume %s to have phase %s", timeout, pvName, phase)