Exemplo n.º 1
0
    def _compare_res(self, gather_subset1, gather_subset2,
                     valid_subsets=None, min_subset=None):

        valid_subsets = valid_subsets or frozenset()
        minimal_gather_subset = min_subset or frozenset()

        res1 = collector.get_collector_names(valid_subsets=valid_subsets,
                                             minimal_gather_subset=minimal_gather_subset,
                                             gather_subset=gather_subset1)

        res2 = collector.get_collector_names(valid_subsets=valid_subsets,
                                             minimal_gather_subset=minimal_gather_subset,
                                             gather_subset=gather_subset2)

        return res1, res2
    def _compare_res(self, gather_subset1, gather_subset2,
                     valid_subsets=None, min_subset=None):

        valid_subsets = valid_subsets or frozenset()
        minimal_gather_subset = min_subset or frozenset()

        res1 = collector.get_collector_names(valid_subsets=valid_subsets,
                                             minimal_gather_subset=minimal_gather_subset,
                                             gather_subset=gather_subset1)

        res2 = collector.get_collector_names(valid_subsets=valid_subsets,
                                             minimal_gather_subset=minimal_gather_subset,
                                             gather_subset=gather_subset2)

        return res1, res2
Exemplo n.º 3
0
    def test_default_collectors(self):
        platform_info = {'system': 'Generic'}
        compat_platforms = [platform_info]
        collectors_for_platform = collector.find_collectors_for_platform(
            default_collectors.collectors, compat_platforms)

        all_fact_subsets, aliases_map = collector.build_fact_id_to_collector_map(
            collectors_for_platform)

        all_valid_subsets = frozenset(all_fact_subsets.keys())
        collector_names = collector.get_collector_names(
            valid_subsets=all_valid_subsets,
            aliases_map=aliases_map,
            platform_info=platform_info)
        complete_collector_names = collector._solve_deps(
            collector_names, all_fact_subsets)

        dep_map = collector.build_dep_data(complete_collector_names,
                                           all_fact_subsets)

        ordered_deps = collector.tsort(dep_map)
        ordered_collector_names = [x[0] for x in ordered_deps]

        res = collector.select_collector_classes(ordered_collector_names,
                                                 all_fact_subsets)

        self.assertTrue(
            res.index(default_collectors.ServiceMgrFactCollector) > res.index(
                default_collectors.DistributionFactCollector), res)
        self.assertTrue(
            res.index(default_collectors.ServiceMgrFactCollector) > res.index(
                default_collectors.PlatformFactCollector), res)
Exemplo n.º 4
0
 def test_one_valid_with_all_gather_subset(self):
     valid_subsets = frozenset(['my_fact'])
     res = collector.get_collector_names(valid_subsets=valid_subsets,
                                         minimal_gather_subset=frozenset([]),
                                         gather_subset=['all'])
     self.assertIsInstance(res, set)
     self.assertEqual(res, set(['my_fact']))
Exemplo n.º 5
0
 def test_empty_valid_and_min_with_all_gather_subset(self):
     res = collector.get_collector_names(valid_subsets=frozenset([]),
                                         minimal_gather_subset=frozenset(
                                             []),
                                         gather_subset=['all'])
     self.assertIsInstance(res, set)
     self.assertEqual(res, set([]))
Exemplo n.º 6
0
    def test_default_collectors(self):
        platform_info = {'system': 'Generic'}
        compat_platforms = [platform_info]
        collectors_for_platform = collector.find_collectors_for_platform(default_collectors.collectors,
                                                                         compat_platforms)

        all_fact_subsets, aliases_map = collector.build_fact_id_to_collector_map(collectors_for_platform)

        all_valid_subsets = frozenset(all_fact_subsets.keys())
        collector_names = collector.get_collector_names(valid_subsets=all_valid_subsets,
                                                        aliases_map=aliases_map,
                                                        platform_info=platform_info)
        complete_collector_names = collector._solve_deps(collector_names, all_fact_subsets)

        dep_map = collector.build_dep_data(complete_collector_names, all_fact_subsets)

        ordered_deps = collector.tsort(dep_map)
        ordered_collector_names = [x[0] for x in ordered_deps]

        res = collector.select_collector_classes(ordered_collector_names,
                                                 all_fact_subsets)

        self.assertTrue(res.index(default_collectors.ServiceMgrFactCollector) >
                        res.index(default_collectors.DistributionFactCollector),
                        res)
        self.assertTrue(res.index(default_collectors.ServiceMgrFactCollector) >
                        res.index(default_collectors.PlatformFactCollector),
                        res)
Exemplo n.º 7
0
 def test_one_valid_with_all_gather_subset(self):
     valid_subsets = frozenset(['my_fact'])
     res = collector.get_collector_names(valid_subsets=valid_subsets,
                                         minimal_gather_subset=frozenset([]),
                                         gather_subset=set(['all']))
     self.assertIsInstance(res, set)
     self.assertEqual(res, set(['my_fact']))
