Adding test to make sure HEAD can run on VM created by latest release

pull/3929/head
Sharif Elgamal 2019-03-21 17:36:13 -07:00
parent b08af1947a
commit ffaa27b256
No known key found for this signature in database
GPG Key ID: 23CC0225BD9FD702
2 changed files with 95 additions and 7 deletions

14
test.sh
View File

@ -20,9 +20,9 @@ REPO_PATH="k8s.io/minikube"
# Check for python on host, and use it if possible, otherwise fall back on python dockerized
if [[ -f $(which python 2>&1) ]]; then
PYTHON="python"
PYTHON="python"
else
PYTHON="docker run --rm -it -v $(pwd):/minikube -w /minikube python python"
PYTHON="docker run --rm -it -v $(pwd):/minikube -w /minikube python python"
fi
@ -51,9 +51,9 @@ set +e
files=$(gofmt -l -s . | grep -v ${ignore})
set -e
if [[ $files ]]; then
gofmt -d ${files}
echo "Gofmt errors in files: $files"
exit 1
gofmt -d ${files}
echo "Gofmt errors in files: $files"
exit 1
fi
# Check boilerplate
@ -64,8 +64,8 @@ set +e
files=$(${PYTHON} ${BOILERPLATEDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BOILERPLATEDIR} | grep -v $ignore)
set -e
if [[ ! -z ${files} ]]; then
echo "Boilerplate missing in: ${files}."
exit 1
echo "Boilerplate missing in: ${files}."
exit 1
fi
echo "Checking releases.json schema"

View File

@ -0,0 +1,88 @@
/*
Copyright 2019 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package integration
import (
"io"
"io/ioutil"
"net/http"
"os"
"os/exec"
"runtime"
"testing"
"github.com/docker/machine/libmachine/state"
"github.com/pkg/errors"
"k8s.io/minikube/test/integration/util"
)
func TestVersionUpgrade(t *testing.T) {
currentRunner := NewMinikubeRunner(t)
currentRunner.RunCommand("delete", true)
currentRunner.CheckStatus(state.None.String())
isoName := "minikube-linux-amd64"
if runtime.GOOS == "darwin" {
isoName = "minikube-darwin-amd64"
} else if runtime.GOOS == "windows" {
isoName = "minikube-windows-amd64.exe"
}
// Grab latest release binary
url := "https://storage.googleapis.com/minikube/releases/latest/" + isoName
resp, err := http.Get(url)
if err != nil {
t.Fatal(errors.Wrap(err, "Failed to get latest release binary"))
}
defer resp.Body.Close()
iso, err := ioutil.TempFile("", isoName)
if err != nil {
t.Fatal(errors.Wrap(err, "Failed to create binary file"))
}
defer os.Remove(iso.Name())
_, err = io.Copy(iso, resp.Body)
if err != nil {
t.Fatal(errors.Wrap(err, "Failed to populate iso file"))
}
if err := iso.Close(); err != nil {
t.Fatal(errors.Wrap(err, "Failed to close iso"))
}
if runtime.GOOS != "windows" {
if err := exec.Command("chmod", "+x", iso.Name()).Run(); err != nil {
t.Fatal(errors.Wrap(err, "Failed to make binary executable."))
}
}
latestRunner := util.MinikubeRunner{
Args: currentRunner.Args,
BinaryPath: iso.Name(),
StartArgs: currentRunner.StartArgs,
MountArgs: currentRunner.MountArgs,
T: t,
}
latestRunner.Start()
latestRunner.CheckStatus(state.Running.String())
latestRunner.RunCommand("stop", true)
latestRunner.CheckStatus(state.Stopped.String())
currentRunner.Start()
currentRunner.CheckStatus(state.Running.String())
currentRunner.RunCommand("delete", true)
currentRunner.CheckStatus(state.None.String())
}