From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6E525469719 for ; Fri, 18 Sep 2020 17:32:21 +0300 (MSK) Date: Fri, 18 Sep 2020 17:32:19 +0300 From: "Alexander V. Tikhonov" Message-ID: <20200918143219.GC27064@hpalx> References: <12913ccaef25726fbc8c16c4d359100cf1a4bd80.1600239621.git.sergeyb@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <12913ccaef25726fbc8c16c4d359100cf1a4bd80.1600239621.git.sergeyb@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 3/4] tools: add script to run Jepsen tests List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: sergeyb@tarantool.org Cc: tarantool-patches@dev.tarantool.org Hi Sergey, thanks a lot for the patch. IMHO the script is on bash and its great for the initiating the new feature, because it is really easy to fix on any needs, so patch LGTM. On Wed, Sep 16, 2020 at 10:07:22AM +0300, sergeyb@tarantool.org wrote: > From: Sergey Bronnikov > > Main script that handle creation of set of virtual machines > using Terraform, setup for remote connection, running > Jepsen tests and teardown test environment. > > Part of #5277 > --- > tools/run-jepsen-tests.sh | 77 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 77 insertions(+) > create mode 100755 tools/run-jepsen-tests.sh > > diff --git a/tools/run-jepsen-tests.sh b/tools/run-jepsen-tests.sh > new file mode 100755 > index 000000000..865a8f4b0 > --- /dev/null > +++ b/tools/run-jepsen-tests.sh > @@ -0,0 +1,77 @@ > +#!/usr/bin/bash > + > +# Script performs setup of test environment using Terraform, > +# runs Jepsen tests and teardown test environment. > +# Script expects following environment variables: > +# TF_VAR_user_name > +# TF_VAR_password > +# TF_VAR_tenant_id > +# TF_VAR_user_domain_id > +# TF_VAR_keypair_name > +# TF_VAR_ssh_key > +# and three arguments: path to a Tarantool project source directory, path to a > +# Tarantool project binary directory and number on instances (optional). > + > +set -Eeo pipefail > + > +PROJECT_SOURCE_DIR=$1 > +PROJECT_BINARY_DIR=$2 > +INSTANCE_COUNT=$3 > + > +TESTS_DIR="$PROJECT_BINARY_DIR/jepsen-tests-prefix/src/jepsen-tests/" > +TERRAFORM_CONFIG="$PROJECT_SOURCE_DIR/extra/tf" > +TERRAFORM_STATE="$PROJECT_BINARY_DIR/terraform.tfstate" > +SSH_KEY_FILENAME="$PROJECT_SOURCE_DIR/build/tf-cloud-init" > +NODES_FILENAME="$PROJECT_SOURCE_DIR/build/nodes" > + > +LEIN_OPTIONS="--nodes-file $NODES_FILENAME --username ubuntu --workload register" > + > +[[ -z ${PROJECT_SOURCE_DIR} ]] && (echo "Please specify path to a project source directory") > +[[ -z ${PROJECT_BINARY_DIR} ]] && (echo "Please specify path to a project binary directory") > +[[ -z ${TF_VAR_ssh_key} ]] && (echo "Please specify TF_VAR_ssh_key env var"; exit 1) > +[[ -z ${TF_VAR_keypair_name} ]] && (echo "Please specify TF_VAR_keypair_name env var"; exit 1) > + > +TERRAFORM_BIN=$(which terraform) > +LEIN_BIN=$(which lein) > +CLOJURE_BIN=$(which clojure) > + > +[[ -z ${TERRAFORM_BIN} ]] && (echo "terraform is not installed"; exit 1) > +[[ -z ${LEIN_BIN} ]] && (echo "lein is not installed"; exit 1) > +[[ -z ${CLOJURE_BIN} ]] && (echo "clojure is not installed"; exit 1) > + > +function cleanup { > + echo "cleanup" > + rm -f $NODES_FILENAME $SSH_KEY_FILENAME > + [[ -e $TERRAFORM_STATE ]] && \ > + terraform destroy -state=$TERRAFORM_STATE -auto-approve $TERRAFORM_CONFIG > +} > + > +trap "{ cleanup; exit 255; }" SIGINT SIGTERM ERR > + > +echo -e "${TF_VAR_ssh_key//_/\\n}" > $SSH_KEY_FILENAME > +chmod 400 $SSH_KEY_FILENAME > +$(pgrep ssh-agent 2>&1 > /dev/null) || eval "$(ssh-agent)" > +ssh-add $SSH_KEY_FILENAME > + > +if [[ -z ${CI_JOB_ID} ]]; then > + TF_VAR_id=$CI_JOB_ID > +else > + RANDOM_ID=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13; echo '') > + TF_VAR_id=TF-$RANDOM_ID > +fi > + > +export TF_VAR_id > +export TF_VAR_ssh_key_path=$SSH_KEY_FILENAME > +[[ -z ${INSTANCE_COUNT} ]] && TF_VAR_instance_count=1 || TF_VAR_instance_count=$INSTANCE_COUNT > +export TF_VAR_instance_count > + > +[[ -e $HOME/.ssh ]] || (mkdir $HOME/.ssh && touch $HOME/.ssh/known_hosts) > + > +terraform init $TERRAFORM_CONFIG > +terraform apply -state=$TERRAFORM_STATE -auto-approve $TERRAFORM_CONFIG > +terraform providers $TERRAFORM_CONFIG > +terraform output -state=$TERRAFORM_STATE instance_names > +terraform output -state=$TERRAFORM_STATE -json instance_ips | jq --raw-output '.[]' > $NODES_FILENAME > +pushd $TESTS_DIR && lein run test $LEIN_OPTIONS > +popd > +cleanup > -- > 2.25.1 >