Skip to content

Commit

Permalink
Fix linter issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bnshr committed Feb 18, 2025
1 parent 40e7a4b commit 643c192
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
Binary file removed tests/operator/operator.test
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
tsparams.OperatorNamespace)

randomTargetingNamespace = randomNamespace + "-targeting"

createTestOperatorGroup(randomTargetingNamespace, tsparams.SingleOrMultiNamespacedOperatorGroup, []string{randomNamespace})

DeferCleanup(func() {

err := globalhelper.DeleteNamespaceAndWait(randomTargetingNamespace, tsparams.Timeout)
Expect(err).ToNot(HaveOccurred(), "Error deleting namespace "+randomTargetingNamespace)
})
Expand All @@ -41,6 +43,7 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
[]string{tsparams.CertsuiteTargetOperatorLabels},
[]string{},
[]string{}, randomCertsuiteConfigDir)

Expect(err).ToNot(HaveOccurred())
})

Expand All @@ -60,19 +63,22 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
globalhelper.ConvertSpecNameToFileName(CurrentSpecReport().FullText()),
randomReportDir,
randomCertsuiteConfigDir)

Expect(err).ToNot(HaveOccurred())

By("Verify test case status in Claim report")
err = globalhelper.ValidateIfReportsAreValid(
tsparams.CertsuiteOperatorSingleOrMultiNamespacedAllowedInTenantNamespaces,
globalparameters.TestCasePassed, randomReportDir)

Expect(err).ToNot(HaveOccurred())
})

// negative
It("operator namespace contains own-namespaced namespace operator", func() {
By("Deploy operator group")
err := tshelper.DeployTestOperatorGroup(randomNamespace, false)

Expect(err).ToNot(HaveOccurred(), "Error deploying operator group")

installAndLabelOperator(randomNamespace)
Expand All @@ -83,12 +89,14 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
globalhelper.ConvertSpecNameToFileName(CurrentSpecReport().FullText()),
randomReportDir,
randomCertsuiteConfigDir)

Expect(err).ToNot(HaveOccurred())

By("Verify test case status in Claim report")
err = globalhelper.ValidateIfReportsAreValid(
tsparams.CertsuiteOperatorSingleOrMultiNamespacedAllowedInTenantNamespaces,
globalparameters.TestCaseFailed, randomReportDir)

Expect(err).ToNot(HaveOccurred())
})

Expand All @@ -106,12 +114,14 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
globalhelper.ConvertSpecNameToFileName(CurrentSpecReport().FullText()),
randomReportDir,
randomCertsuiteConfigDir)

Expect(err).ToNot(HaveOccurred())

By("Verify test case status in Claim report")
err = globalhelper.ValidateIfReportsAreValid(
tsparams.CertsuiteOperatorSingleOrMultiNamespacedAllowedInTenantNamespaces,
globalparameters.TestCasePassed, randomReportDir)

Expect(err).ToNot(HaveOccurred())
})

Expand Down Expand Up @@ -146,6 +156,7 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
globalhelper.GetConfiguration().General.TestImage, tsparams.TestDeploymentLabels)

err := globalhelper.CreateAndWaitUntilPodIsReady(testPod, tsparams.Timeout)

Expect(err).ToNot(HaveOccurred())

By("Start test")
Expand All @@ -154,12 +165,14 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
globalhelper.ConvertSpecNameToFileName(CurrentSpecReport().FullText()),
randomReportDir,
randomCertsuiteConfigDir)

Expect(err).ToNot(HaveOccurred())

By("Verify test case status in Claim report")
err = globalhelper.ValidateIfReportsAreValid(
tsparams.CertsuiteOperatorSingleOrMultiNamespacedAllowedInTenantNamespaces,
globalparameters.TestCaseFailed, randomReportDir)

Expect(err).ToNot(HaveOccurred())
})

Expand All @@ -179,11 +192,13 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
"",
v1alpha1.ApprovalAutomatic,
)

