Skip to content

Commit

Permalink
Adding test for cluster controller
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiljindal committed Jun 14, 2016
1 parent 9b2b763 commit 5a20112
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions test/e2e/federation-apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ package e2e

import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
federationapi "k8s.io/kubernetes/federation/apis/federation"
"k8s.io/kubernetes/federation/client/clientset_generated/federation_internalclientset"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
)

Expand Down Expand Up @@ -54,16 +57,34 @@ var _ = framework.KubeDescribe("Federation apiserver [Feature:Federation]", func
},
},
}
_, err := f.FederationClient.Clusters().Create(&cluster)
_, err := f.FederationClientset.Federation().Clusters().Create(&cluster)
framework.ExpectNoError(err, fmt.Sprintf("creating cluster: %+v", err))
}

for _, context := range contexts {
c, err := f.FederationClient.Clusters().Get(context.Name)
c, err := f.FederationClientset.Federation().Clusters().Get(context.Name)
framework.ExpectNoError(err, fmt.Sprintf("get cluster: %+v", err))
if c.ObjectMeta.Name != context.Name {
framework.Failf("cluster name does not match input context: actual=%+v, expected=%+v", c, context)
}
err = isReady(context.Name, f.FederationClientset)
framework.ExpectNoError(err, fmt.Sprintf("unexpected error in verifying if cluster %s is ready: %+v", context.Name, err))
}
})
})

// Verify that the cluster is marked ready.
func isReady(clusterName string, clientset *federation_internalclientset.Clientset) error {
return wait.PollImmediate(time.Second, wait.ForeverTestTimeout, func() (bool, error) {
c, err := clientset.Federation().Clusters().Get(clusterName)
if err != nil {
return false, err
}
for _, condition := range c.Status.Conditions {
if condition.Type == federationapi.ClusterReady && condition.Status == api.ConditionTrue {
return true, nil
}
}
return false, nil
})
}
2 changes: 1 addition & 1 deletion test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ func (f *Framework) GetUnderlyingFederatedContexts() []E2EContext {

e2eContexts := []E2EContext{}
for _, context := range kubeconfig.Contexts {
if strings.HasPrefix(context.Name, "federation") {
if strings.HasPrefix(context.Name, "federation") && context.Name != "federation-cluster" {

user := kubeconfig.findUser(context.Context.User)
if user == nil {
Expand Down

0 comments on commit 5a20112

Please sign in to comment.