Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support images and instances to exist in different GCP projects for node #26671

Merged
merged 1 commit into from
Jun 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions hack/verify-flags/exceptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,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:-""}
Expand Down
2 changes: 2 additions & 0 deletions hack/verify-flags/known-flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,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
Expand Down Expand Up @@ -410,6 +411,7 @@ service-node-ports
service-overrides
service-sync-period
session-affinity
setup-node
show-all
show-events
show-labels
Expand Down
1 change: 1 addition & 0 deletions test/e2e_node/e2e_node_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ var _ = AfterSuite(func() {
glog.Infof("Stopping node services...")
e2es.stop()
}

glog.Infof("Tests Finished")
})

Expand Down
14 changes: 12 additions & 2 deletions test/e2e_node/e2e_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion test/e2e_node/environment/setup_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,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
5 changes: 3 additions & 2 deletions test/e2e_node/jenkins/e2e-node-jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions test/e2e_node/jenkins/jenkins-ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 2 additions & 0 deletions test/e2e_node/jenkins/jenkins-pull.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion test/e2e_node/jenkins/template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 14 additions & 7 deletions test/e2e_node/runner/run_e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down