diff --git a/runner/main/jobtypes/performance/performance.sh b/runner/main/jobtypes/performance/performance.sh index d0cbc5d..a3c9991 100644 --- a/runner/main/jobtypes/performance/performance.sh +++ b/runner/main/jobtypes/performance/performance.sh @@ -71,6 +71,7 @@ function performance_modules() { moodle-core-copy docker-healthy docker-summary + docker-jmeter ) echo "${modules[@]}" } @@ -113,12 +114,6 @@ function performance_setup_normal() { cd moodle-performance-comparison composer install - # Pull the JMeter Docker image. - docker pull justb4/jmeter - - # Run the JMeter container. - docker run -d --name jmeter-container justb4/jmeter - # Init the Performance site. echo echo ">>> startsection Initialising Performance environment at $(date)<<<" diff --git a/runner/main/modules/docker-jmeter/docker-jmeter.sh b/runner/main/modules/docker-jmeter/docker-jmeter.sh new file mode 100644 index 0000000..3955766 --- /dev/null +++ b/runner/main/modules/docker-jmeter/docker-jmeter.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +# +# This file is part of the Moodle Continuous Integration Project. +# +# Moodle is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Moodle is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Moodle. If not, see . + +# Jmeter module functions. + +# This module defines the following env variables. +function docker-jmeter_env() { + env=( + JMETERTESTURL + ) + echo "${env[@]}" +} + +# JMETER module checks. +function docker-jmeter_check() { + # Check all module dependencies. + verify_modules docker + + # These env variables must be set for the database module to work. + verify_env NETWORK UUID +} + +# JMETER module config. +function docker-jmeter_config() { + JMETER=jmeter"${UUID}" + JMETERTESTURL="jmeter://${JMETER}" +} + +# JMETER module setup, launch the containers. +function docker-jmeter_setup() { + echo + echo ">>> startsection Starting Jmeter server <<<" + echo "============================================================================" + + # Start the jmeter server + docker run \ + --detach \ + --name "${JMETER}" \ + justb4/jmeter + + echo "JMETER: URL: ${JMETERTESTURL}" + echo "JMETER logs:" + docker logs "${JMETER}" + + echo "============================================================================" + echo ">>> stopsection <<<" +}