Skip to content

Commit

Permalink
run k6 test in remote server nightly (#7869)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ScharfViktor and saw-jan authored Dec 4, 2023
1 parent c8dc52c commit 81ace6d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ config = {
"wopiValidatorTests": {
"skip": False,
},
"k6LoadTests": {
"skip": False,
},
"localApiTests": {
"basic": {
"suites": [
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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 changes: 15 additions & 0 deletions tests/config/drone/run_k6_tests.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 81ace6d

Please sign in to comment.