move file download logic to common.sh
parent
04144ca1d4
commit
25bc27e170
|
@ -74,6 +74,12 @@ gsutil -qm cp \
|
||||||
"gs://minikube-builds/${MINIKUBE_LOCATION}/e2e-${OS_ARCH}" out
|
"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/
|
||||||
|
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
|
# Set the executable bit on the e2e binary and out binary
|
||||||
export MINIKUBE_BIN="out/minikube-${OS_ARCH}"
|
export MINIKUBE_BIN="out/minikube-${OS_ARCH}"
|
||||||
|
|
|
@ -32,6 +32,7 @@ func TestFunctional(t *testing.T) {
|
||||||
if !usingNoneDriver(mk) {
|
if !usingNoneDriver(mk) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
}
|
}
|
||||||
|
|
||||||
mk.EnsureRunning()
|
mk.EnsureRunning()
|
||||||
// This one is not parallel, and ensures the cluster comes up
|
// This one is not parallel, and ensures the cluster comes up
|
||||||
// before we run any other tests.
|
// before we run any other tests.
|
||||||
|
|
|
@ -41,6 +41,7 @@ func TestPersistence(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error getting the file path for current directory: %s", curdir)
|
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")
|
podPath := path.Join(curdir, "testdata", "busybox.yaml")
|
||||||
|
|
||||||
// Create a pod and wait for it to be running.
|
// Create a pod and wait for it to be running.
|
||||||
|
|
|
@ -162,6 +162,18 @@ func Retry(t *testing.T, callback func() error, d time.Duration, attempts int) (
|
||||||
return err
|
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.
|
// Logf writes logs to stdout if -v is set.
|
||||||
func Logf(str string, args ...interface{}) {
|
func Logf(str string, args ...interface{}) {
|
||||||
if !testing.Verbose() {
|
if !testing.Verbose() {
|
||||||
|
|
|
@ -19,33 +19,51 @@ package integration
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/machine/libmachine/state"
|
"github.com/docker/machine/libmachine/state"
|
||||||
"github.com/hashicorp/go-getter"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"k8s.io/minikube/pkg/minikube/constants"
|
"k8s.io/minikube/pkg/minikube/constants"
|
||||||
pkgutil "k8s.io/minikube/pkg/util"
|
|
||||||
"k8s.io/minikube/test/integration/util"
|
"k8s.io/minikube/test/integration/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func downloadMinikubeBinary(t *testing.T, dest string, version string) error {
|
// This is moved to common.sh
|
||||||
// Grab latest release binary
|
// func downloadMinikubeBinary(dest string, version string) error {
|
||||||
url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS)
|
// // Grab latest release binary
|
||||||
download := func() error {
|
// url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS)
|
||||||
return getter.GetFile(dest, url)
|
// download := func() error {
|
||||||
}
|
// return getter.GetFile(dest, url)
|
||||||
|
// }
|
||||||
|
|
||||||
if err := util.Retry(t, download, 3*time.Second, 13); err != nil {
|
// if err := util.Retry2(download, 3*time.Second, 13); err != nil {
|
||||||
return errors.Wrap(err, "Failed to get latest release binary")
|
// return errors.Wrap(err, "Failed to get latest release binary")
|
||||||
}
|
// }
|
||||||
if runtime.GOOS != "windows" {
|
// if runtime.GOOS != "windows" {
|
||||||
if err := os.Chmod(dest, 0700); err != nil {
|
// 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
|
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
|
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
|
// and it tries to upgrade from the older supported k8s to news supported k8s
|
||||||
func TestVersionUpgrade(t *testing.T) {
|
func TestVersionUpgrade(t *testing.T) {
|
||||||
p := t.Name()
|
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)
|
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.RunCommand("delete", true)
|
||||||
mkCurrent.CheckStatus(state.None.String())
|
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)
|
defer os.Remove(fname)
|
||||||
|
|
||||||
mkRelease := NewMinikubeRunner(t, p)
|
mkRelease := NewMinikubeRunner(t, p)
|
||||||
|
@ -74,12 +97,8 @@ func TestVersionUpgrade(t *testing.T) {
|
||||||
mkRelease.RunCommand("stop", true)
|
mkRelease.RunCommand("stop", true)
|
||||||
mkRelease.CheckStatus(state.Stopped.String())
|
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.
|
// 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.CheckStatus(state.Running.String())
|
||||||
mkCurrent.RunCommand("delete", true)
|
mkCurrent.RunCommand("delete", true)
|
||||||
mkCurrent.CheckStatus(state.None.String())
|
mkCurrent.CheckStatus(state.None.String())
|
||||||
|
|
Loading…
Reference in New Issue