Skip to content

Commit

Permalink
attempt to fix tests and lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
adityabhatia committed Sep 20, 2023
1 parent 886cdbd commit 89eefd1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
24 changes: 13 additions & 11 deletions test/e2e/quick_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,12 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
var _ = Describe("When following the Cluster API quick-start check finalizers resilience after deletion", func() {
QuickStartSpec(ctx, func() QuickStartSpecInput {
return QuickStartSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InfrastructureProvider: pointer.String("docker"),
PostMachinesProvisioned: func(proxy framework.ClusterProxy, namespace, clusterName string) {
// This check ensures that finalizers are resilient - i.e. correctly re-reconciled - when removed.
framework.ValidateFinalizersResilience(ctx, proxy, namespace, clusterName)
Expand All @@ -201,12 +202,13 @@ var _ = Describe("When following the Cluster API quick-start check finalizers re
var _ = Describe("When following the Cluster API quick-start with ClusterClass check finalizers resilience after deletion [ClusterClass]", func() {
QuickStartSpec(ctx, func() QuickStartSpecInput {
return QuickStartSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: pointer.String("topology"),
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: pointer.String("topology"),
InfrastructureProvider: pointer.String("docker"),
PostMachinesProvisioned: func(proxy framework.ClusterProxy, namespace, clusterName string) {
// This check ensures that finalizers are resilient - i.e. correctly re-reconciled - when removed.
framework.ValidateFinalizersResilience(ctx, proxy, namespace, clusterName)
Expand Down
23 changes: 14 additions & 9 deletions test/framework/finalizers_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package framework
import (
"context"
"fmt"
"sigs.k8s.io/cluster-api/util/patch"
"time"

. "github.com/onsi/gomega"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
clusterctlcluster "sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster"
"sigs.k8s.io/controller-runtime/pkg/client"

clusterctlcluster "sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster"
"sigs.k8s.io/cluster-api/util/patch"
)

// ValidateFinalizersResilience checks that expected finalizers are in place, deletes them, and verifies that expected finalizers are properly added again.
Expand Down Expand Up @@ -58,18 +58,23 @@ func ValidateFinalizersResilience(ctx context.Context, proxy ClusterProxy, names

func getFinalizersFromAllObjs(ctx context.Context, proxy ClusterProxy, namespace string) map[string][]string {
finalizers := map[string][]string{}
graph, err := clusterctlcluster.GetOwnerGraph(ctx, proxy.GetKubeconfigPath(), namespace)
Expect(err).To(BeNil())

graph, err := clusterctlcluster.GetOwnerGraph(ctx, namespace, proxy.GetKubeconfigPath())
Expect(err).ToNot(HaveOccurred())

for _, v := range graph {
obj := &unstructured.Unstructured{}
obj.SetAPIVersion(v.Object.APIVersion)
obj.SetKind(v.Object.Kind)
err := proxy.GetClient().Get(ctx, client.ObjectKey{Namespace: v.Object.Namespace, Name: v.Object.Name}, obj)
Expect(err).To(BeNil())
err = proxy.GetClient().Get(ctx, client.ObjectKey{Namespace: v.Object.Namespace, Name: v.Object.Name}, obj)
Expect(err).ToNot(HaveOccurred())
if obj.GetFinalizers() != nil {
finalizers[fmt.Sprintf("%s/%s", v.Object.Kind, client.ObjectKey{Name: v.Object.Name, Namespace: v.Object.Namespace}.String())] = obj.GetFinalizers()
finalizers[
fmt.Sprintf("%s/%s", v.Object.Kind, client.ObjectKey{Name: v.Object.Name, Namespace: v.Object.Namespace}.String())
] = obj.GetFinalizers()
}
}

return finalizers
}

Expand Down Expand Up @@ -105,6 +110,6 @@ func assertFinalizersExist(ctx context.Context, proxy ClusterProxy, namespace st
for k, v := range missing {
missingString = fmt.Sprintf("%s\n%s %s", missingString, k, v)
}
Expect(len(missing)).To(Equal(0), missingString)
Expect(missing).To(BeEmpty(), missingString)
}).WithTimeout(5 * time.Minute).WithPolling(2 * time.Second).Should(Succeed())
}
2 changes: 1 addition & 1 deletion test/framework/ownerreference_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func AssertOwnerReferences(namespace, kubeconfigPath string, assertFuncs ...map[
}
}
Eventually(func() error {
allErrs := []error{}
var allErrs []error
ctx := context.Background()

graph, err := clusterctlcluster.GetOwnerGraph(ctx, namespace, kubeconfigPath)
Expand Down

0 comments on commit 89eefd1

Please sign in to comment.