Skip to content

Commit

Permalink
e2e: Improve crc-version default value
Browse files Browse the repository at this point in the history
The e2e tests already indirectly depend on the
github.com/crc-org/pkg/crc/version go package, and the correct build
flags are used to build it. Instead of setting VERSION_TO_TEST from
flags in the Makefile, we can directly set it from the go code.
This will check that the crc binary we use is the expected one.
The check can still be disabled with `--crc-version=""`
  • Loading branch information
cfergeau authored and praveenkumar committed Oct 19, 2023
1 parent 5365acf commit c0b949e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ endif
ifndef CRC_BINARY
CRC_BINARY = --crc-binary=$(GOPATH)/bin
endif
ifndef VERSION_TO_TEST
VERSION_TO_TEST = --crc-version=$(CRC_VERSION)+$(COMMIT_SHA)
endif
e2e:
@go test --timeout=180m $(MODULEPATH)/test/e2e -tags "$(BUILDTAGS)" --ldflags="$(VERSION_VARIABLES)" -v $(PULL_SECRET_FILE) $(BUNDLE_LOCATION) $(CRC_BINARY) $(GODOG_OPTS) $(CLEANUP_HOME) $(VERSION_TO_TEST)

Expand Down
7 changes: 6 additions & 1 deletion test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/crc-org/crc/v2/pkg/crc/constants"
"github.com/crc-org/crc/v2/pkg/crc/preset"
"github.com/crc-org/crc/v2/pkg/crc/version"
"github.com/crc-org/crc/v2/test/extended/crc/cmd"
crcCmd "github.com/crc-org/crc/v2/test/extended/crc/cmd"
"github.com/crc-org/crc/v2/test/extended/util"
Expand All @@ -34,6 +35,10 @@ var (
GodogTags string
)

func defaultCRCVersion() string {
return fmt.Sprintf("%s+%s", version.GetCRCVersion(), version.GetCommitSha())
}

func ParseFlags() {

pflag.StringVar(&util.TestDir, "test-dir", "out", "Path to the directory in which to execute the tests")
Expand All @@ -43,7 +48,7 @@ func ParseFlags() {
pflag.StringVar(&pullSecretFile, "pull-secret-file", "/path/to/pull-secret", "Path to the file containing pull secret")
pflag.StringVar(&CRCExecutable, "crc-binary", "", "Path to the CRC executable to be tested")
pflag.BoolVar(&cleanupHome, "cleanup-home", false, "Try to remove crc home folder before starting the suite") // TODO: default=true
pflag.StringVar(&CRCVersion, "crc-version", "", "Version of CRC to be tested")
pflag.StringVar(&CRCVersion, "crc-version", defaultCRCVersion(), "Version of CRC to be tested")
}

func InitializeTestSuite(tctx *godog.TestSuiteContext) {
Expand Down

0 comments on commit c0b949e

Please sign in to comment.