]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
describe-tests: add subsuite columns for combo output
authorJosh Durgin <jdurgin@redhat.com>
Thu, 3 Dec 2015 00:36:12 +0000 (16:36 -0800)
committerJosh Durgin <jdurgin@redhat.com>
Wed, 9 Dec 2015 21:04:54 +0000 (13:04 -0800)
This gives more context when looking at larger suites as a whole,
e.g. rbd or rados.

Sort the rows as well, so tests within subsuites, e.g. basic, thrash,
singleton, etc. are grouped together.

Signed-off-by: Josh Durgin <jdurgin@redhat.com>
teuthology/describe_tests.py
teuthology/test/test_describe_tests.py

index bdb8bf02c5339ccfc0d81fbe95597bb6786a67e7..afbaceaf910cb332825696ab6359546f50390ffd 100644 (file)
@@ -40,6 +40,8 @@ def get_combinations(suite_dir, fields, subset,
     rows = []
 
     facet_headers = set()
+    dirs = {}
+    max_dir_depth = 0
 
     for _, fragment_paths in configs:
         if limit > 0 and num_listed >= limit:
@@ -68,15 +70,41 @@ def get_combinations(suite_dir, fields, subset,
         if include_facet:
             # map final dir (facet) -> filename without the .yaml suffix
             for path in fragment_paths:
-                facet = os.path.basename(os.path.dirname(path))
+                facet_dir = os.path.dirname(path)
+                facet = os.path.basename(facet_dir)
                 metadata[facet] = os.path.basename(path)[:-5]
                 facet_headers.add(facet)
+                facet_dirs = facet_dir.split('/')[:-1]
+                for i, dir_ in enumerate(facet_dirs):
+                    if i not in dirs:
+                        dirs[i] = set()
+                    dirs[i].add(dir_)
+                    metadata['_dir_' + str(i)] = os.path.basename(dir_)
+                    max_dir_depth = max(max_dir_depth, i)
 
         rows.append(metadata)
         num_listed += 1
 
-    headers = sorted(facet_headers) + fields
-    return headers, [[row.get(field, '') for field in headers] for row in rows]
+    subsuite_headers = []
+    if include_facet:
+        first_subsuite_depth = max_dir_depth
+        for i in range(max_dir_depth):
+            if len(dirs[i]) > 1:
+                first_subsuite_depth = i
+                break
+
+        subsuite_headers = ['subsuite depth ' + str(i)
+                            for i in
+                            range(0, max_dir_depth - first_subsuite_depth + 1)]
+
+        for row in rows:
+            for i in range(first_subsuite_depth, max_dir_depth + 1):
+                row[subsuite_headers[i - first_subsuite_depth]] = \
+                    row.get('_dir_' + str(i), '')
+
+    headers = subsuite_headers + sorted(facet_headers) + fields
+    return headers, sorted([[row.get(field, '') for field in headers]
+                            for row in rows])
 
 def describe_combinations(suite_dir, fields, subset,
                           limit, filter_in, filter_out,
index fcd9adc224712574a5829332727223c36b09de2b..1334304e8b0f5a117e4a5a98d93cb5436f5d6528 100644 (file)
@@ -109,6 +109,11 @@ class TestDescribeTests(object):
         self.fake_listdir, self.fake_isfile, self.fake_isdir, self.fake_open = \
             make_fake_fstools(realistic_fs)
 
+    @staticmethod
+    def assert_expected_combo_headers(headers):
+        assert headers == (['subsuite depth 0'] +
+                           sorted(set(filter(bool, expected_facets))))
+
     def test_no_filters(self):
         rows = tree_with_info('basic', [], False, '', [],
                               self.fake_listdir, self.fake_isdir,
@@ -188,8 +193,8 @@ class TestDescribeTests(object):
         headers, rows = get_combinations('basic', [], None, 1, None, None, True,
                                          self.fake_isdir, self.fake_open,
                                          self.fake_isfile, self.fake_listdir)
-        assert headers == sorted(set(filter(bool, expected_facets)))
-        assert rows == [['install', 'fixed-1', 'rbd_api_tests']]
+        self.assert_expected_combo_headers(headers)
+        assert rows == [['basic', 'install', 'fixed-1', 'rbd_api_tests']]
 
     def test_combinations_desc_features(self):
         headers, rows = get_combinations('basic', ['desc', 'rbd_features'],
@@ -205,16 +210,16 @@ class TestDescribeTests(object):
                                          None, True,
                                          self.fake_isdir, self.fake_open,
                                          self.fake_isfile, self.fake_listdir)
-        assert headers == sorted(set(filter(bool, expected_facets)))
-        assert rows == [['install', 'fixed-1', 'rbd_api_tests_old_format']]
+        self.assert_expected_combo_headers(headers)
+        assert rows == [['basic', 'install', 'fixed-1', 'rbd_api_tests_old_format']]
 
     def test_combinations_filter_out(self):
         headers, rows = get_combinations('basic', [], None, 0, None,
                                          ['old_format'], True,
                                          self.fake_isdir, self.fake_open,
                                          self.fake_isfile, self.fake_listdir)
-        assert headers == sorted(set(filter(bool, expected_facets)))
-        assert rows == [['install', 'fixed-1', 'rbd_api_tests']]
+        self.assert_expected_combo_headers(headers)
+        assert rows == [['basic', 'install', 'fixed-1', 'rbd_api_tests']]
 
 
 def test_extract_info_dir():