Skip to content

Commit

Permalink
[qe] change integration get parmeter way
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyLuLiu committed Jun 4, 2024
1 parent 813c80a commit b59633f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 37 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,17 @@ containerized_integration: clean
.PHONY: integration ## Run integration tests in Ginkgo
integration:
ifndef GINKGO_OPTS
export GINKGO_OPTS = --ginkgo.label-filter=""
GINKGO_OPTS = --ginkgo.label-filter=""
endif
ifndef PULL_SECRET_PATH
export PULL_SECRET_PATH = $(HOME)/Downloads/crc-pull-secret
PULL_SECRET_PATH = --pull_secret_path=$(HOME)/Downloads/crc-pull-secret
endif
ifndef BUNDLE_PATH
export BUNDLE_PATH = $(HOME)/Downloads/crc_libvirt_$(OPENSHIFT_VERSION)_$(GOARCH).$(BUNDLE_EXTENSION)
BUNDLE_PATH = --bundle_path=$(HOME)/Downloads/crc_libvirt_$(OPENSHIFT_VERSION)_$(GOARCH).$(BUNDLE_EXTENSION)
endif

integration:
@go test -timeout=90m -tags "$(BUILDTAGS)" $(MODULEPATH)/test/integration -v $(GINKGO_OPTS)
@go test -timeout=90m -tags "$(BUILDTAGS)" $(MODULEPATH)/test/integration $(PULL_SECRET_PATH) $(BUNDLE_PATH) -v $(GINKGO_OPTS)

.PHONY: e2e ## Run e2e tests
e2e:
Expand Down
12 changes: 4 additions & 8 deletions images/build-integration/lib/linux/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,16 @@ mkdir -p $targetFolder/results

# Run tests
export PATH="$PATH:${HOME}/$targetFolder/bin"
export PULL_SECRET_PATH="${HOME}/$targetFolder/pull-secret"
if [ ! -z "$bundleLocation" ]
then
export BUNDLE_PATH="$bundleLocation"
fi

cd $targetFolder/bin
if [ ! -z "$labelFilter" ]
then
./integration.test --ginkgo.timeout $suiteTimeout --ginkgo.label-filter $labelFilter > integration.results
./integration.test --pull_secret_path="${HOME}/$targetFolder/pull-secret" --bundle_path=$bundleLocation --ginkgo.timeout $suiteTimeout --ginkgo.label-filter $labelFilter > integration.results
else
./integration.test --ginkgo.timeout $suiteTimeout > integration.results
./integration.test --pull_secret_path="${HOME}/$targetFolder/pull-secret" --bundle_path=$bundleLocation --ginkgo.timeout $suiteTimeout > integration.results
fi

# Copy results
cd ..
cp bin/integration.results results/integration.results
cp bin/out/integration.xml results/$junitFilename
cp bin/out/integration.xml results/$junitFilename
12 changes: 4 additions & 8 deletions images/build-integration/lib/windows/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ New-Item -ItemType directory -Path "$env:HOME\$targetFolder\results" -Force

# Run tests
cd $targetFolder\bin
if ($bundleLocation) {
$env:BUNDLE_PATH="$bundleLocation"
}
# We need to copy the pull-secret to the target folder
$env:PULL_SECRET_PATH="$env:HOME\$targetFolder\pull-secret"

if ($labelFilter) {
integration.test.exe --ginkgo.timeout $suiteTimeout --ginkgo.label-filter $labelFilter > integration.results
integration.test.exe --pull_secret_path="$env:HOME\$targetFolder\pull-secret" --bundle_path=$bundleLocation --ginkgo.timeout $suiteTimeout --ginkgo.label-filter $labelFilter > integration.results
} else {
integration.test.exe --ginkgo.timeout $suiteTimeout > integration.results
integration.test.exe --pull_secret_path="$env:HOME\$targetFolder\pull-secret" --bundle_path=$bundleLocation --ginkgo.timeout $suiteTimeout > integration.results
}


# Copy results
cd ..
cp bin\integration.results results\integration.results
cp bin\out\integration.xml results\$junitFilename
cp bin\out\integration.xml results\$junitFilename
37 changes: 20 additions & 17 deletions test/integration/testsuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
. "github.com/onsi/gomega"
gomegaformat "github.com/onsi/gomega/format"
"github.com/sirupsen/logrus"

"flag"
"github.com/spf13/pflag"
)

type VersionAnswer struct {
Expand All @@ -25,9 +28,22 @@ var userHome string
var versionInfo VersionAnswer

var bundlePath string
var ginkgoOpts string
var pullSecretPath string


func TestMain(m *testing.M) {
RegisterFlags(flag.CommandLine)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()

os.Exit(m.Run())
}

func RegisterFlags(flags *flag.FlagSet) {
flags.StringVar(&bundlePath, "bundle_path", "", "Path to the bundle to be used in tests.")
flags.StringVar(&pullSecretPath, "pull_secret_path", "", "Path to the file containing pull secret.")
}

func TestTest(t *testing.T) {

RegisterFailHandler(Fail)
Expand Down Expand Up @@ -76,25 +92,12 @@ var _ = BeforeSuite(func() {

Expect(err).NotTo(HaveOccurred())

bundlePath = os.Getenv("BUNDLE_PATH") // this env var should contain location of bundle
if bundlePath != "" {
Expect(bundlePath).To(BeAnExistingFile())
}

ginkgoOpts = os.Getenv("GINKGO_OPTS")
if err != nil {

logrus.Infof("Error: Could not read GINKGO_OPTS.")
logrus.Infof("%v", err)
}
Expect(err).NotTo(HaveOccurred())

pullSecretPath = os.Getenv("PULL_SECRET_PATH") // this env var should contain location of pull-secret file
if err != nil {

logrus.Infof("Error: You need to set PULL_SECRET_PATH to find CRC useful.")
logrus.Infof("%v", err)
if pullSecretPath == "" {
logrus.Infof("Error: You need to set PULL_SECRET_PATH for CRC to function properly.")
}
Expect(err).NotTo(HaveOccurred())

Expect(pullSecretPath).NotTo(BeEmpty())
})

0 comments on commit b59633f

Please sign in to comment.