Skip to content

Commit c0b949e

Browse files
cfergeaupraveenkumar
authored andcommitted
e2e: Improve crc-version default value
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=""`
1 parent 5365acf commit c0b949e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ endif
235235
ifndef CRC_BINARY
236236
CRC_BINARY = --crc-binary=$(GOPATH)/bin
237237
endif
238-
ifndef VERSION_TO_TEST
239-
VERSION_TO_TEST = --crc-version=$(CRC_VERSION)+$(COMMIT_SHA)
240-
endif
241238
e2e:
242239
@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)
243240

test/e2e/testsuite/testsuite.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/crc-org/crc/v2/pkg/crc/constants"
1616
"github.com/crc-org/crc/v2/pkg/crc/preset"
17+
"github.com/crc-org/crc/v2/pkg/crc/version"
1718
"github.com/crc-org/crc/v2/test/extended/crc/cmd"
1819
crcCmd "github.com/crc-org/crc/v2/test/extended/crc/cmd"
1920
"github.com/crc-org/crc/v2/test/extended/util"
@@ -34,6 +35,10 @@ var (
3435
GodogTags string
3536
)
3637

38+
func defaultCRCVersion() string {
39+
return fmt.Sprintf("%s+%s", version.GetCRCVersion(), version.GetCommitSha())
40+
}
41+
3742
func ParseFlags() {
3843

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

4954
func InitializeTestSuite(tctx *godog.TestSuiteContext) {

0 commit comments

Comments
 (0)