Joshua Hesketh | 96052bf | 2014-04-05 19:48:06 +1100 | [diff] [blame] | 1 | # 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 | |
| 15 | import base |
| 16 | import fakes |
| 17 | import fixtures |
| 18 | import json |
| 19 | import logging |
| 20 | import os |
| 21 | import uuid |
| 22 | |
| 23 | from turbo_hipster.lib import utils |
| 24 | |
| 25 | |
| 26 | class TestTaskRunner(base.TestWithGearman): |
| 27 | log = logging.getLogger("TestTaskRunner") |
| 28 | |
Joshua Hesketh | bd5f7cd | 2014-06-12 11:35:35 +1000 | [diff] [blame] | 29 | def _grab_jjb(self): |
Joshua Hesketh | 96052bf | 2014-04-05 19:48:06 +1100 | [diff] [blame] | 30 | # 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 Hesketh | bd5f7cd | 2014-06-12 11:35:35 +1000 | [diff] [blame] | 34 | return os.path.join( |
Joshua Hesketh | 96052bf | 2014-04-05 19:48:06 +1100 | [diff] [blame] | 35 | temp_path, 'config', |
| 36 | 'modules/openstack_project/files/jenkins_job_builder/config' |
| 37 | ) |
| 38 | |
Joshua Hesketh | bd5f7cd | 2014-06-12 11:35:35 +1000 | [diff] [blame] | 39 | def test_jjb_pep8_job(self): |
Joshua Hesketh | 2c879fe | 2014-07-10 13:47:38 +1000 | [diff] [blame] | 40 | self.skipTest("This is buggy atm.") |
Joshua Hesketh | bd5f7cd | 2014-06-12 11:35:35 +1000 | [diff] [blame] | 41 | # 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 Hesketh | 96052bf | 2014-04-05 19:48:06 +1100 | [diff] [blame] | 47 | self._load_config_fixture('jjb-config.yaml') |
| 48 | # set jjb_config to pulled in config |
Joshua Hesketh | bd5f7cd | 2014-06-12 11:35:35 +1000 | [diff] [blame] | 49 | self.config['plugins'][0]['jjb_config'] = jjb_config_dir |
Joshua Hesketh | 96052bf | 2014-04-05 19:48:06 +1100 | [diff] [blame] | 50 | |
| 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']) |