예제 #1
0
    def test_local_job_empty(self):  # pylint: disable=no-self-use
        """Test local jobs with no job defined and absolute path.

        (useful for people who want to store job files in /etc)

        Steps:
            - Configure local jobs in decorator.
            - Check Eve can start (no error in setup).
            - Verify directory (test setup validation).

        """
        cluster = Cluster()
        master = list(cluster._masters.values())[0]
        master.conf['LOCAL_JOBS_DIRPATH'] = '/dev/null'
        with cluster:
            cluster.sanity_check()
예제 #2
0
    def configure_local_jobs(self, master_ids=(0, )):
        """Test a local job on the frontend.

        The local directory is customized with a subdirectory.

        Steps:
            - Configure local job in decorator.
            - Check Eve can start (no error in setup).
            - Verify directories and files (test setup validation).
            - Check schedulers and builders are correct.

        """

        cluster = Cluster()
        for master_id in master_ids:
            master = list(cluster._masters.values())[master_id]
            master.add_conf_file(yaml_data=PERIODIC_LOCAL_JOB,
                                 filename='local2/sub/periodic.yml')
            master.conf['LOCAL_JOBS_DIRPATH'] = 'local2/sub'
            path = os.path.join(master._base_path, 'local2/sub/periodic.yml')
            self.assertTrue(os.path.isfile(path))

        with cluster:
            cluster.sanity_check()
            scheduler = cluster.api.get_scheduler(
                PERIODIC_LOCAL_JOB['scheduler']['name'])
            self.assertTrue(scheduler['enabled'])
            builder = cluster.api.get_builder(
                PERIODIC_LOCAL_JOB['builder']['name'])
            self.assertEqual(builder['description'],
                             PERIODIC_LOCAL_JOB['builder']['description'])

            # let job trigger at least once
            buildset = cluster.api.getw(
                '/buildsets',
                get_params={
                    'limit': 1,
                    'results': 0,  # SUCCESS
                })
            self.assertEqual(
                buildset['reason'], "The Periodic scheduler named "
                "'my-periodic-scheduler' triggered this build")
예제 #3
0
    def test_nightly_build(self):
        """Test that a nightly build is well registred. does not launch it."""

        cluster = Cluster()
        master = list(cluster._masters.values())[0]
        master.add_conf_file(yaml_data=NIGHTLY_LOCAL_JOB,
                             filename='local2/sub/nightly.yml')
        master.conf['LOCAL_JOBS_DIRPATH'] = 'local2/sub'
        path = os.path.join(master._base_path, 'local2/sub/nightly.yml')
        self.assertTrue(os.path.isfile(path))

        with cluster:
            cluster.sanity_check()
            scheduler = cluster.api.get_scheduler(
                NIGHTLY_LOCAL_JOB['scheduler']['name'])
            self.assertTrue(scheduler['enabled'])
            builder = cluster.api.get_builder(
                NIGHTLY_LOCAL_JOB['builder']['name'])
            self.assertEqual(builder['description'],
                             NIGHTLY_LOCAL_JOB['builder']['description'])
