Beispiel #1
0
def test_test_stderr():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.testStdErr(testName='only a test', out='out')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[testStdErr timestamp='2000-11-02T10:23:01.556' name='only a test' out='out']
        """).strip().encode('utf-8')
Beispiel #2
0
def test_test_suite_finished():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.testSuiteFinished('suite emotion')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[testSuiteFinished timestamp='2000-11-02T10:23:01.556' name='suite emotion']
        """).strip().encode('utf-8')
Beispiel #3
0
def test_test_ignored():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.testIgnored(testName='only a test', message='some message')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[testIgnored timestamp='2000-11-02T10:23:01.556' message='some message' name='only a test']
        """).strip().encode('utf-8')
    def __init__(self,
                 num_masters: int, num_agents: int, num_public_agents: int,
                 stable_installer_url: str, installer_url: str,
                 aws_region: str, aws_access_key_id: str, aws_secret_access_key: str,
                 default_os_user: str,
                 config_yaml_override_install: str, config_yaml_override_upgrade: str,
                 dcos_api_session_factory_install: VpcClusterUpgradeTestDcosApiSessionFactory,
                 dcos_api_session_factory_upgrade: VpcClusterUpgradeTestDcosApiSessionFactory):

        self.dcos_api_session_factory_install = dcos_api_session_factory_install
        self.dcos_api_session_factory_upgrade = dcos_api_session_factory_upgrade
        self.num_masters = num_masters
        self.num_agents = num_agents
        self.num_public_agents = num_public_agents
        self.stable_installer_url = stable_installer_url
        self.installer_url = installer_url
        self.aws_region = aws_region
        self.aws_access_key_id = aws_access_key_id
        self.aws_secret_access_key = aws_secret_access_key
        self.default_os_user = default_os_user
        self.config_yaml_override_install = config_yaml_override_install
        self.config_yaml_override_upgrade = config_yaml_override_upgrade
        self.acs_token = None

        self.teamcity_msg = TeamcityServiceMessages()

        # the two following properties are set when running setup_cluster_workload, here we default them to empty
        # values.
        self.test_app_ids = []
        self.tasks_start = []
Beispiel #5
0
def test_compilation_finished():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.compilationFinished('gcc')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[compilationFinished timestamp='2000-11-02T10:23:01.556' compiler='gcc']
        """).strip().encode('utf-8')
def main(tc_user: str, tc_password: str):
    errors = []
    triggered_builds: dict[str, int] = {}
    tc = TeamCity(TC_URL, auth=(tc_user, tc_password))
    tests_info = AutoTestsInfo.get_current(tc)
    tc_msg = TeamcityServiceMessages()
    if tests_info.re_run_builds:
        click.echo("Re run failed builds")
    else:
        click.echo("Run automated tests")

    with tc_msg.testSuite("Automation tests"):
        tc_msg.testCount(len(tests_info.supported_shells))
        for shell_name in tests_info.supported_shells:
            try:
                build_id = _run_tests_for_shell(tc, tc_msg, shell_name,
                                                tests_info)
                if build_id:
                    triggered_builds[shell_name] = build_id
            except Exception as e:
                errors.append(e)
                click.echo(e, err=True)

        builds_statuses, new_errors = _wait_build_finish(
            tc, tc_msg, triggered_builds)
        errors.extend(new_errors)

        if errors:
            raise Exception("There were errors running automation tests.")
    return all(builds_statuses.values())
Beispiel #7
0
 def __init__(self, file, info, sync=True, **kwargs):
     self.messages = TeamcityServiceMessages(file)
     self.messages.message('compile-info',
                           name=info[0],
                           date=info[1],
                           time=info[2])
     self.sync = sync
    def __init__(self, stream=_real_stdout, descriptions=None, verbosity=None):
        super(TeamcityTestResult, self).__init__()

        self.test_started_datetime_map = {}
        self.failed_tests = set()
        self.subtest_failures = {}
        self.messages = TeamcityServiceMessages(_real_stdout)
Beispiel #9
0
def test_build_problem():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.buildProblem(description='something is wrong', identity='me')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[buildProblem timestamp='2000-11-02T10:23:01.556' description='something is wrong' identity='me']
        """).strip().encode('utf-8')
Beispiel #10
0
def test_build_status():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.buildStatus(status='failure', text='compile error')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[buildStatus timestamp='2000-11-02T10:23:01.556' status='failure' text='compile error']
        """).strip().encode('utf-8')
Beispiel #11
0
def test_import_data():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.importData('junit', '/path/to/junit.xml')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[importData timestamp='2000-11-02T10:23:01.556' path='/path/to/junit.xml' type='junit']
        """).strip().encode('utf-8')
Beispiel #12
0
def test_progress_message():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.progressMessage('doing stuff')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[progressMessage 'doing stuff']
        """).strip().encode('utf-8')
Beispiel #13
0
def test_block_opened():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.blockOpened('dummyMessage')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[blockOpened timestamp='2000-11-02T10:23:01.556' name='dummyMessage']
        """).strip().encode('utf-8')
Beispiel #14
0
def test_custom_message():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.customMessage('blah blah blah', status='all good')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[message timestamp='2000-11-02T10:23:01.556' errorDetails='' status='all good' text='blah blah blah']
        """).strip().encode('utf-8')
Beispiel #15
0
def test_publish_artifacts():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.publishArtifacts('/path/to/file')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[publishArtifacts '/path/to/file']
        """).strip().encode('utf-8')
Beispiel #16
0
def test_disable_service_messages():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.disableServiceMessages()
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[disableServiceMessages timestamp='2000-11-02T10:23:01.556']
        """).strip().encode('utf-8')
