A while back I added support for labels with commas to the host list
cli commands. I've now added the same support to dependencies so
metahost scheduling can be used with dependencies that have commas.

Signed-off-by: Dale Curtis <[email protected]>
---
 cli/job.py          |   17 +++++++++--------
 cli/job_unittest.py |   31 +++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/cli/job.py b/cli/job.py
index 5eb00a5..ddb534f 100644
--- a/cli/job.py
+++ b/cli/job.py
@@ -299,7 +299,7 @@ class job_create_or_clone(action_common.atest_create, job):
         return (hosts, meta_hosts)


-    def parse(self):
+    def parse(self, parse_info=[]):
         host_info = topic_common.item_parse_info(attribute_name='hosts',
                                                  inline_option='machine',
                                                  filename_option='mlist')
@@ -310,9 +310,9 @@ class job_create_or_clone(action_common.atest_create, job):
         label_info = topic_common.item_parse_info(attribute_name='labels',
                                                   inline_option='labels')

-        options, leftover = super(job_create_or_clone,
-                                  self).parse([host_info, job_info, oth_info,
-                                               label_info],
req_items='jobname')
+        options, leftover = super(job_create_or_clone, self).parse(
+                [host_info, job_info, oth_info, label_info] + parse_info,
+                req_items='jobname')
         self.data = {}
         if len(self.jobname) > 1:
             self.invalid_syntax('Too many arguments specified, only expected '
@@ -440,7 +440,10 @@ class job_create(job_create_or_clone):


     def parse(self):
-        options, leftover = super(job_create, self).parse()
+        deps_info = topic_common.item_parse_info(attribute_name='dependencies',
+                                                 inline_option='dependencies')
+        options, leftover = super(job_create, self).parse(
+                parse_info=[deps_info])

         if (len(self.hosts) == 0 and not self.one_time_hosts
             and not options.labels and not options.atomic_group):
@@ -499,9 +502,7 @@ class job_create(job_create_or_clone):
         if options.atomic_group:
             self.data['atomic_group_name'] = options.atomic_group

-        deps = options.dependencies.split(',')
-        deps = [dep.strip() for dep in deps if dep.strip()]
-        self.data['dependencies'] = deps
+        self.data['dependencies'] = self.dependencies

         if options.synch_count:
             self.data['synch_count'] = options.synch_count
diff --git a/cli/job_unittest.py b/cli/job_unittest.py
index d0240e5..06d9df1 100755
--- a/cli/job_unittest.py
+++ b/cli/job_unittest.py
@@ -831,6 +831,19 @@ class job_create_unittest(cli_mock.cli_unittest):
         file_temp.clean()


+    def test_execute_create_job_with_control_and_comma_dependencies(self):
+        data = self.data.copy()
+        data['dependencies'] = ['dep2,False', 'dep1,True']
+        file_temp = cli_mock.create_file(self.ctrl_file)
+        self.run_cmd(argv=['atest', 'job', 'create', '-f', file_temp.name,
+                           'test_job0', '-m', 'host0', '-d',
+                           'dep1\,True, dep2\,False ', '--ignore_site_file'],
+                     rpcs=[('create_job', data, True, 42)],
+                     out_words_ok=['test_job0', 'Created'],
+                     out_words_no=['Uploading', 'Done'])
+        file_temp.clean()
+
+
     def test_execute_create_job_with_synch_count(self):
         data = self.data.copy()
         data['synch_count'] = 2
@@ -862,6 +875,24 @@ class job_create_unittest(cli_mock.cli_unittest):
                      out_words_no=['Uploading', 'Done'])


+    def test_execute_create_job_with_test_and_comma_dependencies(self):
+        data = self.data.copy()
+        data['dependencies'] = ['dep1,True', 'dep2,False', 'dep3,123']
+        self.run_cmd(argv=['atest', 'job', 'create', '-t', 'sleeptest',
+                           'test_job0', '-m', 'host0', '-d',
+                           'dep1\,True dep2\,False ', '--ignore_site_file'],
+                     rpcs=[('generate_control_file',
+                            {'tests': ['sleeptest']},
+                            True,
+                            {'control_file' : self.ctrl_file,
+                             'synch_count' : 1,
+                             'is_server' : False,
+                             'dependencies' : ['dep3,123']}),
+                           ('create_job', data, True, 42)],
+                     out_words_ok=['test_job0', 'Created'],
+                     out_words_no=['Uploading', 'Done'])
+
+
     def test_execute_create_job_with_kernel(self):
         data = self.data.copy()
         data['control_file'] = self.kernel_ctrl_file
-- 
1.7.3.1
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to