mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #26671 from vishh/node-e2e-images
Automatic merge from submit-queue Support images and instances to exist in different GCP projects for node Forked off from #26314
This commit is contained in:
		@@ -70,6 +70,7 @@ docs/getting-started-guides/coreos/azure/lib/deployment_logic/kubernetes.js:var
 | 
			
		||||
examples/cassandra/image/run.sh:	cluster_name \
 | 
			
		||||
examples/cluster-dns/images/frontend/client.py:  service_address = socket.gethostbyname(hostname)
 | 
			
		||||
examples/vitess/env.sh:    node_ip=$(get_node_ip)
 | 
			
		||||
hack/jenkins/e2e-runner.sh:    local image_project="$1"
 | 
			
		||||
hack/local-up-cluster.sh:      runtime_config="--runtime-config=${RUNTIME_CONFIG}"
 | 
			
		||||
hack/local-up-cluster.sh:    runtime_config=""
 | 
			
		||||
hack/test-update-storage-objects.sh:  local storage_media_type=${2:-""}
 | 
			
		||||
 
 | 
			
		||||
@@ -194,6 +194,7 @@ ignore-daemonsets
 | 
			
		||||
ignore-not-found
 | 
			
		||||
image-gc-high-threshold
 | 
			
		||||
image-gc-low-threshold
 | 
			
		||||
image-project
 | 
			
		||||
image-pull-policy
 | 
			
		||||
include-extended-apis
 | 
			
		||||
included-types-overrides
 | 
			
		||||
@@ -411,6 +412,7 @@ service-node-ports
 | 
			
		||||
service-overrides
 | 
			
		||||
service-sync-period
 | 
			
		||||
session-affinity
 | 
			
		||||
setup-node
 | 
			
		||||
show-all
 | 
			
		||||
show-events
 | 
			
		||||
show-labels
 | 
			
		||||
 
 | 
			
		||||
