Example #1
0
    def get_test_variants(self):
        """Computes test variants based on the parameters"""

        if self.test_parameters:
            paths = ['/']
            tree_nodes = TreeNode().get_node(paths[0], True)
            tree_nodes.value = self.test_parameters
            variant = {
                "variant": tree_nodes,
                "variant_id": None,
                "paths": paths
            }
            test_variant = [(test, variant) for test in self.tests]

        else:
            # let's use variants when parameters are not available
            # define execution order
            execution_order = self.config.get('run.execution_order')
            if execution_order == "variants-per-test":
                test_variant = [(test, variant) for test in self.tests
                                for variant in self.variants.itertests()]
            elif execution_order == "tests-per-variant":
                test_variant = [(test, variant)
                                for variant in self.variants.itertests()
                                for test in self.tests]
        return test_variant
Example #2
0
    def __iter__(self):
        if self.variants is None:
            return

        variant_ids = []
        for variant in self.variants:
            variant_ids.append("-".join([variant.get(key)
                                         for key in self.headers]))

        for vid, variant in zip(variant_ids, self.variants):
            yield {"variant_id": vid,
                   "variant": [TreeNode('', variant)],
                   "paths": ['/']}
Example #3
0
    def _get_all_runtime_tasks(self, test_suite, job_id):
        runtime_tasks = []
        test_result_total = test_suite.variants.get_number_of_tests(test_suite.tests)
        no_digits = len(str(test_result_total))
        if test_suite.test_parameters:
            paths = ['/']
            tree_nodes = TreeNode().get_node(paths[0], True)
            tree_nodes.value = test_suite.test_parameters
            variant = {"variant": tree_nodes, "variant_id": None, "paths": paths}
            test_variant = [(test, variant) for test in test_suite.tests]

        else:
            # let's use variants when parameters are not available
            # define execution order
            execution_order = test_suite.config.get('run.execution_order')
            if execution_order == "variants-per-test":
                test_variant = [(test, variant) for test in test_suite.tests
                                for variant in test_suite.variants.itertests()]
            elif execution_order == "tests-per-variant":
                test_variant = [(test, variant)
                                for variant in test_suite.variants.itertests()
                                for test in test_suite.tests]

        # decide if a copy of the runnable is needed, in case of more
        # variants than tests
        copy_runnable = len(test_variant) > len(test_suite.tests)
        # create runtime tasks
        for index, (runnable, variant) in enumerate(test_variant, start=1):
            if copy_runnable:
                runnable = deepcopy(runnable)
            runtime_tasks.extend(self._create_runtime_tasks_for_test(
                test_suite,
                runnable,
                no_digits,
                index,
                variant,
                job_id))
        return runtime_tasks
Example #4
0
    def test_whiteboard(self):
        """
        Tests if the whiteboard content is the expected one
        """
        this = os.path.abspath(__file__)
        base = os.path.dirname(os.path.dirname(os.path.dirname(this)))
        module = os.path.join(base, 'examples', 'tests', 'whiteboard.py')
        factory = ['WhiteBoard',
                   {'methodName': 'test',
                    'tags': set([]),
                    'params': ([TreeNode(name='')], ['/run/*']),
                    'job': self.job,
                    'modulePath': module,
                    'base_logdir': self.tmpdir}]
        msg = self._run_test(factory)

        self.assertEqual(msg['whiteboard'], 'TXkgbWVzc2FnZSBlbmNvZGVkIGluIGJhc2U2NA==\n')
Example #5
0
    def __iter__(self):
        if self.variants is None:
            return

        variant_ids = []
        for variant in self.variants:
            base_id = "-".join([variant.get(key) for key in self.headers])
            variant_ids.append(base_id + '-' +
                               hashlib.sha1(base_id).hexdigest()[:4])

        for vid, variant in itertools.izip(variant_ids, self.variants):
            variant_tree_nodes = []
            for key, val in variant.items():
                variant_tree_nodes.append(TreeNode(key, {key: val}))

            yield {
                "variant_id": vid,
                "variant": variant_tree_nodes,
                "paths": self.parameter_path
            }