mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-31 13:50:01 +00:00 
			
		
		
		
	remove hack/e2e.go
This commit is contained in:
		
				
					committed by
					
						 Davanum Srinivas
						Davanum Srinivas
					
				
			
			
				
	
			
			
			
						parent
						
							2b3540068b
						
					
				
				
					commit
					83c56a0373
				
			| @@ -167,7 +167,6 @@ filegroup( | ||||
| filegroup( | ||||
|     name = "test-portable-targets", | ||||
|     srcs = [ | ||||
|         "//hack:e2e.go", | ||||
|         "//hack:get-build.sh", | ||||
|         "//hack:ginkgo-e2e.sh", | ||||
|         "//hack/e2e-internal:all-srcs", | ||||
|   | ||||
| @@ -204,21 +204,6 @@ test-integration: generated_files | ||||
| 	hack/make-rules/test-integration.sh $(WHAT) | ||||
| endif | ||||
|  | ||||
| define TEST_E2E_HELP_INFO | ||||
| # Build and run end-to-end tests. | ||||
| # | ||||
| # Example: | ||||
| #   make test-e2e | ||||
| endef | ||||
| .PHONY: test-e2e | ||||
| ifeq ($(PRINT_HELP),y) | ||||
| test-e2e: | ||||
| 	@echo "$$TEST_E2E_HELP_INFO" | ||||
| else | ||||
| test-e2e: ginkgo generated_files | ||||
| 	go run hack/e2e.go -- --build --up --test --down | ||||
| endif | ||||
|  | ||||
| define TEST_E2E_NODE_HELP_INFO | ||||
| # Build and run node end-to-end tests. | ||||
| # | ||||
|   | ||||
| @@ -11,8 +11,6 @@ This feature is graduating to Beta in release 1.15. | ||||
|  | ||||
| This directory contains the addon config yaml - `nodelocaldns.yaml` | ||||
| The variables will be substituted by the configure scripts when the yaml is copied into master. | ||||
| To create a GCE cluster with nodelocaldns enabled, use  the command: | ||||
| `KUBE_ENABLE_NODELOCAL_DNS=true go run hack/e2e.go -v --up` | ||||
|  | ||||
| We have the following variables in the yaml:   | ||||
| `__PILLAR__DNS__SERVER__` - set to kube-dns service IP.    | ||||
|   | ||||
| @@ -3857,7 +3857,7 @@ function check-resources() { | ||||
| } | ||||
|  | ||||
| # ----------------------------------------------------------------------------- | ||||
| # Cluster specific test helpers used from hack/e2e.go | ||||
| # Cluster specific test helpers | ||||
|  | ||||
| # Execute prior to running tests to build a release if required for env. | ||||
| # | ||||
| @@ -3868,8 +3868,7 @@ function test-build-release() { | ||||
|   "${KUBE_ROOT}/build/release.sh" | ||||
| } | ||||
|  | ||||
| # Execute prior to running tests to initialize required structure. This is | ||||
| # called from hack/e2e.go only when running -up. | ||||
| # Execute prior to running tests to initialize required structure. | ||||
| # | ||||
| # Assumed vars: | ||||
| #   Variables from config.sh | ||||
| @@ -3925,8 +3924,7 @@ function test-setup() { | ||||
|   done | ||||
| } | ||||
|  | ||||
| # Execute after running tests to perform any required clean-up. This is called | ||||
| # from hack/e2e.go | ||||
| # Execute after running tests to perform any required clean-up. | ||||
| function test-teardown() { | ||||
|   detect-project | ||||
|   echo "Shutting down test cluster in background." | ||||
|   | ||||
| @@ -78,9 +78,9 @@ export KUBERNETES_NODE_PLATFORM=windows | ||||
| export LOGGING_STACKDRIVER_RESOURCE_TYPES=new | ||||
| ``` | ||||
|  | ||||
| Now bring up a cluster using one of the following two methods: | ||||
| Now bring up a cluster using kube-up script: | ||||
|  | ||||
| #### 2a. Create a regular Kubernetes cluster | ||||
| #### 2. Create a regular Kubernetes cluster | ||||
|  | ||||
| ``` | ||||
| # Invoke kube-up.sh with these environment variables: | ||||
| @@ -95,30 +95,6 @@ To teardown the cluster run: | ||||
| PROJECT=${CLOUDSDK_CORE_PROJECT} KUBERNETES_SKIP_CONFIRM=y ./cluster/kube-down.sh | ||||
| ``` | ||||
|  | ||||
| #### 2b. Create a Kubernetes end-to-end (E2E) test cluster | ||||
|  | ||||
| If you have built your own release binaries following step 1, run the following | ||||
| command: | ||||
| ``` | ||||
| PROJECT=${CLOUDSDK_CORE_PROJECT} go run ./hack/e2e.go  -- --up | ||||
| ``` | ||||
|  | ||||
| Otherwise, you can specify what branch from which to get the release artifacts: | ||||
| ``` | ||||
| # Get the latest build from the stable1 branch | ||||
| PROJECT=${CLOUDSDK_CORE_PROJECT} go run ./hack/e2e.go  -- --up --extract=ci/k8s-stable1 | ||||
| # Or Get the latest build from master | ||||
| PROJECT=${CLOUDSDK_CORE_PROJECT} go run ./hack/e2e.go  -- --up --extract=ci-cross/latest | ||||
| ``` | ||||
|  | ||||
| This command, by default, tears down any existing E2E cluster and creates a new | ||||
| one. To teardown the cluster run the same command with `--down` instead of | ||||
| `--up`. | ||||
|  | ||||
| No matter what type of cluster you chose to create, the result should be a | ||||
| Kubernetes cluster with one Linux master node, `NUM_NODES` Linux worker nodes | ||||
| and `NUM_WINDOWS_NODES` Windows worker nodes. | ||||
|  | ||||
| ## Validating the cluster | ||||
|  | ||||
| Invoke this script to run a smoke test that verifies that the cluster has been | ||||
|   | ||||
							
								
								
									
										25
									
								
								hack/BUILD
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								hack/BUILD
									
									
									
									
									
								
							| @@ -1,12 +1,5 @@ | ||||
| package(default_visibility = ["//visibility:public"]) | ||||
|  | ||||
| load( | ||||
|     "@io_bazel_rules_go//go:def.bzl", | ||||
|     "go_binary", | ||||
|     "go_library", | ||||
|     "go_test", | ||||
| ) | ||||
|  | ||||
| filegroup( | ||||
|     name = "package-srcs", | ||||
|     srcs = glob(["**"]), | ||||
| @@ -55,24 +48,6 @@ test_suite( | ||||
|     ], | ||||
| ) | ||||
|  | ||||
| go_binary( | ||||
|     name = "hack", | ||||
|     embed = [":go_default_library"], | ||||
| ) | ||||
|  | ||||
| go_test( | ||||
|     name = "go_default_test", | ||||
|     srcs = ["e2e_test.go"], | ||||
|     data = glob(["testdata/**"]), | ||||
|     embed = [":go_default_library"], | ||||
| ) | ||||
|  | ||||
| go_library( | ||||
|     name = "go_default_library", | ||||
|     srcs = ["e2e.go"], | ||||
|     importpath = "k8s.io/kubernetes/hack", | ||||
| ) | ||||
|  | ||||
| sh_binary( | ||||
|     name = "update-mirror", | ||||
|     srcs = ["update-workspace-mirror.sh"], | ||||
|   | ||||
							
								
								
									
										170
									
								
								hack/e2e.go
									
									
									
									
									
								
							
							
						
						
									
										170
									
								
								hack/e2e.go
									
									
									
									
									
								
							| @@ -1,170 +0,0 @@ | ||||
| /* | ||||
| Copyright 2014 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. | ||||
| */ | ||||
|  | ||||
| // User-interface for test-infra/kubetest/e2e.go | ||||
| // Equivalent to go get -u k8s.io/test-infra/kubetest && kubetest "${@}" | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"flag" | ||||
| 	"fmt" | ||||
| 	"go/build" | ||||
| 	"log" | ||||
| 	"os" | ||||
| 	"os/exec" | ||||
| 	"os/signal" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| type flags struct { | ||||
| 	get  bool | ||||
| 	old  time.Duration | ||||
| 	args []string | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	getDefault = true | ||||
| 	oldDefault = 24 * time.Hour | ||||
| ) | ||||
|  | ||||
| func parse(args []string) (flags, error) { | ||||
| 	fs := flag.NewFlagSet(args[0], flag.ContinueOnError) | ||||
| 	get := fs.Bool("get", getDefault, "go get -u kubetest if old or not installed") | ||||
| 	old := fs.Duration("old", oldDefault, "Consider kubetest old if it exceeds this") | ||||
| 	verbose := fs.Bool("v", true, "this flag is translated to kubetest's --verbose-commands") | ||||
| 	var a []string | ||||
| 	if err := fs.Parse(args[1:]); err == flag.ErrHelp { | ||||
| 		os.Stderr.WriteString("  -- kubetestArgs\n") | ||||
| 		os.Stderr.WriteString("        All flags after -- are passed to the kubetest program\n") | ||||
| 		return flags{}, err | ||||
| 	} else if err != nil { | ||||
| 		log.Print("NOTICE: go run hack/e2e.go is now a shim for test-infra/kubetest") | ||||
| 		log.Printf("  Usage: go run hack/e2e.go [--get=%v] [--old=%v] -- [KUBETEST_ARGS]", getDefault, oldDefault) | ||||
| 		log.Print("  The separator is required to use --get or --old flags") | ||||
| 		log.Print("  The -- flag separator also suppresses this message") | ||||
| 		a = args[len(args)-fs.NArg()-1:] | ||||
| 	} else { | ||||
| 		a = append(a, fmt.Sprintf("--verbose-commands=%t", *verbose)) | ||||
| 		a = append(a, fs.Args()...) | ||||
| 	} | ||||
| 	return flags{*get, *old, a}, nil | ||||
| } | ||||
|  | ||||
| func main() { | ||||
| 	log.SetFlags(log.LstdFlags | log.Lshortfile) | ||||
| 	f, err := parse(os.Args) | ||||
| 	if err != nil { | ||||
| 		os.Exit(2) | ||||
| 	} | ||||
| 	t := newTester() | ||||
| 	k, err := t.getKubetest(f.get, f.old) | ||||
| 	if err != nil { | ||||
| 		log.Fatalf("err: %v", err) | ||||
| 	} | ||||
| 	log.Printf("Calling kubetest %v...", strings.Join(f.args, " ")) | ||||
| 	if err = t.wait(k, f.args...); err != nil { | ||||
| 		log.Fatalf("err: %v", err) | ||||
| 	} | ||||
| 	log.Print("Done") | ||||
| } | ||||
|  | ||||
| func wait(cmd string, args ...string) error { | ||||
| 	sigChannel := make(chan os.Signal, 1) | ||||
| 	signal.Notify(sigChannel, os.Interrupt) | ||||
|  | ||||
| 	c := exec.Command(cmd, args...) | ||||
| 	c.Stdout = os.Stdout | ||||
| 	c.Stderr = os.Stderr | ||||
| 	if err := c.Start(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	go func() { | ||||
| 		sig := <-sigChannel | ||||
| 		if err := c.Process.Signal(sig); err != nil { | ||||
| 			log.Fatalf("could not send %s signal %s: %v", cmd, sig, err) | ||||
| 		} | ||||
| 	}() | ||||
| 	return c.Wait() | ||||
| } | ||||
|  | ||||
| // Struct that allows unit tests to override functionality. | ||||
| type tester struct { | ||||
| 	// os.Stat | ||||
| 	stat func(string) (os.FileInfo, error) | ||||
| 	// exec.LookPath | ||||
| 	lookPath func(string) (string, error) | ||||
| 	// build.Default.GOPATH | ||||
| 	goPath string | ||||
| 	wait   func(string, ...string) error | ||||
| } | ||||
|  | ||||
| func newTester() tester { | ||||
| 	return tester{os.Stat, exec.LookPath, build.Default.GOPATH, wait} | ||||
| } | ||||
|  | ||||
| // Try to find kubetest, either GOPATH/bin/kubetest or PATH | ||||
| func (t tester) lookKubetest() (string, error) { | ||||
| 	// Check for kubetest in GOPATH/bin | ||||
| 	if t.goPath != "" { | ||||
| 		p := filepath.Join(t.goPath, "bin", "kubetest") | ||||
| 		_, err := t.stat(p) | ||||
| 		if err == nil { | ||||
| 			return p, nil | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Check for kubetest in PATH | ||||
| 	p, err := t.lookPath("kubetest") | ||||
| 	return p, err | ||||
| } | ||||
|  | ||||
| // Upgrade if kubetest does not exist or has not been updated today | ||||
| func (t tester) getKubetest(get bool, old time.Duration) (string, error) { | ||||
| 	// Find kubetest installation | ||||
| 	p, err := t.lookKubetest() | ||||
| 	if err == nil && !get { | ||||
| 		return p, nil // Installed, Skip update | ||||
| 	} | ||||
| 	if err == nil { | ||||
| 		// Installed recently? | ||||
| 		if s, err := t.stat(p); err != nil { | ||||
| 			return p, err // Cannot stat | ||||
| 		} else if time.Since(s.ModTime()) <= old { | ||||
| 			return p, nil // Recently updated | ||||
| 		} else if t.goPath == "" { | ||||
| 			log.Print("Skipping kubetest upgrade because $GOPATH is empty") | ||||
| 			return p, nil | ||||
| 		} | ||||
| 		log.Printf("The kubetest binary is older than %s.", old) | ||||
| 	} | ||||
| 	if t.goPath == "" { | ||||
| 		return "", fmt.Errorf("cannot install kubetest until $GOPATH is set") | ||||
| 	} | ||||
| 	log.Print("Updating kubetest binary...") | ||||
| 	cmd := []string{"go", "get", "-u", "k8s.io/test-infra/kubetest"} | ||||
| 	if err = t.wait(cmd[0], cmd[1:]...); err != nil { | ||||
| 		return "", fmt.Errorf("%s: %v", strings.Join(cmd, " "), err) // Could not upgrade | ||||
| 	} | ||||
| 	if p, err = t.lookKubetest(); err != nil { | ||||
| 		return "", err // Cannot find kubetest | ||||
| 	} else if err = t.wait("touch", p); err != nil { | ||||
| 		return "", err // Could not touch | ||||
| 	} else { | ||||
| 		return p, nil // Updated modtime | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										373
									
								
								hack/e2e_test.go
									
									
									
									
									
								
							
							
						
						
									
										373
									
								
								hack/e2e_test.go
									
									
									
									
									
								
							| @@ -1,373 +0,0 @@ | ||||
| /* | ||||
| Copyright 2017 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. | ||||
| */ | ||||
|  | ||||
| // Unit tests for hack/e2e.go shim | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"flag" | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"reflect" | ||||
| 	"testing" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| type FileInfo struct { | ||||
| 	when time.Time | ||||
| } | ||||
|  | ||||
| func (f FileInfo) Name() string { | ||||
| 	return "fake-file" | ||||
| } | ||||
|  | ||||
| func (f FileInfo) Size() int64 { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| func (f FileInfo) Mode() os.FileMode { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| func (f FileInfo) ModTime() time.Time { | ||||
| 	return f.when | ||||
| } | ||||
|  | ||||
| func (f FileInfo) IsDir() bool { | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| func (f FileInfo) Sys() interface{} { | ||||
| 	return f | ||||
| } | ||||
|  | ||||
| func TestParse(t *testing.T) { | ||||
| 	cases := []struct { | ||||
| 		args     []string | ||||
| 		expected flags | ||||
| 		err      error | ||||
| 	}{ | ||||
| 		{ | ||||
| 			[]string{"foo", "-v=false"}, | ||||
| 			flags{getDefault, oldDefault, []string{"--verbose-commands=false"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"foo", "-v"}, | ||||
| 			flags{getDefault, oldDefault, []string{"--verbose-commands=true"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"hello", "world"}, | ||||
| 			flags{getDefault, oldDefault, []string{"--verbose-commands=true", "world"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"hello", "--", "--venus", "--karaoke"}, | ||||
| 			flags{getDefault, oldDefault, []string{"--verbose-commands=true", "--venus", "--karaoke"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"hello", "--alpha", "--beta"}, | ||||
| 			flags{getDefault, oldDefault, []string{"--alpha", "--beta"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"so", "--get", "--boo"}, | ||||
| 			flags{true, oldDefault, []string{"--boo"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"omg", "--get=false", "--", "ugh"}, | ||||
| 			flags{false, oldDefault, []string{"--verbose-commands=true", "ugh"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"wee", "--old=5m", "--get"}, | ||||
| 			flags{true, 5 * time.Minute, []string{"--verbose-commands=true"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"fun", "--times", "--old=666s"}, | ||||
| 			flags{getDefault, oldDefault, []string{"--times", "--old=666s"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"wut", "-h"}, | ||||
| 			flags{}, | ||||
| 			flag.ErrHelp, | ||||
| 		}, | ||||
| 		{ | ||||
| 			[]string{"wut", "--", "-h"}, | ||||
| 			flags{getDefault, oldDefault, []string{"--verbose-commands=true", "-h"}}, | ||||
| 			nil, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	for i, c := range cases { | ||||
| 		a, err := parse(c.args) | ||||
| 		if err != c.err { | ||||
| 			t.Errorf("%d: a=%v != e%v", i, err, c.err) | ||||
| 		} | ||||
| 		e := c.expected | ||||
| 		if a.get != e.get { | ||||
| 			t.Errorf("%d: a=%v != e=%v", i, a.get, e.get) | ||||
| 		} | ||||
| 		if a.old != e.old { | ||||
| 			t.Errorf("%d: a=%v != e=%v", i, a.old, e.old) | ||||
| 		} | ||||
| 		if !reflect.DeepEqual(a.args, e.args) { | ||||
| 			t.Errorf("%d: a=%v != e=%v", i, a.args, e.args) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestLook(t *testing.T) { | ||||
| 	lpf := errors.New("lookPath failed") | ||||
| 	sf := errors.New("stat failed") | ||||
| 	lpnc := errors.New("lookPath should not be called") | ||||
| 	snc := errors.New("stat should not be called") | ||||
| 	cases := []struct { | ||||
| 		stat     error | ||||
| 		lookPath error | ||||
| 		goPath   string | ||||
| 		expected error | ||||
| 	}{ | ||||
| 		{ // GOPATH set, stat succeeds returns gopath | ||||
| 			stat:     nil, | ||||
| 			lookPath: lpnc, | ||||
| 			goPath:   "fake-gopath/", | ||||
| 			expected: nil, | ||||
| 		}, | ||||
| 		{ // GOPATH set, stat fails, terms on lookpath | ||||
| 			stat:     sf, | ||||
| 			lookPath: lpf, | ||||
| 			goPath:   "fake-gopath/", | ||||
| 			expected: lpf, | ||||
| 		}, | ||||
| 		{ // GOPATH unset, stat not called, terms on lookpath | ||||
| 			stat:     snc, | ||||
| 			lookPath: lpf, | ||||
| 			goPath:   "", | ||||
| 			expected: lpf, | ||||
| 		}, | ||||
| 		{ // GOPATH unset, stat not called, lookpath matches | ||||
| 			stat:     snc, | ||||
| 			lookPath: nil, | ||||
| 			goPath:   "", | ||||
| 			expected: nil, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	for _, c := range cases { | ||||
| 		l := tester{ | ||||
| 			func(string) (os.FileInfo, error) { | ||||
| 				return FileInfo{}, c.stat | ||||
| 			}, | ||||
| 			func(string) (string, error) { | ||||
| 				if c.lookPath != nil { | ||||
| 					return "FAILED", c.lookPath | ||||
| 				} | ||||
| 				return "$PATH-FOUND", nil | ||||
| 			}, | ||||
| 			c.goPath, | ||||
| 			nil, // wait | ||||
| 		} | ||||
| 		if _, err := l.lookKubetest(); err != c.expected { | ||||
| 			t.Errorf("err: %s != %s", err, c.expected) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestGetKubetest(t *testing.T) { | ||||
| 	gp := "fake-gopath" | ||||
| 	gpk := filepath.Join(gp, "bin", "kubetest") | ||||
| 	p := "PATH" | ||||
| 	pk := filepath.Join(p, "kubetest") | ||||
| 	eu := errors.New("upgrade failed") | ||||
| 	euVerbose := fmt.Errorf("go get -u k8s.io/test-infra/kubetest: %v", eu) | ||||
| 	et := errors.New("touch failed") | ||||
| 	cases := []struct { | ||||
| 		name string | ||||
| 		get  bool | ||||
| 		old  time.Duration | ||||
|  | ||||
| 		stat     string        // stat succeeds on this file | ||||
| 		path     bool          // file exists on path | ||||
| 		age      time.Duration // age of mod time on file | ||||
| 		upgraded bool          // go get -u succeeds | ||||
| 		touched  bool          // touch succeeds | ||||
| 		goPath   string        // GOPATH var | ||||
|  | ||||
| 		returnPath  string | ||||
| 		returnError error | ||||
| 	}{ | ||||
| 		{name: "0: Pass when on GOPATH/bin", | ||||
| 			get: false, | ||||
| 			old: 0, | ||||
|  | ||||
| 			stat:     gpk, | ||||
| 			path:     false, | ||||
| 			age:      100, | ||||
| 			upgraded: false, | ||||
| 			touched:  false, | ||||
| 			goPath:   gp, | ||||
|  | ||||
| 			returnPath:  gpk, | ||||
| 			returnError: nil, | ||||
| 		}, | ||||
| 		{name: "1: Pass when on PATH", | ||||
| 			get: false, | ||||
| 			old: 0, | ||||
|  | ||||
| 			stat:     pk, | ||||
| 			path:     true, | ||||
| 			age:      100, | ||||
| 			upgraded: false, | ||||
| 			touched:  false, | ||||
| 			goPath:   gp, | ||||
|  | ||||
| 			returnPath:  pk, | ||||
| 			returnError: nil, | ||||
| 		}, | ||||
| 		{name: "2: Don't upgrade if on PATH and GOPATH is ''", | ||||
| 			get: true, | ||||
| 			old: 0, | ||||
|  | ||||
| 			stat:     pk, | ||||
| 			path:     true, | ||||
| 			age:      100, | ||||
| 			upgraded: false, | ||||
| 			touched:  false, | ||||
| 			goPath:   "", | ||||
|  | ||||
| 			returnPath:  pk, | ||||
| 			returnError: nil, | ||||
| 		}, | ||||
| 		{name: "3: Don't upgrade on PATH when young.", | ||||
| 			get: true, | ||||
| 			old: time.Hour, | ||||
|  | ||||
| 			stat:     pk, | ||||
| 			path:     true, | ||||
| 			age:      time.Second, | ||||
| 			upgraded: false, | ||||
| 			touched:  false, | ||||
| 			goPath:   gp, | ||||
|  | ||||
| 			returnPath:  pk, | ||||
| 			returnError: nil, | ||||
| 		}, | ||||
| 		{name: "4: Upgrade if old but GOPATH is set.", | ||||
| 			get: true, | ||||
| 			old: 0, | ||||
|  | ||||
| 			stat:     pk, | ||||
| 			path:     true, | ||||
| 			age:      time.Second, | ||||
| 			upgraded: true, | ||||
| 			touched:  true, | ||||
| 			goPath:   gp, | ||||
|  | ||||
| 			returnPath:  pk, | ||||
| 			returnError: nil, | ||||
| 		}, | ||||
| 		{name: "5: Fail if upgrade fails", | ||||
| 			get: true, | ||||
| 			old: 0, | ||||
|  | ||||
| 			stat:     pk, | ||||
| 			path:     true, | ||||
| 			age:      time.Second, | ||||
| 			upgraded: false, | ||||
| 			touched:  false, | ||||
| 			goPath:   gpk, | ||||
|  | ||||
| 			returnPath:  "", | ||||
| 			returnError: euVerbose, | ||||
| 		}, | ||||
| 		{name: "6: Fail if touch fails", | ||||
| 			get: true, | ||||
| 			old: 0, | ||||
|  | ||||
| 			stat:     pk, | ||||
| 			path:     true, | ||||
| 			age:      time.Second, | ||||
| 			upgraded: true, | ||||
| 			touched:  false, | ||||
| 			goPath:   gpk, | ||||
|  | ||||
| 			returnPath:  "", | ||||
| 			returnError: et, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	for i, c := range cases { | ||||
| 		didUp := false | ||||
| 		didTouch := false | ||||
| 		l := tester{ | ||||
| 			stat: func(p string) (os.FileInfo, error) { | ||||
| 				// stat | ||||
| 				if p != c.stat { | ||||
| 					return nil, fmt.Errorf("failed to find %s", p) | ||||
| 				} | ||||
| 				return FileInfo{time.Now().Add(c.age * -1)}, nil | ||||
| 			}, | ||||
| 			lookPath: func(name string) (string, error) { | ||||
| 				if c.path { | ||||
| 					return filepath.Join(p, name), nil | ||||
| 				} | ||||
| 				return "", fmt.Errorf("not on path: %s", name) | ||||
| 			}, | ||||
| 			goPath: c.goPath, | ||||
| 			wait: func(cmd string, args ...string) error { | ||||
| 				if cmd == "go" { | ||||
| 					if c.upgraded { | ||||
| 						didUp = true | ||||
| 						return nil | ||||
| 					} | ||||
| 					return eu | ||||
| 				} | ||||
| 				if c.touched { | ||||
| 					didTouch = true | ||||
| 					return nil | ||||
| 				} | ||||
| 				return et | ||||
| 			}, | ||||
| 		} | ||||
| 		p, e := l.getKubetest(c.get, c.old) | ||||
| 		if p != c.returnPath { | ||||
| 			t.Errorf("%d: test=%q returnPath %q != %q", i, c.name, p, c.returnPath) | ||||
| 		} | ||||
| 		if e == nil || c.returnError == nil { | ||||
| 			if e != c.returnError { | ||||
| 				t.Errorf("%d: test=%q returnError %q != %q", i, c.name, e, c.returnError) | ||||
| 			} | ||||
| 		} else { | ||||
| 			if e.Error() != c.returnError.Error() { | ||||
| 				t.Errorf("%d: test=%q returnError %q != %q", i, c.name, e, c.returnError) | ||||
| 			} | ||||
| 		} | ||||
| 		if didUp != c.upgraded { | ||||
| 			t.Errorf("%d: test=%q bad upgrade state of %v", i, c.name, didUp) | ||||
| 		} | ||||
| 		if didTouch != c.touched { | ||||
| 			t.Errorf("%d: test=%q bad touch state of %v", i, c.name, didTouch) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -274,7 +274,6 @@ readonly KUBE_TEST_BINARIES_WIN=("${KUBE_TEST_BINARIES[@]/%/.exe}") | ||||
| readonly KUBE_TEST_PORTABLE=( | ||||
|   test/e2e/testing-manifests | ||||
|   test/kubemark | ||||
|   hack/e2e.go | ||||
|   hack/e2e-internal | ||||
|   hack/get-build.sh | ||||
|   hack/ginkgo-e2e.sh | ||||
|   | ||||
| @@ -52,7 +52,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| // These tests need privileged containers, which are disabled by default.  Run | ||||
| // the test with "go run hack/e2e.go ... --ginkgo.focus=[Feature:Volumes]" | ||||
| // tests with "--ginkgo.focus=[Feature:Volumes]" | ||||
| var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() { | ||||
| 	f := framework.NewDefaultFramework("gcp-volume") | ||||
|  | ||||
|   | ||||
| @@ -42,13 +42,8 @@ if [[ "${ENABLE_KUBEMARK_CLUSTER_AUTOSCALER}" == "true" ]]; then | ||||
|   ARGS+=("--kubemark-external-kubeconfig=${DEFAULT_KUBECONFIG}") | ||||
| fi | ||||
|  | ||||
| if [[ -f /.dockerenv ]]; then | ||||
| 	# Running inside a dockerized runner. | ||||
| 	go run ./hack/e2e.go -- --check-version-skew=false --test --test_args="--e2e-verify-service-account=false --dump-logs-on-failure=false ${ARGS[*]}" | ||||
| else | ||||
| 	# Running locally. | ||||
| 	for ((i=0; i < ${#ARGS[@]}; i++)); do | ||||
| 	  ARGS[$i]="$(echo "${ARGS[$i]}" | sed -e 's/\[/\\\[/g' -e 's/\]/\\\]/g' )" | ||||
| 	done | ||||
| 	"${KUBE_ROOT}/hack/ginkgo-e2e.sh" "--e2e-verify-service-account=false" "--dump-logs-on-failure=false" "${ARGS[@]}" | ||||
| fi | ||||
| # Running locally. | ||||
| for ((i=0; i < ${#ARGS[@]}; i++)); do | ||||
|   ARGS[$i]="$(echo "${ARGS[$i]}" | sed -e 's/\[/\\\[/g' -e 's/\]/\\\]/g' )" | ||||
| done | ||||
| "${KUBE_ROOT}/hack/ginkgo-e2e.sh" "--e2e-verify-service-account=false" "--dump-logs-on-failure=false" "${ARGS[@]}" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user