Commit 78f04e2a authored by Yang Guo's avatar Yang Guo

Add node e2e tests for GKE environment

parent 72b2a03d
...@@ -135,6 +135,10 @@ type NodeTestContextType struct { ...@@ -135,6 +135,10 @@ type NodeTestContextType struct {
KubeletConfig componentconfig.KubeletConfiguration KubeletConfig componentconfig.KubeletConfiguration
// ImageDescription is the description of the image on which the test is running. // ImageDescription is the description of the image on which the test is running.
ImageDescription string ImageDescription string
// SystemSpecName is the name of the system spec (e.g., gke) that's used in
// the node e2e test. If empty, the default one (system.DefaultSpec) is
// used. The system specs are in test/e2e_node/system/specs/.
SystemSpecName string
} }
type CloudConfig struct { type CloudConfig struct {
...@@ -256,6 +260,7 @@ func RegisterNodeFlags() { ...@@ -256,6 +260,7 @@ func RegisterNodeFlags() {
flag.BoolVar(&TestContext.NodeConformance, "conformance", false, "If true, the test suite will not start kubelet, and fetch system log (kernel, docker, kubelet log etc.) to the report directory.") flag.BoolVar(&TestContext.NodeConformance, "conformance", false, "If true, the test suite will not start kubelet, and fetch system log (kernel, docker, kubelet log etc.) to the report directory.")
flag.BoolVar(&TestContext.PrepullImages, "prepull-images", true, "If true, prepull images so image pull failures do not cause test failures.") flag.BoolVar(&TestContext.PrepullImages, "prepull-images", true, "If true, prepull images so image pull failures do not cause test failures.")
flag.StringVar(&TestContext.ImageDescription, "image-description", "", "The description of the image which the test will be running on.") flag.StringVar(&TestContext.ImageDescription, "image-description", "", "The description of the image which the test will be running on.")
flag.StringVar(&TestContext.SystemSpecName, "system-spec-name", "", "The name of the system spec (e.g., gke) that's used in the node e2e test. The system specs are in test/e2e_node/system/specs/. This is used by the test framework to determine which tests to run for validating the system requirements.")
} }
// ViperizeFlags sets up all flag and config processing. Future configuration info should be added to viper, not to flags. // ViperizeFlags sets up all flag and config processing. Future configuration info should be added to viper, not to flags.
......
...@@ -356,6 +356,24 @@ func SkipIfContainerRuntimeIs(runtimes ...string) { ...@@ -356,6 +356,24 @@ func SkipIfContainerRuntimeIs(runtimes ...string) {
} }
} }
func RunIfContainerRuntimeIs(runtimes ...string) {
for _, runtime := range runtimes {
if runtime == TestContext.ContainerRuntime {
return
}
}
Skipf("Skipped because container runtime %q is not in %s", TestContext.ContainerRuntime, runtimes)
}
func RunIfSystemSpecNameIs(names ...string) {
for _, name := range names {
if name == TestContext.SystemSpecName {
return
}
}
Skipf("Skipped because system spec name %q is not in %v", TestContext.SystemSpecName, names)
}
func ProviderIs(providers ...string) bool { func ProviderIs(providers ...string) bool {
for _, provider := range providers { for _, provider := range providers {
if strings.ToLower(provider) == strings.ToLower(TestContext.Provider) { if strings.ToLower(provider) == strings.ToLower(TestContext.Provider) {
......
...@@ -75,6 +75,7 @@ go_test( ...@@ -75,6 +75,7 @@ go_test(
"dynamic_kubelet_configuration_test.go", "dynamic_kubelet_configuration_test.go",
"e2e_node_suite_test.go", "e2e_node_suite_test.go",
"garbage_collector_test.go", "garbage_collector_test.go",
"gke_environment_test.go",
"image_id_test.go", "image_id_test.go",
"inode_eviction_test.go", "inode_eviction_test.go",
"kubelet_test.go", "kubelet_test.go",
......
...@@ -43,5 +43,7 @@ ENTRYPOINT ginkgo --focus="$FOCUS" \ ...@@ -43,5 +43,7 @@ ENTRYPOINT ginkgo --focus="$FOCUS" \
--prepull-images=false \ --prepull-images=false \
--report-dir="$REPORT_PATH" \ --report-dir="$REPORT_PATH" \
# This is a placeholder that will be substituted in the Makefile. # This is a placeholder that will be substituted in the Makefile.
--system-spec-name=SYSTEM_SPEC_NAME \
# This is a placeholder that will be substituted in the Makefile.
--system-spec-file=SYSTEM_SPEC_FILE_PATH \ --system-spec-file=SYSTEM_SPEC_FILE_PATH \
$TEST_ARGS $TEST_ARGS
...@@ -64,6 +64,7 @@ endif ...@@ -64,6 +64,7 @@ endif
cd ${TEMP_DIR} && sed -i.back \ cd ${TEMP_DIR} && sed -i.back \
"s|BASEIMAGE|${BASEIMAGE}|g;\ "s|BASEIMAGE|${BASEIMAGE}|g;\
s|COPY_SYSTEM_SPEC_FILE|${COPY_SYSTEM_SPEC_FILE}|g;\ s|COPY_SYSTEM_SPEC_FILE|${COPY_SYSTEM_SPEC_FILE}|g;\
s|SYSTEM_SPEC_NAME|${SYSTEM_SPEC_NAME}|g;\
s|SYSTEM_SPEC_FILE_PATH|${SYSTEM_SPEC_FILE_PATH}|g" Dockerfile s|SYSTEM_SPEC_FILE_PATH|${SYSTEM_SPEC_FILE_PATH}|g" Dockerfile
# Make scripts executable before they are copied into the Docker image. If we make them executable later, in another layer # Make scripts executable before they are copied into the Docker image. If we make them executable later, in another layer
......
...@@ -211,8 +211,8 @@ func (n *NodeE2ERemote) RunTest(host, workspace, results, imageDesc, junitFilePr ...@@ -211,8 +211,8 @@ func (n *NodeE2ERemote) RunTest(host, workspace, results, imageDesc, junitFilePr
glog.V(2).Infof("Starting tests on %q", host) glog.V(2).Infof("Starting tests on %q", host)
cmd := getSSHCommand(" && ", cmd := getSSHCommand(" && ",
fmt.Sprintf("cd %s", workspace), fmt.Sprintf("cd %s", workspace),
fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-file=%s --logtostderr --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=%s %s", fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-name=%s --system-spec-file=%s --logtostderr --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=%s %s",
timeout.Seconds(), ginkgoArgs, systemSpecFile, host, results, junitFilePrefix, imageDesc, testArgs), timeout.Seconds(), ginkgoArgs, systemSpecName, systemSpecFile, host, results, junitFilePrefix, imageDesc, testArgs),
) )
return SSH(host, "sh", "-c", cmd) return SSH(host, "sh", "-c", cmd)
} }
...@@ -66,7 +66,7 @@ func main() { ...@@ -66,7 +66,7 @@ func main() {
glog.Fatalf("Failed to get k8s root directory: %v", err) glog.Fatalf("Failed to get k8s root directory: %v", err)
} }
systemSpecFile := filepath.Join(rootDir, systemSpecPath, *systemSpecName+".yaml") systemSpecFile := filepath.Join(rootDir, systemSpecPath, *systemSpecName+".yaml")
runCommand(ginkgo, *ginkgoFlags, test, "--", fmt.Sprintf("--system-spec-file=%s", systemSpecFile), *testFlags) runCommand(ginkgo, *ginkgoFlags, test, "--", fmt.Sprintf("--system-spec-name=%s --system-spec-file=%s", *systemSpecName, systemSpecFile), *testFlags)
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment