Пример #1
0
// can not be moved to util, as By and Expect must be put in Ginkgo test unit
func registerClusters(clusters map[string]*cluster, userAgentName, federationName string, f *framework.Framework) string {
	contexts := f.GetUnderlyingFederatedContexts()

	for _, context := range contexts {
		createClusterObjectOrFail(f, &context)
	}

	By("Obtaining a list of all the clusters")
	clusterList := waitForAllClustersReady(f, len(contexts))

	framework.Logf("Checking that %d clusters are Ready", len(contexts))
	for _, context := range contexts {
		clusterIsReadyOrFail(f, &context)
	}
	framework.Logf("%d clusters are Ready", len(contexts))

	primaryClusterName := clusterList.Items[0].Name
	By(fmt.Sprintf("Labeling %q as the first cluster", primaryClusterName))
	for i, c := range clusterList.Items {
		framework.Logf("Creating a clientset for the cluster %s", c.Name)
		Expect(framework.TestContext.KubeConfig).ToNot(Equal(""), "KubeConfig must be specified to load clusters' client config")
		clusters[c.Name] = &cluster{c.Name, createClientsetForCluster(c, i, userAgentName), false, nil}
	}
	createNamespaceInClusters(clusters, f)
	return primaryClusterName
}
Пример #2
0
func buildClustersOrFail_14(f *framework.Framework) []*federation_api.Cluster {
	contexts := f.GetUnderlyingFederatedContexts()

	for _, context := range contexts {
		createClusterObjectOrFail_14(f, &context)
	}

	// Wait for all clusters to become ready for up to 5 min.
	if err := wait.PollImmediate(5*time.Second, 5*time.Minute, func() (bool, error) {
		for _, context := range contexts {
			cluster, err := f.FederationClientset_1_4.Federation().Clusters().Get(context.Name)
			if err != nil {
				return false, err
			}
			ready := false
			for _, condition := range cluster.Status.Conditions {
				if condition.Type == federation_api.ClusterReady && condition.Status == api_v1.ConditionTrue {
					ready = true
				}
			}
			if !ready {
				return false, nil
			}
		}
		return true, nil
	}); err != nil {
		framework.Failf("Not all clusters are ready: %v", err)
	}

	clusterList, err := f.FederationClientset_1_4.Federation().Clusters().List(api.ListOptions{})
	if err != nil {
		framework.Failf("Error in get clusters: %v", err)
	}
	result := make([]*federation_api.Cluster, 0, len(contexts))
	for i := range clusterList.Items {
		result = append(result, &clusterList.Items[i])
	}
	return result
}