Expect(err).ToNot(HaveOccurred(), ErrorDeployOperatorStr+
tsparams.OperatorPrefixAnchore)

err = waitUntilOperatorIsReady(tsparams.OperatorPrefixAnchore,
randomTargetingNamespace)

Expect(err).ToNot(HaveOccurred(), "Operator "+tsparams.OperatorPrefixAnchore+
" is not ready")

Expand All @@ -210,12 +225,14 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
globalhelper.ConvertSpecNameToFileName(CurrentSpecReport().FullText()),
randomReportDir,
randomCertsuiteConfigDir)

Expect(err).ToNot(HaveOccurred())

By("Verify test case status in Claim report")
err = globalhelper.ValidateIfReportsAreValid(
tsparams.CertsuiteOperatorSingleOrMultiNamespacedAllowedInTenantNamespaces,
globalparameters.TestCaseFailed, randomReportDir)

Expect(err).ToNot(HaveOccurred())
})

Expand All @@ -225,7 +242,6 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
installAndLabelOperator(randomNamespace)

By("Deploy anchore-engine operator for testing")
createTestOperatorGroup(randomNamespace, tsparams.SingleOrMultiNamespacedOperatorGroup, []string{randomNamespace})
err := tshelper.DeployOperatorSubscription(
tsparams.OperatorPrefixAnchore,
tsparams.OperatorPrefixAnchore,
Expand All @@ -236,21 +252,30 @@ var _ = Describe("Operator single-or-multi-namespaced-allowed-in-tenant-namespac
"",
v1alpha1.ApprovalAutomatic,
)

Expect(err).ToNot(HaveOccurred(), ErrorDeployOperatorStr+
tsparams.OperatorPrefixAnchore)

err = waitUntilOperatorIsReady(tsparams.OperatorPrefixAnchore,
randomNamespace)

Expect(err).ToNot(HaveOccurred(), "Operator "+tsparams.OperatorPrefixAnchore+
" is not ready")

By("Start test")
err = globalhelper.LaunchTests(
tsparams.CertsuiteOperatorSingleOrMultiNamespacedAllowedInTenantNamespaces,
globalhelper.ConvertSpecNameToFileName(CurrentSpecReport().FullText()),
randomReportDir,
randomCertsuiteConfigDir)

Expect(err).ToNot(HaveOccurred())

By("Verify test case status in Claim report")
err = globalhelper.ValidateIfReportsAreValid(
tsparams.CertsuiteOperatorSingleOrMultiNamespacedAllowedInTenantNamespaces,
globalparameters.TestCaseFailed, randomReportDir)

Expect(err).ToNot(HaveOccurred())
})
})
Expand All @@ -262,31 +287,30 @@ func installClusterWideOperator() {
)

By("Create openshift-logging namespace")

err := globalhelper.CreateNamespace(openshiftLoggingNamespace)

Check failure on line 290 in tests/operator/tests/operator_single_or_multi_namespaced_allowed_in_tenant_namespaces.go

View workflow job for this annotation

GitHub Actions / lint

assignments should only be cuddled with other assignments (wsl)

Expect(err).ToNot(HaveOccurred())

By("Create fake operator group for cluster-logging operator")

err = tshelper.DeployTestOperatorGroup(openshiftLoggingNamespace, true)

Check failure on line 295 in tests/operator/tests/operator_single_or_multi_namespaced_allowed_in_tenant_namespaces.go

View workflow job for this annotation

GitHub Actions / lint

assignments should only be cuddled with other assignments (wsl)

Expect(err).ToNot(HaveOccurred(), "Error deploying operator group")

By("Query the packagemanifest for defaultChannel for " + clusterLoggingOperatorName)

channel, err := globalhelper.QueryPackageManifestForDefaultChannel(clusterLoggingOperatorName, openshiftLoggingNamespace)

Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for "+clusterLoggingOperatorName)

