Commit dfe5341a authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

Merge branch 'MDLSITE-6127' into 'master'

MDLSITE-6127 CI: Add support for database slaves

See merge request integration/nightlyjobs!18
parents 3cc449dd 5b3ce327
......@@ -68,6 +68,11 @@ class Task {
*/
protected String database = 'pgsql'
/**
* The number of database slaves to include.
*/
protected Integer databaseSlaveCount = 0
/**
* The version of PHP to test against.
*/
......@@ -404,4 +409,19 @@ class Task {
String getBuildDescription() {
return "${branch}: ${task} ${database} (PHP" + getPhpVersion() + ")"
}
/**
* Get the number of database slaves.
*
* @return The number of database slaves
*/
Integer getDatabaseSlaveCount() {
if (databaseSlaveCount < 0) {
return 0
}
if (databaseSlaveCount > 1) {
return 1
}
return databaseSlaveCount
}
}
......@@ -324,4 +324,61 @@ class TaskSpec extends Specification {
then:
assert output == true
}
def "databaseSlaveCount with slave not specified"() {
when:
def task = new Task()
def output = task.databaseSlaveCount
then:
assert output == 0
}
def "databaseSlaveCount with no slaves"() {
given:
def databaseSlaveCount = 0
when:
def task = new Task(databaseSlaveCount: databaseSlaveCount)
def output = task.databaseSlaveCount
then:
assert output == 0
}
def "databaseSlaveCount with slaves"() {
given:
def databaseSlaveCount = 1
when:
def task = new Task(databaseSlaveCount: databaseSlaveCount)
def output = task.databaseSlaveCount
then:
assert output == 1
}
def "databaseSlaveCount with too many slaves"() {
given:
def databaseSlaveCount = 2
when:
def task = new Task(databaseSlaveCount: databaseSlaveCount)
def output = task.databaseSlaveCount
then:
assert output == 1
}
def "databaseSlaveCount with too few slaves"() {
given:
def databaseSlaveCount = -1
when:
def task = new Task(databaseSlaveCount: databaseSlaveCount)
def output = task.databaseSlaveCount
then:
assert output == 0
}
}
......@@ -7,6 +7,7 @@ def call(org.moodle.ci.Task task) {
environment {
PHP_VERSION = "${task.phpVersion}"
DBTYPE = "${task.database}"
DBSLAVES = "${task.databaseSlaveCount}"
TESTTORUN = "${task.task}"
PATHTORUNNER = "${HOME}/scripts/runner"
PATHTOTESTRUNNER = "${HOME}/testscripts/runner"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment