~sinzui/juju-ci-tools/cloudsigma-lib

« back to all changes in this revision

Viewing changes to test_schedule_hetero_control.py

  • Committer: seman.said at canonical
  • Date: 2015-09-03 19:04:07 UTC
  • mto: This revision was merged to the branch mainline in revision 1084.
  • Revision ID: seman.said@canonical.com-20150903190407-8s145s1wqbjueiu7
Added scheduling client-server tests for all OSes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
    build_jobs,
16
16
    calculate_jobs,
17
17
    get_args,
18
 
    get_candidate_version,
 
18
    get_candidate_info,
19
19
    get_releases,
20
20
    )
21
21
from utility import temp_dir
56
56
                'http://localhost:8080', 'jrandom', 'password1')
57
57
 
58
58
 
59
 
class TestGetCandidateVersion(TestCase):
60
 
    def test_get_candidate_version(self):
 
59
class TestGetCandidateInfo(TestCase):
 
60
    def test_get_candidate_info(self):
61
61
        with temp_dir() as dir_path:
62
62
            make_build_var_file(dir_path, version='1.24.3')
63
 
            version = get_candidate_version(dir_path)
 
63
            version, revision = get_candidate_info(dir_path)
64
64
        self.assertEqual(version, '1.24.3')
 
65
        self.assertEqual(revision, '2870')
65
66
 
66
67
 
67
68
class CalculateJobs(TestCase):
73
74
            os.makedirs(candidate_path)
74
75
            make_build_var_file(candidate_path, version='1.24.3')
75
76
            jobs = list(calculate_jobs(root))
76
 
        expected = [{'new_to_old': 'true',
77
 
                     'old_version': '1.20.11',
78
 
                     'candidate': '1.24.3',
79
 
                     'candidate_path': '1.24',
80
 
                     'client_os': 'ubuntu',
81
 
                     },
82
 
                    {'new_to_old': 'false',
83
 
                     'old_version': '1.20.11',
84
 
                     'candidate': '1.24.3',
85
 
                     'candidate_path': '1.24',
86
 
                     'client_os': 'ubuntu'}]
87
 
 
 
77
        expected = self.make_jobs('1.24.3', '1.20.11', '1.24')
88
78
        self.assertItemsEqual(jobs, expected)
89
79
 
90
80
    def test_calculate_jobs_schedule_all(self):
101
91
            os.utime(buildvars_path, (time(), a_week_ago))
102
92
            jobs = list(calculate_jobs(root, schedule_all=False))
103
93
            jobs_schedule_all = list(calculate_jobs(root, schedule_all=True))
104
 
        expected = [{'new_to_old': 'true',
105
 
                     'client_os': 'ubuntu',
106
 
                     'old_version': '1.20.11',
107
 
                     'candidate': '1.23.3',
108
 
                     'candidate_path': '1.23'},
109
 
                    {'new_to_old': 'false',
110
 
                     'client_os': 'ubuntu',
111
 
                     'old_version': '1.20.11',
112
 
                     'candidate': '1.23.3',
113
 
                     'candidate_path': '1.23'},
114
 
                    {'new_to_old': 'true',
115
 
                     'client_os': 'ubuntu',
116
 
                     'old_version': '1.20.11',
117
 
                     'candidate': '1.24.3',
118
 
                     'candidate_path': '1.24'},
119
 
                    {'new_to_old': 'false',
120
 
                     'client_os': 'ubuntu',
121
 
                     'old_version': '1.20.11',
122
 
                     'candidate': '1.24.3',
123
 
                     'candidate_path': '1.24'}]
124
 
        self.assertItemsEqual(jobs, expected[2:])
 
94
        expected = self.make_jobs('1.24.3', '1.20.11', '1.24')
 
95
        expected.extend(self.make_jobs('1.23.3', '1.20.11', '1.23'))
 
96
        self.assertItemsEqual(jobs, expected[:6])
125
97
        self.assertItemsEqual(jobs_schedule_all, expected)
126
98
 
127
99
    def test_calculate_jobs_osx(self):
128
100
        with temp_dir() as root:
129
101
            release_path = os.path.join(root, 'old-juju', '1.20.11')
130
102
            os.makedirs(release_path)
131
 
            release_path = os.path.join(root, 'old-juju', '1.20.11-osx')
132
 
            os.makedirs(release_path)
133
 
 
134
 
            candidate_path_1 = os.path.join(root, 'candidate', '1.24.4')
135
 
            os.makedirs(candidate_path_1)
136
 
            make_build_var_file(candidate_path_1, '1.24.4')
137
 
 
138
 
            candidate_path_2 = os.path.join(root, 'candidate', '1.24.4-osx')
139
 
            os.makedirs(candidate_path_2)
140
 
            make_build_var_file(candidate_path_2, '1.24.4')
 
103
            candidate_path = os.path.join(root, 'candidate', '1.24.4')
 
104
            os.makedirs(candidate_path)
 
105
            make_build_var_file(candidate_path, '1.24.4')
141
106
            jobs = list(calculate_jobs(root, schedule_all=False))
142
 
        expected = [{'candidate': '1.24.4',
143
 
                     'candidate_path': '1.24.4',
144
 
                     'client_os': 'ubuntu',
145
 
                     'new_to_old': 'true',
146
 
                     'old_version': '1.20.11'},
147
 
                    {'candidate': '1.24.4',
148
 
                     'candidate_path': '1.24.4',
149
 
                     'client_os': 'ubuntu',
150
 
                     'new_to_old': 'false',
151
 
                     'old_version': '1.20.11'},
152
 
                    {'candidate': '1.24.4',
153
 
                     'candidate_path': '1.24.4-osx',
154
 
                     'client_os': 'osx',
155
 
                     'new_to_old': 'true',
156
 
                     'old_version': '1.20.11-osx'},
157
 
                    {'candidate': '1.24.4',
158
 
                     'candidate_path': '1.24.4-osx',
159
 
                     'client_os': 'osx',
160
 
                     'new_to_old': 'false',
161
 
                     'old_version': '1.20.11-osx'}]
 
107
        expected = self.make_jobs('1.24.4', '1.20.11')
162
108
        self.assertItemsEqual(jobs, expected)
163
109
 
 
110
    def make_jobs(self, candidate, old_version, candidate_path=False):
 
111
        jobs = []
 
112
        for client_os in ('ubuntu', 'osx', 'windows'):
 
113
            for new_to_old in ('false', 'true'):
 
114
                jobs.append({
 
115
                    'candidate': candidate,
 
116
                    'candidate_path': candidate_path or candidate,
 
117
                    'client_os': client_os,
 
118
                    'new_to_old': new_to_old,
 
119
                    'old_version': old_version,
 
120
                    'revision_build': '2870'})
 
121
        return jobs
 
122
 
164
123
 
165
124
def make_build_var_file(dir_path, version):
166
125
    build_vars = {"version": version, "revision_build": "2870"}