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