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 <saw.jan.grg3e@gmail.com>
This commit is contained in:
Viktor Scharf
2023-12-04 11:49:16 +01:00
committed by GitHub
parent c8dc52cd61
commit 81ace6dd1d
2 changed files with 73 additions and 0 deletions
+58
View File
@@ -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",
],
},
}]
+15
View File
@@ -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"