def test_block_closed(): stream = StreamStub() messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date) messages.blockClosed('dummyMessage') assert stream.observed_output.strip() == textwrap.dedent("""\ ##teamcity[blockClosed timestamp='2000-11-02T10:23:01.556' name='dummyMessage'] """).strip().encode('utf-8')
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 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 test_build_statistic_value(): stream = StreamStub() messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date) messages.buildStatisticValue('CustomKey', '1234') assert stream.observed_output.strip() == textwrap.dedent("""\ ##teamcity[buildStatisticValue timestamp='2000-11-02T10:23:01.556' key='CustomKey' value='1234'] """).strip().encode('utf-8')
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')
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')
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')
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')
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')
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')
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')
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')
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')
def test_test_failed(): stream = StreamStub() messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date) messages.testFailed(testName='only a test', message='some message', details='details') assert stream.observed_output.strip() == textwrap.dedent("""\ ##teamcity[testFailed timestamp='2000-11-02T10:23:01.556' details='details' message='some message' name='only a test'] """).strip().encode('utf-8')
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')
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 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')
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.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 = []
def _run_tests_for_shell( tc: TeamCity, tc_msg: TeamcityServiceMessages, shell_name: str, tests_info: AutoTestsInfo, ) -> Optional[int]: build_id = None if is_shell_uses_package(shell_name, tests_info): if tests_info.re_run_builds: success, build_url = is_last_build_successful( tc, shell_name, tests_info) if success: tc_msg.testIgnored( shell_name, f"{shell_name} last auto tests for this package and commit " f"id was successful, skip it. {build_url}", ) else: build_id, build_url = trigger_auto_tests_build( tc, shell_name, tests_info) click.echo( f"{shell_name} Re run automation tests. {build_url}") else: build_id, build_url = trigger_auto_tests_build( tc, shell_name, tests_info) click.echo( f"{shell_name} Automation tests build triggered. {build_url}") else: tc_msg.testIgnored( shell_name, f"{shell_name} is not uses package with this version, skipped tests", ) return build_id
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, 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)
def test_one_property(self): stream = MessagesTest.StreamStub() messages = TeamcityServiceMessages(output=stream, now=lambda: datetime.min) messages.message("dummyMessage", fruit="apple") self.assertEqual( stream.observed_output, "\n##teamcity[dummyMessage timestamp='0001-01-01T00:00' fruit='apple']\n" )
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())
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"
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(self): stream = MessagesTest.StreamStub() messages = TeamcityServiceMessages(output=stream, now=lambda: datetime.min) messages.message("dummyMessage", fruit="apple", meat="steak", pie="raspberry") self.assertEqual( stream.observed_output, "\n##teamcity[dummyMessage timestamp='0001-01-01T00:00' " "fruit='apple' meat='steak' pie='raspberry']\n", )
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')
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
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')
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 == ("\n##teamcity[%s timestamp='2000-11-02T10:23:01.556']\n" % bjork).encode('utf-8')
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')
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_blocks_with_flowid(): stream = StreamStub() messages = TeamcityServiceMessages(output=stream, now=lambda: fixed_date) with messages.block("Doing something that's important", flowId='a'): messages.message("Doing stuff") expected_output = textwrap.dedent("""\ ##teamcity[blockOpened timestamp='2000-11-02T10:23:01.556' flowId='a' name='Doing something that|'s important'] ##teamcity[Doing stuff timestamp='2000-11-02T10:23:01.556'] ##teamcity[blockClosed timestamp='2000-11-02T10:23:01.556' flowId='a' name='Doing something that|'s important'] """) expected_output = expected_output.encode('utf-8') assert stream.observed_output == expected_output
def test_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.message('foo', u=bjork, b=bjork.encode('utf-8')) expected_output = b( "##teamcity[foo timestamp='2000-11-02T10:23:01.556' " "b='Bj\xc3\xb6rk Gu\xc3\xb0mundsd\xc3\xb3ttir' " "u='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' )
class TeamcityStatisticsReport(pep8.StandardReport): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.teamcity_messages = TeamcityServiceMessages() def report_statistics(self, error_key, value): self.teamcity_messages.message('buildStatisticValue', key='PEP8-'+error_key, value=str(value)) def print_statistics(self, prefix=''): super().print_statistics(prefix) for error_key in sorted(self.messages): self.report_statistics(error_key, self.counters[error_key]) self.report_statistics('TOTAL', self.get_count()) self.report_statistics('TOTAL-ERRORS', self.get_count('E')) self.report_statistics('TOTAL-WARNINGS', self.get_count('W'))
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(stream)
def main(): parser = argparse.ArgumentParser(description='run_memory_map') parser.add_argument('--toolchain', type=str, help='GCC toolchain path', default='') parser.add_argument('--binutils_prefix', type=str, help='GNU binutils prefix', default='') parser.add_argument('--file', type=str, help='Binary file') parser.add_argument('--key_name', type=str, help='TeamCity buildStatisticValue key name suffix', default='none') args = parser.parse_args() tsm = TeamcityServiceMessages() sections = parse_size(args.toolchain, args.binutils_prefix, args.file) if sections: flash_size = 0 ram_size = 0 other_size = 0 for section in sections: if section.name in ['.text', '.ARM.exidx', '.relocate']: flash_size += section.size elif section.name in ['.bss', '.stack']: ram_size += section.size else: other_size += section.size tsm.message('buildStatisticValue', key='FLASH ({0})'.format(args.key_name), value=str(flash_size)) tsm.message('buildStatisticValue', key='RAM ({0})'.format(args.key_name), value=str(ram_size)) # tsm.message('buildStatisticValue', key='OTHER ({0})'.format(args.key_name), value=str(other_size)) else: tsm.buildProblem('Unable to detect sections', '')