blob: bdcee2dd26a4b1cff6eded0682aa894d11f08095 [file] [log] [blame]
Joshua Hesketh96052bf2014-04-05 19:48:06 +11001# Copyright 2014 Rackspace Australia
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import base
16import fakes
17import fixtures
18import json
19import logging
20import os
21import uuid
22
23from turbo_hipster.lib import utils
24
25
26class TestTaskRunner(base.TestWithGearman):
27 log = logging.getLogger("TestTaskRunner")
28
Joshua Heskethbd5f7cd2014-06-12 11:35:35 +100029 def _grab_jjb(self):
Joshua Hesketh96052bf2014-04-05 19:48:06 +110030 # Grab a copy of JJB's config
31 temp_path = self.useFixture(fixtures.TempDir()).path
32 cmd = 'git clone git://git.openstack.org/openstack-infra/config'
33 utils.execute_to_log(cmd, '/dev/null', cwd=temp_path)
Joshua Heskethbd5f7cd2014-06-12 11:35:35 +100034 return os.path.join(
Joshua Hesketh96052bf2014-04-05 19:48:06 +110035 temp_path, 'config',
36 'modules/openstack_project/files/jenkins_job_builder/config'
37 )
38
Joshua Heskethbd5f7cd2014-06-12 11:35:35 +100039 def test_jjb_pep8_job(self):
Joshua Hesketh2c879fe2014-07-10 13:47:38 +100040 self.skipTest("This is buggy atm.")
Joshua Heskethbd5f7cd2014-06-12 11:35:35 +100041 # We can only do this if we have the slave scripts installed in
42 # /usr/local/jenkins/slave_scripts/
43 if not os.path.isdir('/usr/local/jenkins/slave_scripts/'):
44 self.skipTest("Slave scripts aren't installed")
45
46 jjb_config_dir = self._grab_jjb()
Joshua Hesketh96052bf2014-04-05 19:48:06 +110047 self._load_config_fixture('jjb-config.yaml')
48 # set jjb_config to pulled in config
Joshua Heskethbd5f7cd2014-06-12 11:35:35 +100049 self.config['plugins'][0]['jjb_config'] = jjb_config_dir
Joshua Hesketh96052bf2014-04-05 19:48:06 +110050
51 self.start_server()
52 zuul = fakes.FakeZuul(self.config['zuul_server']['gearman_host'],
53 self.config['zuul_server']['gearman_port'])
54
55 job_uuid = str(uuid.uuid1())[:8]
56 data_req = {
57 'ZUUL_UUID': job_uuid,
58 'ZUUL_PROJECT': 'stackforge/turbo-hipster',
59 'ZUUL_PIPELINE': 'check',
60 'ZUUL_URL': 'git://git.openstack.org/',
61 'BRANCH': 'master',
62 'BASE_LOG_PATH': '56/123456/8',
63 'LOG_PATH': '56/123456/8/check/job_name/%s' % job_uuid
64 }
65
66 zuul.submit_job('build:gate-turbo-hipster-pep8', data_req)
67 zuul.wait_for_completion()
68
69 self.assertTrue(zuul.job.complete)
70 last_data = json.loads(zuul.job.data[-1])
71 self.log.debug(last_data)
72 self.assertEqual("SUCCESS", last_data['result'])