Skip to content

Commit

Permalink
test/node_e2e: wire-in "container-runtime" for local tests
Browse files Browse the repository at this point in the history
This commit wires-in the pre-existing `--container-runtime` flag for
local node_e2e testing.
This is needed in order to further skip docker specific testing
and validation.

Local CRI node_e2e can now be performed via
`make test-e2e-node RUNTIME=remote REMOTE=false`
which will also take care of passing the appropriate arguments to
the kubelet.
  • Loading branch information
lucab committed Feb 1, 2017
1 parent 373ff83 commit 42bdbe5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ define TEST_E2E_NODE_HELP_INFO
# GUBERNATOR: For REMOTE=true only. Produce link to Gubernator to view logs.
# Defaults to false.
# PARALLELISM: The number of gingko nodes to run. Defaults to 8.
# RUNTIME: Container runtime to use (eg. docker, rkt, remote).
# Defaults to "docker".
#
# Example:
# make test-e2e-node FOCUS=Kubelet SKIP=container
Expand Down
9 changes: 8 additions & 1 deletion hack/make-rules/test-e2e-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ skip=${SKIP-"\[Flaky\]|\[Slow\]|\[Serial\]"}
parallelism=${PARALLELISM:-8}
artifacts=${ARTIFACTS:-"/tmp/_artifacts/`date +%y%m%dT%H%M%S`"}
remote=${REMOTE:-"false"}
runtime=${RUNTIME:-"docker"}
run_until_failure=${RUN_UNTIL_FAILURE:-"false"}
test_args=${TEST_ARGS:-""}

Expand Down Expand Up @@ -144,10 +145,16 @@ else
# test_args.
test_args='--kubelet-flags="--network-plugin= --network-plugin-dir=" '$test_args

# Runtime flags
test_args='--kubelet-flags="--container-runtime='$runtime'" '$test_args
if [[ $runtime == "remote" ]] ; then
test_args='--kubelet-flags="--experimental-cri=true" '$test_args
fi

# Test using the host the script was run on
# Provided for backwards compatibility
go run test/e2e_node/runner/local/run_local.go --ginkgo-flags="$ginkgoflags" \
--test-flags="--alsologtostderr --v 4 --report-dir=${artifacts} --node-name $(hostname) \
--test-flags="--container-runtime=${runtime} --alsologtostderr --v 4 --report-dir=${artifacts} --node-name $(hostname) \
$test_args" --build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"
exit $?
fi
1 change: 0 additions & 1 deletion hack/verify-flags/known-flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ duration-sec
e2e-output-dir
e2e-verify-service-account
enable-controller-attach-detach
enable-cri
enable-custom-metrics
enable-debugging-handlers
enable-dynamic-provisioning
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func RegisterCommonFlags() {
flag.StringVar(&TestContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
flag.StringVar(&TestContext.FeatureGates, "feature-gates", "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
flag.StringVar(&TestContext.Viper, "viper-config", "e2e", "The name of the viper config i.e. 'e2e' will read values from 'e2e.json' locally. All e2e parameters are meant to be configurable by viper.")
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker/rkt/remote).")
}

// Register flags specific to the cluster e2e test suite.
Expand All @@ -173,7 +174,6 @@ func RegisterClusterFlags() {
flag.StringVar(&TestContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.")
flag.StringVar(&TestContext.OutputDir, "e2e-output-dir", "/tmp", "Output directory for interesting/useful test data, like performance data, benchmarks, and other metrics.")
flag.StringVar(&TestContext.Prefix, "prefix", "e2e", "A prefix to be added to cloud resources created during testing.")
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker or rkt).")
flag.StringVar(&TestContext.MasterOSDistro, "master-os-distro", "debian", "The OS distribution of cluster master (debian, trusty, or coreos).")
flag.StringVar(&TestContext.NodeOSDistro, "node-os-distro", "debian", "The OS distribution of cluster VM instances (debian, trusty, or coreos).")

Expand Down
3 changes: 1 addition & 2 deletions test/e2e_node/e2e_node_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func init() {
// It seems that someone is using flag.Parse() after init() and TestMain().
// TODO(random-liu): Find who is using flag.Parse() and cause errors and move the following logic
// into TestContext.
pflag.CommandLine.MarkHidden("enable-cri")
}

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -99,7 +98,7 @@ func TestE2eNode(t *testing.T) {
glog.Exitf("chroot %q failed: %v", rootfs, err)
}
}
if err := system.ValidateDefault(); err != nil {
if err := system.ValidateDefault(framework.TestContext.ContainerRuntime); err != nil {
glog.Exitf("system validation failed: %v", err)
}
return
Expand Down
31 changes: 20 additions & 11 deletions test/e2e_node/system/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,9 @@ type Reporter interface {
Report(string, string, ValidationResultType) error
}

// Validate uses all validators to validate the system.
func Validate(spec SysSpec, report Reporter) error {
// Validate uses validators to validate the system.
func Validate(spec SysSpec, validators []Validator) error {
var errs []error
// validators are all the validators.
var validators = []Validator{
&OSValidator{Reporter: report},
&KernelValidator{Reporter: report},
&CgroupsValidator{Reporter: report},
&DockerValidator{Reporter: report},
}

for _, v := range validators {
glog.Infof("Validating %s...", v.Name())
Expand All @@ -54,6 +47,22 @@ func Validate(spec SysSpec, report Reporter) error {
}

// ValidateDefault uses all default validators to validate the system and writes to stdout.
func ValidateDefault() error {
return Validate(DefaultSysSpec, DefaultReporter)
func ValidateDefault(runtime string) error {
// OS-level validators.
var osValidators = []Validator{
&OSValidator{Reporter: DefaultReporter},
&KernelValidator{Reporter: DefaultReporter},
&CgroupsValidator{Reporter: DefaultReporter},
}
// Docker-specific validators.
var dockerValidators = []Validator{
&DockerValidator{Reporter: DefaultReporter},
}

validators := osValidators
switch runtime {
case "docker":
validators = append(validators, dockerValidators...)
}
return Validate(DefaultSysSpec, validators)
}

0 comments on commit 42bdbe5

Please sign in to comment.