mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #27650 from nikhiljindal/fixFedTest
Automatic merge from submit-queue federation-apiserver test: Fixing the AfterEach order in e2e test Moving "It" and "AfterEach" into a "Describe" fixes the order of AfterEach. Verified that now, test.AfterEach is run before running framework.AfterEach. Removing the temporary disabling of framework.SkipUnlessFederated(f.Client) in AfterEach. cc @kubernetes/sig-cluster-federation @mml
This commit is contained in:
commit
64f79df54e
@ -34,52 +34,54 @@ import (
|
|||||||
var _ = framework.KubeDescribe("Federation apiserver [Feature:Federation]", func() {
|
var _ = framework.KubeDescribe("Federation apiserver [Feature:Federation]", func() {
|
||||||
f := framework.NewDefaultFederatedFramework("federation-cluster")
|
f := framework.NewDefaultFederatedFramework("federation-cluster")
|
||||||
|
|
||||||
AfterEach(func() {
|
Describe("Cluster objects", func() {
|
||||||
// framework.SkipUnlessFederated(f.Client) TODO: quinton-hoole: Temporarily disabled
|
AfterEach(func() {
|
||||||
|
framework.SkipUnlessFederated(f.Client)
|
||||||
|
|
||||||
// Delete registered clusters.
|
// Delete registered clusters.
|
||||||
// This is if a test failed, it should not affect other tests.
|
// This is if a test failed, it should not affect other tests.
|
||||||
clusterList, err := f.FederationClientset.Federation().Clusters().List(api.ListOptions{})
|
clusterList, err := f.FederationClientset.Federation().Clusters().List(api.ListOptions{})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
for _, cluster := range clusterList.Items {
|
|
||||||
err := f.FederationClientset.Federation().Clusters().Delete(cluster.Name, &api.DeleteOptions{})
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}
|
for _, cluster := range clusterList.Items {
|
||||||
})
|
err := f.FederationClientset.Federation().Clusters().Delete(cluster.Name, &api.DeleteOptions{})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
It("should allow creation and deletion of cluster api objects", func() {
|
It("should be created and deleted successfully", func() {
|
||||||
framework.SkipUnlessFederated(f.Client)
|
framework.SkipUnlessFederated(f.Client)
|
||||||
|
|
||||||
contexts := f.GetUnderlyingFederatedContexts()
|
contexts := f.GetUnderlyingFederatedContexts()
|
||||||
|
|
||||||
framework.Logf("Creating %d cluster objects", len(contexts))
|
framework.Logf("Creating %d cluster objects", len(contexts))
|
||||||
for _, context := range contexts {
|
for _, context := range contexts {
|
||||||
createClusterObjectOrFail(f, &context)
|
createClusterObjectOrFail(f, &context)
|
||||||
}
|
}
|
||||||
|
|
||||||
framework.Logf("Checking that %d clusters are Ready", len(contexts))
|
framework.Logf("Checking that %d clusters are Ready", len(contexts))
|
||||||
for _, context := range contexts {
|
for _, context := range contexts {
|
||||||
clusterIsReadyOrFail(f, &context)
|
clusterIsReadyOrFail(f, &context)
|
||||||
}
|
}
|
||||||
framework.Logf("%d clusters are Ready", len(contexts))
|
framework.Logf("%d clusters are Ready", len(contexts))
|
||||||
|
|
||||||
// Verify that deletion works.
|
// Verify that deletion works.
|
||||||
framework.Logf("Deleting %d clusters", len(contexts))
|
framework.Logf("Deleting %d clusters", len(contexts))
|
||||||
for _, context := range contexts {
|
for _, context := range contexts {
|
||||||
framework.Logf("Deleting cluster object: %s (%s, secret: %s)", context.Name, context.Cluster.Cluster.Server, context.Name)
|
framework.Logf("Deleting cluster object: %s (%s, secret: %s)", context.Name, context.Cluster.Cluster.Server, context.Name)
|
||||||
err := f.FederationClientset.Federation().Clusters().Delete(context.Name, &api.DeleteOptions{})
|
err := f.FederationClientset.Federation().Clusters().Delete(context.Name, &api.DeleteOptions{})
|
||||||
framework.ExpectNoError(err, fmt.Sprintf("unexpected error in deleting cluster %s: %+v", context.Name, err))
|
framework.ExpectNoError(err, fmt.Sprintf("unexpected error in deleting cluster %s: %+v", context.Name, err))
|
||||||
framework.Logf("Successfully deleted cluster object: %s (%s, secret: %s)", context.Name, context.Cluster.Cluster.Server, context.Name)
|
framework.Logf("Successfully deleted cluster object: %s (%s, secret: %s)", context.Name, context.Cluster.Cluster.Server, context.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// There should not be any remaining cluster.
|
// There should not be any remaining cluster.
|
||||||
framework.Logf("Verifying that zero clusters remain")
|
framework.Logf("Verifying that zero clusters remain")
|
||||||
clusterList, err := f.FederationClientset.Federation().Clusters().List(api.ListOptions{})
|
clusterList, err := f.FederationClientset.Federation().Clusters().List(api.ListOptions{})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
if len(clusterList.Items) != 0 {
|
if len(clusterList.Items) != 0 {
|
||||||
framework.Failf("there should not have been any remaining clusters. Found: %+v", clusterList)
|
framework.Failf("there should not have been any remaining clusters. Found: %+v", clusterList)
|
||||||
}
|
}
|
||||||
framework.Logf("Verified that zero clusters remain")
|
framework.Logf("Verified that zero clusters remain")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user