Beispiel #17
0
def test_build_statistic_lines_uncovered():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.buildStatisticLinesUncovered(5)
    assert stream.observed_output.strip() == textwrap.dedent("""\
            ##teamcity[buildStatisticValue timestamp='2000-11-02T10:23:01.556' key='CodeCoverageAbsLUncovered' value='5']
        """).strip().encode('utf-8')
Beispiel #18
0
def test_set_parameter():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.setParameter(name='env', value='mt3')
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[setParameter timestamp='2000-11-02T10:23:01.556' name='env' value='mt3']
        """).strip().encode('utf-8')
    def __init__(self):
        super(TeamcityReport, self).__init__()

        self.messages = TeamcityServiceMessages(_real_stdout)
        self.test_started_datetime_map = {}
        self.config = None
        self.total_tests = 0
        self.enabled = False
def test_three_properties():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    messages.message('dummyMessage',
                     fruit='apple',
                     meat='steak',
                     pie='raspberry')
    assert stream.observed_output == "\n##teamcity[dummyMessage timestamp='2000-11-02T10:23:01.556' fruit='apple' meat='steak' pie='raspberry']\n"
Beispiel #21
0
    def __init__(self, output_capture_enabled, coverage_controller):
        self.coverage_controller = coverage_controller
        self.output_capture_enabled = output_capture_enabled

        self.teamcity = TeamcityServiceMessages()
        self.test_start_reported_mark = set()

        self.max_reported_output_size = 1 * 1024 * 1024
        self.reported_output_chunk_size = 50000
Beispiel #22
0
def test_progress():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    with messages.progress('only a test'):
        pass
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[progressStart 'only a test']
        ##teamcity[progressFinish 'only a test']
        """).strip().encode('utf-8')
Beispiel #23
0
def test_test():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    with messages.test('only a test'):
        pass
    assert stream.observed_output.strip() == textwrap.dedent("""\
        ##teamcity[testStarted timestamp='2000-11-02T10:23:01.556' name='only a test']
        ##teamcity[testFinished timestamp='2000-11-02T10:23:01.556' name='only a test']
        """).strip().encode('utf-8')
Beispiel #24
0
    def run(self, test):
        # noinspection PyBroadException
        try:
            total_tests = test.countTestCases()
            TeamcityServiceMessages(_real_stdout).testCount(total_tests)
        except:
            pass

        return super(TeamcityTestRunner, self).run(test)
Beispiel #25
0
    def __init__(self, stream=_real_stdout, descriptions=None, verbosity=None):
        super(TeamcityTestResult, self).__init__()

        # Some code may ask for self.failfast, see unittest2.case.TestCase.subTest
        self.failfast = getattr(self, "failfast", False)

        self.test_started_datetime_map = {}
        self.failed_tests = set()
        self.subtest_failures = {}
        self.messages = TeamcityServiceMessages(_real_stdout)
    def __init__(self, configuration, project_root):
        super().__init__(configuration, project_root)

        # This accounts for the volume mapping from the container.
        # Our local /results is mapped to some relative ./results on the host,
        # so we use /results/artifacts to copy our files but results/artifacts as
        # an artifact path for teamcity.
        # TODO abstract out the volume mapping
        self.artifact_dir = Path("/results/artifacts")

        self.teamcity_messages = TeamcityServiceMessages()
def test_progress_message_unicode():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    if sys.version_info < (3, ):
        bjork = 'Bj\xc3\xb6rk Gu\xc3\xb0mundsd\xc3\xb3ttir'.decode('utf-8')
    else:
        bjork = b('Bj\xc3\xb6rk Gu\xc3\xb0mundsd\xc3\xb3ttir').decode('utf-8')
    messages.progressMessage(bjork)
    expected_output = b("##teamcity[progressMessage "
                        "'Bj\xc3\xb6rk Gu\xc3\xb0mundsd\xc3\xb3ttir']")
    assert stream.observed_output.strip() == expected_output
def test_handling_eagain_ioerror():
    stream = StreamStub(raise_ioerror=errno.EAGAIN)
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    assert stream.raise_ioerror == errno.EAGAIN
    messages.testStarted('only a test')
    assert stream.raise_ioerror is None
    assert stream.observed_output == b('##teamcity['
                                       'testStarted'
                                       ' timestamp=\'2000-11-02T10:23:01.556\''
                                       ' name=\'only a test\''
                                       ']\n')
def test_unicode():
    stream = StreamStub()
    messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date)
    if sys.version_info < (3, ):
        bjork = 'Bj\xc3\xb6rk Gu\xc3\xb0mundsd\xc3\xb3ttir'.decode('utf-8')
    else:
        bjork = b('Bj\xc3\xb6rk Gu\xc3\xb0mundsd\xc3\xb3ttir').decode('utf-8')
    messages.message(bjork)
    assert stream.observed_output == (
        "##teamcity[%s timestamp='2000-11-02T10:23:01.556']\n" %
        bjork).encode('utf-8')
Beispiel #30
0
    def __init__(self, stream_opener, config):
        super(TeamcityFormatter, self).__init__(stream_opener, config)
        self._messages = TeamcityServiceMessages()

        self.__feature = None
        self.__scenario = None
        self.__steps = deque()
        self.__scenario_opened = False
        self.__feature_opened = False

        self.__test_start_time = None