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