From 1b24bd07c507181b41b667a53ab424bb7077d747 Mon Sep 17 00:00:00 2001 From: AhmadBassyiouni <30308260+abassyiouni@users.noreply.github.com> Date: Tue, 2 Nov 2021 10:00:24 -0700 Subject: [PATCH] test: Added context deploy benchmarking script (#111) * Context deploy benchmark script --- .../context-benchmark.sh | 51 +++++++++++++++++++ .../cromwell/agc-project.yaml | 24 +++++++++ .../nextflow/agc-project.yaml | 24 +++++++++ 3 files changed, 99 insertions(+) create mode 100755 scripts/context-deploy-benchmark/context-benchmark.sh create mode 100644 scripts/context-deploy-benchmark/cromwell/agc-project.yaml create mode 100644 scripts/context-deploy-benchmark/nextflow/agc-project.yaml diff --git a/scripts/context-deploy-benchmark/context-benchmark.sh b/scripts/context-deploy-benchmark/context-benchmark.sh new file mode 100755 index 00000000..5dc54a90 --- /dev/null +++ b/scripts/context-deploy-benchmark/context-benchmark.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +CONTEXT_AMOUNT=5 +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +deploy_contexts_sequential() { + for ((i = 1; i <= CONTEXT_AMOUNT; i++)) + do + agc context deploy -c "$1$i"; + done +} + +cleanup_contexts() { + for ((i = 1; i <= CONTEXT_AMOUNT; i++)) + do + agc context destroy -c "$1$i"; + done +} + +deploy_contexts_all() { + agc context deploy --all; +} + +get_average_runtime() { + START_SECONDS=$(date +%s) + $1 $2 + END_SECONDS=$(date +%s) + DIFF_SECONDS=$((END_SECONDS-START_SECONDS)) + AVERAGE_SECONDS=$(((DIFF_SECONDS%60)/CONTEXT_AMOUNT)) + AVERAGE_MINUTES=$(((DIFF_SECONDS/60)/CONTEXT_AMOUNT)) + echo "Average $2 $3 time across $CONTEXT_AMOUNT contexts is: $AVERAGE_MINUTES m $AVERAGE_SECONDS s" +} + +get_all_averages() { + get_average_runtime deploy_contexts_sequential "$1" "sequential deployment" + cleanup_contexts "$1" + get_average_runtime deploy_contexts_all "$1" "all deployment" + get_average_runtime cleanup_contexts "$1" "destruction" +} + +validate_and_run() { + if [ $1 != "1" ] || [[ $2 != "cromwell" && $2 != "nextflow" ]] + then + echo "Please specify engine type to benchmark (cromwell | nextflow)" + else + cd "$SCRIPT_DIR/$2" + get_all_averages $2 + fi +} + +validate_and_run $# $1 diff --git a/scripts/context-deploy-benchmark/cromwell/agc-project.yaml b/scripts/context-deploy-benchmark/cromwell/agc-project.yaml new file mode 100644 index 00000000..cd23c0d5 --- /dev/null +++ b/scripts/context-deploy-benchmark/cromwell/agc-project.yaml @@ -0,0 +1,24 @@ +--- +name: CromwellContextBenchmarkTest +schemaVersion: 1 +contexts: + cromwell1: + engines: + - type: wdl + engine: cromwell + cromwell2: + engines: + - type: wdl + engine: cromwell + cromwell3: + engines: + - type: wdl + engine: cromwell + cromwell4: + engines: + - type: wdl + engine: cromwell + cromwell5: + engines: + - type: wdl + engine: cromwell \ No newline at end of file diff --git a/scripts/context-deploy-benchmark/nextflow/agc-project.yaml b/scripts/context-deploy-benchmark/nextflow/agc-project.yaml new file mode 100644 index 00000000..e8c93a98 --- /dev/null +++ b/scripts/context-deploy-benchmark/nextflow/agc-project.yaml @@ -0,0 +1,24 @@ +--- +name: NextflowContextBenchmarkTest +schemaVersion: 1 +contexts: + nextflow1: + engines: + - type: nextflow + engine: nextflow + nextflow2: + engines: + - type: nextflow + engine: nextflow + nextflow3: + engines: + - type: nextflow + engine: nextflow + nextflow4: + engines: + - type: nextflow + engine: nextflow + nextflow5: + engines: + - type: nextflow + engine: nextflow