From 81ace6dd1db15f5395f397b3ff691ceb9e66ed52 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Mon, 4 Dec 2023 11:49:16 +0100 Subject: [PATCH] run k6 test in remote server nightly (#7869) * run k6 test in remote server nightly * fix pipeline disable clone step download script file enable only for cron events --------- Co-authored-by: Saw-jan --- .drone.star | 58 ++++++++++++++++++++++++++++++ tests/config/drone/run_k6_tests.sh | 15 ++++++++ 2 files changed, 73 insertions(+) create mode 100644 tests/config/drone/run_k6_tests.sh diff --git a/.drone.star b/.drone.star index 1d40dd3c1d..db4bc4b50f 100644 --- a/.drone.star +++ b/.drone.star @@ -59,6 +59,9 @@ config = { "wopiValidatorTests": { "skip": False, }, + "k6LoadTests": { + "skip": False, + }, "localApiTests": { "basic": { "suites": [ @@ -336,6 +339,9 @@ def testPipelines(ctx): if "skip" not in config["e2eTests"] or not config["e2eTests"]["skip"]: pipelines += e2eTests(ctx) + if "skip" not in config["k6LoadTests"] or not config["k6LoadTests"]["skip"]: + pipelines += k6LoadTests(ctx) + return pipelines def getGoBinForTesting(ctx): @@ -2776,3 +2782,55 @@ def logRequests(): ], }, }] + +def k6LoadTests(ctx): + ocis_git_base_url = "https://raw.githubusercontent.com/owncloud/ocis" + script_link = "%s/%s/tests/config/drone/run_k6_tests.sh" % (ocis_git_base_url, ctx.build.commit) + return [{ + "kind": "pipeline", + "type": "docker", + "name": "k6-load-test", + "clone": { + "disable": True, + }, + "steps": [ + { + "name": "k6-load-test", + "image": OC_CI_ALPINE, + "environment": { + "SSH_OCIS_REMOTE": { + "from_secret": "ssh_ocis_remote", + }, + "SSH_OCIS_USERNAME": { + "from_secret": "ssh_ocis_user", + }, + "SSH_OCIS_PASSWORD": { + "from_secret": "ssh_ocis_pass", + }, + "TEST_SERVER_URL": { + "from_secret": "ssh_ocis_server_url", + }, + "SSH_K6_REMOTE": { + "from_secret": "ssh_k6_remote", + }, + "SSH_K6_USERNAME": { + "from_secret": "ssh_k6_user", + }, + "SSH_K6_PASSWORD": { + "from_secret": "ssh_k6_pass", + }, + }, + "commands": [ + "curl -s -o run_k6_tests.sh %s" % script_link, + "apk add --no-cache openssh-client sshpass", + "sh %s/run_k6_tests.sh" % (dirs["base"]), + ], + }, + ], + "depends_on": [], + "trigger": { + "event": [ + "cron", + ], + }, + }] diff --git a/tests/config/drone/run_k6_tests.sh b/tests/config/drone/run_k6_tests.sh new file mode 100644 index 0000000000..2c57070c68 --- /dev/null +++ b/tests/config/drone/run_k6_tests.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# start ocis server +sshpass -p "$SSH_OCIS_PASSWORD" ssh -o StrictHostKeyChecking=no "$SSH_OCIS_USERNAME@$SSH_OCIS_REMOTE" \ + "OCIS_URL=${TEST_SERVER_URL} \ + OCIS_COMMIT_ID=${DRONE_COMMIT} \ + bash ~/scripts/ocis.sh start" + +# start k6 tests +sshpass -p "$SSH_K6_PASSWORD" ssh -o StrictHostKeyChecking=no "$SSH_K6_USERNAME@$SSH_K6_REMOTE" \ + "TEST_SERVER_URL=${TEST_SERVER_URL} \ + bash ~/scripts/k6-tests.sh" + +# stop ocis server +sshpass -p "$SSH_OCIS_PASSWORD" ssh -o StrictHostKeyChecking=no "$SSH_OCIS_USERNAME@$SSH_OCIS_REMOTE" "bash ~/scripts/ocis.sh stop"