diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..120b655 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,75 @@ +language: ruby +sudo: required +services: +- docker +before_install: +- echo "Installing test gems" +- gem install yaml-lint +- export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" +- echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee + -a /etc/apt/sources.list.d/google-cloud-sdk.list +- curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - +- sudo apt-get update +- sudo apt-get install -y dpkg +- sudo apt-get install google-cloud-sdk +- curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.10.5/bin/linux/amd64/kubectl; + chmod +x ./kubectl; sudo mv ./kubectl /usr/bin/ +- sudo apt-get install jq +- echo $GCP_KEY_FILE | base64 -d > ./keyfile +- gcloud auth activate-service-account -q $(jq -r .client_email keyfile) --key-file=./keyfile + --project $(jq -r .project_id keyfile) +- rm ./keyfile +install: true +script: +- pwd +- | + echo '#!/bin/bash + SOLACE_DOCKER_IMAGE_REFERENCE="solace/solace-pubsub-standard:latest" + ADMIN_PASSWORD="admin-password" + GITHUB_BRANCH=BRANCH_REF + if [ ! -d /var/lib/solace ]; then + mkdir /var/lib/solace + cd /var/lib/solace + LOOP_COUNT=0 + while [ $LOOP_COUNT -lt 30 ]; do + yum install -y wget || echo "yum not ready, waiting" + wget https://raw.githubusercontent.com/$GITHUB_BRANCH/scripts/install-solace.sh + if [ 0 != `echo $?` ]; then + ((LOOP_COUNT++)) + else + break + fi + done + if [ ${LOOP_COUNT} == 30 ]; then + echo "`date` ERROR: Failed to download initial install script - exiting" + exit 1 + fi + chmod +x /var/lib/solace/install-solace.sh + /var/lib/solace/install-solace.sh -p $ADMIN_PASSWORD -i $SOLACE_DOCKER_IMAGE_REFERENCE + fi' > automation_script +- sed -i "s:BRANCH_REF:${TRAVIS_REPO_SLUG}/${TRAVIS_BRANCH}:g" automation_script +- cat automation_script +- export VM_NAME=travis-gcp-$(date +%s) +- export NETWORK_TAG=$VM_NAME-tag +- export FIREWALL_RULE=$VM_NAME-access +- gcloud compute instances create $VM_NAME --image-family centos-7 --image-project centos-cloud --create-disk size=20 --machine-type=n1-standard-2 --zone us-east1-b --metadata-from-file startup-script=./automation_script +- gcloud compute instances add-tags $VM_NAME --zone us-east1-b --tags $NETWORK_TAG +- gcloud compute firewall-rules create $FIREWALL_RULE --target-tags $NETWORK_TAG --source-ranges 0.0.0.0/0 --allow tcp:60080,tcp:60443,tcp:8080,tcp:60943,tcp:1883,tcp:8000,tcp:9000,tcp:55003,tcp:55443,tcp:55555 +- until gcloud compute instances list | grep $VM_NAME | grep RUNNING; do sleep 10; done +- export url="$(gcloud compute instances list | grep $VM_NAME + | awk '{print $5}')"; echo $url +- until timeout 10 curl $url:8080; do sleep 5; done +- sleep 30 +- curl -O https://sftp.solace.com/download/SDKPERF_C_LINUX64 +- tar -xvf SDKPERF_C_LINUX64 +- pubSubTools/sdkperf_c -cip=$url -mn=100000 -mr=0 -ptl=t1 -stl=t1 | grep "Total Messages" + +after_success: +- echo "Test Success - Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)" +- echo "YAML linted" +- echo "GCP deployment tested" +- echo "Messaging tested" + +after_script: +- gcloud compute instances delete $VM_NAME --zone us-east1-b --quiet +- gcloud compute firewall-rules delete $FIREWALL_RULE --quiet diff --git a/scripts/install-solace.sh b/scripts/install-solace.sh index b48e4f3..e750c1a 100644 --- a/scripts/install-solace.sh +++ b/scripts/install-solace.sh @@ -72,31 +72,15 @@ yum -y install lvm2 echo "`date` INFO:Set up Docker Repository" &>> ${LOG_FILE} # ----------------------------------- -tee /etc/yum.repos.d/docker.repo <<-EOF -[dockerrepo] -name=Docker Repository -baseurl=https://yum.dockerproject.org/repo/main/centos/7/ -enabled=1 -gpgcheck=1 -gpgkey=https://yum.dockerproject.org/gpg -EOF -echo "`date` INFO:/etc/yum.repos.d/docker.repo =\n `cat /etc/yum.repos.d/docker.repo`" &>> ${LOG_FILE} +yum -y install yum-utils +yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo echo "`date` INFO:Intall Docker" &>> ${LOG_FILE} # ------------------------- -yum -y install docker-engine +yum -y install docker-ce docker-ce-cli containerd.io echo "`date` INFO:Configure Docker as a service" &>> ${LOG_FILE} # ---------------------------------------- -mkdir /etc/systemd/system/docker.service.d &>> install.log -tee /etc/systemd/system/docker.service.d/docker.conf <<-EOF -[Service] - ExecStart= - ExecStart=/usr/bin/dockerd --iptables=false --storage-driver=devicemapper -EOF -echo "`date` INFO:/etc/systemd/system/docker.service.d =\n `cat /etc/systemd/system/docker.service.d`" &>> ${LOG_FILE} - -systemctl enable docker systemctl start docker ## First make sure Docker is actually up