mirror of https://github.com/k3s-io/k3s
Make it possible to run node e2e with GCI via make
Signed-off-by: Vishnu kannan <vishnuk@google.com>pull/6/head
parent
f55206a675
commit
d31608fcc8
1
Makefile
1
Makefile
|
@ -157,6 +157,7 @@ test-e2e: ginkgo generated_files
|
|||
# IMAGES. Defaults to "kubernetes-node-e2e-images".
|
||||
# INSTANCE_PREFIX: For REMOTE=true only. Instances created from images will
|
||||
# have the name "${INSTANCE_PREFIX}-${IMAGE_NAME}". Defaults to "test".
|
||||
# INSTANCE_METADATA: For REMOTE=true and running on GCE only.
|
||||
#
|
||||
# Example:
|
||||
# make test-e2e-node FOCUS=Kubelet SKIP=container
|
||||
|
|
|
@ -51,6 +51,7 @@ Why run tests *Locally*? Much faster than running tests Remotely.
|
|||
Prerequisites:
|
||||
- [Install etcd](https://github.com/coreos/etcd/releases) on your PATH
|
||||
- Verify etcd is installed correctly by running `which etcd`
|
||||
- Or make etcd binary available and executable at `/tmp/etcd`
|
||||
- [Install ginkgo](https://github.com/onsi/ginkgo) on your PATH
|
||||
- Verify ginkgo is installed correctly by running `which ginkgo`
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ delete_instances=${DELETE_INSTANCES:-"false"}
|
|||
run_until_failure=${RUN_UNTIL_FAILURE:-"false"}
|
||||
list_images=${LIST_IMAGES:-"false"}
|
||||
test_args=${TEST_ARGS:-""}
|
||||
metadata=${INSTANCE_METADATA:-""}
|
||||
|
||||
if [[ $list_images == "true" ]]; then
|
||||
gcloud compute images list --project="${image_project}" | grep "e2e-node"
|
||||
|
@ -111,14 +112,14 @@ if [ $remote = true ] ; then
|
|||
echo "Images: $images"
|
||||
echo "Hosts: $hosts"
|
||||
echo "Ginkgo Flags: $ginkgoflags"
|
||||
|
||||
echo "Instance Metadata: $metadata"
|
||||
# Invoke the runner
|
||||
go run test/e2e_node/runner/run_e2e.go --logtostderr --vmodule=*=2 --ssh-env="gce" \
|
||||
--zone="$zone" --project="$project" \
|
||||
--hosts="$hosts" --images="$images" --cleanup="$cleanup" \
|
||||
--results-dir="$artifacts" --ginkgo-flags="$ginkgoflags" \
|
||||
--image-project="$image_project" --instance-name-prefix="$instance_prefix" --setup-node="true" \
|
||||
--delete-instances="$delete_instances" --test_args="$test_args"
|
||||
--delete-instances="$delete_instances" --test_args="$test_args" --instance-metadata="$metadata"
|
||||
exit $?
|
||||
|
||||
else
|
||||
|
|
|
@ -135,7 +135,9 @@ var _ = AfterSuite(func() {
|
|||
func maskLocksmithdOnCoreos() {
|
||||
data, err := ioutil.ReadFile("/etc/os-release")
|
||||
if err != nil {
|
||||
glog.Fatalf("Could not read /etc/os-release: %v", err)
|
||||
// Not all distros contain this file.
|
||||
glog.Infof("Could not read /etc/os-release: %v", err)
|
||||
return
|
||||
}
|
||||
if bytes.Contains(data, []byte("ID=coreos")) {
|
||||
if output, err := exec.Command("sudo", "systemctl", "mask", "--now", "locksmithd").CombinedOutput(); err != nil {
|
||||
|
|
|
@ -57,6 +57,8 @@ type logFileData struct {
|
|||
const (
|
||||
// This is consistent with the level used in a cluster e2e test.
|
||||
LOG_VERBOSITY_LEVEL = "4"
|
||||
// Etcd binary is expected to either be available via PATH, or at this location.
|
||||
defaultEtcdPath = "/tmp/etcd"
|
||||
)
|
||||
|
||||
func newE2eService(nodeName string, cgroupsPerQOS bool) *e2eService {
|
||||
|
@ -179,7 +181,16 @@ func (es *e2eService) startEtcd() (*killCmd, error) {
|
|||
return nil, err
|
||||
}
|
||||
es.etcdDataDir = dataDir
|
||||
cmd := exec.Command("etcd")
|
||||
etcdPath, err := exec.LookPath("etcd")
|
||||
if err != nil {
|
||||
glog.Infof("etcd not found in PATH. Defaulting to %s...", defaultEtcdPath)
|
||||
_, err = os.Stat(defaultEtcdPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("etcd binary not found")
|
||||
}
|
||||
etcdPath = defaultEtcdPath
|
||||
}
|
||||
cmd := exec.Command(etcdPath)
|
||||
// Execute etcd in the data directory instead of using --data-dir because the flag sometimes requires additional
|
||||
// configuration (e.g. --name in version 0.4.9)
|
||||
cmd.Dir = es.etcdDataDir
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#cloud-config
|
||||
|
||||
runcmd:
|
||||
- mount /tmp /tmp -o remount,exec,suid
|
||||
- ETCD_VERSION=v2.2.5
|
||||
- curl -L https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz -o /tmp/etcd.tar.gz
|
||||
- tar xzvf /tmp/etcd.tar.gz -C /tmp
|
||||
- sudo mv /tmp/etcd-${ETCD_VERSION}-linux-amd64/etcd* /usr/local/bin/
|
||||
- sudo chown root:root /usr/local/bin/etcd*
|
||||
- rm -r /tmp/etcd*
|
||||
- cp /tmp/etcd-${ETCD_VERSION}-linux-amd64/etcd* /tmp/
|
||||
- rm -rf /tmp/etcd-${ETCD_VERSION}-linux-amd64/
|
||||
|
|
|
@ -310,7 +310,9 @@ func createInstance(image, imageProject string) (string, error) {
|
|||
},
|
||||
}
|
||||
if *instanceMetadata != "" {
|
||||
glog.V(2).Infof("parsing instance metadata: %q", *instanceMetadata)
|
||||
raw := parseInstanceMetadata(*instanceMetadata)
|
||||
glog.V(3).Infof("parsed instance metadata: %v", raw)
|
||||
i.Metadata = &compute.Metadata{}
|
||||
metadata := []*compute.MetadataItems{}
|
||||
for k, v := range raw {
|
||||
|
@ -422,12 +424,12 @@ func parseInstanceMetadata(str string) map[string]string {
|
|||
}
|
||||
kp := strings.Split(s, "<")
|
||||
if len(kp) != 2 {
|
||||
glog.Errorf("Invalid instance metadata: %q", s)
|
||||
glog.Fatalf("Invalid instance metadata: %q", s)
|
||||
continue
|
||||
}
|
||||
v, err := ioutil.ReadFile(kp[1])
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to read metadata file %q: %v", kp[1], err)
|
||||
glog.Fatalf("Failed to read metadata file %q: %v", kp[1], err)
|
||||
continue
|
||||
}
|
||||
metadata[kp[0]] = string(v)
|
||||
|
|
Loading…
Reference in New Issue