Skip to content

Commit

Permalink
Merge pull request #99960 from knabben/fix-runtime-config
Browse files Browse the repository at this point in the history
Enabling runtime config on E2E node tests
  • Loading branch information
k8s-ci-robot committed Mar 9, 2021
2 parents 5c8c72c + 0341e4c commit 0df8c69
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 12 deletions.
7 changes: 5 additions & 2 deletions hack/make-rules/test-e2e-node.sh
Expand Up @@ -46,6 +46,7 @@ test_args=${TEST_ARGS:-""}
timeout_arg=""
system_spec_name=${SYSTEM_SPEC_NAME:-}
extra_envs=${EXTRA_ENVS:-}
runtime_config=${RUNTIME_CONFIG:-}

# Parse the flags to pass to ginkgo
ginkgoflags=""
Expand Down Expand Up @@ -168,7 +169,8 @@ if [ "${remote}" = true ] ; then
--image-project="${image_project}" --instance-name-prefix="${instance_prefix}" \
--delete-instances="${delete_instances}" --test_args="${test_args}" --instance-metadata="${metadata}" \
--image-config-file="${image_config_file}" --system-spec-name="${system_spec_name}" \
--preemptible-instances="${preemptible_instances}" --extra-envs="${extra_envs}" --test-suite="${test_suite}" \
--runtime-config="${runtime_config}" --preemptible-instances="${preemptible_instances}" \
--extra-envs="${extra_envs}" --test-suite="${test_suite}" \
"${timeout_arg}" \
2>&1 | tee -i "${artifacts}/build-log.txt"
exit $?
Expand Down Expand Up @@ -203,6 +205,7 @@ else
--system-spec-name="${system_spec_name}" --extra-envs="${extra_envs}" \
--ginkgo-flags="${ginkgoflags}" --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"
${test_args}" --runtime-config="${runtime_config}" \
--build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"
exit $?
fi
2 changes: 2 additions & 0 deletions test/e2e/framework/test_context.go
Expand Up @@ -217,6 +217,8 @@ type NodeTestContextType struct {
KubeletConfig kubeletconfig.KubeletConfiguration
// ImageDescription is the description of the image on which the test is running.
ImageDescription string
// RuntimeConfig is a map of API server runtime configuration values.
RuntimeConfig map[string]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/.
Expand Down
1 change: 1 addition & 0 deletions test/e2e_node/e2e_node_suite_test.go
Expand Up @@ -85,6 +85,7 @@ func registerNodeFlags(flags *flag.FlagSet) {
flags.Var(cliflag.NewMapStringString(&framework.TestContext.ExtraEnvs), "extra-envs", "The extra environment variables needed for node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2")
flags.StringVar(&framework.TestContext.SriovdpConfigMapFile, "sriovdp-configmap-file", "", "The name of the SRIOV device plugin Config Map to load.")
flag.StringVar(&framework.TestContext.ClusterDNSDomain, "dns-domain", "", "The DNS Domain of the cluster.")
flag.Var(cliflag.NewMapStringString(&framework.TestContext.RuntimeConfig), "runtime-config", "The runtime configuration used on node e2e tests.")
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e_node/remote/cadvisor_e2e.go
Expand Up @@ -63,7 +63,7 @@ func runCommand(command string, args ...string) error {
}

// RunTest implements TestSuite.RunTest
func (n *CAdvisorE2ERemote) RunTest(host, workspace, results, imageDesc, junitFilePrefix, testArgs, ginkgoArgs, systemSpecName, extraEnvs string, timeout time.Duration) (string, error) {
func (n *CAdvisorE2ERemote) RunTest(host, workspace, _, _, _, _, _, _, _, _ string, timeout time.Duration) (string, error) {
// Kill any running node processes
cleanupNodeProcesses(host)

Expand Down
2 changes: 1 addition & 1 deletion test/e2e_node/remote/node_conformance.go
Expand Up @@ -262,7 +262,7 @@ func stopKubelet(host, workspace string) error {
}

// RunTest runs test on the node.
func (c *ConformanceRemote) RunTest(host, workspace, results, imageDesc, junitFilePrefix, testArgs, _, systemSpecName, extraEnvs string, timeout time.Duration) (string, error) {
func (c *ConformanceRemote) RunTest(host, workspace, results, imageDesc, junitFilePrefix, testArgs, _, systemSpecName, extraEnvs, _ string, timeout time.Duration) (string, error) {
// Install the cni plugins and add a basic CNI configuration.
if err := setupCNI(host, workspace); err != nil {
return "", err
Expand Down
6 changes: 3 additions & 3 deletions test/e2e_node/remote/node_e2e.go
Expand Up @@ -154,7 +154,7 @@ func getOSDistribution(host string) (string, error) {
}

// RunTest runs test on the node.
func (n *NodeE2ERemote) RunTest(host, workspace, results, imageDesc, junitFilePrefix, testArgs, ginkgoArgs, systemSpecName, extraEnvs string, timeout time.Duration) (string, error) {
func (n *NodeE2ERemote) RunTest(host, workspace, results, imageDesc, junitFilePrefix, testArgs, ginkgoArgs, systemSpecName, extraEnvs, runtimeConfig string, timeout time.Duration) (string, error) {
// Install the cni plugins and add a basic CNI configuration.
// TODO(random-liu): Do this in cloud init after we remove containervm test.
if err := setupCNI(host, workspace); err != nil {
Expand Down Expand Up @@ -183,8 +183,8 @@ func (n *NodeE2ERemote) RunTest(host, workspace, results, imageDesc, junitFilePr
klog.V(2).Infof("Starting tests on %q", host)
cmd := getSSHCommand(" && ",
fmt.Sprintf("cd %s", workspace),
fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-name=%s --system-spec-file=%s --extra-envs=%s --logtostderr --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=\"%s\" %s",
timeout.Seconds(), ginkgoArgs, systemSpecName, systemSpecFile, extraEnvs, host, results, junitFilePrefix, imageDesc, testArgs),
fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-name=%s --system-spec-file=%s --extra-envs=%s --runtime-config=%s --logtostderr --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=\"%s\" %s",
timeout.Seconds(), ginkgoArgs, systemSpecName, systemSpecFile, extraEnvs, runtimeConfig, host, results, junitFilePrefix, imageDesc, testArgs),
)
return SSH(host, "sh", "-c", cmd)
}
4 changes: 2 additions & 2 deletions test/e2e_node/remote/remote.go
Expand Up @@ -66,7 +66,7 @@ func CreateTestArchive(suite TestSuite, systemSpecName string) (string, error) {

// RunRemote returns the command output, whether the exit was ok, and any errors
// TODO(random-liu): junitFilePrefix is not prefix actually, the file name is junit-junitFilePrefix.xml. Change the variable name.
func RunRemote(suite TestSuite, archive string, host string, cleanup bool, imageDesc, junitFilePrefix string, testArgs string, ginkgoArgs string, systemSpecName string, extraEnvs string) (string, bool, error) {
func RunRemote(suite TestSuite, archive string, host string, cleanup bool, imageDesc, junitFilePrefix, testArgs, ginkgoArgs, systemSpecName, extraEnvs, runtimeConfig string) (string, bool, error) {
// Create the temp staging directory
klog.V(2).Infof("Staging test binaries on %q", host)
workspace := newWorkspaceDir()
Expand Down Expand Up @@ -111,7 +111,7 @@ func RunRemote(suite TestSuite, archive string, host string, cleanup bool, image
}

klog.V(2).Infof("Running test on %q", host)
output, err := suite.RunTest(host, workspace, resultDir, imageDesc, junitFilePrefix, testArgs, ginkgoArgs, systemSpecName, extraEnvs, *testTimeout)
output, err := suite.RunTest(host, workspace, resultDir, imageDesc, junitFilePrefix, testArgs, ginkgoArgs, systemSpecName, extraEnvs, runtimeConfig, *testTimeout)

aggErrs := []error{}
// Do not log the output here, let the caller deal with the test output.
Expand Down
3 changes: 2 additions & 1 deletion test/e2e_node/remote/types.go
Expand Up @@ -47,6 +47,7 @@ type TestSuite interface {
// * systemSpecName is the name of the system spec used for validating the
// image on which the test runs.
// * extraEnvs is the extra environment variables needed for node e2e tests.
// * runtimeConfig is the API runtime configuration used for node e2e tests.
// * timeout is the test timeout.
RunTest(host, workspace, results, imageDesc, junitFilePrefix, testArgs, ginkgoArgs, systemSpecName, extraEnvs string, timeout time.Duration) (string, error)
RunTest(host, workspace, results, imageDesc, junitFilePrefix, testArgs, ginkgoArgs, systemSpecName, extraEnvs, runtimeConfig string, timeout time.Duration) (string, error)
}
3 changes: 2 additions & 1 deletion test/e2e_node/runner/local/run_local.go
Expand Up @@ -36,6 +36,7 @@ var ginkgoFlags = flag.String("ginkgo-flags", "", "Space-separated list of argum
var testFlags = flag.String("test-flags", "", "Space-separated list of arguments to pass to node e2e test.")
var systemSpecName = flag.String("system-spec-name", "", fmt.Sprintf("The name of the system spec used for validating the image in the node conformance test. The specs are at %s. If unspecified, the default built-in spec (system.DefaultSpec) will be used.", system.SystemSpecPath))
var extraEnvs = flag.String("extra-envs", "", "The extra environment variables needed for node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2")
var runtimeConfig = flag.String("runtime-config", "", "The runtime configuration for the API server on the node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2")

func main() {
klog.InitFlags(nil)
Expand All @@ -57,7 +58,7 @@ func main() {
ginkgo := filepath.Join(outputDir, "ginkgo")
test := filepath.Join(outputDir, "e2e_node.test")

args := []string{*ginkgoFlags, test, "--", *testFlags}
args := []string{*ginkgoFlags, test, "--", *testFlags, fmt.Sprintf("--runtime-config=%s", *runtimeConfig)}
if *systemSpecName != "" {
rootDir, err := utils.GetK8sRootDir()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion test/e2e_node/runner/remote/run_remote.go
Expand Up @@ -66,6 +66,7 @@ var gubernator = flag.Bool("gubernator", false, "If true, output Gubernator link
var ginkgoFlags = flag.String("ginkgo-flags", "", "Passed to ginkgo to specify additional flags such as --skip=.")
var systemSpecName = flag.String("system-spec-name", "", fmt.Sprintf("The name of the system spec used for validating the image in the node conformance test. The specs are at %s. If unspecified, the default built-in spec (system.DefaultSpec) will be used.", system.SystemSpecPath))
var extraEnvs = flag.String("extra-envs", "", "The extra environment variables needed for node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2")
var runtimeConfig = flag.String("runtime-config", "", "The runtime configuration for the API server on the node e2e tests.. Format: a list of key=value pairs, e.g., env1=val1,env2=val2")

// envs is the type used to collect all node envs. The key is the env name,
// and the value is the env value
Expand Down Expand Up @@ -446,7 +447,7 @@ func testHost(host string, deleteFiles bool, imageDesc, junitFilePrefix, ginkgoF
}
}

output, exitOk, err := remote.RunRemote(suite, path, host, deleteFiles, imageDesc, junitFilePrefix, *testArgs, ginkgoFlagsStr, *systemSpecName, *extraEnvs)
output, exitOk, err := remote.RunRemote(suite, path, host, deleteFiles, imageDesc, junitFilePrefix, *testArgs, ginkgoFlagsStr, *systemSpecName, *extraEnvs, *runtimeConfig)
return &TestResult{
output: output,
err: err,
Expand Down
3 changes: 3 additions & 0 deletions test/e2e_node/services/apiserver.go
Expand Up @@ -54,6 +54,9 @@ func (a *APIServer) Start() error {
if err != nil {
return err
}
if len(framework.TestContext.RuntimeConfig) > 0 {
o.APIEnablement.RuntimeConfig = framework.TestContext.RuntimeConfig
}
o.SecureServing.BindAddress = net.ParseIP("127.0.0.1")
o.ServiceClusterIPRanges = ipnet.String()
o.AllowPrivileged = true
Expand Down

0 comments on commit 0df8c69

Please sign in to comment.