Ejemplo n.º 1
0
    def _sync_artifact_as_xunit(self, jobstep, artifact):
        resp = self.fetch_artifact(jobstep, artifact)

        # TODO(dcramer): requests doesnt seem to provide a non-binary file-like
        # API, so we're stuffing it into StringIO
        handler = XunitHandler(jobstep)
        handler.process(StringIO(resp.content))
Ejemplo n.º 2
0
def test_result_generation():
    jobstep = JobStep(
        id=uuid.uuid4(),
        project_id=uuid.uuid4(),
        job_id=uuid.uuid4(),
    )

    fp = StringIO(SAMPLE_XUNIT)

    handler = XunitHandler(jobstep)
    results = handler.get_tests(fp)

    assert len(results) == 2

    r1 = results[0]
    assert type(r1) == TestResult
    assert r1.step == jobstep
    assert r1.package is None
    assert r1.name == 'tests.test_report'
    assert r1.duration == 0.0
    assert r1.result == Result.failed
    assert r1.message == """tests/test_report.py:1: in <module>
>   import mock
E   ImportError: No module named mock"""
    r2 = results[1]
    assert type(r2) == TestResult
    assert r2.step == jobstep
    assert r2.package is None
    assert r2.name == 'tests.test_report.ParseTestResultsTest.test_simple'
    assert r2.duration == 1.65796279907
    assert r2.result == Result.passed
    assert r2.message == ''
    assert r2.reruns == 1
Ejemplo n.º 3
0
    def _sync_artifact_as_xunit(self, jobstep, artifact):
        resp = self.fetch_artifact(jobstep, artifact)

        # TODO(dcramer): requests doesnt seem to provide a non-binary file-like
        # API, so we're stuffing it into StringIO
        handler = XunitHandler(jobstep)
        handler.process(StringIO(resp.content))
Ejemplo n.º 4
0
    def _sync_artifact_as_xunit(self, jobstep, job_name, build_no, artifact):
        url = '{base}/job/{job}/{build}/artifact/{artifact}'.format(
            base=self.base_url, job=job_name,
            build=build_no, artifact=artifact['relativePath'],
        )

        resp = requests.get(url, stream=True, timeout=15)

        # TODO(dcramer): requests doesnt seem to provide a non-binary file-like
        # API, so we're stuffing it into StringIO
        handler = XunitHandler(jobstep.job)
        handler.process(StringIO(resp.content))
Ejemplo n.º 5
0
    def _sync_artifact_as_xunit(self, jobstep, artifact):
        resp = self.fetch_artifact(jobstep, artifact)

        # TODO(dcramer): requests doesnt seem to provide a non-binary file-like
        # API, so we're stuffing it into StringIO
        try:
            handler = XunitHandler(jobstep)
            handler.process(StringIO(resp.content))
        except Exception:
            db.session.rollback()
            self.logger.exception(
                'Failed to sync test results for job step %s', jobstep.id)
        else:
            db.session.commit()