Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Fix linter for the e2e test packages #718

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # tag=v6.1.1
with:
version: v1.60.2
version: v1.63.3
args: --timeout 15m
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cmd/clusterctl/clusterctl
bin
hack/tools/bin
hack/tools/_out
/vendor

# go.work files
go.work
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ CONTROLLER_GEN_VER := v0.16.1
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)

GOLANGCI_LINT_VER := v1.60.2
GOLANGCI_LINT_VER := v1.63.3
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)

Expand Down Expand Up @@ -290,7 +290,7 @@ plugin: ## Build plugin binary
.PHONY: lint
lint: $(GOLANGCI_LINT) ## Lint the codebase
$(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS) --timeout=10m
cd $(TEST_DIR); $(GOLANGCI_LINT) run --path-prefix $(TEST_DIR) -v $(GOLANGCI_LINT_EXTRA_ARGS) --timeout=10m
cd $(TEST_DIR); $(GOLANGCI_LINT) run --path-prefix $(TEST_DIR) --build-tags e2e -v $(GOLANGCI_LINT_EXTRA_ARGS) --timeout=10m

.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/air_gapped_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build e2e
// +build e2e

/*
Copyright 2023 The Kubernetes Authors.
Expand Down Expand Up @@ -85,7 +84,7 @@ var _ = Describe("Install Core Provider in an air-gapped environment", func() {
},
},
},
Version: "v1.7.7",
Version: previousCAPIVersion,
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/compressed_manifests_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build e2e
// +build e2e

/*
Copyright 2023 The Kubernetes Authors.
Expand Down Expand Up @@ -45,7 +44,7 @@ const (
)

var _ = Describe("Create and delete a provider with manifests that don't fit the configmap", func() {
var ociInfrastructureConfigMap = &corev1.ConfigMap{}
ociInfrastructureConfigMap := &corev1.ConfigMap{}

It("should successfully create a CoreProvider", func() {
bootstrapCluster := bootstrapClusterProxy.GetClient()
Expand Down Expand Up @@ -152,7 +151,8 @@ var _ = Describe("Create and delete a provider with manifests that don't fit the
},
},
},
}}
},
}

// Re-use configmap created on the previous step.
ociInfrastructureConfigMap.ObjectMeta.UID = ""
Expand Down
1 change: 0 additions & 1 deletion test/e2e/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build e2e
// +build e2e

/*
Copyright 2023 The Kubernetes Authors.
Expand Down
16 changes: 12 additions & 4 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build e2e
// +build e2e

/*
Copyright 2022 The Kubernetes Authors.
Expand Down Expand Up @@ -147,7 +146,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {

Expect(componentsPath).To(BeAnExistingFile(), "Invalid test suite argument. e2e.components should be an existing file.")
Expect(configPath).To(BeAnExistingFile(), "Invalid test suite argument. e2e.config should be an existing file.")
Expect(os.MkdirAll(artifactFolder, 0755)).To(Succeed(), "Invalid test suite argument. Can't create e2e.artifacts-folder %q", artifactFolder)
Expect(os.MkdirAll(artifactFolder, 0o755)).To(Succeed(), "Invalid test suite argument. Can't create e2e.artifacts-folder %q", artifactFolder)
Expect(helmBinaryPath).To(BeAnExistingFile(), "Invalid test suite argument. helm-binary-path should be an existing file.")
Expect(chartPath).To(BeAnExistingFile(), "Invalid test suite argument. chart-path should be an existing file.")

Expand Down Expand Up @@ -212,6 +211,7 @@ func initScheme() *runtime.Scheme {
framework.TryAddDefaultSchemes(scheme)
Expect(operatorv1.AddToScheme(scheme)).To(Succeed())
Expect(operatorv1alpha1.AddToScheme(scheme)).To(Succeed())

return scheme
}

Expand All @@ -238,12 +238,15 @@ func createClusterctlLocalRepository(config *clusterctl.E2EConfig, repositoryFol

clusterctlConfig := clusterctl.CreateRepository(ctx, createRepositoryInput)
Expect(clusterctlConfig).To(BeAnExistingFile(), "The clusterctl config file does not exists in the local repository %s", repositoryFolder)

return clusterctlConfig
}

func setupCluster(config *clusterctl.E2EConfig, scheme *runtime.Scheme, useExistingCluster bool, clusterProxyName string) (bootstrap.ClusterProvider, framework.ClusterProxy) {
var clusterProvider bootstrap.ClusterProvider

kubeconfigPath := ""

if !useExistingCluster {
clusterProvider = bootstrap.CreateKindBootstrapClusterAndLoadImages(ctx, bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{
Name: config.ManagementClusterName,
Expand All @@ -264,8 +267,9 @@ func setupCluster(config *clusterctl.E2EConfig, scheme *runtime.Scheme, useExist
func initBootstrapCluster(bootstrapClusterProxy framework.ClusterProxy, config *clusterctl.E2EConfig, clusterctlConfigPath, artifactFolder string) {
Expect(bootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. bootstrapClusterProxy can't be nil when calling initBootstrapCluster")
Expect(clusterctlConfigPath).To(BeAnExistingFile(), "Invalid argument. clusterctlConfigPath must be an existing file when calling initBootstrapCluster")

logFolder := filepath.Join(artifactFolder, "clusters", bootstrapClusterProxy.GetName())
Expect(os.MkdirAll(logFolder, 0750)).To(Succeed(), "Invalid argument. Log folder can't be created for initBootstrapCluster")
Expect(os.MkdirAll(logFolder, 0o750)).To(Succeed(), "Invalid argument. Log folder can't be created for initBootstrapCluster")

ensureCertManager(bootstrapClusterProxy, config)

Expand Down Expand Up @@ -295,13 +299,15 @@ func initBootstrapCluster(bootstrapClusterProxy framework.ClusterProxy, config *

func initHelmCluster(clusterProxy framework.ClusterProxy, config *clusterctl.E2EConfig) {
Expect(clusterProxy).ToNot(BeNil(), "Invalid argument. bootstrapClusterProxy can't be nil when calling initHelmCluster")

logFolder := filepath.Join(artifactFolder, "clusters", helmClusterProxy.GetName())
Expect(os.MkdirAll(logFolder, 0750)).To(Succeed(), "Invalid argument. Log folder can't be created for initHelmCluster")
Expect(os.MkdirAll(logFolder, 0o750)).To(Succeed(), "Invalid argument. Log folder can't be created for initHelmCluster")
ensureCertManager(clusterProxy, config)
}

func ensureCertManager(clusterProxy framework.ClusterProxy, config *clusterctl.E2EConfig) {
By("Deploying cert-manager")

addCertChart := &HelmChart{
BinaryPath: helmBinaryPath,
Name: "jetstack",
Expand Down Expand Up @@ -336,6 +342,7 @@ func ensureCertManager(clusterProxy framework.ClusterProxy, config *clusterctl.E
_, err = certChart.Run(map[string]string{
"installCRDs": "true",
})
Expect(err).ToNot(HaveOccurred())
}

func deleteClusterAPICRDs(clusterProxy framework.ClusterProxy) {
Expand Down Expand Up @@ -389,6 +396,7 @@ func tearDown(clusterProvider bootstrap.ClusterProvider, clusterProxy framework.
if clusterProxy != nil {
clusterProxy.Dispose(ctx)
}

if clusterProvider != nil {
clusterProvider.Dispose(ctx)
}
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/helm_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build e2e
// +build e2e

/*
Copyright 2023 The Kubernetes Authors.
Expand Down Expand Up @@ -52,9 +51,10 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
defer func() {
fullHelmChart.Commands = Commands(Uninstall)
fullHelmChart.AdditionalFlags = Flags("--namespace", operatorNamespace)
fullHelmChart.Run(nil)
_, err := fullHelmChart.Run(nil)
Expect(err).ToNot(HaveOccurred())

err := clusterProxy.DeleteAllOf(ctx, &apiextensionsv1.CustomResourceDefinition{}, client.MatchingLabels{
err = clusterProxy.DeleteAllOf(ctx, &apiextensionsv1.CustomResourceDefinition{}, client.MatchingLabels{
"clusterctl.cluster.x-k8s.io/core": "capi-operator",
})
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -135,6 +135,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
manifests, err := fullRun.Run(nil)
Expect(err).ToNot(HaveOccurred())
fullChartInstall, err := os.ReadFile(filepath.Join(customManifestsFolder, "full-chart-install.yaml"))
Expect(err).ToNot(HaveOccurred())
Expect(manifests).To(Equal(string(fullChartInstall)))
})

Expand Down
5 changes: 1 addition & 4 deletions test/e2e/helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build e2e
// +build e2e

/*
Copyright 2022 The Kubernetes Authors.
Expand All @@ -23,9 +22,7 @@ import (
"context"
)

var (
ctx = context.Background()
)
var ctx = context.Background()

const (
operatorNamespace = "capi-operator-system"
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/minimal_configuration_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build e2e
// +build e2e

/*
Copyright 2022 The Kubernetes Authors.
Expand Down Expand Up @@ -38,6 +37,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

const (
mediaType = "application/vnd.test.file"
artifactType = "application/vnd.acme.config"
)

var _ = Describe("Create, upgrade, downgrade and delete providers with minimal specified configuration", func() {
It("should successfully create a CoreProvider", func() {
bootstrapCluster := bootstrapClusterProxy.GetClient()
Expand Down Expand Up @@ -99,6 +103,7 @@ metadata:
if v, ok := deployment.Labels["test-label"]; ok {
return v == "test-value"
}

return false
}), e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

Expand All @@ -117,7 +122,8 @@ metadata:
ObjectMeta: metav1.ObjectMeta{
Name: "test-config-map",
Namespace: operatorNamespace,
}}
},
}
WaitFor(ctx, For(cm).In(bootstrapCluster).ToSatisfy(func() bool {
value, ok := cm.Data["test"]
return ok && value == "test"
Expand Down Expand Up @@ -353,7 +359,6 @@ metadata:
Expect(fs.Close()).To(Succeed())
}()

mediaType := "application/vnd.test.file"
fds := []v1.Descriptor{}

fileDescriptor, err := fs.Add(ctx, "infrastructure-custom-v0.0.1-metadata.yaml", mediaType, "")
Expand All @@ -372,7 +377,6 @@ metadata:
Expect(err).ToNot(HaveOccurred())
fds = append(fds, fileDescriptor)

artifactType := "application/vnd.acme.config"
opts := oras.PackManifestOptions{
Layers: fds,
}
Expand Down Expand Up @@ -442,7 +446,6 @@ metadata:
Expect(fs.Close()).To(Succeed())
}()

mediaType := "application/vnd.test.file"
fds := []v1.Descriptor{}

fileDescriptor, err := fs.Add(ctx, "infrastructure-custom-v0.0.1-metadata.yaml", mediaType, "")
Expand All @@ -461,7 +464,6 @@ metadata:
Expect(err).ToNot(HaveOccurred())
fds = append(fds, fileDescriptor)

artifactType := "application/vnd.acme.config"
opts := oras.PackManifestOptions{
Layers: fds,
}
Expand Down Expand Up @@ -531,7 +533,6 @@ metadata:
Expect(fs.Close()).To(Succeed())
}()

mediaType := "application/vnd.test.file"
fds := []v1.Descriptor{}

fileDescriptor, err := fs.Add(ctx, "infrastructure-docker-v0.0.1-metadata.yaml", mediaType, "")
Expand All @@ -550,7 +551,6 @@ metadata:
Expect(err).ToNot(HaveOccurred())
fds = append(fds, fileDescriptor)

artifactType := "application/vnd.acme.config"
opts := oras.PackManifestOptions{
Layers: fds,
}
Expand Down
Loading