Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrew Lyons
pipeline
Commits
5b3ce327
Commit
5b3ce327
authored
May 22, 2020
by
Andrew Nicols
Browse files
MDLSITE-6127 CI: Add support for database slaves
parent
3cc449dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/org/moodle/ci/Task.groovy
View file @
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
}
}
test/org/moodle/ci/TaskSpec.groovy
View file @
5b3ce327
...
...
@@ -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
}
}
vars/runTask.groovy
View file @
5b3ce327
...
...
@@ -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"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment