From 51c4371e391e9ab55e32eb4f35f52b650cf95c27 Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Thu, 11 May 2017 10:57:09 -0700 Subject: [PATCH] Jenkinsfile,tests: Add etcd3-terraform cluster to pipeline * Test the Terraform-based etcd3 cluster in parallel --- Jenkinsfile | 17 ++++++++++++---- scripts/devnet | 5 +++-- tests/smoke/etcd3 | 2 +- tests/smoke/etcd3-terraform | 39 +++++++++++++++++++++++++++++++++++++ tests/smoke/etcd3.tfvars | 3 +++ 5 files changed, 59 insertions(+), 7 deletions(-) create mode 100755 tests/smoke/etcd3-terraform create mode 100644 tests/smoke/etcd3.tfvars diff --git a/Jenkinsfile b/Jenkinsfile index 9005d471..3738c9bc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,10 +9,9 @@ parallel ( etcd3: { node('fedora && bare-metal') { stage('etcd3') { - timeout(time:3, unit:'MINUTES') { + timeout(time:5, unit:'MINUTES') { checkout scm sh '''#!/bin/bash -e - cat /etc/os-release export ASSETS_DIR=~/assets; ./tests/smoke/etcd3 ''' } @@ -25,7 +24,6 @@ parallel ( timeout(time:12, unit:'MINUTES') { checkout scm sh '''#!/bin/bash -e - cat /etc/os-release export ASSETS_DIR=~/assets; ./tests/smoke/k8s ''' } @@ -38,12 +36,23 @@ parallel ( timeout(time:12, unit:'MINUTES') { checkout scm sh '''#!/bin/bash -e - cat /etc/os-release chmod 600 ./tests/smoke/fake_rsa export ASSETS_DIR=~/assets; ./tests/smoke/bootkube ''' } } } + }, + "etcd3-terraform": { + node('fedora && bare-metal') { + stage('etcd3-terraform') { + timeout(time:8, unit:'MINUTES') { + checkout scm + sh '''#!/bin/bash -e + export ASSETS_DIR=~/assets; export CONFIG_DIR=~/matchbox/examples/etc/matchbox; ./tests/smoke/etcd3-terraform + ''' + } + } + } } ) diff --git a/scripts/devnet b/scripts/devnet index 622807c9..76bb815a 100755 --- a/scripts/devnet +++ b/scripts/devnet @@ -14,6 +14,7 @@ COREOS_VERSION=1298.7.0 MATCHBOX_ARGS="" ASSETS_DIR="${ASSETS_DIR:-$PWD/examples/assets}" +CONFIG_DIR="${CONFIG_DIR:-$PWD/examples/etc/matchbox}" if [ "$EUID" -ne 0 ] then echo "Please run as root" @@ -87,10 +88,10 @@ function create { --trust-keys-from-https \ --net=metal0:IP=172.18.0.2 \ --mount volume=config,target=/etc/matchbox \ - --volume config,kind=host,source=$PWD/examples/etc/matchbox,readOnly=true \ + --volume config,kind=host,source=$CONFIG_DIR,readOnly=true \ --mount volume=data,target=/var/lib/matchbox \ $DATA_MOUNT \ - quay.io/coreos/matchbox:c8af40108fb06f345a5fdae915874b0b1b606e1a -- -address=0.0.0.0:8080 -log-level=debug $MATCHBOX_ARGS + quay.io/coreos/matchbox:v0.6.0 -- -address=0.0.0.0:8080 -log-level=debug $MATCHBOX_ARGS echo "Starting dnsmasq to provide DHCP/TFTP/DNS services" rkt rm --uuid-file=/var/run/dnsmasq-pod.uuid > /dev/null 2>&1 diff --git a/tests/smoke/etcd3 b/tests/smoke/etcd3 index 1f11db67..de3468cc 100755 --- a/tests/smoke/etcd3 +++ b/tests/smoke/etcd3 @@ -19,7 +19,7 @@ main() { echo "Waiting for etcd cluster..." done - echo "etcd cluster came up!" + echo "etcd3 cluster came up!" echo cleanup diff --git a/tests/smoke/etcd3-terraform b/tests/smoke/etcd3-terraform new file mode 100755 index 00000000..646c502e --- /dev/null +++ b/tests/smoke/etcd3-terraform @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${DIR}/common" + +main() { + cleanup + trap cleanup EXIT + + ./scripts/devnet create + + pushd examples/terraform/etcd3-install + terraform get + terraform apply -var-file $DIR/etcd3.tfvars + popd + + ./scripts/libvirt create + + until etcd "node1.example.com" \ + && etcd "node2.example.com" \ + && etcd "node3.example.com" + do + sleep 3 + echo "Waiting for etcd cluster..." + done + + echo "etcd3 cluster came up!" + echo + + cleanup +} + +# etcd health checks the given etcd client endpoint +etcd() { + curl --silent --fail -m 1 http://$1:2379/health > /dev/null +} + +main $@ diff --git a/tests/smoke/etcd3.tfvars b/tests/smoke/etcd3.tfvars new file mode 100644 index 00000000..8691a5fa --- /dev/null +++ b/tests/smoke/etcd3.tfvars @@ -0,0 +1,3 @@ +matchbox_http_endpoint = "http://matchbox.example.com:8080" +matchbox_rpc_endpoint = "matchbox.example.com:8081" +ssh_authorized_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDPQFdwVLr+alsWIgYRz9OdqDhnx9jjuFbkdSdpqq4gd9uZApYlivMDD4UgjFazQpezx8DiNhu9ym7i6LgAcdwi+10hE4L9yoJv9uBgbBxOAd65znqLqF91NtV4mlKP5YfJtR7Ehs+pTB+IIC+o5veDbPn+BYgDMJ2x7Osbn1/gFSDken/yoOFbYbRMGMfVEQYjJzC4r/qCKH0bl/xuVNLxf9FkWSTCcQFKGOndwuGITDkshD4r2Kk8gUddXPxoahBv33/2QH0CY5zbKYjhgN6I6WtwO+O1uJwtNeV1AGhYjurdd60qggNwx+W7623uK3nIXvJd3hzDO8u5oa53/tIL fake-test-key"