예제 #4
0
    def test_junit_step(self):  # pylint: disable=too-many-statements
        """Test customized JUnitShellCommand step with OK tests.

        Steps:
            - Spawn worker.
            - Have various commands create JUnit reports and parse them.

        """
        cluster = Cluster().start()
        cluster.sanity_check()

        local_repo = cluster.clone()
        parent = abspath(join(__file__, pardir))
        yaml = join(parent, 'main.yml')
        reports_dir = join(parent, 'reports')
        local_repo.push(yaml=yaml, dirs=(reports_dir, ))
        cluster.sanity_check()
        buildset = cluster.api.force(branch=local_repo.branch)
        self.assertEqual(buildset.result, 'failure')
        child_build = \
            buildset.buildrequest.build.children[0].buildrequest.build

        results = [(step.name, step.state_string, step.result)
                   for step in child_build.steps]
        expected = [
            (
                u'worker_preparation',
                u'worker ready',
                'success'
            ),
            (
                u'prevent unuseful restarts',
                u"'[ $(expr ...'",
                'success'
            ),
            (
                u'set the artifacts private url',
                u"property 'artifacts_private_url' set",
                'success'
            ),
            (
                u'Check worker OS distribution',
                u'finished',
                u'success'
            ),
            (
                u'Set the current builder id',
                u'finished',
                u'success'
            ),
            (
                u'Set the current build url',
                u'finished',
                u'success'
            ),
            (
                u'extract steps from yaml',
                u'finished',
                'success'
            ),
            (
                u'git pull',
                u'update',
                'success'),
            (
                u'SetProperty',
                u'Set',
                'success'
            ),
            (
                u'single report with one pass',
                u'T:1 E:0 F:0 S:0',
                'success'
            ),
            (
                u'three reports with lots of pass',
                u'T:217 E:0 F:0 S:0',
                # u'T:2134 E:0 F:0 S:108',
                'success'
            ),
            (
                u'no files in directory',
                u'no test results found',
                'warnings'
            ),
            (
                u'missing report directory',
                u'no test results found',
                'warnings'
            ),
            (
                u'single report with invalid data',
                u'no test results found',
                'warnings'
            ),
            (
                u'report with invalid data along valid report',
                u'T:1 E:0 F:0 S:0',
                'success'
            ),
            (
                u'single report with invalid extension',
                u'no test results found',
                'warnings'
            ),
            (
                u'report with failures and successful command',
                u'FAIL: toto.tests.sample.test_sample.test_sample',
                'failure'
            ),
            (
                u'report with no failures and failed command',
                u'T:1 E:0 F:0 S:0',
                'failure'
            ),
            (
                u'report with failures',
                u'FAIL: toto.tests.sample.test_sample.test_sample',
                'failure'
            ),
            (
                u'report with errors',
                u'ERROR: supervisor.test_01_deployment.TestGenericDeployment.'
                u'test_supervisor_configuration[os_trusty]',
                'failure'
            ),
            (
                u'report with skips',
                u'T:144 E:0 F:0 S:24',
                'success'),
            (
                u'report with both errors and failures',
                u'ERROR: supervisor.test_01_deployment.TestGenericDeployment.'
                u'test_supervisor_configuration[os_trusty]',
                'failure'
            ),
            (
                u'report with one xfail and one xpass',
                u'T:2 E:0 F:0 S:2',
                'success'
            ),
            (
                u'undeclared report directory and a pass',
                u'no test results found',
                'warnings'
            ),
            (
                u'undeclared report directory and a fail',
                u'no test results found',
                'failure'
            ),
            (
                u'test report paths with success',
                u'T:1 E:0 F:0 S:0',
                'success'
            ),
            (
                u'test report paths with failure',
                u'FAIL: toto.tests.sample.test_sample.test_sample',
                'failure'
            ),
            (
                u'test report paths with success and failure',
                u'FAIL: toto.tests.sample.test_sample.test_sample',
                'failure'
            ),
            (
                u'test report paths with success and failure in same',
                u'FAIL: toto.tests.sample.test_sample.test_sample',
                'failure'
            ),
            (
                u'test report paths only uploading success',
                u'T:1 E:0 F:0 S:0',
                'success'
            ),
            (
                u'test report paths only uploading failure',
                u'FAIL: toto.tests.sample.test_sample.test_sample',
                'failure'
            ),
            (
                u'test report paths without list',
                u'T:1 E:0 F:0 S:0',
                'success'
            ),
            (
                u'test report paths with non existing file',
                u'no test results found',
                'warnings'
            ),
            (
                u'test report paths with non matching glob',
                u'no test results found',
                'warnings'
            )
        ]

        self.assertEqual(results, expected)
        cluster.stop()