Return immediately when controllers/pods are committed
Add client waiting conditions.
This commit is contained in:
@@ -37,6 +37,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
@@ -135,7 +136,24 @@ func startComponents(manifestURL string) (apiServerURL string) {
|
||||
return apiServer.URL
|
||||
}
|
||||
|
||||
func runReplicationControllerTest(kubeClient *client.Client) {
|
||||
// podsOnMinions returns true when all of the selected pods exist on a minion.
|
||||
func podsOnMinions(c *client.Client, pods api.PodList) wait.ConditionFunc {
|
||||
podInfo := fakePodInfoGetter{}
|
||||
return func() (bool, error) {
|
||||
for i := range pods.Items {
|
||||
host, id := pods.Items[i].CurrentState.Host, pods.Items[i].ID
|
||||
if len(host) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
if _, err := podInfo.GetPodInfo(host, id); err != nil {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
func runReplicationControllerTest(c *client.Client) {
|
||||
data, err := ioutil.ReadFile("api/examples/controller.json")
|
||||
if err != nil {
|
||||
glog.Fatalf("Unexpected error: %#v", err)
|
||||
@@ -146,20 +164,26 @@ func runReplicationControllerTest(kubeClient *client.Client) {
|
||||
}
|
||||
|
||||
glog.Infof("Creating replication controllers")
|
||||
if _, err := kubeClient.CreateReplicationController(controllerRequest); err != nil {
|
||||
if _, err := c.CreateReplicationController(controllerRequest); err != nil {
|
||||
glog.Fatalf("Unexpected error: %#v", err)
|
||||
}
|
||||
glog.Infof("Done creating replication controllers")
|
||||
|
||||
// Give the controllers some time to actually create the pods
|
||||
time.Sleep(time.Second * 10)
|
||||
|
||||
// Validate that they're truly up.
|
||||
pods, err := kubeClient.ListPods(labels.Set(controllerRequest.DesiredState.ReplicaSelector).AsSelector())
|
||||
if err != nil || len(pods.Items) != controllerRequest.DesiredState.Replicas {
|
||||
glog.Fatalf("FAILED: %#v", pods.Items)
|
||||
if err := wait.Poll(time.Second, 10, c.ControllerHasDesiredReplicas(controllerRequest)); err != nil {
|
||||
glog.Fatalf("FAILED: pods never created %v", err)
|
||||
}
|
||||
glog.Infof("Replication controller produced:\n\n%#v\n\n", pods)
|
||||
|
||||
// wait for minions to indicate they have info about the desired pods
|
||||
pods, err := c.ListPods(labels.Set(controllerRequest.DesiredState.ReplicaSelector).AsSelector())
|
||||
if err != nil {
|
||||
glog.Fatalf("FAILED: unable to get pods to list: %v", err)
|
||||
}
|
||||
if err := wait.Poll(time.Second, 10, podsOnMinions(c, pods)); err != nil {
|
||||
glog.Fatalf("FAILED: pods never started running %v", err)
|
||||
}
|
||||
|
||||
glog.Infof("Pods created")
|
||||
}
|
||||
|
||||
func runAtomicPutTest(c *client.Client) {
|
||||
|
Reference in New Issue
Block a user