Add Dockerfile and Makefile to containerize node conformance test.

This commit is contained in:
Random-Liu
2016-08-18 22:43:20 -07:00
parent 919935beec
commit 9345e12bc9
5 changed files with 294 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ import (
"os"
"os/exec"
"path"
"syscall"
"testing"
"time"
@@ -71,6 +72,10 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
// When running the containerized conformance test, we'll mount the
// host root filesystem as readonly to /rootfs.
const rootfs = "/rootfs"
func TestE2eNode(t *testing.T) {
if *runServicesMode {
// If run-services-mode is specified, only run services in current process.
@@ -79,6 +84,15 @@ func TestE2eNode(t *testing.T) {
}
if *systemValidateMode {
// If system-validate-mode is specified, only run system validation in current process.
if framework.TestContext.NodeConformance {
// Chroot to /rootfs to make system validation can check system
// as in the root filesystem.
// TODO(random-liu): Consider to chroot the whole test process to make writing
// test easier.
if err := syscall.Chroot(rootfs); err != nil {
glog.Exitf("chroot %q failed: %v", rootfs, err)
}
}
if err := system.Validate(); err != nil {
glog.Exitf("system validation failed: %v", err)
}
@@ -172,6 +186,7 @@ func validateSystem() error {
if err != nil {
return fmt.Errorf("can't get current binary: %v", err)
}
// Pass all flags into the child process, so that it will see the same flag set.
output, err := exec.Command(testBin, append([]string{"--system-validate-mode"}, os.Args[1:]...)...).CombinedOutput()
// The output of system validation should have been formatted, directly print here.
fmt.Print(string(output))