From 6d532084e551de06657e331692c8cdad14edcbe0 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 2 Nov 2021 11:53:25 -0700 Subject: [PATCH 1/2] removed unused test/e2e_kubeadm/runner/local/run_local.go --- test/e2e_kubeadm/runner/local/run_local.go | 107 --------------------- 1 file changed, 107 deletions(-) delete mode 100644 test/e2e_kubeadm/runner/local/run_local.go diff --git a/test/e2e_kubeadm/runner/local/run_local.go b/test/e2e_kubeadm/runner/local/run_local.go deleted file mode 100644 index 54829aefea3..00000000000 --- a/test/e2e_kubeadm/runner/local/run_local.go +++ /dev/null @@ -1,107 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "flag" - "fmt" - "os" - "os/exec" - "path/filepath" - "runtime" - "strings" - - "k8s.io/klog/v2" - "k8s.io/kubernetes/test/utils" -) - -func bazelBuild() error { - targets := []string{ - "//vendor/github.com/onsi/ginkgo/ginkgo", - "//test/e2e_kubeadm:e2e_kubeadm.test", - } - - args := append([]string{"build"}, targets...) - - return execCommand("bazel", args...) -} - -var ginkgoFlags = flag.String("ginkgo-flags", "", "Space-separated list of arguments to pass to Ginkgo test runner.") -var testFlags = flag.String("test-flags", "", "Space-separated list of arguments to pass to kubeadm e2e test.") -var build = flag.Bool("build", false, "use Bazel to build binaries before testing") - -func main() { - flag.Parse() - - if *build { - if err := bazelBuild(); err != nil { - klog.Exitf("couldn't build with bazel: %v", err) - } - } - - ginkgo, err := getBazelGinkgo() - if err != nil { - klog.Fatalf("Failed to get ginkgo binary: %v", err) - } - - test, err := getBazelTestBin() - if err != nil { - klog.Fatalf("Failed to get test file: %v", err) - } - - args := append(strings.Split(*ginkgoFlags, " "), test, "--") - args = append(args, strings.Split(*testFlags, " ")...) - - if execCommand(ginkgo, args...); err != nil { - klog.Exitf("Test failed: %v", err) - } - -} - -func getBazelTestBin() (string, error) { - k8sRoot, err := utils.GetK8sRootDir() - if err != nil { - return "", err - } - buildFile := filepath.Join(k8sRoot, "bazel-bin/test/e2e_kubeadm/e2e_kubeadm.test") - if _, err := os.Stat(buildFile); err != nil { - return "", err - } - return buildFile, nil - -} - -func getBazelGinkgo() (string, error) { - k8sRoot, err := utils.GetK8sRootDir() - if err != nil { - return "", err - } - buildOutputDir := filepath.Join(k8sRoot, "bazel-bin", "vendor/github.com/onsi/ginkgo/ginkgo", fmt.Sprintf("%s_%s_stripped", runtime.GOOS, runtime.GOARCH), "ginkgo") - if _, err := os.Stat(buildOutputDir); err != nil { - return "", err - } - return buildOutputDir, nil -} - -func execCommand(binary string, args ...string) error { - fmt.Printf("Running command: %v %v\n", binary, strings.Join(args, " ")) - cmd := exec.Command("sh", "-c", strings.Join(append([]string{binary}, args...), " ")) - - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - return cmd.Run() -} From 71071d13ab741323876d6b60e6df5449c7752e4a Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 2 Nov 2021 12:04:14 -0700 Subject: [PATCH 2/2] remove make rule for test-e2e-kubeadm this target depended on a broken binary and is clearly unused kubeadm e2e development should be done with: https://github.com/kubernetes/kubeadm/tree/main/kinder --- build/root/Makefile | 30 -------------- hack/make-rules/test-e2e-kubeadm.sh | 64 ----------------------------- 2 files changed, 94 deletions(-) delete mode 100755 hack/make-rules/test-e2e-kubeadm.sh diff --git a/build/root/Makefile b/build/root/Makefile index 46fea1fd332..623a482a700 100644 --- a/build/root/Makefile +++ b/build/root/Makefile @@ -272,36 +272,6 @@ test-e2e-node: ginkgo generated_files hack/make-rules/test-e2e-node.sh endif -define TEST_E2E_KUBEADM_HELP_INFO -# Build and run kubeadm end-to-end tests. -# -# Args: -# FOCUS: Regexp that matches the tests to be run. Defaults to "". -# SKIP: Regexp that matches the tests that needs to be skipped. Defaults -# to "". -# RUN_UNTIL_FAILURE: If true, pass --untilItFails to ginkgo so tests are run -# repeatedly until they fail. Defaults to false. -# ARTIFACTS: Local directory to save test artifacts into. Defaults to "/tmp/_artifacts". -# PARALLELISM: The number of ginkgo nodes to run. If empty ginkgo default -# parallelism (cores - 1) is used -# BUILD: Build kubeadm end-to-end tests. Defaults to true. -# -# Example: -# make test-e2e-kubeadm -# make test-e2e-kubeadm FOCUS=kubeadm-config -# make test-e2e-kubeadm SKIP=kubeadm-config -# -# Build and run tests. -endef -.PHONY: test-e2e-kubeadm -ifeq ($(PRINT_HELP),y) -test-e2e-kubeadm: - @echo "$$TEST_E2E_KUBEADM_HELP_INFO" -else -test-e2e-kubeadm: - hack/make-rules/test-e2e-kubeadm.sh -endif - define TEST_CMD_HELP_INFO # Build and run cmdline tests. # diff --git a/hack/make-rules/test-e2e-kubeadm.sh b/hack/make-rules/test-e2e-kubeadm.sh deleted file mode 100755 index 3f8b54eae5a..00000000000 --- a/hack/make-rules/test-e2e-kubeadm.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2019 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. -source "${KUBE_ROOT}/hack/lib/init.sh" - -focus=${FOCUS:-""} -skip=${SKIP:-""} -parallelism=${PARALLELISM:-""} -artifacts=${ARTIFACTS:-"/tmp/_artifacts/$(date +%y%m%dT%H%M%S)"} -run_until_failure=${RUN_UNTIL_FAILURE:-"false"} -build=${BUILD:-"true"} - -# Parse the flags to pass to ginkgo -ginkgoflags="" -if [[ ${parallelism} != "" ]]; then - ginkgoflags="${ginkgoflags} -nodes=${parallelism} " -else - ginkgoflags="${ginkgoflags} -p " -fi - -if [[ ${focus} != "" ]]; then - ginkgoflags="${ginkgoflags} -focus=\"${focus}\" " -fi - -if [[ ${skip} != "" ]]; then - ginkgoflags="${ginkgoflags} -skip=\"${skip}\" " -fi - -if [[ ${run_until_failure} != "false" ]]; then - ginkgoflags="${ginkgoflags} -untilItFails=${run_until_failure} " -fi - -# Setup the directory to copy test artifacts (logs, junit.xml, etc) from remote host to local host -if [[ ! -d "${artifacts}" ]]; then - echo "Creating artifacts directory at ${artifacts}" - mkdir -p "${artifacts}" -fi -echo "Test artifacts will be written to ${artifacts}" - -# Test -kube::golang::verify_go_version - -go run test/e2e_kubeadm/runner/local/run_local.go \ - --ginkgo-flags="${ginkgoflags}" \ - --test-flags="--provider=skeleton --report-dir=${artifacts}" \ - --build="${build}" 2>&1 | tee -i "${artifacts}/build-log.txt"