Exemplo n.º 8
0
    def test_one_minimal_with_not_all_gather_subset(self):
        valid_subsets = frozenset(['my_fact', 'something_else', 'whatever'])
        minimal_gather_subset = frozenset(['my_fact'])

        # even with '!all', the minimal_gather_subset should be returned
        res = collector.get_collector_names(valid_subsets=valid_subsets,
                                            minimal_gather_subset=minimal_gather_subset,
                                            gather_subset=['!all'])
        self.assertIsInstance(res, set)
        self.assertEqual(res, set(['my_fact']))
    def test_one_minimal_with_all_gather_subset(self):
        my_fact = 'my_fact'
        valid_subsets = frozenset([my_fact])
        minimal_gather_subset = valid_subsets

        res = collector.get_collector_names(valid_subsets=valid_subsets,
                                            minimal_gather_subset=minimal_gather_subset,
                                            gather_subset=['all'])
        self.assertIsInstance(res, set)
        self.assertEqual(res, set(['my_fact']))
Exemplo n.º 10
0
    def test_one_minimal_with_not_all_gather_subset(self):
        valid_subsets = frozenset(['my_fact', 'something_else', 'whatever'])
        minimal_gather_subset = frozenset(['my_fact'])

        # even with '!all', the minimal_gather_subset should be returned
        res = collector.get_collector_names(valid_subsets=valid_subsets,
                                            minimal_gather_subset=minimal_gather_subset,
                                            gather_subset=set(['!all']))
        self.assertIsInstance(res, set)
        self.assertEqual(res, set(['my_fact']))
Exemplo n.º 11
0
    def test_gather_subset_excludes_min_and_all(self):
        valid_subsets = frozenset(['min_fact', 'something_else', 'whatever'])
        minimal_gather_subset = frozenset(['min_fact'])

        res = collector.get_collector_names(valid_subsets=valid_subsets,
                                            minimal_gather_subset=minimal_gather_subset,
                                            gather_subset=['whatever', '!all', '!min'])
        self.assertIsInstance(res, set)
        # excludes are higher precedence than includes, so !all excludes everything
        # and then minimal_gather_subset is added. so '!all', 'other' == '!all'
        self.assertEqual(res, set(['whatever']))
Exemplo n.º 12
0
    def test_gather_subset_excludes(self):
        valid_subsets = frozenset(['my_fact', 'something_else', 'whatever'])
        minimal_gather_subset = frozenset(['my_fact'])

        # even with '!all', the minimal_gather_subset should be returned
        res = collector.get_collector_names(valid_subsets=valid_subsets,
                                            minimal_gather_subset=minimal_gather_subset,
                                            gather_subset=set(['all', '!my_fact', '!whatever']))
        self.assertIsInstance(res, set)
        # my_facts is in minimal_gather_subset, so always returned
        self.assertEqual(res, set(['my_fact', 'something_else']))
Exemplo n.º 13
0
    def test_gather_subset_excludes_ordering(self):
        valid_subsets = frozenset(['my_fact', 'something_else', 'whatever'])
        minimal_gather_subset = frozenset(['my_fact'])

        res = collector.get_collector_names(valid_subsets=valid_subsets,
                                            minimal_gather_subset=minimal_gather_subset,
                                            gather_subset=set(['!all', 'whatever']))
        self.assertIsInstance(res, set)
        # excludes are higher precedence than includes, so !all excludes everything
        # and then minimal_gather_subset is added. so '!all', 'other' == '!all'
        self.assertEqual(res, set(['my_fact']))
Exemplo n.º 14
0
    def test_gather_subset_excludes(self):
        valid_subsets = frozenset(['my_fact', 'something_else', 'whatever'])
        minimal_gather_subset = frozenset(['min_fact', 'min_another'])

        # even with '!all', the minimal_gather_subset should be returned
        res = collector.get_collector_names(valid_subsets=valid_subsets,
                                            minimal_gather_subset=minimal_gather_subset,
                                            # gather_subset=set(['all', '!my_fact', '!whatever']))
                                            # gather_subset=['all', '!my_fact', '!whatever'])
                                            gather_subset=['!min_fact', '!whatever'])
        self.assertIsInstance(res, set)
        # min_another is in minimal_gather_subset, so always returned
        self.assertEqual(res, set(['min_another']))
    def test_default_collectors(self):
        platform_info = {'system': 'Generic'}
        compat_platforms = [platform_info]
        collectors_for_platform = collector.find_collectors_for_platform(
            default_collectors.collectors, compat_platforms)

        all_fact_subsets, aliases_map = collector.build_fact_id_to_collector_map(
            collectors_for_platform)

        all_valid_subsets = frozenset(all_fact_subsets.keys())
        collector_names = collector.get_collector_names(
            valid_subsets=all_valid_subsets,
            aliases_map=aliases_map,
            platform_info=platform_info)
        collector.select_collector_classes(collector_names, all_fact_subsets,
                                           default_collectors.collectors)
Exemplo n.º 16
0
 def test_empty_valid_and_min_with_all_gather_subset(self):
     res = collector.get_collector_names(valid_subsets=frozenset([]),
                                         minimal_gather_subset=frozenset([]),
                                         gather_subset=['all'])
     self.assertIsInstance(res, set)
     self.assertEqual(res, set([]))
Exemplo n.º 17
0
 def test_none(self):
     res = collector.get_collector_names()
     self.assertIsInstance(res, set)
     self.assertEqual(res, set([]))
Exemplo n.º 18
0
 def test_none(self):
     res = collector.get_collector_names()
     self.assertIsInstance(res, set)
     self.assertEqual(res, set([]))
Exemplo n.º 19
0
 def test_empty_sets(self):
     res = collector.get_collector_names(valid_subsets=frozenset([]),
                                         minimal_gather_subset=frozenset([]),
                                         gather_subset=set([]))
     self.assertIsInstance(res, set)
     self.assertEqual(res, set([]))