
The initial work to support running job instructions pulled in from jenkins-job-builder config. Because the XML is tightly coupled with JJB it's easier to use xmltodict at this point. Ideally a new interpreter for JJB formatted files to turbo-hipster instructions could be made. At the moment we're ignoring JJB instructions from items we aren't interested in (for example, publishers and build wrappers). Some level of support should be added later for these or the job instructions should be updated to not use them. Change-Id: I0560d8e0a7e33548bacee3aa98bd45a5907bec21
67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
# Copyright 2014 Rackspace Australia
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import base
|
|
import fakes
|
|
import fixtures
|
|
import json
|
|
import logging
|
|
import os
|
|
import uuid
|
|
|
|
from turbo_hipster.lib import utils
|
|
|
|
|
|
class TestTaskRunner(base.TestWithGearman):
|
|
log = logging.getLogger("TestTaskRunner")
|
|
|
|
def setUp(self):
|
|
super(TestTaskRunner, self).setUp()
|
|
# Grab a copy of JJB's config
|
|
temp_path = self.useFixture(fixtures.TempDir()).path
|
|
cmd = 'git clone git://git.openstack.org/openstack-infra/config'
|
|
utils.execute_to_log(cmd, '/dev/null', cwd=temp_path)
|
|
self.jjb_config_dir = os.path.join(
|
|
temp_path, 'config',
|
|
'modules/openstack_project/files/jenkins_job_builder/config'
|
|
)
|
|
|
|
def test_job_can_shutdown_th(self):
|
|
self._load_config_fixture('jjb-config.yaml')
|
|
# set jjb_config to pulled in config
|
|
self.config['plugins'][0]['jjb_config'] = self.jjb_config_dir
|
|
|
|
self.start_server()
|
|
zuul = fakes.FakeZuul(self.config['zuul_server']['gearman_host'],
|
|
self.config['zuul_server']['gearman_port'])
|
|
|
|
job_uuid = str(uuid.uuid1())[:8]
|
|
data_req = {
|
|
'ZUUL_UUID': job_uuid,
|
|
'ZUUL_PROJECT': 'stackforge/turbo-hipster',
|
|
'ZUUL_PIPELINE': 'check',
|
|
'ZUUL_URL': 'git://git.openstack.org/',
|
|
'BRANCH': 'master',
|
|
'BASE_LOG_PATH': '56/123456/8',
|
|
'LOG_PATH': '56/123456/8/check/job_name/%s' % job_uuid
|
|
}
|
|
|
|
zuul.submit_job('build:gate-turbo-hipster-pep8', data_req)
|
|
zuul.wait_for_completion()
|
|
|
|
self.assertTrue(zuul.job.complete)
|
|
last_data = json.loads(zuul.job.data[-1])
|
|
self.log.debug(last_data)
|
|
self.assertEqual("SUCCESS", last_data['result'])
|