Skip to content

Commit

Permalink
Integration-e2e: Add function for setup command to honor bundle path
Browse files Browse the repository at this point in the history
With this patch if test is run with bundle path then `crc setup`
will not download bundle but use it. For release bits `crc setup`
will download bundle from provided location.
  • Loading branch information
praveenkumar committed Mar 7, 2022
1 parent 75ba79b commit 82d937e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
33 changes: 18 additions & 15 deletions test/e2e/crcsuite/crcsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
)

var (
CRCHome string
CRCExecutable string
bundleEmbedded bool
bundleName string
bundleLocation string
pullSecretFile string
cleanupHome bool
CRCHome string
CRCExecutable string
userProvidedBundle bool
bundleName string
bundleLocation string
pullSecretFile string
cleanupHome bool
)

func usingPreexistingCluster() bool {
Expand Down Expand Up @@ -113,11 +113,11 @@ func FeatureContext(s *godog.Suite) {
}

if bundleLocation == "" {
fmt.Println("Expecting the bundle to be embedded in the CRC executable.")
bundleEmbedded = true
fmt.Println("Expecting the bundle provided by the user")
userProvidedBundle = false
bundleName = constants.GetDefaultBundle(preset.OpenShift)
} else {
bundleEmbedded = false
userProvidedBundle = true
_, bundleName = filepath.Split(bundleLocation)
}

Expand All @@ -135,7 +135,7 @@ func FeatureContext(s *godog.Suite) {
}
}

if !bundleEmbedded {
if userProvidedBundle {
if _, err := os.Stat(bundleLocation); err != nil {
if !os.IsNotExist(err) {
fmt.Printf("Unexpected error obtaining the bundle %v.\n", bundleLocation)
Expand Down Expand Up @@ -365,7 +365,7 @@ func StartCRCWithDefaultBundleSucceedsOrFails(expected string) error {
var cmd string
var extraBundleArgs string

if !bundleEmbedded {
if userProvidedBundle {
extraBundleArgs = fmt.Sprintf("-b %s", bundleLocation)
}
crcStart := crcCmd.CRC("start").ToString()
Expand All @@ -380,7 +380,7 @@ func StartCRCWithDefaultBundleWithStopNetworkTimeSynchronizationSucceedsOrFails(
var cmd string
var extraBundleArgs string

if !bundleEmbedded {
if userProvidedBundle {
extraBundleArgs = fmt.Sprintf("-b %s", bundleLocation)
}
crcStart := crcCmd.CRC("start").WithDisableNTP().ToString()
Expand All @@ -399,7 +399,7 @@ func StartCRCWithCustomBundleSucceedsOrFails(expected string) error {
func StartCRCWithDefaultBundleAndNameServerSucceedsOrFails(nameserver string, expected string) error {

var extraBundleArgs string
if !bundleEmbedded {
if userProvidedBundle {
extraBundleArgs = fmt.Sprintf("-b %s", bundleLocation)
}

Expand All @@ -410,7 +410,7 @@ func StartCRCWithDefaultBundleAndNameServerSucceedsOrFails(nameserver string, ex

func SetConfigPropertyToValueSucceedsOrFails(property string, value string, expected string) error {
if value == "current bundle" {
if bundleEmbedded {
if !userProvidedBundle {
value = filepath.Join(CRCHome, "cache", bundleName)
} else {
value = bundleLocation
Expand All @@ -424,5 +424,8 @@ func ExecuteCommand(command string) error {
}

func ExecuteCommandWithExpectedExitStatus(command string, expectedExitStatus string) error {
if command == "setup" && userProvidedBundle {
command = fmt.Sprintf("%s -b %s", command, bundleLocation)
}
return crcCmd.CRC(command).ExecuteWithExpectedExit(expectedExitStatus)
}
2 changes: 1 addition & 1 deletion test/e2e/features/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Feature: Basic test
Then executing "crc setup --check-only" fails
And starting CRC with default bundle fails
And stderr should contain "Preflight checks failed during `crc start`, please try to run `crc setup` first in case you haven't done so yet"
And executing "crc setup" succeeds
And executing crc setup command succeeds

@darwin
Scenario: CRC setup on Mac
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/features/cert_rotation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: Certificate rotation test
an app and check its accessibility.

Scenario: Setup CRC
Given execute crc setup command succeeds
Given executing crc setup command succeeds

Scenario: Set clock to 3 months ahead on the host
Given executing "sudo timedatectl set-ntp off" succeeds
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/features/story_health.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: End-to-end health check

@linux @darwin @startstop
Scenario: Start CRC
Given execute crc setup command succeeds
Given executing crc setup command succeeds
When setting config property "memory" to value "12000" succeeds
When starting CRC with default bundle succeeds
Then stdout should contain "Started the OpenShift cluster"
Expand All @@ -21,7 +21,7 @@ Feature: End-to-end health check

@windows @startstop
Scenario: Start CRC on Windows
Given execute crc setup command succeeds
Given executing crc setup command succeeds
When setting config property "memory" to value "12000" succeeds
When starting CRC with default bundle and nameserver "10.75.5.25" succeeds
Then stdout should contain "Started the OpenShift cluster"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/features/story_marketplace.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: Operator from marketplace

@linux @darwin @startstop
Scenario: Start CRC
Given execute crc setup command succeeds
Given executing crc setup command succeeds
When starting CRC with default bundle succeeds
Then stdout should contain "Started the OpenShift cluster"

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/features/story_registry.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: Local image to image-registry

@startstop
Scenario: Start CRC
Given execute crc setup command succeeds
Given executing crc setup command succeeds
When starting CRC with default bundle succeeds
Then stdout should contain "Started the OpenShift cluster"

Expand Down

0 comments on commit 82d937e

Please sign in to comment.