From 996192f223ff935ae75baf8d42a2723540a2c6c1 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Wed, 2 Dec 2015 16:36:12 -0800 Subject: [PATCH] describe-tests: add subsuite columns for combo output 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 --- teuthology/describe_tests.py | 34 +++++++++++++++++++++++--- teuthology/test/test_describe_tests.py | 17 ++++++++----- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/teuthology/describe_tests.py b/teuthology/describe_tests.py index bdb8bf02c5..afbaceaf91 100644 --- a/teuthology/describe_tests.py +++ b/teuthology/describe_tests.py @@ -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, diff --git a/teuthology/test/test_describe_tests.py b/teuthology/test/test_describe_tests.py index fcd9adc224..1334304e8b 100644 --- a/teuthology/test/test_describe_tests.py +++ b/teuthology/test/test_describe_tests.py @@ -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(): -- 2.39.5