@@ -105,6 +105,7 @@ var _ = AfterSuite(func() {
 | 
			
		||||
		glog.Infof("Stopping node services...")
 | 
			
		||||
		e2es.stop()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	glog.Infof("Tests Finished")
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -124,9 +124,19 @@ func CreateTestArchive() string {
 | 
			
		||||
	return filepath.Join(dir, archiveName)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RunRemote copies the archive file to a /tmp file on host, unpacks it, and runs the e2e_node.test
 | 
			
		||||
// Returns the command output, whether the exit was ok, and any errors
 | 
			
		||||
func RunRemote(archive string, host string, cleanup bool, junitFileNumber int) (string, bool, error) {
 | 
			
		||||
func RunRemote(archive string, host string, cleanup bool, junitFileNumber int, setupNode bool) (string, bool, error) {
 | 
			
		||||
	if setupNode {
 | 
			
		||||
		uname, err := user.Current()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", false, fmt.Errorf("could not find username: %v", err)
 | 
			
		||||
		}
 | 
			
		||||
		output, err := RunSshCommand("ssh", host, "--", "sudo", "usermod", "-a", "-G", "docker", uname.Username)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", false, fmt.Errorf("Instance %s not running docker daemon - Command failed: %s", host, output)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Create the temp staging directory
 | 
			
		||||
	glog.Infof("Staging test binaries on %s", host)
 | 
			
		||||
	tmp := fmt.Sprintf("/tmp/gcloud-e2e-%d", rand.Int31())
 | 
			
		||||
 
 | 
			
		||||
@@ -92,4 +92,4 @@ fi
 | 
			
		||||
# delete init kubelet from containervm so that is doesn't startup
 | 
			
		||||
if [ -f /etc/init.d/kubelet ]; then
 | 
			
		||||
  sudo rm /etc/init.d/kubelet
 | 
			
		||||
fi
 | 
			
		||||
fi
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,7 @@ go build test/e2e_node/environment/conformance.go
 | 
			
		||||
ARTIFACTS=${WORKSPACE}/_artifacts
 | 
			
		||||
mkdir -p ${ARTIFACTS}
 | 
			
		||||
go run test/e2e_node/runner/run_e2e.go  --logtostderr --vmodule=*=2 --ssh-env="gce" \
 | 
			
		||||
  --zone="$GCE_ZONE" --project="$GCE_PROJECT"  \
 | 
			
		||||
  --zone="$GCE_ZONE" --project="$GCE_PROJECT" --image-project="$GCE_IMAGE_PROJECT" \
 | 
			
		||||
  --hosts="$GCE_HOSTS" --images="$GCE_IMAGES" --cleanup="$CLEANUP" \
 | 
			
		||||
  --results-dir="$ARTIFACTS" --ginkgo-flags="$GINKGO_FLAGS"
 | 
			
		||||
  --results-dir="$ARTIFACTS" --ginkgo-flags="$GINKGO_FLAGS" \
 | 
			
		||||
  --setup-node="$SETUP_NODE"
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,9 @@ GCE_HOSTS=
 | 
			
		||||
GCE_IMAGES=e2e-node-ubuntu-trusty-docker10-image,e2e-node-ubuntu-trusty-docker9-image,e2e-node-ubuntu-trusty-docker8-image,e2e-node-coreos-stable20160218-image,e2e-node-containervm-v20160321-image
 | 
			
		||||
GCE_ZONE=us-central1-f
 | 
			
		||||
GCE_PROJECT=kubernetes-jenkins
 | 
			
		||||
GCE_IMAGE_PROJECT=kubernetes-jenkins
 | 
			
		||||
INSTALL_GODEP=true
 | 
			
		||||
CLEANUP=true
 | 
			
		||||
GINKGO_FLAGS=
 | 
			
		||||
SETUP_NODE=false
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,8 @@ GCE_HOSTS=
 | 
			
		||||
GCE_IMAGES=e2e-node-ubuntu-trusty-docker10-image,e2e-node-ubuntu-trusty-docker9-image,e2e-node-ubuntu-trusty-docker8-image,e2e-node-coreos-stable20160218-image,e2e-node-containervm-v20160321-image
 | 
			
		||||
GCE_ZONE=us-central1-f
 | 
			
		||||
GCE_PROJECT=kubernetes-jenkins-pull
 | 
			
		||||
GCE_IMAGE_PROJECT=kubernetes-jenkins-pull
 | 
			
		||||
INSTALL_GODEP=true
 | 
			
		||||
CLEANUP=true
 | 
			
		||||
GINKGO_FLAGS=
 | 
			
		||||
SETUP_NODE=false
 | 
			
		||||
@@ -5,9 +5,15 @@ GCE_HOSTS=
 | 
			
		||||
GCE_IMAGES=
 | 
			
		||||
# Gce zone to use - required when using GCE_IMAGES
 | 
			
		||||
GCE_ZONE=
 | 
			
		||||
# Gce project to use - required when using GCE_IMAGES
 | 
			
		||||
# Gce project to use for creating instances 
 | 
			
		||||
# required when using GCE_IMAGES
 | 
			
		||||
GCE_PROJECT=
 | 
			
		||||
# Gce project to use for GCE_IMAGES
 | 
			
		||||
# required when using GCE_IMAGES
 | 
			
		||||
GCE_IMAGE_PROJECT=
 | 
			
		||||
# If true, assume a pristine GOPATH and install necessary godeps
 | 
			
		||||
INSTALL_GODEP=false
 | 
			
		||||
# If true, delete instances created from GCE_IMAGES and files copied to GCE_HOSTS
 | 
			
		||||
CLEANUP=true
 | 
			
		||||
# If true, current user will be added to the docker group on test node
 | 
			
		||||
SETUP_NODE=false
 | 
			
		||||
 
 | 
			
		||||
@@ -41,10 +41,12 @@ import (
 | 
			
		||||
var instanceNamePrefix = flag.String("instance-name-prefix", "", "prefix for instance names")
 | 
			
		||||
var zone = flag.String("zone", "", "gce zone the hosts live in")
 | 
			
		||||
var project = flag.String("project", "", "gce project the hosts live in")
 | 
			
		||||
var imageProject = flag.String("image-project", "", "gce project the hosts live in")
 | 
			
		||||
var images = flag.String("images", "", "images to test")
 | 
			
		||||
var hosts = flag.String("hosts", "", "hosts to test")
 | 
			
		||||
var cleanup = flag.Bool("cleanup", true, "If true remove files from remote hosts and delete temporary instances")
 | 
			
		||||
var buildOnly = flag.Bool("build-only", false, "If true, build e2e_node_test.tar.gz and exit.")
 | 
			
		||||
var setupNode = flag.Bool("setup-node", false, "When true, current user will be added to docker group on the test machine")
 | 
			
		||||
 | 
			
		||||
var computeService *compute.Service
 | 
			
		||||
 | 
			
		||||
@@ -70,8 +72,13 @@ func main() {
 | 
			
		||||
	if *images != "" && *zone == "" {
 | 
			
		||||
		glog.Fatal("Must specify --zone flag")
 | 
			
		||||
	}
 | 
			
		||||
	if *images != "" && *project == "" {
 | 
			
		||||
		glog.Fatal("Must specify --project flag")
 | 
			
		||||
	if *images != "" {
 | 
			
		||||
		if *imageProject == "" {
 | 
			
		||||
			glog.Fatal("Must specify --image-project flag")
 | 
			
		||||
		}
 | 
			
		||||
		if *project == "" {
 | 
			
		||||
			glog.Fatal("Must specify --project flag")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if *instanceNamePrefix == "" {
 | 
			
		||||
		*instanceNamePrefix = "tmp-node-e2e-" + uuid.NewUUID().String()[:8]
 | 
			
		||||
@@ -123,7 +130,7 @@ func main() {
 | 
			
		||||
			fmt.Printf("Initializing e2e tests using host %s.\n", host)
 | 
			
		||||
			running++
 | 
			
		||||
			go func(host string, junitFileNum int) {
 | 
			
		||||
				results <- testHost(host, archive, *cleanup, junitFileNum)
 | 
			
		||||
				results <- testHost(host, archive, *cleanup, junitFileNum, *setupNode)
 | 
			
		||||
			}(host, running)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -153,8 +160,8 @@ func main() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Run tests in archive against host
 | 
			
		||||
func testHost(host, archive string, deleteFiles bool, junitFileNum int) *TestResult {
 | 
			
		||||
	output, exitOk, err := e2e_node.RunRemote(archive, host, deleteFiles, junitFileNum)
 | 
			
		||||
func testHost(host, archive string, deleteFiles bool, junitFileNum int, setupNode bool) *TestResult {
 | 
			
		||||
	output, exitOk, err := e2e_node.RunRemote(archive, host, deleteFiles, junitFileNum, setupNode)
 | 
			
		||||
	return &TestResult{
 | 
			
		||||
		output: output,
 | 
			
		||||
		err:    err,
 | 
			
		||||
@@ -175,7 +182,7 @@ func testImage(image, archive string, junitFileNum int) *TestResult {
 | 
			
		||||
			err: fmt.Errorf("Unable to create gce instance with running docker daemon for image %s.  %v", image, err),
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return testHost(host, archive, false, junitFileNum)
 | 
			
		||||
	return testHost(host, archive, false, junitFileNum, *setupNode)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Provision a gce instance using image
 | 
			
		||||
@@ -253,7 +260,7 @@ func imageToInstanceName(image string) string {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func sourceImage(image string) string {
 | 
			
		||||
	return fmt.Sprintf("projects/%s/global/images/%s", *project, image)
 | 
			
		||||
	return fmt.Sprintf("projects/%s/global/images/%s", *imageProject, image)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func machineType() string {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user