Skip to content
Merged
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
45 changes: 45 additions & 0 deletions test/e2e/e2e_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package e2e

import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
Expand All @@ -31,9 +32,18 @@ import (
. "github.com/onsi/gomega" //nolint:golint
kbtestutils "sigs.k8s.io/kubebuilder/test/e2e/utils"

"github.com/operator-framework/operator-sdk/pkg/apis/scorecard/v1alpha3"
testutils "github.com/operator-framework/operator-sdk/test/internal"
)

const (
OLMBundleValidationTest = "olm-bundle-validation"
OLMCRDsHaveValidationTest = "olm-crds-have-validation"
OLMCRDsHaveResourcesTest = "olm-crds-have-resources"
OLMSpecDescriptorsTest = "olm-spec-descriptors"
OLMStatusDescriptorsTest = "olm-status-descriptors"
)

var _ = Describe("operator-sdk", func() {
Context("with the new project layout", func() {
var (
Expand Down Expand Up @@ -204,6 +214,41 @@ var _ = Describe("operator-sdk", func() {
_, err = tc.Run(runPkgManCmd)
Expect(err).NotTo(HaveOccurred())

By("running basic scorecard tests")
Comment thread
camilamacedo86 marked this conversation as resolved.
var scorecardOutput v1alpha3.TestList
runScorecardCmd := exec.Command(tc.BinaryName, "scorecard", "bundle",
"--selector=suite=basic",
"--output=json",
"--wait-time=40s")
scorecardOutputBytes, err := tc.Run(runScorecardCmd)
Expect(err).NotTo(HaveOccurred())
err = json.Unmarshal(scorecardOutputBytes, &scorecardOutput)
Comment thread
camilamacedo86 marked this conversation as resolved.
Expect(err).NotTo(HaveOccurred())
Expect(len(scorecardOutput.Items)).To(Equal(1))
Expect(scorecardOutput.Items[0].Status.Results[0].State).To(Equal(v1alpha3.PassState))

By("running olm scorecard tests")
runOLMScorecardCmd := exec.Command(tc.BinaryName, "scorecard", "bundle",
"--selector=suite=olm",
"--output=json",
"--wait-time=40s")
scorecardOutputBytes, err = tc.Run(runOLMScorecardCmd)
Expect(err).To(HaveOccurred())
err = json.Unmarshal(scorecardOutputBytes, &scorecardOutput)
Expect(err).NotTo(HaveOccurred())

resultTable := make(map[string]v1alpha3.State)
resultTable[OLMStatusDescriptorsTest] = v1alpha3.FailState
resultTable[OLMCRDsHaveResourcesTest] = v1alpha3.FailState
resultTable[OLMBundleValidationTest] = v1alpha3.PassState
resultTable[OLMSpecDescriptorsTest] = v1alpha3.FailState
resultTable[OLMCRDsHaveValidationTest] = v1alpha3.PassState

Expect(len(scorecardOutput.Items)).To(Equal(len(resultTable)))
for a := 0; a < len(scorecardOutput.Items); a++ {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use test names to index into the resultTable map to make sure each test is run.

Expect(scorecardOutput.Items[a].Status.Results[0].State).To(Equal(resultTable[scorecardOutput.Items[a].Status.Results[0].Name]))
}

By("destroying the deployed package manifests-formatted operator")
cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", "packagemanifests",
"--operator-namespace", tc.Kubectl.Namespace,
Expand Down