mbligh | 0a66913 | 2008-10-10 20:02:32 +0000 | [diff] [blame] | 1 | #!/usr/bin/python -u |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2008 Google Inc. All Rights Reserved. |
| 4 | |
mbligh | fb8f0ab | 2008-11-13 01:11:48 +0000 | [diff] [blame] | 5 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 6 | """Tests for job.""" |
| 7 | |
| 8 | import copy, getpass, unittest, sys, os |
| 9 | |
| 10 | import common |
| 11 | from autotest_lib.cli import cli_mock, topic_common, job |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 12 | from autotest_lib.client.common_lib.test_utils import mock |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 13 | |
| 14 | |
| 15 | class job_unittest(cli_mock.cli_unittest): |
| 16 | def setUp(self): |
| 17 | super(job_unittest, self).setUp() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 18 | self.values = copy.deepcopy(self.values_template) |
| 19 | |
| 20 | results = [{u'status_counts': {u'Aborted': 1}, |
| 21 | u'control_file': |
| 22 | u"job.run_test('sleeptest')\n", |
| 23 | u'name': u'test_job0', |
| 24 | u'control_type': u'Server', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 25 | u'priority': |
| 26 | u'Medium', |
| 27 | u'owner': u'user0', |
| 28 | u'created_on': |
| 29 | u'2008-07-08 17:45:44', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 30 | u'synch_count': 2, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 31 | u'id': 180}, |
| 32 | {u'status_counts': {u'Queued': 1}, |
| 33 | u'control_file': |
| 34 | u"job.run_test('sleeptest')\n", |
| 35 | u'name': u'test_job1', |
| 36 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 37 | u'priority': |
| 38 | u'High', |
| 39 | u'owner': u'user0', |
| 40 | u'created_on': |
| 41 | u'2008-07-08 12:17:47', |
| 42 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 43 | u'id': 338}] |
| 44 | |
| 45 | |
| 46 | values_template = [{u'id': 180, # Valid job |
| 47 | u'priority': u'Low', |
| 48 | u'name': u'test_job0', |
| 49 | u'owner': u'Cringer', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 50 | u'invalid': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 51 | u'created_on': u'2008-07-02 13:02:40', |
| 52 | u'control_type': u'Server', |
| 53 | u'status_counts': {u'Queued': 1}, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 54 | u'synch_count': 2}, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 55 | {u'id': 338, # Valid job |
| 56 | u'priority': 'High', |
| 57 | u'name': u'test_job1', |
| 58 | u'owner': u'Fisto', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 59 | u'invalid': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 60 | u'created_on': u'2008-07-06 14:05:33', |
| 61 | u'control_type': u'Client', |
| 62 | u'status_counts': {u'Queued': 1}, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 63 | u'synch_count': 1}, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 64 | {u'id': 339, # Valid job |
| 65 | u'priority': 'Medium', |
| 66 | u'name': u'test_job2', |
| 67 | u'owner': u'Roboto', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 68 | u'invalid': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 69 | u'created_on': u'2008-07-07 15:33:18', |
| 70 | u'control_type': u'Server', |
| 71 | u'status_counts': {u'Queued': 1}, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 72 | u'synch_count': 1}, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 73 | {u'id': 340, # Invalid job priority |
| 74 | u'priority': u'Uber', |
| 75 | u'name': u'test_job3', |
| 76 | u'owner': u'Panthor', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 77 | u'invalid': True, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 78 | u'created_on': u'2008-07-04 00:00:01', |
| 79 | u'control_type': u'Server', |
| 80 | u'status_counts': {u'Queued': 1}, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 81 | u'synch_count': 2}, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 82 | {u'id': 350, # Invalid job created_on |
| 83 | u'priority': 'Medium', |
| 84 | u'name': u'test_job4', |
| 85 | u'owner': u'Icer', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 86 | u'invalid': True, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 87 | u'created_on': u'Today', |
| 88 | u'control_type': u'Client', |
| 89 | u'status_counts': {u'Queued': 1}, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 90 | u'synch_count': 1}, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 91 | {u'id': 420, # Invalid job control_type |
| 92 | u'priority': 'Urgent', |
| 93 | u'name': u'test_job5', |
| 94 | u'owner': u'Spikor', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 95 | u'invalid': True, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 96 | u'created_on': u'2012-08-08 18:54:37', |
| 97 | u'control_type': u'Child', |
| 98 | u'status_counts': {u'Queued': 1}, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 99 | u'synch_count': 2}] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 100 | |
| 101 | |
| 102 | class job_list_unittest(job_unittest): |
| 103 | def test_job_list_jobs(self): |
showard | f4a6899 | 2010-02-03 20:29:59 +0000 | [diff] [blame] | 104 | self.god.stub_function(getpass, 'getuser') |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 105 | getpass.getuser.expect_call().and_return('user0') |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 106 | self.run_cmd(argv=['atest', 'job', 'list', '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 107 | rpcs=[('get_jobs_summary', {'owner': 'user0', |
| 108 | 'running': None}, |
| 109 | True, self.values)], |
| 110 | out_words_ok=['test_job0', 'test_job1', 'test_job2'], |
| 111 | out_words_no=['Uber', 'Today', 'Child']) |
| 112 | |
| 113 | |
| 114 | def test_job_list_jobs_only_user(self): |
| 115 | values = [item for item in self.values if item['owner'] == 'Cringer'] |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 116 | self.run_cmd(argv=['atest', 'job', 'list', '-u', 'Cringer', |
| 117 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 118 | rpcs=[('get_jobs_summary', {'owner': 'Cringer', |
| 119 | 'running': None}, |
| 120 | True, values)], |
| 121 | out_words_ok=['Cringer'], |
| 122 | out_words_no=['Fisto', 'Roboto', 'Panthor', 'Icer', |
| 123 | 'Spikor']) |
| 124 | |
| 125 | |
| 126 | def test_job_list_jobs_all(self): |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 127 | self.run_cmd(argv=['atest', 'job', 'list', '--all', |
| 128 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 129 | rpcs=[('get_jobs_summary', {'running': None}, |
| 130 | True, self.values)], |
| 131 | out_words_ok=['Fisto', 'Roboto', 'Panthor', |
| 132 | 'Icer', 'Spikor', 'Cringer'], |
| 133 | out_words_no=['Created', 'Priority']) |
| 134 | |
| 135 | |
| 136 | def test_job_list_jobs_id(self): |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 137 | self.run_cmd(argv=['atest', 'job', 'list', '5964', |
| 138 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 139 | rpcs=[('get_jobs_summary', {'id__in': ['5964'], |
| 140 | 'running': None}, |
| 141 | True, |
| 142 | [{u'status_counts': {u'Completed': 1}, |
| 143 | u'control_file': u'kernel = \'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\'\ndef step_init():\n job.next_step([step_test])\n testkernel = job.kernel(\'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\')\n \n testkernel.install()\n testkernel.boot(args=\'console_always_print=1\')\n\ndef step_test():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "Autotest Team"\n NAME = "Sleeptest"\n TIME = "SHORT"\n TEST_CATEGORY = "Functional"\n TEST_CLASS = "General"\n TEST_TYPE = "client"\n \n DOC = """\n This test simply sleeps for 1 second by default. It\'s a good way to test\n profilers and double check that autotest is working.\n The seconds argument can also be modified to make the machine sleep for as\n long as needed.\n """\n \n job.run_test(\'sleeptest\', seconds = 1)', |
| 144 | u'name': u'mytest', |
| 145 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 146 | u'run_verify': 1, |
| 147 | u'priority': u'Medium', |
| 148 | u'owner': u'user0', |
| 149 | u'created_on': u'2008-07-28 12:42:52', |
| 150 | u'timeout': 144, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 151 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 152 | u'id': 5964}])], |
| 153 | out_words_ok=['user0', 'Completed', '1', '5964'], |
| 154 | out_words_no=['sleeptest', 'Priority', 'Client', '2008']) |
| 155 | |
| 156 | |
| 157 | def test_job_list_jobs_id_verbose(self): |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 158 | self.run_cmd(argv=['atest', 'job', 'list', '5964', '-v', |
| 159 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 160 | rpcs=[('get_jobs_summary', {'id__in': ['5964'], |
| 161 | 'running': None}, |
| 162 | True, |
| 163 | [{u'status_counts': {u'Completed': 1}, |
| 164 | u'control_file': u'kernel = \'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\'\ndef step_init():\n job.next_step([step_test])\n testkernel = job.kernel(\'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\')\n \n testkernel.install()\n testkernel.boot(args=\'console_always_print=1\')\n\ndef step_test():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "Autotest Team"\n NAME = "Sleeptest"\n TIME = "SHORT"\n TEST_CATEGORY = "Functional"\n TEST_CLASS = "General"\n TEST_TYPE = "client"\n \n DOC = """\n This test simply sleeps for 1 second by default. It\'s a good way to test\n profilers and double check that autotest is working.\n The seconds argument can also be modified to make the machine sleep for as\n long as needed.\n """\n \n job.run_test(\'sleeptest\', seconds = 1)', |
| 165 | u'name': u'mytest', |
| 166 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 167 | u'run_verify': 1, |
| 168 | u'priority': u'Medium', |
| 169 | u'owner': u'user0', |
| 170 | u'created_on': u'2008-07-28 12:42:52', |
| 171 | u'timeout': 144, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 172 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 173 | u'id': 5964}])], |
| 174 | out_words_ok=['user0', 'Completed', '1', '5964', |
| 175 | 'Client', '2008', 'Priority'], |
| 176 | out_words_no=['sleeptest']) |
| 177 | |
| 178 | |
| 179 | def test_job_list_jobs_name(self): |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 180 | self.run_cmd(argv=['atest', 'job', 'list', 'myt*', |
| 181 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 182 | rpcs=[('get_jobs_summary', {'name__startswith': 'myt', |
| 183 | 'running': None}, |
| 184 | True, |
| 185 | [{u'status_counts': {u'Completed': 1}, |
| 186 | u'control_file': u'kernel = \'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\'\ndef step_init():\n job.next_step([step_test])\n testkernel = job.kernel(\'8210088647656509311.kernel-smp-2.6.18-220.5.x86_64.rpm\')\n \n testkernel.install()\n testkernel.boot(args=\'console_always_print=1\')\n\ndef step_test():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "Autotest Team"\n NAME = "Sleeptest"\n TIME = "SHORT"\n TEST_CATEGORY = "Functional"\n TEST_CLASS = "General"\n TEST_TYPE = "client"\n \n DOC = """\n This test simply sleeps for 1 second by default. It\'s a good way to test\n profilers and double check that autotest is working.\n The seconds argument can also be modified to make the machine sleep for as\n long as needed.\n """\n \n job.run_test(\'sleeptest\', seconds = 1)', |
| 187 | u'name': u'mytest', |
| 188 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 189 | u'run_verify': 1, |
| 190 | u'priority': u'Medium', |
| 191 | u'owner': u'user0', |
| 192 | u'created_on': u'2008-07-28 12:42:52', |
| 193 | u'timeout': 144, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 194 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 195 | u'id': 5964}])], |
| 196 | out_words_ok=['user0', 'Completed', '1', '5964'], |
| 197 | out_words_no=['sleeptest', 'Priority', 'Client', '2008']) |
| 198 | |
| 199 | |
| 200 | def test_job_list_jobs_all_verbose(self): |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 201 | self.run_cmd(argv=['atest', 'job', 'list', '--all', '--verbose', |
| 202 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 203 | rpcs=[('get_jobs_summary', {'running': None}, |
| 204 | True, self.values)], |
| 205 | out_words_ok=['Fisto', 'Spikor', 'Cringer', 'Priority', |
| 206 | 'Created']) |
| 207 | |
| 208 | |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 209 | class job_list_jobs_all_and_user_unittest(cli_mock.cli_unittest): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 210 | def test_job_list_jobs_all_and_user(self): |
| 211 | testjob = job.job_list() |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 212 | sys.argv = ['atest', 'job', 'list', '-a', '-u', 'user0', |
| 213 | '--ignore_site_file'] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 214 | self.god.mock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 215 | (sys.exit.expect_call(mock.anything_comparator()) |
| 216 | .and_raises(cli_mock.ExitException)) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 217 | self.assertRaises(cli_mock.ExitException, testjob.parse) |
| 218 | self.god.unmock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 219 | self.god.check_playback() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 220 | |
| 221 | |
| 222 | class job_stat_unittest(job_unittest): |
| 223 | def test_job_stat_job(self): |
| 224 | results = copy.deepcopy(self.results) |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 225 | self.run_cmd(argv=['atest', 'job', 'stat', '180', |
| 226 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 227 | rpcs=[('get_jobs_summary', {'id__in': ['180']}, True, |
| 228 | [results[0]]), |
| 229 | ('get_host_queue_entries', {'job__in': ['180']}, |
| 230 | True, |
| 231 | [{u'status': u'Failed', |
| 232 | u'complete': 1, |
| 233 | u'host': {u'status': u'Repair Failed', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 234 | u'locked': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 235 | u'hostname': u'host0', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 236 | u'invalid': True, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 237 | u'id': 4432, |
| 238 | u'synch_id': None}, |
| 239 | u'priority': 1, |
| 240 | u'meta_host': None, |
jadmanski | 8d631c9 | 2008-08-18 21:12:40 +0000 | [diff] [blame] | 241 | u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 242 | u'name': u'test_sleep', |
| 243 | u'control_type': u'Server', |
| 244 | u'synchronizing': 0, |
| 245 | u'priority': u'Medium', |
| 246 | u'owner': u'user0', |
| 247 | u'created_on': u'2008-03-18 11:27:29', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 248 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 249 | u'id': 180}, |
| 250 | u'active': 0, |
| 251 | u'id': 101084}])], |
| 252 | out_words_ok=['test_job0', 'host0', 'Failed', |
| 253 | 'Aborted']) |
| 254 | |
| 255 | |
mbligh | fca5ed1 | 2009-11-06 02:59:56 +0000 | [diff] [blame] | 256 | |
| 257 | def test_job_stat_list_unassigned_host(self): |
| 258 | self.run_cmd(argv=['atest', 'job', 'stat', '6761', |
| 259 | '--list-hosts', '--ignore_site_file'], |
| 260 | rpcs=[('get_jobs_summary', {'id__in': ['6761']}, True, |
| 261 | [{u'status_counts': {u'Queued': 1}, |
| 262 | u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 263 | u'name': u'test_on_meta_hosts', |
| 264 | u'control_type': u'Client', |
| 265 | u'run_verify': 1, |
| 266 | u'priority': u'Medium', |
| 267 | u'owner': u'user0', |
| 268 | u'created_on': u'2008-07-30 22:15:43', |
| 269 | u'timeout': 144, |
| 270 | u'synch_count': 1, |
| 271 | u'id': 6761}]), |
| 272 | ('get_host_queue_entries', {'job__in': ['6761']}, |
| 273 | True, |
| 274 | [{u'status': u'Queued', |
| 275 | u'complete': 0, |
| 276 | u'deleted': 0, |
| 277 | u'host': None, |
| 278 | u'priority': 1, |
| 279 | u'meta_host': u'Xeon', |
| 280 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 281 | u'name': u'test_on_meta_hosts', |
| 282 | u'control_type': u'Client', |
| 283 | u'run_verify': 1, |
| 284 | u'priority': u'Medium', |
| 285 | u'owner': u'user0', |
| 286 | u'created_on': u'2008-07-30 22:15:43', |
| 287 | u'timeout': 144, |
| 288 | u'synch_count': 1, |
| 289 | u'id': 6761}, |
| 290 | u'active': 0, |
| 291 | u'id': 193166} ])], |
| 292 | err_words_ok=['unassigned', 'meta-hosts'], |
| 293 | out_words_no=['Xeon']) |
| 294 | |
| 295 | |
| 296 | def test_job_stat_list_hosts(self): |
| 297 | self.run_cmd(argv=['atest', 'job', 'stat', '6761', |
| 298 | '--list-hosts', '--ignore_site_file'], |
| 299 | rpcs=[('get_jobs_summary', {'id__in': ['6761']}, True, |
| 300 | [{u'status_counts': {u'Queued': 1}, |
| 301 | u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 302 | u'name': u'test_on_meta_hosts', |
| 303 | u'control_type': u'Client', |
| 304 | u'run_verify': 1, |
| 305 | u'priority': u'Medium', |
| 306 | u'owner': u'user0', |
| 307 | u'created_on': u'2008-07-30 22:15:43', |
| 308 | u'timeout': 144, |
| 309 | u'synch_count': 1, |
| 310 | u'id': 6761}]), |
| 311 | ('get_host_queue_entries', {'job__in': ['6761']}, |
| 312 | True, |
| 313 | [{u'status': u'Queued', |
| 314 | u'complete': 0, |
| 315 | u'deleted': 0, |
| 316 | u'host': {u'status': u'Running', |
| 317 | u'lock_time': None, |
| 318 | u'hostname': u'host41', |
| 319 | u'locked': False, |
| 320 | u'locked_by': None, |
| 321 | u'invalid': False, |
| 322 | u'id': 4833, |
| 323 | u'protection': u'Repair filesystem only', |
| 324 | u'synch_id': None}, |
| 325 | u'priority': 1, |
| 326 | u'meta_host': u'Xeon', |
| 327 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 328 | u'name': u'test_on_meta_hosts', |
| 329 | u'control_type': u'Client', |
| 330 | u'run_verify': 1, |
| 331 | u'priority': u'Medium', |
| 332 | u'owner': u'user0', |
| 333 | u'created_on': u'2008-07-30 22:15:43', |
| 334 | u'timeout': 144, |
| 335 | u'synch_count': 1, |
| 336 | u'id': 6761}, |
| 337 | u'active': 0, |
| 338 | u'id': 193166}, |
| 339 | {u'status': u'Running', |
| 340 | u'complete': 0, |
| 341 | u'deleted': 0, |
| 342 | u'host': {u'status': u'Running', |
| 343 | u'lock_time': None, |
| 344 | u'hostname': u'host42', |
| 345 | u'locked': False, |
| 346 | u'locked_by': None, |
| 347 | u'invalid': False, |
| 348 | u'id': 4833, |
| 349 | u'protection': u'Repair filesystem only', |
| 350 | u'synch_id': None}, |
| 351 | u'priority': 1, |
| 352 | u'meta_host': u'Xeon', |
| 353 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 354 | u'name': u'test_on_meta_hosts', |
| 355 | u'control_type': u'Client', |
| 356 | u'run_verify': 1, |
| 357 | u'priority': u'Medium', |
| 358 | u'owner': u'user0', |
| 359 | u'created_on': u'2008-07-30 22:15:43', |
| 360 | u'timeout': 144, |
| 361 | u'synch_count': 1, |
| 362 | u'id': 6761}, |
| 363 | u'active': 0, |
| 364 | u'id': 193166} ])], |
| 365 | out_words_ok=['host41', 'host42'], |
| 366 | out_words_no=['Xeon', 'Running', 'Queued'], |
| 367 | err_words_no=['unassigned']) |
| 368 | |
| 369 | |
| 370 | def test_job_stat_list_hosts_status(self): |
| 371 | self.run_cmd(argv=['atest', 'job', 'stat', '6761', |
| 372 | '--list-hosts-status', 'Running,Queued', |
| 373 | '--ignore_site_file'], |
| 374 | rpcs=[('get_jobs_summary', {'id__in': ['6761']}, True, |
| 375 | [{u'status_counts': {u'Queued': 1, u'Running': 1}, |
| 376 | u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 377 | u'name': u'test', |
| 378 | u'control_type': u'Client', |
| 379 | u'run_verify': 1, |
| 380 | u'priority': u'Medium', |
| 381 | u'owner': u'user0', |
| 382 | u'created_on': u'2008-07-30 22:15:43', |
| 383 | u'timeout': 144, |
| 384 | u'synch_count': 1, |
| 385 | u'id': 6761}]), |
| 386 | ('get_host_queue_entries', {'job__in': ['6761']}, |
| 387 | True, |
| 388 | [{u'status': u'Queued', |
| 389 | u'complete': 0, |
| 390 | u'deleted': 0, |
| 391 | u'host': {u'status': u'Queued', |
| 392 | u'lock_time': None, |
| 393 | u'hostname': u'host41', |
| 394 | u'locked': False, |
| 395 | u'locked_by': None, |
| 396 | u'invalid': False, |
| 397 | u'id': 4833, |
| 398 | u'protection': u'Repair filesystem only', |
| 399 | u'synch_id': None}, |
| 400 | u'priority': 1, |
| 401 | u'meta_host': None, |
| 402 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 403 | u'name': u'test', |
| 404 | u'control_type': u'Client', |
| 405 | u'run_verify': 1, |
| 406 | u'priority': u'Medium', |
| 407 | u'owner': u'user0', |
| 408 | u'created_on': u'2008-07-30 22:15:43', |
| 409 | u'timeout': 144, |
| 410 | u'synch_count': 1, |
| 411 | u'id': 6761}, |
| 412 | u'active': 0, |
| 413 | u'id': 193166}, |
| 414 | {u'status': u'Running', |
| 415 | u'complete': 0, |
| 416 | u'deleted': 0, |
| 417 | u'host': {u'status': u'Running', |
| 418 | u'lock_time': None, |
| 419 | u'hostname': u'host42', |
| 420 | u'locked': False, |
| 421 | u'locked_by': None, |
| 422 | u'invalid': False, |
| 423 | u'id': 4833, |
| 424 | u'protection': u'Repair filesystem only', |
| 425 | u'synch_id': None}, |
| 426 | u'priority': 1, |
| 427 | u'meta_host': None, |
| 428 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 429 | u'name': u'test', |
| 430 | u'control_type': u'Client', |
| 431 | u'run_verify': 1, |
| 432 | u'priority': u'Medium', |
| 433 | u'owner': u'user0', |
| 434 | u'created_on': u'2008-07-30 22:15:43', |
| 435 | u'timeout': 144, |
| 436 | u'synch_count': 1, |
| 437 | u'id': 6761}, |
| 438 | u'active': 0, |
| 439 | u'id': 193166} ])], |
| 440 | out_words_ok=['Queued', 'Running', 'host41', 'host42'], |
| 441 | out_words_no=['Xeon'], |
| 442 | err_words_no=['unassigned']) |
| 443 | |
| 444 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 445 | def test_job_stat_job_multiple_hosts(self): |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 446 | self.run_cmd(argv=['atest', 'job', 'stat', '6761', |
| 447 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 448 | rpcs=[('get_jobs_summary', {'id__in': ['6761']}, True, |
| 449 | [{u'status_counts': {u'Running': 1, |
| 450 | u'Queued': 4}, |
| 451 | u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 452 | u'name': u'test_on_meta_hosts', |
| 453 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 454 | u'run_verify': 1, |
| 455 | u'priority': u'Medium', |
| 456 | u'owner': u'user0', |
| 457 | u'created_on': u'2008-07-30 22:15:43', |
| 458 | u'timeout': 144, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 459 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 460 | u'id': 6761}]), |
| 461 | ('get_host_queue_entries', {'job__in': ['6761']}, |
| 462 | True, |
| 463 | [{u'status': u'Queued', |
| 464 | u'complete': 0, |
| 465 | u'deleted': 0, |
| 466 | u'host': None, |
| 467 | u'priority': 1, |
| 468 | u'meta_host': u'Xeon', |
| 469 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 470 | u'name': u'test_on_meta_hosts', |
| 471 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 472 | u'run_verify': 1, |
| 473 | u'priority': u'Medium', |
| 474 | u'owner': u'user0', |
| 475 | u'created_on': u'2008-07-30 22:15:43', |
| 476 | u'timeout': 144, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 477 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 478 | u'id': 6761}, |
| 479 | u'active': 0, |
| 480 | u'id': 193166}, |
| 481 | {u'status': u'Queued', |
| 482 | u'complete': 0, |
| 483 | u'deleted': 0, |
| 484 | u'host': None, |
| 485 | u'priority': 1, |
| 486 | u'meta_host': u'Xeon', |
| 487 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 488 | u'name': u'test_on_meta_hosts', |
| 489 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 490 | u'run_verify': 1, |
| 491 | u'priority': u'Medium', |
| 492 | u'owner': u'user0', |
| 493 | u'created_on': u'2008-07-30 22:15:43', |
| 494 | u'timeout': 144, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 495 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 496 | u'id': 6761}, |
| 497 | u'active': 0, |
| 498 | u'id': 193167}, |
| 499 | {u'status': u'Queued', |
| 500 | u'complete': 0, |
| 501 | u'deleted': 0, |
| 502 | u'host': None, |
| 503 | u'priority': 1, |
| 504 | u'meta_host': u'Athlon', |
| 505 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 506 | u'name': u'test_on_meta_hosts', |
| 507 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 508 | u'run_verify': 1, |
| 509 | u'priority': u'Medium', |
| 510 | u'owner': u'user0', |
| 511 | u'created_on': u'2008-07-30 22:15:43', |
| 512 | u'timeout': 144, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 513 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 514 | u'id': 6761}, |
| 515 | u'active': 0, |
| 516 | u'id': 193168}, |
| 517 | {u'status': u'Queued', |
| 518 | u'complete': 0, |
| 519 | u'deleted': 0, |
| 520 | u'host': None, |
| 521 | u'priority': 1, |
| 522 | u'meta_host': u'x286', |
| 523 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 524 | u'name': u'test_on_meta_hosts', |
| 525 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 526 | u'run_verify': 1, |
| 527 | u'priority': u'Medium', |
| 528 | u'owner': u'user0', |
| 529 | u'created_on': u'2008-07-30 22:15:43', |
| 530 | u'timeout': 144, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 531 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 532 | u'id': 6761}, |
| 533 | u'active': 0, |
| 534 | u'id': 193169}, |
| 535 | {u'status': u'Running', |
| 536 | u'complete': 0, |
| 537 | u'deleted': 0, |
| 538 | u'host': {u'status': u'Running', |
| 539 | u'lock_time': None, |
| 540 | u'hostname': u'host42', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 541 | u'locked': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 542 | u'locked_by': None, |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 543 | u'invalid': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 544 | u'id': 4833, |
| 545 | u'protection': u'Repair filesystem only', |
| 546 | u'synch_id': None}, |
| 547 | u'priority': 1, |
| 548 | u'meta_host': u'Athlon', |
| 549 | u'job': {u'control_file': u'def step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "mbligh@google.com (Martin Bligh)"\n NAME = "Kernbench"\n TIME = "SHORT"\n TEST_CLASS = "Kernel"\n TEST_CATEGORY = "Benchmark"\n TEST_TYPE = "client"\n \n DOC = """\n A standard CPU benchmark. Runs a kernel compile and measures the performance.\n """\n \n job.run_test(\'kernbench\')', |
| 550 | u'name': u'test_on_meta_hosts', |
| 551 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 552 | u'run_verify': 1, |
| 553 | u'priority': u'Medium', |
| 554 | u'owner': u'user0', |
| 555 | u'created_on': u'2008-07-30 22:15:43', |
| 556 | u'timeout': 144, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 557 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 558 | u'id': 6761}, |
| 559 | u'active': 1, |
| 560 | u'id': 193170} ])], |
| 561 | out_words_ok=['test_on_meta_hosts', |
| 562 | 'host42', 'Queued', 'Running'], |
| 563 | out_words_no=['Athlon', 'Xeon', 'x286']) |
| 564 | |
| 565 | |
| 566 | def test_job_stat_job_no_host_in_qes(self): |
| 567 | results = copy.deepcopy(self.results) |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 568 | self.run_cmd(argv=['atest', 'job', 'stat', '180', |
| 569 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 570 | rpcs=[('get_jobs_summary', {'id__in': ['180']}, True, |
| 571 | [results[0]]), |
| 572 | ('get_host_queue_entries', {'job__in': ['180']}, |
| 573 | True, |
| 574 | [{u'status': u'Failed', |
| 575 | u'complete': 1, |
| 576 | u'host': None, |
| 577 | u'priority': 1, |
| 578 | u'meta_host': None, |
jadmanski | 8d631c9 | 2008-08-18 21:12:40 +0000 | [diff] [blame] | 579 | u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 580 | u'name': u'test_sleep', |
| 581 | u'control_type': u'Server', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 582 | u'priority': u'Medium', |
| 583 | u'owner': u'user0', |
| 584 | u'created_on': u'2008-03-18 11:27:29', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 585 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 586 | u'id': 180}, |
| 587 | u'active': 0, |
| 588 | u'id': 101084}])], |
mbligh | fca5ed1 | 2009-11-06 02:59:56 +0000 | [diff] [blame] | 589 | err_words_ok=['unassigned', 'meta-hosts']) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 590 | |
| 591 | |
| 592 | def test_job_stat_multi_jobs(self): |
| 593 | results = copy.deepcopy(self.results) |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 594 | self.run_cmd(argv=['atest', 'job', 'stat', '180', '338', |
| 595 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 596 | rpcs=[('get_jobs_summary', {'id__in': ['180', '338']}, |
| 597 | True, results), |
| 598 | ('get_host_queue_entries', |
| 599 | {'job__in': ['180', '338']}, |
| 600 | True, |
| 601 | [{u'status': u'Failed', |
| 602 | u'complete': 1, |
| 603 | u'host': {u'status': u'Repair Failed', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 604 | u'locked': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 605 | u'hostname': u'host0', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 606 | u'invalid': True, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 607 | u'id': 4432, |
| 608 | u'synch_id': None}, |
| 609 | u'priority': 1, |
| 610 | u'meta_host': None, |
jadmanski | 8d631c9 | 2008-08-18 21:12:40 +0000 | [diff] [blame] | 611 | u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 612 | u'name': u'test_sleep', |
| 613 | u'control_type': u'Server', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 614 | u'priority': u'Medium', |
| 615 | u'owner': u'user0', |
| 616 | u'created_on': u'2008-03-18 11:27:29', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 617 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 618 | u'id': 180}, |
| 619 | u'active': 0, |
| 620 | u'id': 101084}, |
| 621 | {u'status': u'Failed', |
| 622 | u'complete': 1, |
| 623 | u'host': {u'status': u'Repair Failed', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 624 | u'locked': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 625 | u'hostname': u'host10', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 626 | u'invalid': True, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 627 | u'id': 4432, |
| 628 | u'synch_id': None}, |
| 629 | u'priority': 1, |
| 630 | u'meta_host': None, |
jadmanski | 8d631c9 | 2008-08-18 21:12:40 +0000 | [diff] [blame] | 631 | u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 632 | u'name': u'test_sleep', |
| 633 | u'control_type': u'Server', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 634 | u'priority': u'Medium', |
| 635 | u'owner': u'user0', |
| 636 | u'created_on': u'2008-03-18 11:27:29', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 637 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 638 | u'id': 338}, |
| 639 | u'active': 0, |
| 640 | u'id': 101084}])], |
| 641 | out_words_ok=['test_job0', 'test_job1']) |
| 642 | |
| 643 | |
| 644 | def test_job_stat_multi_jobs_name_id(self): |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 645 | self.run_cmd(argv=['atest', 'job', 'stat', 'mytest', '180', |
| 646 | '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 647 | rpcs=[('get_jobs_summary', {'id__in': ['180']}, |
| 648 | True, |
| 649 | [{u'status_counts': {u'Aborted': 1}, |
| 650 | u'control_file': |
| 651 | u"job.run_test('sleeptest')\n", |
| 652 | u'name': u'job0', |
| 653 | u'control_type': u'Server', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 654 | u'priority': |
| 655 | u'Medium', |
| 656 | u'owner': u'user0', |
| 657 | u'created_on': |
| 658 | u'2008-07-08 17:45:44', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 659 | u'synch_count': 2, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 660 | u'id': 180}]), |
| 661 | ('get_jobs_summary', {'name__in': ['mytest']}, |
| 662 | True, |
| 663 | [{u'status_counts': {u'Queued': 1}, |
| 664 | u'control_file': |
| 665 | u"job.run_test('sleeptest')\n", |
| 666 | u'name': u'mytest', |
| 667 | u'control_type': u'Client', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 668 | u'priority': |
| 669 | u'High', |
| 670 | u'owner': u'user0', |
| 671 | u'created_on': u'2008-07-08 12:17:47', |
| 672 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 673 | u'id': 338}]), |
| 674 | ('get_host_queue_entries', |
| 675 | {'job__in': ['180']}, |
| 676 | True, |
| 677 | [{u'status': u'Failed', |
| 678 | u'complete': 1, |
| 679 | u'host': {u'status': u'Repair Failed', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 680 | u'locked': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 681 | u'hostname': u'host0', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 682 | u'invalid': True, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 683 | u'id': 4432, |
| 684 | u'synch_id': None}, |
| 685 | u'priority': 1, |
| 686 | u'meta_host': None, |
jadmanski | 8d631c9 | 2008-08-18 21:12:40 +0000 | [diff] [blame] | 687 | u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 688 | u'name': u'test_sleep', |
| 689 | u'control_type': u'Server', |
| 690 | u'synchronizing': 0, |
| 691 | u'priority': u'Medium', |
| 692 | u'owner': u'user0', |
| 693 | u'created_on': u'2008-03-18 11:27:29', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 694 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 695 | u'id': 180}, |
| 696 | u'active': 0, |
| 697 | u'id': 101084}]), |
| 698 | ('get_host_queue_entries', |
| 699 | {'job__name__in': ['mytest']}, |
| 700 | True, |
| 701 | [{u'status': u'Failed', |
| 702 | u'complete': 1, |
| 703 | u'host': {u'status': u'Repair Failed', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 704 | u'locked': False, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 705 | u'hostname': u'host10', |
mbligh | 0887d40 | 2009-01-30 00:50:29 +0000 | [diff] [blame] | 706 | u'invalid': True, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 707 | u'id': 4432, |
| 708 | u'synch_id': None}, |
| 709 | u'priority': 1, |
| 710 | u'meta_host': None, |
jadmanski | 8d631c9 | 2008-08-18 21:12:40 +0000 | [diff] [blame] | 711 | u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 712 | u'name': u'test_sleep', |
| 713 | u'control_type': u'Server', |
| 714 | u'synchronizing': 0, |
| 715 | u'priority': u'Medium', |
| 716 | u'owner': u'user0', |
| 717 | u'created_on': u'2008-03-18 11:27:29', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 718 | u'synch_count': 1, |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 719 | u'id': 338}, |
| 720 | u'active': 0, |
| 721 | u'id': 101084}])], |
| 722 | out_words_ok=['job0', 'mytest', 'Aborted', 'Queued', |
| 723 | 'Failed', 'Medium', 'High']) |
| 724 | |
| 725 | |
| 726 | class job_create_unittest(cli_mock.cli_unittest): |
| 727 | ctrl_file = '\ndef step_init():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "Autotest Team"\n NAME = "Sleeptest"\n TIME =\n "SHORT"\n TEST_CATEGORY = "Functional"\n TEST_CLASS = "General"\n\n TEST_TYPE = "client"\n \n DOC = """\n This test simply sleeps for 1\n second by default. It\'s a good way to test\n profilers and double check\n that autotest is working.\n The seconds argument can also be modified to\n make the machine sleep for as\n long as needed.\n """\n \n\n job.run_test(\'sleeptest\', seconds = 1)' |
| 728 | |
| 729 | kernel_ctrl_file = 'kernel = \'kernel\'\ndef step_init():\n job.next_step([step_test])\n testkernel = job.kernel(\'kernel\')\n \n testkernel.install()\n testkernel.boot(args=\'console_always_print=1\')\n\ndef step_test():\n job.next_step(\'step0\')\n\ndef step0():\n AUTHOR = "Autotest Team"\n NAME = "Sleeptest"\n TIME = "SHORT"\n TEST_CATEGORY = "Functional"\n TEST_CLASS = "General"\n TEST_TYPE = "client"\n \n DOC = """\n This test simply sleeps for 1 second by default. It\'s a good way to test\n profilers and double check that autotest is working.\n The seconds argument can also be modified to make the machine sleep for as\n long as needed.\n """\n \n job.run_test(\'sleeptest\', seconds = 1)' |
| 730 | |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 731 | trivial_ctrl_file = 'print "Hello"\n' |
| 732 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 733 | data = {'priority': 'Medium', 'control_file': ctrl_file, 'hosts': ['host0'], |
mbligh | 6fee7fd | 2008-10-10 15:44:39 +0000 | [diff] [blame] | 734 | 'name': 'test_job0', 'control_type': 'Client', 'email_list': '', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 735 | 'meta_hosts': [], 'synch_count': 1, 'dependencies': []} |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 736 | |
| 737 | |
| 738 | def test_execute_create_job(self): |
| 739 | self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 740 | 'test_job0', '-m', 'host0', '--ignore_site_file'], |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 741 | rpcs=[('generate_control_file', |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 742 | {'tests': ['sleeptest']}, |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 743 | True, |
| 744 | {'control_file' : self.ctrl_file, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 745 | 'synch_count' : 1, |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 746 | 'is_server' : False, |
| 747 | 'dependencies' : []}), |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 748 | ('create_job', self.data, True, 180)], |
| 749 | out_words_ok=['test_job0', 'Created'], |
| 750 | out_words_no=['Uploading', 'Done']) |
| 751 | |
| 752 | |
showard | 648a35c | 2009-05-01 00:08:42 +0000 | [diff] [blame] | 753 | def test_execute_create_job_with_atomic_group(self): |
| 754 | data = dict(self.data) |
| 755 | data['atomic_group_name'] = 'my-atomic-group' |
| 756 | data['control_type'] = 'Server' |
| 757 | mock_ctrl_file = 'mock control file' |
| 758 | data['control_file'] = mock_ctrl_file |
| 759 | data['synch_count'] = 2 |
| 760 | data['hosts'] = [] |
| 761 | self.run_cmd(argv=['atest', 'job', 'create', '-t', 'mocktest', |
| 762 | 'test_job0', '--ignore_site_file', |
| 763 | '-G', 'my-atomic-group'], |
| 764 | rpcs=[('generate_control_file', |
| 765 | {'tests': ['mocktest']}, |
| 766 | True, |
| 767 | {'control_file' : mock_ctrl_file, |
| 768 | 'synch_count' : 2, |
| 769 | 'is_server' : True, |
| 770 | 'dependencies' : []}), |
| 771 | ('create_job', data, True, 180)], |
| 772 | out_words_ok=['test_job0', 'Created'], |
| 773 | out_words_no=['Uploading', 'Done']) |
| 774 | |
| 775 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 776 | def test_execute_create_job_with_control(self): |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 777 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 778 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 779 | 'test_job0', '-m', 'host0', '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 780 | rpcs=[('create_job', self.data, True, 42)], |
| 781 | out_words_ok=['test_job0', 'Created'], |
| 782 | out_words_no=['Uploading', 'Done']) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 783 | file_temp.clean() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 784 | |
| 785 | |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 786 | def test_execute_create_job_with_control_and_kernel(self): |
| 787 | data = self.data.copy() |
| 788 | data['control_file'] = '# Made up control "file" for unittest.' |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 789 | file_temp = cli_mock.create_file(self.trivial_ctrl_file) |
| 790 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 791 | '-k', 'Kernel', 'test_job0', '-m', 'host0', |
| 792 | '--ignore_site_file'], |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 793 | rpcs=[('generate_control_file', |
| 794 | {'client_control_file': self.trivial_ctrl_file, |
| 795 | 'do_push_packages': True, |
mbligh | a3c58d2 | 2009-08-24 22:01:51 +0000 | [diff] [blame] | 796 | 'kernel': [{'version': 'Kernel'}]}, |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 797 | True, |
| 798 | {'control_file': data['control_file'], |
| 799 | 'synch_count': 1, |
| 800 | 'is_server': False, |
| 801 | 'dependencies': []}), |
| 802 | ('create_job', data, True, 42)], |
| 803 | out_words_ok=['test_job0', 'Created', |
| 804 | 'Uploading', 'Done']) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 805 | file_temp.clean() |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 806 | |
| 807 | |
mbligh | 0a66913 | 2008-10-10 20:02:32 +0000 | [diff] [blame] | 808 | def test_execute_create_job_with_control_and_email(self): |
| 809 | data = self.data.copy() |
| 810 | data['email_list'] = 'em' |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 811 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 812 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 813 | 'test_job0', '-m', 'host0', '-e', 'em', |
| 814 | '--ignore_site_file'], |
mbligh | 0a66913 | 2008-10-10 20:02:32 +0000 | [diff] [blame] | 815 | rpcs=[('create_job', data, True, 42)], |
| 816 | out_words_ok=['test_job0', 'Created'], |
| 817 | out_words_no=['Uploading', 'Done']) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 818 | file_temp.clean() |
mbligh | 0a66913 | 2008-10-10 20:02:32 +0000 | [diff] [blame] | 819 | |
| 820 | |
showard | b27f4ad | 2009-05-01 00:08:26 +0000 | [diff] [blame] | 821 | def test_execute_create_job_with_control_and_dependencies(self): |
mbligh | 0a66913 | 2008-10-10 20:02:32 +0000 | [diff] [blame] | 822 | data = self.data.copy() |
| 823 | data['dependencies'] = ['dep1', 'dep2'] |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 824 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 825 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
showard | b27f4ad | 2009-05-01 00:08:26 +0000 | [diff] [blame] | 826 | 'test_job0', '-m', 'host0', '-d', 'dep1, dep2 ', |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 827 | '--ignore_site_file'], |
mbligh | 0a66913 | 2008-10-10 20:02:32 +0000 | [diff] [blame] | 828 | rpcs=[('create_job', data, True, 42)], |
| 829 | out_words_ok=['test_job0', 'Created'], |
| 830 | out_words_no=['Uploading', 'Done']) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 831 | file_temp.clean() |
mbligh | 0a66913 | 2008-10-10 20:02:32 +0000 | [diff] [blame] | 832 | |
| 833 | |
showard | 7bce102 | 2008-11-14 22:51:05 +0000 | [diff] [blame] | 834 | def test_execute_create_job_with_synch_count(self): |
| 835 | data = self.data.copy() |
| 836 | data['synch_count'] = 2 |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 837 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 838 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 839 | 'test_job0', '-m', 'host0', '-y', '2', |
| 840 | '--ignore_site_file'], |
showard | 7bce102 | 2008-11-14 22:51:05 +0000 | [diff] [blame] | 841 | rpcs=[('create_job', data, True, 42)], |
| 842 | out_words_ok=['test_job0', 'Created'], |
| 843 | out_words_no=['Uploading', 'Done']) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 844 | file_temp.clean() |
showard | 7bce102 | 2008-11-14 22:51:05 +0000 | [diff] [blame] | 845 | |
| 846 | |
showard | b27f4ad | 2009-05-01 00:08:26 +0000 | [diff] [blame] | 847 | def test_execute_create_job_with_test_and_dependencies(self): |
mbligh | b9a8b16 | 2008-10-29 16:47:29 +0000 | [diff] [blame] | 848 | data = self.data.copy() |
| 849 | data['dependencies'] = ['dep1', 'dep2', 'dep3'] |
| 850 | self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', |
showard | b27f4ad | 2009-05-01 00:08:26 +0000 | [diff] [blame] | 851 | 'test_job0', '-m', 'host0', '-d', 'dep1, dep2 ', |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 852 | '--ignore_site_file'], |
mbligh | b9a8b16 | 2008-10-29 16:47:29 +0000 | [diff] [blame] | 853 | rpcs=[('generate_control_file', |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 854 | {'tests': ['sleeptest']}, |
mbligh | b9a8b16 | 2008-10-29 16:47:29 +0000 | [diff] [blame] | 855 | True, |
| 856 | {'control_file' : self.ctrl_file, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 857 | 'synch_count' : 1, |
mbligh | b9a8b16 | 2008-10-29 16:47:29 +0000 | [diff] [blame] | 858 | 'is_server' : False, |
| 859 | 'dependencies' : ['dep3']}), |
| 860 | ('create_job', data, True, 42)], |
| 861 | out_words_ok=['test_job0', 'Created'], |
| 862 | out_words_no=['Uploading', 'Done']) |
| 863 | |
| 864 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 865 | def test_execute_create_job_with_kernel(self): |
| 866 | data = self.data.copy() |
| 867 | data['control_file'] = self.kernel_ctrl_file |
| 868 | self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 869 | '-k', 'kernel', 'test_job0', '-m', 'host0', |
| 870 | '--ignore_site_file'], |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 871 | rpcs=[('generate_control_file', |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 872 | {'tests': ['sleeptest'], |
mbligh | a3c58d2 | 2009-08-24 22:01:51 +0000 | [diff] [blame] | 873 | 'kernel': [{'version': 'kernel'}], |
| 874 | 'do_push_packages': True}, |
| 875 | True, |
| 876 | {'control_file' : self.kernel_ctrl_file, |
| 877 | 'synch_count' : 1, |
| 878 | 'is_server' : False, |
| 879 | 'dependencies' : []}), |
| 880 | ('create_job', data, True, 180)], |
| 881 | out_words_ok=['test_job0', 'Created', |
| 882 | 'Uploading', 'Done']) |
| 883 | |
| 884 | |
| 885 | def test_execute_create_job_with_kernels_and_cmdline(self): |
| 886 | data = self.data.copy() |
| 887 | data['control_file'] = self.kernel_ctrl_file |
| 888 | self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', |
| 889 | '-k', 'kernel1,kernel2', '--kernel-cmdline', |
| 890 | 'arg1 arg2', 'test_job0', '-m', 'host0', |
| 891 | '--ignore_site_file'], |
| 892 | rpcs=[('generate_control_file', |
| 893 | {'tests': ['sleeptest'], |
| 894 | 'kernel': [{'version': 'kernel1', |
| 895 | 'cmdline': 'arg1 arg2'}, |
| 896 | {'version': 'kernel2', |
| 897 | 'cmdline': 'arg1 arg2'}], |
| 898 | 'do_push_packages': True}, |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 899 | True, |
| 900 | {'control_file' : self.kernel_ctrl_file, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 901 | 'synch_count' : 1, |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 902 | 'is_server' : False, |
| 903 | 'dependencies' : []}), |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 904 | ('create_job', data, True, 180)], |
| 905 | out_words_ok=['test_job0', 'Created', |
| 906 | 'Uploading', 'Done']) |
| 907 | |
| 908 | |
| 909 | def test_execute_create_job_with_kernel_spaces(self): |
| 910 | data = self.data.copy() |
| 911 | data['control_file'] = self.kernel_ctrl_file |
| 912 | data['name'] = 'test job with spaces' |
| 913 | self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', |
| 914 | '-k', 'kernel', 'test job with spaces', |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 915 | '-m', 'host0', '--ignore_site_file'], |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 916 | rpcs=[('generate_control_file', |
mbligh | 120351e | 2009-01-24 01:40:45 +0000 | [diff] [blame] | 917 | {'tests': ['sleeptest'], |
mbligh | a3c58d2 | 2009-08-24 22:01:51 +0000 | [diff] [blame] | 918 | 'kernel': [{'version': 'kernel'}], |
| 919 | 'do_push_packages': True}, |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 920 | True, |
| 921 | {'control_file' : self.kernel_ctrl_file, |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 922 | 'synch_count' : 1, |
showard | 989f25d | 2008-10-01 11:38:11 +0000 | [diff] [blame] | 923 | 'is_server' : False, |
| 924 | 'dependencies' : []}), |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 925 | ('create_job', data, True, 180)], |
mbligh | c613317 | 2009-09-18 19:34:50 +0000 | [diff] [blame] | 926 | # This is actually 7 spaces, the extra single quote that |
| 927 | # gets displayed before "test" causes the tab completion |
| 928 | # to move to the next 8 char boundary which is 7 characters |
| 929 | # away. Hence the 7 spaces in out_words_ok. |
| 930 | # The tab has been converted by print. |
| 931 | out_words_ok=['test job with spaces', 'Created', |
| 932 | 'id', '180']) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 933 | |
| 934 | |
| 935 | def test_execute_create_job_no_args(self): |
| 936 | testjob = job.job_create() |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 937 | sys.argv = ['atest', 'job', 'create', '--ignore_site_file'] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 938 | self.god.mock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 939 | (sys.exit.expect_call(mock.anything_comparator()) |
| 940 | .and_raises(cli_mock.ExitException)) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 941 | self.assertRaises(cli_mock.ExitException, testjob.parse) |
| 942 | self.god.unmock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 943 | self.god.check_playback() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 944 | |
| 945 | |
| 946 | def test_execute_create_job_no_hosts(self): |
| 947 | testjob = job.job_create() |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 948 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 949 | sys.argv = ['atest', '-f', file_temp.name, 'test_job0', |
| 950 | '--ignore_site_file'] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 951 | self.god.mock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 952 | (sys.exit.expect_call(mock.anything_comparator()) |
| 953 | .and_raises(cli_mock.ExitException)) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 954 | self.assertRaises(cli_mock.ExitException, testjob.parse) |
| 955 | self.god.unmock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 956 | self.god.check_playback() |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 957 | file_temp.clean() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 958 | |
| 959 | |
| 960 | def test_execute_create_job_cfile_and_tests(self): |
| 961 | testjob = job.job_create() |
| 962 | sys.argv = ['atest', 'job', 'create', '-t', 'sleeptest', '-f', |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 963 | 'control_file', 'test_job0', '-m', 'host0', |
| 964 | '--ignore_site_file'] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 965 | self.god.mock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 966 | (sys.exit.expect_call(mock.anything_comparator()) |
| 967 | .and_raises(cli_mock.ExitException)) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 968 | self.assertRaises(cli_mock.ExitException, testjob.parse) |
| 969 | self.god.unmock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 970 | self.god.check_playback() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 971 | |
| 972 | |
| 973 | def test_execute_create_job_cfile_and_kernel(self): |
| 974 | testjob = job.job_create() |
| 975 | sys.argv = ['atest', 'job', 'create', '-f', 'control_file', '-k', |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 976 | 'kernel', 'test_job0', '-m', 'host0', '--ignore_site_file'] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 977 | self.god.mock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 978 | (sys.exit.expect_call(mock.anything_comparator()) |
| 979 | .and_raises(cli_mock.ExitException)) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 980 | self.assertRaises(cli_mock.ExitException, testjob.parse) |
| 981 | self.god.unmock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 982 | self.god.check_playback() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 983 | |
| 984 | |
| 985 | def test_execute_create_job_bad_cfile(self): |
| 986 | testjob = job.job_create() |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 987 | sys.argv = ['atest', 'job', 'create', '-f', 'control_file', |
| 988 | 'test_job0', '-m', 'host0', '--ignore_site_file'] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 989 | self.god.mock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 990 | (sys.exit.expect_call(mock.anything_comparator()) |
| 991 | .and_raises(IOError)) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 992 | self.assertRaises(IOError, testjob.parse) |
| 993 | self.god.unmock_io() |
| 994 | |
| 995 | |
| 996 | def test_execute_create_job_bad_priority(self): |
| 997 | testjob = job.job_create() |
| 998 | sys.argv = ['atest', 'job', 'create', '-t', 'sleeptest', '-p', 'Uber', |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 999 | '-m', 'host0', 'test_job0', '--ignore_site_file'] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1000 | self.god.mock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 1001 | (sys.exit.expect_call(mock.anything_comparator()) |
| 1002 | .and_raises(cli_mock.ExitException)) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1003 | self.assertRaises(cli_mock.ExitException, testjob.parse) |
| 1004 | self.god.unmock_io() |
showard | 53cb10c | 2009-05-01 00:09:36 +0000 | [diff] [blame] | 1005 | self.god.check_playback() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1006 | |
| 1007 | |
| 1008 | def test_execute_create_job_with_mfile(self): |
| 1009 | data = self.data.copy() |
| 1010 | data['hosts'] = ['host3', 'host2', 'host1', 'host0'] |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1011 | ctemp = cli_mock.create_file(self.ctrl_file) |
| 1012 | file_temp = cli_mock.create_file('host0\nhost1\nhost2\nhost3') |
| 1013 | self.run_cmd(argv=['atest', 'job', 'create', '--mlist', file_temp.name, |
| 1014 | '-f', ctemp.name, 'test_job0', '--ignore_site_file'], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1015 | rpcs=[('create_job', data, True, 42)], |
| 1016 | out_words_ok=['test_job0', 'Created']) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1017 | ctemp.clean() |
| 1018 | file_temp.clean() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1019 | |
| 1020 | |
mbligh | 5d0b4b3 | 2008-12-22 14:43:01 +0000 | [diff] [blame] | 1021 | def test_execute_create_job_with_timeout(self): |
| 1022 | data = self.data.copy() |
| 1023 | data['timeout'] = '222' |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1024 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 1025 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 1026 | 'test_job0', '-m', 'host0', '-o', '222', |
| 1027 | '--ignore_site_file'], |
mbligh | 5d0b4b3 | 2008-12-22 14:43:01 +0000 | [diff] [blame] | 1028 | rpcs=[('create_job', data, True, 42)], |
| 1029 | out_words_ok=['test_job0', 'Created'],) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1030 | file_temp.clean() |
mbligh | 5d0b4b3 | 2008-12-22 14:43:01 +0000 | [diff] [blame] | 1031 | |
| 1032 | |
showard | 12f3e32 | 2009-05-13 21:27:42 +0000 | [diff] [blame] | 1033 | def test_execute_create_job_with_max_runtime(self): |
| 1034 | data = self.data.copy() |
| 1035 | data['max_runtime_hrs'] = '222' |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1036 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 1037 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
showard | 12f3e32 | 2009-05-13 21:27:42 +0000 | [diff] [blame] | 1038 | 'test_job0', '-m', 'host0', '--max_runtime', '222', |
| 1039 | '--ignore_site_file'], |
| 1040 | rpcs=[('create_job', data, True, 42)], |
| 1041 | out_words_ok=['test_job0', 'Created'],) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1042 | file_temp.clean() |
showard | 12f3e32 | 2009-05-13 21:27:42 +0000 | [diff] [blame] | 1043 | |
| 1044 | |
| 1045 | |
mbligh | 5d0b4b3 | 2008-12-22 14:43:01 +0000 | [diff] [blame] | 1046 | def test_execute_create_job_with_noverify(self): |
| 1047 | data = self.data.copy() |
| 1048 | data['run_verify'] = False |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1049 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 1050 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 1051 | 'test_job0', '-m', 'host0', '-n', |
| 1052 | '--ignore_site_file'], |
mbligh | 5d0b4b3 | 2008-12-22 14:43:01 +0000 | [diff] [blame] | 1053 | rpcs=[('create_job', data, True, 42)], |
| 1054 | out_words_ok=['test_job0', 'Created'],) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1055 | file_temp.clean() |
mbligh | 5d0b4b3 | 2008-12-22 14:43:01 +0000 | [diff] [blame] | 1056 | |
| 1057 | |
mbligh | ce34864 | 2009-02-12 21:50:39 +0000 | [diff] [blame] | 1058 | def test_execute_create_job_oth(self): |
| 1059 | data = self.data.copy() |
mbligh | ad57516 | 2010-03-24 22:14:18 +0000 | [diff] [blame] | 1060 | data['hosts'] = [] |
mbligh | ce34864 | 2009-02-12 21:50:39 +0000 | [diff] [blame] | 1061 | data['one_time_hosts'] = ['host0'] |
| 1062 | self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', |
| 1063 | 'test_job0', '--one-time-hosts', 'host0'], |
| 1064 | rpcs=[('generate_control_file', |
| 1065 | {'tests': ['sleeptest']}, |
| 1066 | True, |
| 1067 | {'control_file' : self.ctrl_file, |
| 1068 | 'synch_count' : 1, |
| 1069 | 'is_server' : False, |
| 1070 | 'dependencies' : []}), |
| 1071 | ('create_job', data, True, 180)], |
| 1072 | out_words_ok=['test_job0', 'Created'], |
| 1073 | out_words_no=['Uploading', 'Done']) |
| 1074 | |
| 1075 | |
| 1076 | def test_execute_create_job_multi_oth(self): |
| 1077 | data = self.data.copy() |
mbligh | ad57516 | 2010-03-24 22:14:18 +0000 | [diff] [blame] | 1078 | data['hosts'] = [] |
mbligh | ce34864 | 2009-02-12 21:50:39 +0000 | [diff] [blame] | 1079 | data['one_time_hosts'] = ['host1', 'host0'] |
| 1080 | self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', |
| 1081 | 'test_job0', '--one-time-hosts', 'host0,host1'], |
| 1082 | rpcs=[('generate_control_file', |
| 1083 | {'tests': ['sleeptest']}, |
| 1084 | True, |
| 1085 | {'control_file' : self.ctrl_file, |
| 1086 | 'synch_count' : 1, |
| 1087 | 'is_server' : False, |
| 1088 | 'dependencies' : []}), |
| 1089 | ('create_job', data, True, 180)], |
| 1090 | out_words_ok=['test_job0', 'Created'], |
| 1091 | out_words_no=['Uploading', 'Done']) |
| 1092 | |
| 1093 | |
| 1094 | def test_execute_create_job_oth_exists(self): |
| 1095 | data = self.data.copy() |
mbligh | ad57516 | 2010-03-24 22:14:18 +0000 | [diff] [blame] | 1096 | data['hosts'] = [] |
mbligh | ce34864 | 2009-02-12 21:50:39 +0000 | [diff] [blame] | 1097 | data['one_time_hosts'] = ['host0'] |
| 1098 | self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest', |
| 1099 | 'test_job0', '--one-time-hosts', 'host0'], |
| 1100 | rpcs=[('generate_control_file', |
| 1101 | {'tests': ['sleeptest']}, |
| 1102 | True, |
| 1103 | {'control_file' : self.ctrl_file, |
| 1104 | 'synch_count' : 1, |
| 1105 | 'is_server' : False, |
| 1106 | 'dependencies' : []}), |
| 1107 | ('create_job', data, False, |
| 1108 | '''ValidationError: {'hostname': 'host0 ''' |
| 1109 | '''already exists in the autotest DB. ''' |
| 1110 | '''Select it rather than entering it as ''' |
| 1111 | '''a one time host.'}''')], |
| 1112 | out_words_no=['test_job0', 'Created'], |
| 1113 | err_words_ok=['failed', 'already exists']) |
| 1114 | |
| 1115 | |
showard | b27f4ad | 2009-05-01 00:08:26 +0000 | [diff] [blame] | 1116 | def test_execute_create_job_with_control_and_labels(self): |
| 1117 | data = self.data.copy() |
| 1118 | data['hosts'] = ['host0', 'host1', 'host2'] |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1119 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 1120 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
showard | b27f4ad | 2009-05-01 00:08:26 +0000 | [diff] [blame] | 1121 | 'test_job0', '-m', 'host0', '-b', 'label1,label2', |
| 1122 | '--ignore_site_file'], |
| 1123 | rpcs=[('get_hosts', {'multiple_labels': ['label1', |
| 1124 | 'label2']}, True, |
| 1125 | [{u'status': u'Running', u'lock_time': None, |
| 1126 | u'hostname': u'host1', u'locked': False, |
| 1127 | u'locked_by': None, u'invalid': False, u'id': 42, |
| 1128 | u'labels': [u'label1'], u'platform': |
| 1129 | u'Warp18_Diskfull', u'protection': |
| 1130 | u'Repair software only', u'dirty': |
| 1131 | True, u'synch_id': None}, |
| 1132 | {u'status': u'Running', u'lock_time': None, |
| 1133 | u'hostname': u'host2', u'locked': False, |
| 1134 | u'locked_by': None, u'invalid': False, u'id': 43, |
| 1135 | u'labels': [u'label2'], u'platform': |
| 1136 | u'Warp18_Diskfull', u'protection': |
| 1137 | u'Repair software only', u'dirty': True, |
| 1138 | u'synch_id': None}]), |
| 1139 | ('create_job', data, True, 42)], |
| 1140 | out_words_ok=['test_job0', 'Created'], |
| 1141 | out_words_no=['Uploading', 'Done']) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1142 | file_temp.clean() |
showard | b27f4ad | 2009-05-01 00:08:26 +0000 | [diff] [blame] | 1143 | |
| 1144 | |
| 1145 | def test_execute_create_job_with_label_and_duplicate_hosts(self): |
| 1146 | data = self.data.copy() |
| 1147 | data['hosts'] = ['host1', 'host0'] |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1148 | file_temp = cli_mock.create_file(self.ctrl_file) |
| 1149 | self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name, |
showard | b27f4ad | 2009-05-01 00:08:26 +0000 | [diff] [blame] | 1150 | 'test_job0', '-m', 'host0,host1', '-b', 'label1', |
| 1151 | '--ignore_site_file'], |
| 1152 | rpcs=[('get_hosts', {'multiple_labels': ['label1']}, True, |
| 1153 | [{u'status': u'Running', u'lock_time': None, |
| 1154 | u'hostname': u'host1', u'locked': False, |
| 1155 | u'locked_by': None, u'invalid': False, u'id': 42, |
| 1156 | u'labels': [u'label1'], u'platform': |
| 1157 | u'Warp18_Diskfull', u'protection': |
| 1158 | u'Repair software only', u'dirty': |
| 1159 | True, u'synch_id': None}]), |
| 1160 | ('create_job', data, True, 42)], |
| 1161 | out_words_ok=['test_job0', 'Created'], |
| 1162 | out_words_no=['Uploading', 'Done']) |
mbligh | 4151539 | 2009-07-11 00:13:11 +0000 | [diff] [blame] | 1163 | file_temp.clean() |
showard | b27f4ad | 2009-05-01 00:08:26 +0000 | [diff] [blame] | 1164 | |
| 1165 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1166 | def _test_parse_hosts(self, args, exp_hosts=[], exp_meta_hosts=[]): |
mbligh | 56f1f4a | 2009-08-03 16:45:12 +0000 | [diff] [blame] | 1167 | testjob = job.job_create_or_clone() |
| 1168 | (hosts, meta_hosts) = testjob._parse_hosts(args) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1169 | self.assertEqualNoOrder(hosts, exp_hosts) |
| 1170 | self.assertEqualNoOrder(meta_hosts, exp_meta_hosts) |
| 1171 | |
| 1172 | |
| 1173 | def test_parse_hosts_regular(self): |
| 1174 | self._test_parse_hosts(['host0'], ['host0']) |
| 1175 | |
| 1176 | |
| 1177 | def test_parse_hosts_regulars(self): |
| 1178 | self._test_parse_hosts(['host0', 'host1'], ['host0', 'host1']) |
| 1179 | |
| 1180 | |
| 1181 | def test_parse_hosts_meta_one(self): |
| 1182 | self._test_parse_hosts(['*meta0'], [], ['meta0']) |
| 1183 | |
| 1184 | |
| 1185 | def test_parse_hosts_meta_five(self): |
| 1186 | self._test_parse_hosts(['5*meta0'], [], ['meta0']*5) |
| 1187 | |
| 1188 | |
| 1189 | def test_parse_hosts_metas_five(self): |
| 1190 | self._test_parse_hosts(['5*meta0', '2*meta1'], [], |
| 1191 | ['meta0']*5 + ['meta1']*2) |
| 1192 | |
| 1193 | |
| 1194 | def test_parse_hosts_mix(self): |
| 1195 | self._test_parse_hosts(['5*meta0', 'host0', '2*meta1', 'host1', |
| 1196 | '*meta2'], ['host0', 'host1'], |
| 1197 | ['meta0']*5 + ['meta1']*2 + ['meta2']) |
| 1198 | |
| 1199 | |
mbligh | 5a49608 | 2009-08-03 16:44:54 +0000 | [diff] [blame] | 1200 | class job_clone_unittest(cli_mock.cli_unittest): |
| 1201 | job_data = {'control_file': u'NAME = \'Server Sleeptest\'\nAUTHOR = \'mbligh@google.com (Martin Bligh)\'\nTIME = \'SHORT\'\nTEST_CLASS = \'Software\'\nTEST_CATEGORY = \'Functional\'\nTEST_TYPE = \'server\'\nEXPERIMENTAL = \'False\'\n\nDOC = """\nruns sleep for one second on the list of machines.\n"""\n\ndef run(machine):\n host = hosts.create_host(machine)\n job.run_test(\'sleeptest\')\n\njob.parallel_simple(run, machines)\n', |
| 1202 | 'control_type': u'Server', |
| 1203 | 'dependencies': [], |
| 1204 | 'email_list': u'', |
| 1205 | 'max_runtime_hrs': 480, |
| 1206 | 'parse_failed_repair': True, |
| 1207 | 'priority': u'Medium', |
| 1208 | 'reboot_after': u'Always', |
| 1209 | 'reboot_before': u'If dirty', |
| 1210 | 'run_verify': True, |
| 1211 | 'synch_count': 1, |
| 1212 | 'timeout': 480} |
| 1213 | |
mbligh | 56f1f4a | 2009-08-03 16:45:12 +0000 | [diff] [blame] | 1214 | local_hosts = [{u'acls': [u'acl0'], |
| 1215 | u'atomic_group': None, |
| 1216 | u'attributes': {}, |
| 1217 | u'dirty': False, |
| 1218 | u'hostname': u'host0', |
| 1219 | u'id': 8, |
| 1220 | u'invalid': False, |
| 1221 | u'labels': [u'label0', u'label1'], |
| 1222 | u'lock_time': None, |
| 1223 | u'locked': False, |
| 1224 | u'locked_by': None, |
| 1225 | u'other_labels': u'label0, label1', |
| 1226 | u'platform': u'plat0', |
| 1227 | u'protection': u'Repair software only', |
| 1228 | u'status': u'Ready', |
| 1229 | u'synch_id': None}, |
| 1230 | {u'acls': [u'acl0'], |
| 1231 | u'atomic_group': None, |
| 1232 | u'attributes': {}, |
| 1233 | u'dirty': False, |
| 1234 | u'hostname': u'host1', |
| 1235 | u'id': 9, |
| 1236 | u'invalid': False, |
| 1237 | u'labels': [u'label0', u'label1'], |
| 1238 | u'lock_time': None, |
| 1239 | u'locked': False, |
| 1240 | u'locked_by': None, |
| 1241 | u'other_labels': u'label0, label1', |
| 1242 | u'platform': u'plat0', |
| 1243 | u'protection': u'Repair software only', |
| 1244 | u'status': u'Ready', |
| 1245 | u'synch_id': None}] |
| 1246 | |
| 1247 | |
mbligh | 5a49608 | 2009-08-03 16:44:54 +0000 | [diff] [blame] | 1248 | def setUp(self): |
| 1249 | super(job_clone_unittest, self).setUp() |
| 1250 | self.job_data_clone_info = copy.deepcopy(self.job_data) |
| 1251 | self.job_data_clone_info['created_on'] = '2009-07-23 16:21:29' |
| 1252 | self.job_data_clone_info['name'] = 'testing_clone' |
| 1253 | self.job_data_clone_info['id'] = 42 |
| 1254 | self.job_data_clone_info['owner'] = 'user0' |
| 1255 | |
| 1256 | self.job_data_cloned = copy.deepcopy(self.job_data) |
| 1257 | self.job_data_cloned['name'] = 'cloned' |
| 1258 | self.job_data_cloned['hosts'] = [u'host0'] |
| 1259 | self.job_data_cloned['meta_hosts'] = [] |
| 1260 | |
| 1261 | |
| 1262 | def test_backward_compat(self): |
| 1263 | self.run_cmd(argv=['atest', 'job', 'create', '--clone', '42', |
| 1264 | '-r', 'cloned'], |
| 1265 | rpcs=[('get_info_for_clone', {'id': '42', |
| 1266 | 'preserve_metahosts': True}, |
| 1267 | True, |
| 1268 | {u'atomic_group_name': None, |
| 1269 | u'hosts': [{u'acls': [u'acl0'], |
| 1270 | u'atomic_group': None, |
| 1271 | u'attributes': {}, |
| 1272 | u'dirty': False, |
| 1273 | u'hostname': u'host0', |
| 1274 | u'id': 4378, |
| 1275 | u'invalid': False, |
| 1276 | u'labels': [u'label0', u'label1'], |
| 1277 | u'lock_time': None, |
| 1278 | u'locked': False, |
| 1279 | u'locked_by': None, |
| 1280 | u'other_labels': u'label0, label1', |
| 1281 | u'platform': u'plat0', |
| 1282 | u'protection': u'Repair software only', |
| 1283 | u'status': u'Ready', |
| 1284 | u'synch_id': None}], |
| 1285 | u'job': self.job_data_clone_info, |
| 1286 | u'meta_host_counts': {}}), |
| 1287 | ('create_job', self.job_data_cloned, True, 43)], |
| 1288 | out_words_ok=['Created job', '43']) |
| 1289 | |
| 1290 | |
| 1291 | def test_clone_reuse_hosts(self): |
mbligh | 56f1f4a | 2009-08-03 16:45:12 +0000 | [diff] [blame] | 1292 | self.job_data_cloned['hosts'] = [u'host0', 'host1'] |
mbligh | 5a49608 | 2009-08-03 16:44:54 +0000 | [diff] [blame] | 1293 | self.run_cmd(argv=['atest', 'job', 'clone', '--id', '42', |
| 1294 | '-r', 'cloned'], |
| 1295 | rpcs=[('get_info_for_clone', {'id': '42', |
| 1296 | 'preserve_metahosts': True}, |
| 1297 | True, |
| 1298 | {u'atomic_group_name': None, |
mbligh | 56f1f4a | 2009-08-03 16:45:12 +0000 | [diff] [blame] | 1299 | u'hosts': self.local_hosts, |
mbligh | 5a49608 | 2009-08-03 16:44:54 +0000 | [diff] [blame] | 1300 | u'job': self.job_data_clone_info, |
| 1301 | u'meta_host_counts': {}}), |
| 1302 | ('create_job', self.job_data_cloned, True, 43)], |
| 1303 | out_words_ok=['Created job', '43']) |
| 1304 | |
| 1305 | |
mbligh | 56f1f4a | 2009-08-03 16:45:12 +0000 | [diff] [blame] | 1306 | def test_clone_reuse_metahosts(self): |
| 1307 | self.job_data_cloned['hosts'] = [] |
| 1308 | self.job_data_cloned['meta_hosts'] = ['type1']*4 + ['type0'] |
| 1309 | self.run_cmd(argv=['atest', 'job', 'clone', '--id', '42', |
| 1310 | '-r', 'cloned'], |
| 1311 | rpcs=[('get_info_for_clone', {'id': '42', |
| 1312 | 'preserve_metahosts': True}, |
| 1313 | True, |
| 1314 | {u'atomic_group_name': None, |
| 1315 | u'hosts': [], |
| 1316 | u'job': self.job_data_clone_info, |
| 1317 | u'meta_host_counts': {u'type0': 1, |
| 1318 | u'type1': 4}}), |
| 1319 | ('create_job', self.job_data_cloned, True, 43)], |
| 1320 | out_words_ok=['Created job', '43']) |
| 1321 | |
| 1322 | |
| 1323 | def test_clone_reuse_both(self): |
| 1324 | self.job_data_cloned['hosts'] = [u'host0', 'host1'] |
| 1325 | self.job_data_cloned['meta_hosts'] = ['type1']*4 + ['type0'] |
| 1326 | self.run_cmd(argv=['atest', 'job', 'clone', '--id', '42', |
| 1327 | '-r', 'cloned'], |
| 1328 | rpcs=[('get_info_for_clone', {'id': '42', |
| 1329 | 'preserve_metahosts': True}, |
| 1330 | True, |
| 1331 | {u'atomic_group_name': None, |
| 1332 | u'hosts': self.local_hosts, |
| 1333 | u'job': self.job_data_clone_info, |
| 1334 | u'meta_host_counts': {u'type0': 1, |
| 1335 | u'type1': 4}}), |
| 1336 | ('create_job', self.job_data_cloned, True, 43)], |
| 1337 | out_words_ok=['Created job', '43']) |
| 1338 | |
| 1339 | |
mbligh | 5a49608 | 2009-08-03 16:44:54 +0000 | [diff] [blame] | 1340 | def test_clone_no_hosts(self): |
| 1341 | self.run_cmd(argv=['atest', 'job', 'clone', '--id', '42', 'cloned'], |
| 1342 | exit_code=1, |
| 1343 | out_words_ok=['usage'], |
| 1344 | err_words_ok=['machine']) |
| 1345 | |
| 1346 | |
mbligh | 56f1f4a | 2009-08-03 16:45:12 +0000 | [diff] [blame] | 1347 | def test_clone_reuse_and_hosts(self): |
| 1348 | self.run_cmd(argv=['atest', 'job', 'clone', '--id', '42', |
| 1349 | '-r', '-m', 'host5', 'cloned'], |
| 1350 | exit_code=1, |
| 1351 | out_words_ok=['usage'], |
| 1352 | err_words_ok=['specify']) |
| 1353 | |
| 1354 | |
| 1355 | def test_clone_new_multiple_hosts(self): |
| 1356 | self.job_data_cloned['hosts'] = [u'host5', 'host4', 'host3'] |
| 1357 | self.run_cmd(argv=['atest', 'job', 'clone', '--id', '42', |
| 1358 | '-m', 'host5,host4,host3', 'cloned'], |
| 1359 | rpcs=[('get_info_for_clone', {'id': '42', |
| 1360 | 'preserve_metahosts': False}, |
| 1361 | True, |
| 1362 | {u'atomic_group_name': None, |
| 1363 | u'hosts': self.local_hosts, |
| 1364 | u'job': self.job_data_clone_info, |
| 1365 | u'meta_host_counts': {}}), |
| 1366 | ('create_job', self.job_data_cloned, True, 43)], |
| 1367 | out_words_ok=['Created job', '43']) |
| 1368 | |
| 1369 | |
| 1370 | def test_clone_oth(self): |
| 1371 | self.job_data_cloned['hosts'] = [] |
| 1372 | self.job_data_cloned['one_time_hosts'] = [u'host5'] |
| 1373 | self.run_cmd(argv=['atest', 'job', 'clone', '--id', '42', |
| 1374 | '--one-time-hosts', 'host5', 'cloned'], |
| 1375 | rpcs=[('get_info_for_clone', {'id': '42', |
| 1376 | 'preserve_metahosts': False}, |
| 1377 | True, |
| 1378 | {u'atomic_group_name': None, |
| 1379 | u'hosts': self.local_hosts, |
| 1380 | u'job': self.job_data_clone_info, |
| 1381 | u'meta_host_counts': {}}), |
| 1382 | ('create_job', self.job_data_cloned, True, 43)], |
| 1383 | out_words_ok=['Created job', '43']) |
mbligh | 5a49608 | 2009-08-03 16:44:54 +0000 | [diff] [blame] | 1384 | |
| 1385 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1386 | class job_abort_unittest(cli_mock.cli_unittest): |
| 1387 | results = [{u'status_counts': {u'Aborted': 1}, u'control_file': |
| 1388 | u"job.run_test('sleeptest')\n", u'name': u'test_job0', |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 1389 | u'control_type': u'Server', u'priority': |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1390 | u'Medium', u'owner': u'user0', u'created_on': |
showard | 2bab8f4 | 2008-11-12 18:15:22 +0000 | [diff] [blame] | 1391 | u'2008-07-08 17:45:44', u'synch_count': 2, u'id': 180}] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1392 | |
| 1393 | def test_execute_job_abort(self): |
mbligh | a212d71 | 2009-02-11 01:22:36 +0000 | [diff] [blame] | 1394 | self.run_cmd(argv=['atest', 'job', 'abort', '180', |
| 1395 | '--ignore_site_file'], |
mbligh | 206d50a | 2008-11-13 01:19:25 +0000 | [diff] [blame] | 1396 | rpcs=[('abort_host_queue_entries', |
| 1397 | {'job__id__in': ['180']}, True, None)], |
| 1398 | out_words_ok=['Aborting', '180']) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1399 | |
| 1400 | |
| 1401 | if __name__ == '__main__': |
| 1402 | unittest.main() |