summaryrefslogtreecommitdiff
path: root/tests/disabled_jjb_runner.py
blob: bdcee2dd26a4b1cff6eded0682aa894d11f08095 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 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 _grab_jjb(self):
        # 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)
        return os.path.join(
            temp_path, 'config',
            'modules/openstack_project/files/jenkins_job_builder/config'
        )

    def test_jjb_pep8_job(self):
        self.skipTest("This is buggy atm.")
        # We can only do this if we have the slave scripts installed in
        # /usr/local/jenkins/slave_scripts/
        if not os.path.isdir('/usr/local/jenkins/slave_scripts/'):
            self.skipTest("Slave scripts aren't installed")

        jjb_config_dir = self._grab_jjb()
        self._load_config_fixture('jjb-config.yaml')
        # set jjb_config to pulled in config
        self.config['plugins'][0]['jjb_config'] = 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'])