|
| 1 | +package e2e |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "k8s.io/client-go/discovery" |
| 7 | + restclient "k8s.io/client-go/rest" |
| 8 | + |
| 9 | + "sigs.k8s.io/kubefed/pkg/controller/util" |
| 10 | + "sigs.k8s.io/kubefed/test/e2e/framework" |
| 11 | + |
| 12 | + . "github.com/onsi/ginkgo" //nolint:stylecheck |
| 13 | + . "github.com/onsi/gomega" //nolint:stylecheck |
| 14 | +) |
| 15 | + |
| 16 | +var _ = Describe("KubeFedCluster", func() { |
| 17 | + f := framework.NewKubeFedFramework("kubefedcluster") |
| 18 | + |
| 19 | + tl := framework.NewE2ELogger() |
| 20 | + |
| 21 | + It("should correctly report the Kubernetes git version of the cluster", func() { |
| 22 | + userAgent := "test-kubefedcluster-kubernetes-version" |
| 23 | + client := f.Client(userAgent) |
| 24 | + clusterList := framework.ListKubeFedClusters(tl, client, framework.TestContext.KubeFedSystemNamespace) |
| 25 | + |
| 26 | + for _, cluster := range clusterList.Items { |
| 27 | + config, err := util.BuildClusterConfig(&cluster, client, framework.TestContext.KubeFedSystemNamespace) |
| 28 | + Expect(err).NotTo(HaveOccurred()) |
| 29 | + restclient.AddUserAgent(config, userAgent) |
| 30 | + |
| 31 | + client, err := discovery.NewDiscoveryClientForConfig(config) |
| 32 | + if err != nil { |
| 33 | + tl.Fatalf("Error creating discovery client for cluster %q", cluster.Name) |
| 34 | + } |
| 35 | + version, err := client.ServerVersion() |
| 36 | + if err != nil { |
| 37 | + tl.Fatalf("Error retrieving Kubernetes version of cluster %q", cluster.Name) |
| 38 | + } |
| 39 | + Expect(cluster.Status.KubernetesVersion).To(Equal(version.GitVersion), fmt.Sprintf( |
| 40 | + "the KubernetesVersion field of KubeFedCluster %q should be equal to the Kubernetes git version of the cluster", cluster.Name)) |
| 41 | + } |
| 42 | + }) |
| 43 | +}) |
0 commit comments