fmt.Printf("CHANNEL FOUND: %s\n", channel)

By("Query the packagemanifest for the " + clusterLoggingOperatorName)

version, err := globalhelper.QueryPackageManifestForVersion(clusterLoggingOperatorName, openshiftLoggingNamespace, channel)

Expect(err).ToNot(HaveOccurred(), "Error querying package manifest for "+clusterLoggingOperatorName)

fmt.Printf("VERSION FOUND: %s\n", version)

By("Deploy cluster-logging operator for testing")

err = tshelper.DeployOperatorSubscription(

Check failure on line 314 in tests/operator/tests/operator_single_or_multi_namespaced_allowed_in_tenant_namespaces.go

View workflow job for this annotation

GitHub Actions / lint

assignments should only be cuddled with other assignments (wsl)
clusterLoggingOperatorName,
clusterLoggingOperatorName,
Expand All @@ -297,11 +321,12 @@ func installClusterWideOperator() {
clusterLoggingOperatorName+".v"+version,
v1alpha1.ApprovalAutomatic,
)

Expect(err).ToNot(HaveOccurred(), ErrorDeployOperatorStr+clusterLoggingOperatorName)

By("Wait until operator is ready")

err = tshelper.WaitUntilOperatorIsReady(clusterLoggingOperatorName, openshiftLoggingNamespace)

Check failure on line 328 in tests/operator/tests/operator_single_or_multi_namespaced_allowed_in_tenant_namespaces.go

View workflow job for this annotation

GitHub Actions / lint

assignments should only be cuddled with other assignments (wsl)

Expect(err).ToNot(HaveOccurred(), "Operator "+clusterLoggingOperatorName+" is not ready")

By("Label operators")
Expand All @@ -321,25 +346,27 @@ func createTestOperatorGroup(namespace, operatorGroupName string, targetNamespac
By("Create target namespaces")
for _, targetNamespace := range targetNamespaces {

Check failure on line 347 in tests/operator/tests/operator_single_or_multi_namespaced_allowed_in_tenant_namespaces.go

View workflow job for this annotation

GitHub Actions / lint

ranges should only be cuddled with assignments used in the iteration (wsl)
err := globalhelper.CreateNamespace(targetNamespace)

Expect(err).ToNot(HaveOccurred(), "Error creating namespace "+targetNamespace)
}

DeferCleanup(func() {

for _, targetNamespace := range targetNamespaces {

Check failure on line 354 in tests/operator/tests/operator_single_or_multi_namespaced_allowed_in_tenant_namespaces.go

View workflow job for this annotation

GitHub Actions / lint

block should not start with a whitespace (wsl)

err := globalhelper.DeleteNamespaceAndWait(targetNamespace, tsparams.Timeout)
Expect(err).ToNot(HaveOccurred(), "Error deleting namespace "+targetNamespace)
}
})

By("Deploy operator group for namespace " + namespace)
err = tshelper.DeployTestOperatorGroupWithTargetNamespace(operatorGroupName, namespace, targetNamespaces)

Expect(err).ToNot(HaveOccurred(), "Error deploying operator group")
}

func installAndLabelOperator(operatorNamespace string) {
By("Query the packagemanifest for the default channel")
channel, err := globalhelper.QueryPackageManifestForDefaultChannel(
channel, err := globalhelper.QueryPackageManifestForDefaultChannel( //nolint:wsl
tsparams.CertifiedOperatorPrefixNginx,
operatorNamespace,
)
Expand All @@ -365,6 +392,7 @@ func installAndLabelOperator(operatorNamespace string) {

err = waitUntilOperatorIsReady(tsparams.CertifiedOperatorPrefixNginx,
operatorNamespace)

Expect(err).ToNot(HaveOccurred(), "Operator "+tsparams.CertifiedOperatorPrefixNginx+".v"+version+
" is not ready")

Expand Down

0 comments on commit 643c192

Please sign in to comment.