diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index 95325154e2..e34fe0481f 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -74,6 +74,12 @@ gsutil -qm cp \ "gs://minikube-builds/${MINIKUBE_LOCATION}/e2e-${OS_ARCH}" out gsutil -qm cp "gs://minikube-builds/${MINIKUBE_LOCATION}/testdata"/* testdata/ +gsutil -qm cp "gs://minikube-builds/${MINIKUBE_LOCATION}/testdata"/* testdata/ + +# to be used by TestVersionUpgrade +gsutil -qm cp gs://minikube/releases/latest/minikube-${OS_ARCH} testdata/minikube-${OS_ARCH}-latest-stable +chmod +x "testdata/minikube-${OS_ARCH}-latest-stable" + # Set the executable bit on the e2e binary and out binary export MINIKUBE_BIN="out/minikube-${OS_ARCH}" diff --git a/test/integration/fn_test.go b/test/integration/fn_test.go index 992097c841..34b9c0168f 100644 --- a/test/integration/fn_test.go +++ b/test/integration/fn_test.go @@ -32,6 +32,7 @@ func TestFunctional(t *testing.T) { if !usingNoneDriver(mk) { t.Parallel() } + mk.EnsureRunning() // This one is not parallel, and ensures the cluster comes up // before we run any other tests. diff --git a/test/integration/persistence_test.go b/test/integration/persistence_test.go index 0b1609cc21..031d72380c 100644 --- a/test/integration/persistence_test.go +++ b/test/integration/persistence_test.go @@ -41,6 +41,7 @@ func TestPersistence(t *testing.T) { if err != nil { t.Errorf("Error getting the file path for current directory: %s", curdir) } + // TODO change all testdata path to get from flag vs hardcode podPath := path.Join(curdir, "testdata", "busybox.yaml") // Create a pod and wait for it to be running. diff --git a/test/integration/util/common.go b/test/integration/util/common.go index 2def4eb5e4..86ad337cb1 100644 --- a/test/integration/util/common.go +++ b/test/integration/util/common.go @@ -162,6 +162,18 @@ func Retry(t *testing.T, callback func() error, d time.Duration, attempts int) ( return err } +// Retry2 tries the callback for a number of attempts, with a delay without *testing.T +func Retry2(callback func() error, d time.Duration, attempts int) (err error) { + for i := 0; i < attempts; i++ { + err = callback() + if err == nil { + return nil + } + time.Sleep(d) + } + return err +} + // Logf writes logs to stdout if -v is set. func Logf(str string, args ...interface{}) { if !testing.Verbose() { diff --git a/test/integration/version_upgrade_test.go b/test/integration/version_upgrade_test.go index 2d65d5c18a..d6dd6b463c 100644 --- a/test/integration/version_upgrade_test.go +++ b/test/integration/version_upgrade_test.go @@ -19,33 +19,51 @@ package integration import ( "fmt" "os" + "path/filepath" "runtime" "strings" "testing" "time" "github.com/docker/machine/libmachine/state" - "github.com/hashicorp/go-getter" "github.com/pkg/errors" "k8s.io/minikube/pkg/minikube/constants" - pkgutil "k8s.io/minikube/pkg/util" "k8s.io/minikube/test/integration/util" ) -func downloadMinikubeBinary(t *testing.T, dest string, version string) error { - // Grab latest release binary - url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS) - download := func() error { - return getter.GetFile(dest, url) - } +// This is moved to common.sh +// func downloadMinikubeBinary(dest string, version string) error { +// // Grab latest release binary +// url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS) +// download := func() error { +// return getter.GetFile(dest, url) +// } - if err := util.Retry(t, download, 3*time.Second, 13); err != nil { - return errors.Wrap(err, "Failed to get latest release binary") - } - if runtime.GOOS != "windows" { - if err := os.Chmod(dest, 0700); err != nil { +// if err := util.Retry2(download, 3*time.Second, 13); err != nil { +// return errors.Wrap(err, "Failed to get latest release binary") +// } +// if runtime.GOOS != "windows" { +// if err := os.Chmod(dest, 0700); err != nil { +// return err +// } +// } +// return nil +// } + +func fileExists(fname string) error { + check := func() error { + info, err := os.Stat(fname) + if os.IsNotExist(err) { return err } + if info.IsDir() { + return fmt.Errorf("Error expect file got dir") + } + return nil + } + + if err := util.Retry2(check, 1*time.Second, 3); err != nil { + return errors.Wrap(err, fmt.Sprintf("Failed check if file (%q) exists,", fname)) } return nil } @@ -55,15 +73,20 @@ func downloadMinikubeBinary(t *testing.T, dest string, version string) error { // and it tries to upgrade from the older supported k8s to news supported k8s func TestVersionUpgrade(t *testing.T) { p := t.Name() + // this gets downloaded by common.sh in the CI + fname := filepath.Join(*testdataDir, fmt.Sprintf("minikube-%s-%s-latest-stable", runtime.GOOS, runtime.GOARCH)) + err := fileExists(fname) + if err != nil { + t.Fail() + } + mkCurrent := NewMinikubeRunner(t, p) + if usingNoneDriver(mkCurrent) { // TODO (medyagh@): bring back once soled https://github.com/kubernetes/minikube/issues/4418 + t.Skip("skipping test as none driver does not support persistence") + } mkCurrent.RunCommand("delete", true) mkCurrent.CheckStatus(state.None.String()) - fname := "minikube_latest_binary" - err := downloadMinikubeBinary(t, fname, "latest") - if err != nil { - t.Fatal(errors.Wrap(err, "Failed to download minikube binary.")) - } defer os.Remove(fname) mkRelease := NewMinikubeRunner(t, p) @@ -74,12 +97,8 @@ func TestVersionUpgrade(t *testing.T) { mkRelease.RunCommand("stop", true) mkRelease.CheckStatus(state.Stopped.String()) - opts := "" - if usingNoneDriver(mkCurrent) { // to avoid https://github.com/kubernetes/minikube/issues/4418 - opts = "--apiserver-port=8444" - } // Trim the leading "v" prefix to assert that we handle it properly. - mkCurrent.Start(fmt.Sprintf("--kubernetes-version=%s", strings.TrimPrefix(constants.NewestKubernetesVersion, "v")), opts) + mkCurrent.Start(fmt.Sprintf("--kubernetes-version=%s", strings.TrimPrefix(constants.NewestKubernetesVersion, "v"))) mkCurrent.CheckStatus(state.Running.String()) mkCurrent.RunCommand("delete", true) mkCurrent.CheckStatus(state.None.String())