mirror of https://github.com/k3s-io/k3s
Remove PrepareVersion from hack/e2e.go.
parent
0b9451cb73
commit
930291588c
|
@ -63,9 +63,6 @@ go run hack/e2e.go -v --build
|
||||||
# Create a fresh cluster. Deletes a cluster first, if it exists
|
# Create a fresh cluster. Deletes a cluster first, if it exists
|
||||||
go run hack/e2e.go -v --up
|
go run hack/e2e.go -v --up
|
||||||
|
|
||||||
# Create a fresh cluster at a specific release version.
|
|
||||||
go run hack/e2e.go -v --up --version=0.7.0
|
|
||||||
|
|
||||||
# Test if a cluster is up.
|
# Test if a cluster is up.
|
||||||
go run hack/e2e.go -v --isup
|
go run hack/e2e.go -v --isup
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,13 @@ set -o pipefail
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||||
|
|
||||||
: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}}
|
: ${KUBECTL:=${KUBE_ROOT}/cluster/kubectl.sh}
|
||||||
: ${KUBECTL:=${KUBE_VERSION_ROOT}/cluster/kubectl.sh}
|
|
||||||
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
||||||
|
|
||||||
export KUBECTL KUBE_CONFIG_FILE
|
export KUBECTL KUBE_CONFIG_FILE
|
||||||
|
|
||||||
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
||||||
source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
||||||
|
|
||||||
prepare-e2e
|
prepare-e2e
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,13 @@ set -o pipefail
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||||
|
|
||||||
: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}}
|
: ${KUBECTL:=${KUBE_ROOT}/cluster/kubectl.sh}
|
||||||
: ${KUBECTL:=${KUBE_VERSION_ROOT}/cluster/kubectl.sh}
|
|
||||||
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
||||||
|
|
||||||
export KUBECTL KUBE_CONFIG_FILE
|
export KUBECTL KUBE_CONFIG_FILE
|
||||||
|
|
||||||
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
||||||
source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
||||||
|
|
||||||
prepare-e2e
|
prepare-e2e
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,13 @@ set -o pipefail
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||||
|
|
||||||
: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}}
|
: ${KUBECTL:=${KUBE_ROOT}/cluster/kubectl.sh}
|
||||||
: ${KUBECTL:=${KUBE_VERSION_ROOT}/cluster/kubectl.sh}
|
|
||||||
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
||||||
|
|
||||||
export KUBECTL KUBE_CONFIG_FILE
|
export KUBECTL KUBE_CONFIG_FILE
|
||||||
|
|
||||||
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
||||||
source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
||||||
|
|
||||||
prepare-e2e
|
prepare-e2e
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,14 @@ set -o pipefail
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||||
|
|
||||||
: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}}
|
: ${KUBECTL:=${KUBE_ROOT}/cluster/kubectl.sh}
|
||||||
: ${KUBECTL:=${KUBE_VERSION_ROOT}/cluster/kubectl.sh}
|
|
||||||
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
||||||
|
|
||||||
export KUBECTL KUBE_CONFIG_FILE
|
export KUBECTL KUBE_CONFIG_FILE
|
||||||
|
|
||||||
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
||||||
source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
||||||
|
|
||||||
prepare-e2e
|
prepare-e2e
|
||||||
|
|
||||||
"${KUBE_VERSION_ROOT}/cluster/kube-push.sh" $@
|
"${KUBE_ROOT}/cluster/kube-push.sh" $@
|
||||||
|
|
|
@ -20,14 +20,13 @@ set -o pipefail
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||||
|
|
||||||
: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}}
|
: ${KUBECTL:=${KUBE_ROOT}/cluster/kubectl.sh}
|
||||||
: ${KUBECTL:=${KUBE_VERSION_ROOT}/cluster/kubectl.sh}
|
|
||||||
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
||||||
|
|
||||||
export KUBECTL KUBE_CONFIG_FILE
|
export KUBECTL KUBE_CONFIG_FILE
|
||||||
|
|
||||||
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
||||||
source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
||||||
|
|
||||||
prepare-e2e
|
prepare-e2e
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,13 @@ set -o pipefail
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||||
|
|
||||||
: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}}
|
: ${KUBECTL:=${KUBE_ROOT}/cluster/kubectl.sh}
|
||||||
: ${KUBECTL:=${KUBE_VERSION_ROOT}/cluster/kubectl.sh}
|
|
||||||
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
||||||
|
|
||||||
export KUBECTL KUBE_CONFIG_FILE
|
export KUBECTL KUBE_CONFIG_FILE
|
||||||
|
|
||||||
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
||||||
source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
||||||
|
|
||||||
prepare-e2e
|
prepare-e2e
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,14 @@ set -o pipefail
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||||
|
|
||||||
: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}}
|
: ${KUBECTL:=${KUBE_ROOT}/cluster/kubectl.sh}
|
||||||
: ${KUBECTL:=${KUBE_VERSION_ROOT}/cluster/kubectl.sh}
|
|
||||||
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
||||||
|
|
||||||
export KUBECTL KUBE_CONFIG_FILE
|
export KUBECTL KUBE_CONFIG_FILE
|
||||||
|
|
||||||
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
source "${KUBE_ROOT}/cluster/kube-env.sh"
|
||||||
source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
||||||
|
|
||||||
prepare-e2e
|
prepare-e2e
|
||||||
|
|
||||||
"${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/upgrade.sh" $@
|
"${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/upgrade.sh" $@
|
||||||
|
|
83
hack/e2e.go
83
hack/e2e.go
|
@ -19,10 +19,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
@ -35,7 +32,6 @@ import (
|
||||||
var (
|
var (
|
||||||
isup = flag.Bool("isup", false, "Check to see if the e2e cluster is up, then exit.")
|
isup = flag.Bool("isup", false, "Check to see if the e2e cluster is up, then exit.")
|
||||||
build = flag.Bool("build", false, "If true, build a new release. Otherwise, use whatever is there.")
|
build = flag.Bool("build", false, "If true, build a new release. Otherwise, use whatever is there.")
|
||||||
version = flag.String("version", "", "The version to be tested (including the leading 'v'). An empty string defaults to the local build, but it can be set to any release (e.g. v0.4.4, v0.6.0).")
|
|
||||||
up = flag.Bool("up", false, "If true, start the the e2e cluster. If cluster is already up, recreate it.")
|
up = flag.Bool("up", false, "If true, start the the e2e cluster. If cluster is already up, recreate it.")
|
||||||
push = flag.Bool("push", false, "If true, push to e2e cluster. Has no effect if -up is true.")
|
push = flag.Bool("push", false, "If true, push to e2e cluster. Has no effect if -up is true.")
|
||||||
pushup = flag.Bool("pushup", false, "If true, push to e2e cluster if it's up, otherwise start the e2e cluster.")
|
pushup = flag.Bool("pushup", false, "If true, push to e2e cluster if it's up, otherwise start the e2e cluster.")
|
||||||
|
@ -53,18 +49,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
serverTarName = "kubernetes-server-linux-amd64.tar.gz"
|
minNodeCount = 2
|
||||||
saltTarName = "kubernetes-salt.tar.gz"
|
|
||||||
downloadDirName = "_output/downloads"
|
|
||||||
tarDirName = "server"
|
|
||||||
tempDirName = "upgrade-e2e-temp-dir"
|
|
||||||
minNodeCount = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// Root directory of the specified cluster version, rather than of where
|
|
||||||
// this script is being run from.
|
|
||||||
versionRoot = *root
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func absOrDie(path string) string {
|
func absOrDie(path string) string {
|
||||||
|
@ -107,21 +92,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *version != "" {
|
os.Setenv("KUBECTL", *root+`/cluster/kubectl.sh`+kubectlArgs())
|
||||||
// If the desired version isn't available already, do whatever's needed
|
|
||||||
// to make it available. Once done, update the root directory for client
|
|
||||||
// tools to be the root of the release directory so that the given
|
|
||||||
// release's tools will be used. We can't use this new root for
|
|
||||||
// everything because it likely doesn't have the hack/ directory in it.
|
|
||||||
if newVersionRoot, err := PrepareVersion(*version); err != nil {
|
|
||||||
log.Fatalf("Error preparing a binary of version %s: %s. Aborting.", *version, err)
|
|
||||||
} else {
|
|
||||||
versionRoot = newVersionRoot
|
|
||||||
os.Setenv("KUBE_VERSION_ROOT", newVersionRoot)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
os.Setenv("KUBECTL", versionRoot+`/cluster/kubectl.sh`+kubectlArgs())
|
|
||||||
os.Setenv("KUBE_TEST_DEBUG", "y")
|
os.Setenv("KUBE_TEST_DEBUG", "y")
|
||||||
|
|
||||||
if *pushup {
|
if *pushup {
|
||||||
|
@ -150,7 +121,7 @@ func main() {
|
||||||
case *ctlCmd != "":
|
case *ctlCmd != "":
|
||||||
ctlArgs := strings.Fields(*ctlCmd)
|
ctlArgs := strings.Fields(*ctlCmd)
|
||||||
os.Setenv("KUBE_CONFIG_FILE", "config-test.sh")
|
os.Setenv("KUBE_CONFIG_FILE", "config-test.sh")
|
||||||
success = finishRunning("'kubectl "+*ctlCmd+"'", exec.Command(path.Join(versionRoot, "cluster/kubectl.sh"), ctlArgs...))
|
success = finishRunning("'kubectl "+*ctlCmd+"'", exec.Command(path.Join(*root, "cluster/kubectl.sh"), ctlArgs...))
|
||||||
case *test:
|
case *test:
|
||||||
success = Test()
|
success = Test()
|
||||||
}
|
}
|
||||||
|
@ -206,54 +177,6 @@ func IsUp() bool {
|
||||||
return finishRunning("get status", exec.Command(path.Join(*root, "hack/e2e-internal/e2e-status.sh")))
|
return finishRunning("get status", exec.Command(path.Join(*root, "hack/e2e-internal/e2e-status.sh")))
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrepareVersion makes sure that the specified release version is locally
|
|
||||||
// available and ready to be used by kube-up or kube-push. Returns the director
|
|
||||||
// path of the release.
|
|
||||||
func PrepareVersion(version string) (string, error) {
|
|
||||||
if version == "" {
|
|
||||||
// Assume that the build flag already handled building a local binary.
|
|
||||||
return *root, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the version isn't a local build, try fetching the release from Google
|
|
||||||
// Cloud Storage.
|
|
||||||
downloadDir := filepath.Join(*root, downloadDirName)
|
|
||||||
if err := os.MkdirAll(downloadDir, 0755); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
localReleaseDir := filepath.Join(downloadDir, version)
|
|
||||||
if err := os.MkdirAll(localReleaseDir, 0755); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
remoteReleaseTar := fmt.Sprintf("https://storage.googleapis.com/kubernetes-release/release/%s/kubernetes.tar.gz", version)
|
|
||||||
localReleaseTar := filepath.Join(downloadDir, fmt.Sprintf("kubernetes-%s.tar.gz", version))
|
|
||||||
if _, err := os.Stat(localReleaseTar); os.IsNotExist(err) {
|
|
||||||
out, err := os.Create(localReleaseTar)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
resp, err := http.Get(remoteReleaseTar)
|
|
||||||
if err != nil {
|
|
||||||
out.Close()
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
io.Copy(out, resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
out.Close()
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
out.Close()
|
|
||||||
}
|
|
||||||
if !finishRunning("untarRelease", exec.Command("tar", "-C", localReleaseDir, "-zxf", localReleaseTar, "--strip-components=1")) {
|
|
||||||
log.Fatal("Failed to untar release. Aborting.")
|
|
||||||
}
|
|
||||||
// Now that we have the binaries saved locally, use the path to the untarred
|
|
||||||
// directory as the "root" path for future operations.
|
|
||||||
return localReleaseDir, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test() bool {
|
func Test() bool {
|
||||||
if !IsUp() {
|
if !IsUp() {
|
||||||
log.Fatal("Testing requested, but e2e cluster not up!")
|
log.Fatal("Testing requested, but e2e cluster not up!")
|
||||||
|
|
|
@ -33,8 +33,7 @@ e2e_test=$(kube::util::find-binary "e2e.test")
|
||||||
|
|
||||||
# --- Setup some env vars.
|
# --- Setup some env vars.
|
||||||
|
|
||||||
: ${KUBE_VERSION_ROOT:=${KUBE_ROOT}}
|
: ${KUBECTL:="${KUBE_ROOT}/cluster/kubectl.sh"}
|
||||||
: ${KUBECTL:="${KUBE_VERSION_ROOT}/cluster/kubectl.sh"}
|
|
||||||
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
||||||
|
|
||||||
export KUBECTL KUBE_CONFIG_FILE
|
export KUBECTL KUBE_CONFIG_FILE
|
||||||
|
@ -54,7 +53,7 @@ if [[ -n "${KUBERNETES_CONFORMANCE_TEST:-}" ]]; then
|
||||||
else
|
else
|
||||||
echo "Setting up for KUBERNETES_PROVIDER=\"${KUBERNETES_PROVIDER}\"."
|
echo "Setting up for KUBERNETES_PROVIDER=\"${KUBERNETES_PROVIDER}\"."
|
||||||
|
|
||||||
source "${KUBE_VERSION_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
||||||
|
|
||||||
prepare-e2e
|
prepare-e2e
|
||||||
|
|
||||||
|
@ -103,7 +102,7 @@ export PATH=$(dirname "${e2e_test}"):"${PATH}"
|
||||||
--gke-cluster="${CLUSTER_NAME:-}" \
|
--gke-cluster="${CLUSTER_NAME:-}" \
|
||||||
--kube-master="${KUBE_MASTER:-}" \
|
--kube-master="${KUBE_MASTER:-}" \
|
||||||
--cluster-tag="${CLUSTER_ID:-}" \
|
--cluster-tag="${CLUSTER_ID:-}" \
|
||||||
--repo-root="${KUBE_VERSION_ROOT}" \
|
--repo-root="${KUBE_ROOT}" \
|
||||||
--node-instance-group="${NODE_INSTANCE_GROUP:-}" \
|
--node-instance-group="${NODE_INSTANCE_GROUP:-}" \
|
||||||
--num-nodes="${NUM_NODES:-}" \
|
--num-nodes="${NUM_NODES:-}" \
|
||||||
--prefix="${KUBE_GCE_INSTANCE_PREFIX:-e2e}" \
|
--prefix="${KUBE_GCE_INSTANCE_PREFIX:-e2e}" \
|
||||||
|
|
Loading…
Reference in New Issue