Test creation of multiple jobs from templates

Concatenate each job XML created from the parsed yaml when using the
YamlParser class for testing. Ensures that multiple jobs created from a
single yaml file can be tested.

Remove erroneous multiple job from scm_remote_deep_bug test.

Change-Id: I2732a7303fefff1f321a1a5b7eef9144d168e39a
This commit is contained in:
Darragh Bailey 2014-05-03 14:35:55 +01:00
parent 8cbc93a026
commit 07c5bd1cc3
5 changed files with 78 additions and 28 deletions

View File

@ -152,29 +152,7 @@ with those values. The example above would create the job called
The ``jobs:`` list can also allow for specifying job-specific
substitutions as follows::
- job-template:
name: '{name}-unit-tests'
builders:
- shell: unittest
publishers:
- email:
recipients: '{mail-to}'
- job-template:
name: '{name}-perf-tests'
builders:
- shell: perftest
publishers:
- email:
recipients: '{mail-to}'
- project:
name: project-name
jobs:
- '{name}-unit-tests':
mail-to: developer@nowhere.net
- '{name}-perf-tests':
mail-to: projmanager@nowhere.net
.. literalinclude:: /../../tests/yamlparser/fixtures/templates001.yaml
If a variable is a list, the job template will be realized with the
variable set to each value in the list. Multiple lists will lead to

View File

@ -4,10 +4,6 @@
- git:
url: 'http://example.org/'
- job:
name: 'scm_remote_deep_bug_job'
defaults: 'scm_remote_deep_bug_defs'
- job-template:
name: 'scm_remote_deep_bug_tpl'
defaults: 'scm_remote_deep_bug_defs'

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<builders>
<hudson.tasks.Shell>
<command>perftest</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.tasks.Mailer>
<recipients>projmanager@nowhere.net</recipients>
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
<sendToIndividuals>false</sendToIndividuals>
</hudson.tasks.Mailer>
</publishers>
<buildWrappers/>
</project>
<?xml version="1.0" encoding="utf-8"?>
<project>
<actions/>
<description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<builders>
<hudson.tasks.Shell>
<command>unittest</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.tasks.Mailer>
<recipients>developer@nowhere.net</recipients>
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
<sendToIndividuals>false</sendToIndividuals>
</hudson.tasks.Mailer>
</publishers>
<buildWrappers/>
</project>

View File

@ -0,0 +1,23 @@
- job-template:
name: '{name}-unit-tests'
builders:
- shell: unittest
publishers:
- email:
recipients: '{mail-to}'
- job-template:
name: '{name}-perf-tests'
builders:
- shell: perftest
publishers:
- email:
recipients: '{mail-to}'
- project:
name: project-name
jobs:
- '{name}-unit-tests':
mail-to: developer@nowhere.net
- '{name}-perf-tests':
mail-to: projmanager@nowhere.net

View File

@ -15,6 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import operator
import os
from ConfigParser import ConfigParser
from testtools import TestCase
@ -51,8 +52,10 @@ class TestCaseModuleYamlInclude(TestWithScenarios, TestCase, BaseTestCase):
# Generate the XML tree
parser.generateXML()
parser.jobs.sort(key=operator.attrgetter('name'))
# Prettify generated XML
pretty_xml = parser.jobs[0].output()
pretty_xml = "\n".join(job.output() for job in parser.jobs)
self.assertThat(
pretty_xml,