Merge pull request #77016 from jiatongw/e2e/framework/upgrade

[e2e] Move framework/upgrade_util.go to framework/lifecycle/upgrade.go
This commit is contained in:
Kubernetes Prow Robot
2019-05-06 17:07:41 -07:00
committed by GitHub
5 changed files with 63 additions and 31 deletions

View File

@@ -30,7 +30,6 @@ go_library(
"ssh.go",
"statefulset_utils.go",
"test_context.go",
"upgrade_util.go",
"util.go",
],
importpath = "k8s.io/kubernetes/test/e2e/framework",
@@ -91,7 +90,6 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/util/version:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/version:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/authentication/serviceaccount:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
@@ -152,6 +150,7 @@ filegroup(
"//test/e2e/framework/gpu:all-srcs",
"//test/e2e/framework/ingress:all-srcs",
"//test/e2e/framework/job:all-srcs",
"//test/e2e/framework/lifecycle:all-srcs",
"//test/e2e/framework/log:all-srcs",
"//test/e2e/framework/metrics:all-srcs",
"//test/e2e/framework/podlogs:all-srcs",

View File

@@ -0,0 +1,29 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["upgrade.go"],
importpath = "k8s.io/kubernetes/test/e2e/framework/lifecycle",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/version:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//test/e2e/framework:go_default_library",
"//test/e2e/framework/log:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package framework
package lifecycle
import (
"fmt"
@@ -26,39 +26,41 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/version"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
)
// RealVersion turns a version constants into a version string deployable on
// GKE. See hack/get-build.sh for more information.
func RealVersion(s string) (string, error) {
Logf("Getting real version for %q", s)
v, _, err := RunCmd(path.Join(TestContext.RepoRoot, "hack/get-build.sh"), "-v", s)
e2elog.Logf("Getting real version for %q", s)
v, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/get-build.sh"), "-v", s)
if err != nil {
return v, fmt.Errorf("error getting real version for %q: %v", s, err)
}
Logf("Version for %q is %q", s, v)
e2elog.Logf("Version for %q is %q", s, v)
return strings.TrimPrefix(strings.TrimSpace(v), "v"), nil
}
func traceRouteToMaster() {
path, err := exec.LookPath("traceroute")
if err != nil {
Logf("Could not find traceroute program")
e2elog.Logf("Could not find traceroute program")
return
}
cmd := exec.Command(path, "-I", GetMasterHost())
cmd := exec.Command(path, "-I", framework.GetMasterHost())
out, err := cmd.Output()
if len(out) != 0 {
Logf(string(out))
e2elog.Logf(string(out))
}
if exiterr, ok := err.(*exec.ExitError); err != nil && ok {
Logf("Error while running traceroute: %s", exiterr.Stderr)
e2elog.Logf("Error while running traceroute: %s", exiterr.Stderr)
}
}
// CheckMasterVersion validates the master version
func CheckMasterVersion(c clientset.Interface, want string) error {
Logf("Checking master version")
e2elog.Logf("Checking master version")
var err error
var v *version.Info
waitErr := wait.PollImmediate(5*time.Second, 2*time.Minute, func() (bool, error) {
@@ -79,13 +81,13 @@ func CheckMasterVersion(c clientset.Interface, want string) error {
if !strings.HasPrefix(got, want) {
return fmt.Errorf("master had kube-apiserver version %s which does not start with %s", got, want)
}
Logf("Master is at version %s", want)
e2elog.Logf("Master is at version %s", want)
return nil
}
// CheckNodesVersions validates the nodes versions
func CheckNodesVersions(cs clientset.Interface, want string) error {
l := GetReadySchedulableNodesOrDie(cs)
l := framework.GetReadySchedulableNodesOrDie(cs)
for _, n := range l.Items {
// We do prefix trimming and then matching because:
// want looks like: 0.19.3-815-g50e67d4