Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Alexander V. Tikhonov" <avtikhon@tarantool.org>
To: sergeyb@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 3/4] tools: add script to run Jepsen tests
Date: Fri, 18 Sep 2020 17:32:19 +0300	[thread overview]
Message-ID: <20200918143219.GC27064@hpalx> (raw)
In-Reply-To: <12913ccaef25726fbc8c16c4d359100cf1a4bd80.1600239621.git.sergeyb@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 <sergeyb@tarantool.org>
> 
> 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
> 

  reply	other threads:[~2020-09-18 14:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16  7:07 [Tarantool-patches] [PATCH 0/4] Integrate Jepsen tests to CI sergeyb
2020-09-16  7:07 ` [Tarantool-patches] [PATCH 1/4] extra: add Terraform config files sergeyb
2020-09-18 14:20   ` Alexander V. Tikhonov
2020-09-16  7:07 ` [Tarantool-patches] [PATCH 2/4] cmake: add targets to run Jepsen tests sergeyb
2020-09-18 14:23   ` Alexander V. Tikhonov
2020-09-16  7:07 ` [Tarantool-patches] [PATCH 3/4] tools: add script " sergeyb
2020-09-18 14:32   ` Alexander V. Tikhonov [this message]
2020-09-16  7:07 ` [Tarantool-patches] [PATCH 4/4] ci: integrate Jepsen tests to GitLab CI sergeyb
2020-09-17  7:12   ` Alexander V. Tikhonov
2020-09-17 15:25     ` Alexander Turenko
2020-09-18 12:28       ` Sergey Bronnikov
2020-09-18 12:34         ` Alexander V. Tikhonov
2020-09-18 12:33     ` Sergey Bronnikov
2020-09-18 15:03 ` [Tarantool-patches] [PATCH 0/4] Integrate Jepsen tests to CI Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200918143219.GC27064@hpalx \
    --to=avtikhon@tarantool.org \
    --cc=sergeyb@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 3/4] tools: add script to run Jepsen tests' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox