~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to tests/test_schedule_reliability_tests.py

  • Committer: Curtis Hovey
  • Date: 2016-09-20 01:59:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1602.
  • Revision ID: curtis@canonical.com-20160920015947-ko27xkj3a4i774h6
Convert juju instance=ids to true azuzre ids.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    )
21
21
from test_utility import (
22
22
    make_candidate_dir,
23
 
    write_config,
24
23
    )
25
24
from tests import parse_error
26
25
from utility import temp_dir
76
75
    def test_build_job(self):
77
76
        jenkins_cxt = patch('schedule_reliability_tests.Jenkins')
78
77
        with jenkins_cxt as jenkins_mock, temp_dir() as root:
79
 
            write_config(root, 'foo', 'quxxx')
80
78
            build_job(Credentials('jrandom', 'password1'), root, 'foo',
81
79
                      [('bar', 1), ('baz', 2)], ['qux'])
82
80
        jenkins_mock.assert_called_once_with(
83
 
            'http://localhost:8080', 'jrandom', 'password1')
 
81
            'http://juju-ci.vapour.ws:8080', 'jrandom', 'password1')
84
82
        calls = jenkins_mock.return_value.build_job.mock_calls
85
83
        expected = [
86
84
            call('foo', {
87
85
                'suite': 'qux',
88
86
                'attempts': '10',
89
 
                'new_juju_dir': 'bar',
90
87
                'revision_build': '1',
91
 
                }, token='quxxx'),
 
88
                }),
92
89
            call('foo', {
93
90
                'suite': 'qux',
94
91
                'attempts': '10',
95
 
                'new_juju_dir': 'baz',
96
92
                'revision_build': '2'
97
 
                }, token='quxxx'),
 
93
                }),
98
94
            ]
99
95
        self.assertEqual(calls, expected)
100
96
 
101
97
    def test_build_job_multi_suite(self):
102
98
        jenkins_cxt = patch('schedule_reliability_tests.Jenkins')
103
99
        with jenkins_cxt as jenkins_mock, temp_dir() as root:
104
 
            write_config(root, 'foo', 'bar')
105
100
            build_job(Credentials('jrandom', 'password1'), root, 'foo',
106
101
                      [('baz', 1)], ['qux', 'quxx'])
107
102
        jenkins_mock.return_value.build_job.assert_called_once_with(
108
103
            'foo', {
109
104
                'suite': 'qux,quxx',
110
105
                'attempts': '10',
111
 
                'new_juju_dir': 'baz',
112
106
                'revision_build': '1',
113
 
                }, token='bar')
 
107
                })
114
108
 
115
109
 
116
110
class TestMain(TestCase):
118
112
    @contextmanager
119
113
    def build_job_context(self):
120
114
        with temp_dir() as root:
121
 
            write_config(root, 'foo', 'quxxx')
122
115
            yield root
123
116
 
124
117
    def run_main(self, root):
128
121
 
129
122
    def test_selects_newest_candidate(self):
130
123
        with self.build_job_context() as root:
131
 
            path_1234 = make_candidate_dir(
132
 
                root, '1234', 'mybranch', '1234')
 
124
            make_candidate_dir(root, '1234-artifacts', 'mybranch', '1234')
133
125
            make_candidate_dir(root, '1233', 'mybranch', '1233')
134
126
            build_job_mock = self.run_main(root)
135
127
        build_job_mock.assert_called_once_with('foo', {
136
 
            'new_juju_dir': path_1234,
137
128
            'attempts': '10',
138
129
            'suite': 'full',
139
130
            'revision_build': '1234',
140
 
            }, token='quxxx')
 
131
            })
141
132
 
142
133
    def test_limit_3(self):
143
134
        # Even though it's only testing the latest, it should only test 3,
144
135
        # even if there are more than 3 latest.
145
136
        with self.build_job_context() as root:
146
137
            make_candidate_dir(
147
 
                root, 'branch1', 'mybranch1')
148
 
            make_candidate_dir(
149
 
                root, 'branch2', 'mybranch2')
150
 
            make_candidate_dir(
151
 
                root, 'branch3', 'mybranch3')
152
 
            make_candidate_dir(
153
 
                root, 'branch4', 'mybranch4')
 
138
                root, 'branch1-artifacts', 'mybranch1')
 
139
            make_candidate_dir(
 
140
                root, 'branch2-artifacts', 'mybranch2')
 
141
            make_candidate_dir(
 
142
                root, 'branch3-artifacts', 'mybranch3')
 
143
            make_candidate_dir(
 
144
                root, 'branch4-artifacts', 'mybranch4')
154
145
            build_job_mock = self.run_main(root)
155
146
        self.assertEqual(build_job_mock.call_count, 3)