]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
suite/run,schedule,result: write rerun memo as the first job in suite 1198/head
authorKefu Chai <kchai@redhat.com>
Fri, 24 Aug 2018 13:15:31 +0000 (21:15 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 3 Sep 2018 14:26:32 +0000 (22:26 +0800)
so we don't need to wait for the job to write result to for rerunning
the test suite. without this change, the "result" is normally the last
job in the suite to be scheduled, so it's likely we will not have the
results.log until the suite is almost completed. afer this change,
a "first-in-suite" job is scheduled as the first job to note down
the subset and seed to run the suite.

Signed-off-by: Kefu Chai <kchai@redhat.com>
scripts/schedule.py
teuthology/results.py
teuthology/schedule.py
teuthology/suite/run.py
teuthology/suite/test/test_run_.py
teuthology/test/test_schedule.py
teuthology/worker.py

index 35a4f70ae9b1df83661c30b6992a21bc089c6723..feeafd770e0765d1c3b93d325b2c0e5a096d4df1 100644 (file)
@@ -26,6 +26,9 @@ optional arguments:
   -N <num>, --num <num>                Number of times to run/queue the job
                                        [default: 1]
 
+  --first-in-suite                     Mark the first job in a suite so suite
+                                       can note down the rerun-related info
+                                       [default: False]
   --last-in-suite                      Mark the last job in a suite so suite
                                        post-processing can be run
                                        [default: False]
index f652a2d9b009924cb05c139d4dd38c0e1e9919e7..c5baa91b27671157f068c59fce622440ee1c1ceb 100644 (file)
@@ -28,21 +28,26 @@ def main(args):
         teuthology.setup_log_file(log_path)
 
     try:
-        results(args['--archive-dir'], args['--name'], args['--email'],
-                int(args['--timeout']), args['--dry-run'],
-                args['--subset'], args['--seed'])
+        if args['--seed']:
+            note_rerun_params(args['--subset'], args['--seed'])
+        else:
+            results(args['--archive-dir'], args['--name'], args['--email'],
+                    int(args['--timeout']), args['--dry-run'])
     except Exception:
-        log.exception('error generating results')
+        log.exception('error generating memo/results')
         raise
 
 
-def results(archive_dir, name, email, timeout, dry_run, subset, seed):
-    starttime = time.time()
-
+def note_rerun_params(subset, seed):
     if subset:
         log.info('subset: %r', subset)
     if seed:
         log.info('seed: %r', seed)
+
+
+def results(archive_dir, name, email, timeout, dry_run):
+    starttime = time.time()
+
     if timeout:
         log.info('Waiting up to %d seconds for tests to finish...', timeout)
 
index d7762c268c0ab2a98ff9c8d75eba790ca48e6d72..8305aa10a2f326ab183912f240d4a6ac24eb7dff 100644 (file)
@@ -7,8 +7,16 @@ from teuthology import report
 
 
 def main(args):
+    if not args['--first-in-suite']:
+        first_job_args = ['subset', 'seed']
+        for arg in first_job_args:
+            opt = '--{arg}'.format(arg=arg)
+            msg_fmt = '{opt} is only applicable to the first job in a suite'
+            if args[opt]:
+                raise ValueError(msg_fmt.format(opt=opt))
+
     if not args['--last-in-suite']:
-        last_job_args = ['email', 'timeout', 'subset', 'seed']
+        last_job_args = ['email', 'timeout']
         for arg in last_job_args:
             opt = '--{arg}'.format(arg=arg)
             msg_fmt = '{opt} is only applicable to the last job in a suite'
@@ -43,6 +51,7 @@ def build_config(args):
 
     job_config = dict(
         name=args['--name'],
+        first_in_suite=args['--first-in-suite'],
         last_in_suite=args['--last-in-suite'],
         email=args['--email'],
         description=args['--description'],
index 8de984bdba3709aab7c6ab6b91277ba9dd529dab..5c01e39ceba6621aff2209685965c85296d0441d 100644 (file)
@@ -291,15 +291,26 @@ class Run(object):
             base_args.extend(['--owner', self.args.owner])
         return base_args
 
+
+    def write_rerun_memo(self):
+        args = copy.deepcopy(self.base_args)
+        args.append('--first-in-suite')
+        if self.args.subset:
+            subset = '/'.join(str(i) for i in self.args.subset)
+            args.extend(['--subset', subset])
+        args.extend(['--seed', str(self.args.seed)])
+        util.teuthology_schedule(
+            args=args,
+            dry_run=self.args.dry_run,
+            verbose=self.args.verbose,
+            log_prefix="Memo: ")
+
+
     def write_result(self):
         arg = copy.deepcopy(self.base_args)
         arg.append('--last-in-suite')
         if self.base_config.email:
             arg.extend(['--email', self.base_config.email])
-        if self.args.subset:
-            subset = '/'.join(str(i) for i in self.args.subset)
-            arg.extend(['--subset', subset])
-        arg.extend(['--seed', str(self.args.seed)])
         if self.args.timeout:
             arg.extend(['--timeout', self.args.timeout])
         util.teuthology_schedule(
@@ -311,6 +322,7 @@ class Run(object):
         if results_url:
             log.info("Test results viewable at %s", results_url)
 
+
     def prepare_and_schedule(self):
         """
         Puts together some "base arguments" with which to execute
@@ -526,6 +538,10 @@ class Run(object):
 
         with open(base_yaml_path, 'w+b') as base_yaml:
             base_yaml.write(str(self.base_config))
+
+        if jobs_to_schedule:
+            self.write_rerun_memo()
+
         self.schedule_jobs(jobs_missing_packages, jobs_to_schedule, name)
 
         os.remove(base_yaml_path)
index 363781e2366e1f545a12683a8d3089c75a23f025..3251356b06f24fb1962d51bab99219d6d404b19b 100644 (file)
@@ -196,6 +196,7 @@ class TestScheduleSuite(object):
         self.args = YamlConfig.from_dict(self.args_dict)
 
     @patch('teuthology.suite.run.Run.schedule_jobs')
+    @patch('teuthology.suite.run.Run.write_rerun_memo')
     @patch('teuthology.suite.util.has_packages_for_distro')
     @patch('teuthology.suite.util.get_package_versions')
     @patch('teuthology.suite.util.get_install_task_flavor')
@@ -216,6 +217,7 @@ class TestScheduleSuite(object):
         m_get_install_task_flavor,
         m_get_package_versions,
         m_has_packages_for_distro,
+        m_write_rerun_memo,
         m_schedule_jobs,
     ):
         m_get_arch.return_value = 'x86_64'
@@ -266,6 +268,7 @@ class TestScheduleSuite(object):
         m_schedule_jobs.assert_has_calls(
             [call([], [expected_job], runobj.name)],
         )
+        m_write_rerun_memo.assert_called_once_with()
 
     @patch('teuthology.suite.util.find_git_parent')
     @patch('teuthology.suite.run.Run.schedule_jobs')
@@ -323,6 +326,7 @@ class TestScheduleSuite(object):
 
     @patch('teuthology.suite.util.find_git_parent')
     @patch('teuthology.suite.run.Run.schedule_jobs')
+    @patch('teuthology.suite.run.Run.write_rerun_memo')
     @patch('teuthology.suite.util.has_packages_for_distro')
     @patch('teuthology.suite.util.get_package_versions')
     @patch('teuthology.suite.util.get_install_task_flavor')
@@ -343,6 +347,7 @@ class TestScheduleSuite(object):
         m_get_install_task_flavor,
         m_get_package_versions,
         m_has_packages_for_distro,
+        m_write_rerun_memo,
         m_schedule_jobs,
         m_find_git_parent,
     ):
index fef0d4e0195fe87fa78fb751305746c847a2d5b0..4c52eed768643fa1a8de22613292163e3042050d 100644 (file)
@@ -8,6 +8,7 @@ class TestSchedule(object):
         '--owner': 'OWNER',
         '--description': 'DESC',
         '--email': 'EMAIL',
+        '--first-in-suite': False,
         '--last-in-suite': True,
         '--name': 'NAME',
         '--worker': 'tala',
@@ -22,6 +23,7 @@ class TestSchedule(object):
         expected = {
             'description': 'DESC',
             'email': 'EMAIL',
+            'first_in_suite': False,
             'last_in_suite': True,
             'machine_type': 'tala',
             'name': 'NAME',
index 4b76de96056f545d2c58ca420680cd9bf135c560..351f47e97b0d8bdac3314aa9ed21640c5dd4e7dc 100644 (file)
@@ -190,10 +190,10 @@ def prep_job(job_config, log_file_path, archive_dir):
 
 def run_job(job_config, teuth_bin_path, archive_dir, verbose):
     safe_archive = safepath.munge(job_config['name'])
-    if job_config.get('last_in_suite'):
+    if job_config.get('first_in_suite') or job_config.get('last_in_suite'):
         if teuth_config.results_server:
             report.try_delete_jobs(job_config['name'], job_config['job_id'])
-        log.info('Generating results for %s', job_config['name'])
+        log.info('Generating memo/results for %s', job_config['name'])
         args = [
             os.path.join(teuth_bin_path, 'teuthology-results'),
             '--timeout',
@@ -203,11 +203,11 @@ def run_job(job_config, teuth_bin_path, archive_dir, verbose):
             os.path.join(archive_dir, safe_archive),
             '--name',
             job_config['name'],
-            '--seed',
-            job_config['seed'],
         ]
         if job_config.get('email'):
             args.extend(['--email', job_config['email']])
+        if job_config.get('seed'):
+            args.extend(['--seed', job_config['seed']])
         if job_config.get('subset'):
             args.extend(['--subset', job_config['subset']])
         # Execute teuthology-results, passing 'preexec_fn=os.setpgrp' to