]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
teuthology-suite: very-verbose mode 607/head
authorZack Cerza <zack@redhat.com>
Mon, 31 Aug 2015 21:26:00 +0000 (15:26 -0600)
committerZack Cerza <zack@redhat.com>
Mon, 31 Aug 2015 21:26:00 +0000 (15:26 -0600)
If called with --dry-run --verbose --verbose (or --dry-run -vv), call
teuthology-schedule --dry-run for each job that would be scheduled. This
causes teuthology-schedule to print out each would-be job config.

Signed-off-by: Zack Cerza <zack@redhat.com>
scripts/suite.py
teuthology/suite.py

index 1984e57c023f680728836d53582ef3467a4ed296..01b12e5e0e749a68f91fbed449b5e6634da0bd59 100644 (file)
@@ -6,7 +6,7 @@ from teuthology.config import config
 
 doc = """
 usage: teuthology-suite --help
-       teuthology-suite --suite <suite> [options] [<config_yaml>...]
+       teuthology-suite [-v | -vv ]--suite <suite> [options] [<config_yaml>...]
 
 Run a suite of ceph integration tests. A suite is a directory containing
 facets. A facet is a directory containing config snippets. Running a suite
@@ -20,7 +20,9 @@ runs the dumpling-x facet of the upgrade suite.
 Miscellaneous arguments:
   -h, --help                  Show this help message and exit
   -v, --verbose               Be more verbose
-  --dry-run                   Do a dry run; do not schedule anything
+  --dry-run                   Do a dry run; do not schedule anything. In
+                              combination with -vv, also call
+                              teuthology-schedule with --dry-run.
 
 Standard arguments:
   <config_yaml>               Optional extra job yaml to include
index f48fa4191bc51a2333e04a5879cefab7c5c17116..bf2df8a441543e4bde9c145fd3e70cd5efadfd70 100644 (file)
@@ -265,11 +265,12 @@ def prepare_and_schedule(job_config, suite_repo_path, base_yaml_paths, limit,
     arch = get_arch(job_config.machine_type)
 
     base_args = [
-        os.path.join(os.path.dirname(sys.argv[0]), 'teuthology-schedule'),
         '--name', job_config.name,
         '--num', str(num),
         '--worker', get_worker(job_config.machine_type),
     ]
+    if dry_run:
+        base_args.append('--dry-run')
     if job_config.priority:
         base_args.extend(['--priority', str(job_config.priority)])
     if verbose:
@@ -294,6 +295,7 @@ def prepare_and_schedule(job_config, suite_repo_path, base_yaml_paths, limit,
         arch=arch,
         limit=limit,
         dry_run=dry_run,
+        verbose=verbose,
         filter_in=filter_in,
         filter_out=filter_out,
         subset=subset
@@ -307,9 +309,11 @@ def prepare_and_schedule(job_config, suite_repo_path, base_yaml_paths, limit,
             arg.extend(['--timeout', timeout])
         if dry_run:
             log.info('dry-run: %s' % ' '.join(arg))
-        else:
-            subprocess.check_call(
+            teuthology_schedule(
                 args=arg,
+                dry_run=dry_run,
+                verbose=verbose,
+                log_prefix="Results email: ",
             )
         results_url = get_results_url(job_config.name)
         if results_url:
@@ -492,6 +496,7 @@ def schedule_suite(job_config,
                    arch,
                    limit=0,
                    dry_run=True,
+                   verbose=1,
                    filter_in=None,
                    filter_out=None,
                    subset=None
@@ -599,23 +604,15 @@ def schedule_suite(job_config,
             'Scheduling %s', job['desc']
         )
 
-        if dry_run:
-            # Quote any individual args so that individual commands can be
-            # copied and pasted in order to execute them individually.
-            printable_args = []
-            for item in job['args']:
-                if ' ' in item:
-                    printable_args.append("'%s'" % item)
-                else:
-                    printable_args.append(item)
-            prefix = "dry-run:"
-            if job in jobs_missing_packages:
-                prefix = "dry-run (missing packages):"
-            log.info('%s %s' % (prefix, ' '.join(printable_args)))
-        else:
-            subprocess.check_call(
-                args=job['args'],
-            )
+        log_prefix = ''
+        if dry_run and job in jobs_missing_packages:
+            log_prefix = "Missing Packages: "
+        teuthology_schedule(
+            args=job['args'],
+            dry_run=dry_run,
+            verbose=verbose,
+            log_prefix=log_prefix,
+        )
 
     count = len(jobs_to_schedule)
     missing_count = len(jobs_missing_packages)
@@ -628,6 +625,37 @@ def schedule_suite(job_config,
     return count
 
 
+def teuthology_schedule(args, verbose, dry_run, log_prefix=''):
+    """
+    Run teuthology-schedule to schedule individual jobs.
+
+    If --dry-run has been passed but --verbose has been passed just once, don't
+    actually run the command - only print what would be executed.
+
+    If --dry-run has been passed and --verbose has been passed multiple times,
+    do both.
+    """
+    exec_path = os.path.join(
+        os.path.dirname(sys.argv[0]),
+        'teuthology-schedule')
+    args.insert(0, exec_path)
+    if dry_run:
+        # Quote any individual args so that individual commands can be copied
+        # and pasted in order to execute them individually.
+        printable_args = []
+        for item in args:
+            if ' ' in item:
+                printable_args.append("'%s'" % item)
+            else:
+                printable_args.append(item)
+        log.info('{0}{1}'.format(
+            log_prefix,
+            ' '.join(printable_args),
+        ))
+    if not dry_run or (dry_run and verbose > 1):
+        subprocess.check_call(args=args)
+
+
 def get_install_task_flavor(job_config):
     """
     Pokes through the install task's configuration (including its overrides) to