예제 #1
0
    def test_asc_diff_link(self, mocker):
        """Validate when configured with asc as ci-environment"""
        molecule_test_repo = 'molecule-validate-neutron-deploy'
        molecule_scenario_name = 'default'
        fork = 'rcbops'

        zz = mocker.MagicMock()
        zz.testsuite_props = {
            'REPO_URL': 'https://github.com/{}/rpc-openstack'.format(fork),
            'MOLECULE_GIT_COMMIT': SHA,
            'MOLECULE_TEST_REPO': molecule_test_repo,
            'MOLECULE_SCENARIO_NAME': molecule_scenario_name,
        }

        lgf = LinkGenerationFacade(zz)
        pass_fork = 'zreichert'
        pass_base = 'master'

        diff_link = lgf.github_diff_link(pass_fork, pass_base)
        assert diff_link == ('https://github.com/'
                             '{}/'
                             '{}/'
                             'compare/'
                             '{}...{}:{}'.format(fork, molecule_test_repo, SHA,
                                                 pass_fork, pass_base))
예제 #2
0
    def test_asc_failure_link(self, asc_zigzag_config_file, mocker):
        """Validate when configured with a config file similar to the one used by the asc-team"""

        molecule_test_repo = 'molecule-validate-neutron-deploy'
        molecule_scenario_name = 'default'
        testsuite_props = {
            'REPO_URL': 'https://github.com/rcbops/rpc-openstack',
            'MOLECULE_GIT_COMMIT': SHA,
            'MOLECULE_TEST_REPO': molecule_test_repo,
            'MOLECULE_SCENARIO_NAME': molecule_scenario_name,
        }

        # mock
        zz = mocker.MagicMock()
        zztl = mocker.MagicMock()
        zztl._mediator = zz

        zztl.test_file = TEST_FILE
        zztl.failure_output = 'This property contains truncated content......'
        zztl.full_failure_output = FAILURE_OUTPUT

        zz.config_dict = ZigZagConfig(asc_zigzag_config_file, testsuite_props)

        lgf = LinkGenerationFacade(zz)
        failure_link = lgf.github_testlog_failure_link(zztl)
        assert failure_link == ('https://github.com/'
                                'rcbops/'
                                '{}/'
                                'tree/{}/'
                                'molecule/{}/tests/'
                                '{}#L{}'.format(molecule_test_repo, SHA,
                                                molecule_scenario_name,
                                                TEST_FILE, LINE_NUMBER))
예제 #3
0
    def test_asc_file_link(self, asc_zigzag_config_file, mocker):
        """Validate fallback to file with no line number"""

        molecule_test_repo = 'molecule-validate-neutron-deploy'
        molecule_scenario_name = 'default'
        testsuite_props = {
            'REPO_URL': 'https://github.com/rcbops/rpc-openstack',
            'MOLECULE_GIT_COMMIT': SHA,
            'MOLECULE_TEST_REPO': molecule_test_repo,
            'MOLECULE_SCENARIO_NAME': molecule_scenario_name,
        }

        # Mock
        zz = mocker.MagicMock()
        zztl = mocker.MagicMock()

        zztl.test_file = TEST_FILE
        zztl.failure_output = 'This property contains truncated content......'
        zztl.full_failure_output = 'I dont contain an assert message'
        zztl.def_line_number = ''

        zz.config_dict = ZigZagConfig(asc_zigzag_config_file, testsuite_props)

        lgf = LinkGenerationFacade(zz)
        failure_link = lgf.github_testlog_failure_link(zztl)
        assert failure_link == ('https://github.com/'
                                'rcbops/'
                                '{}/'
                                'tree/{}/'
                                'molecule/{}/tests/'
                                '{}'.format(molecule_test_repo, SHA,
                                            molecule_scenario_name, TEST_FILE))
예제 #4
0
    def test_mk8s_pr_testing(self, mk8s_zigzag_config_file, mocker):
        """Validate when configured with a config file similar to the one used by the mk8s-team testing a PR"""
        change_branch = 'asc-123/master/this_is_my_feature'
        change_fork = 'zreichert'

        zz = mocker.MagicMock()
        testsuite_props = {
            'GIT_URL': 'https://github.com/rcbops/mk8s.git',
            'GIT_COMMIT': SHA,
            'CHANGE_BRANCH': change_branch,
            'CHANGE_FORK': change_fork,
        }

        zztl = mocker.MagicMock()
        zztl.test_file = TEST_FILE
        zztl.failure_output = 'This property contains truncated content......'
        zztl.full_failure_output = FAILURE_OUTPUT

        zz.config_dict = ZigZagConfig(mk8s_zigzag_config_file, testsuite_props)

        lgf = LinkGenerationFacade(zz)
        failure_link = lgf.github_testlog_failure_link(zztl)
        assert failure_link == ('https://github.com/'
                                '{}/'
                                'mk8s/'
                                'tree/{}/'
                                'tools/installer/tests/'
                                '{}#L{}'.format(change_fork, SHA, TEST_FILE,
                                                LINE_NUMBER))
예제 #5
0
    def test_asc_failure_link(self, mocker):
        """Validate when configured with asc as ci-environment"""
        molecule_test_repo = 'molecule-validate-neutron-deploy'
        molecule_scenario_name = 'default'

        zz = mocker.MagicMock()
        zz.ci_environment = 'asc'
        zz.testsuite_props = {
            'REPO_URL': 'https://github.com/rcbops/rpc-openstack',
            'MOLECULE_GIT_COMMIT': SHA,
            'MOLECULE_TEST_REPO': molecule_test_repo,
            'MOLECULE_SCENARIO_NAME': molecule_scenario_name,
        }

        zztl = mocker.MagicMock()
        zztl.test_file = TEST_FILE
        zztl.failure_output = 'This property contains truncated content......'
        zztl.full_failure_output = FAILURE_OUTPUT

        lgf = LinkGenerationFacade(zz)
        failure_link = lgf.github_testlog_failure_link(zztl)
        assert failure_link == ('https://github.com/'
                                'rcbops/'
                                '{}/'
                                'tree/{}/'
                                'molecule/{}/'
                                '{}#L{}'.format(molecule_test_repo, SHA,
                                                molecule_scenario_name,
                                                TEST_FILE, LINE_NUMBER))
예제 #6
0
    def test_asc_diff_link_missing_info(self, mocker):
        """diff link should be 'Unknown' when it cant be calculated"""

        zz = mocker.MagicMock()
        zz.testsuite_props = {}

        lgf = LinkGenerationFacade(zz)
        pass_fork = 'zreichert'
        pass_base = 'master'

        diff_link = lgf.github_diff_link(pass_fork, pass_base)
        assert diff_link == 'Unknown'
예제 #7
0
    def test_asc_missing_data(self, asc_zigzag_config_file, mocker):
        """Failure link should be None when it cant be calculated"""
        zz = mocker.MagicMock()

        zztl = mocker.MagicMock()
        zztl.test_file = TEST_FILE
        zztl.failure_output = 'This property contains truncated content......'
        zztl.full_failure_output = FAILURE_OUTPUT

        zz.config_dict = ZigZagConfig(asc_zigzag_config_file, {})

        lgf = LinkGenerationFacade(zz)
        failure_link = lgf.github_testlog_failure_link(zztl)
        assert failure_link is None
예제 #8
0
    def test_asc_missing_data(self, mocker):
        """Failure link should be None when it cant be calculated"""
        zz = mocker.MagicMock()
        zz.ci_environment = 'asc'
        zz.testsuite_props = {}

        zztl = mocker.MagicMock()
        zztl.test_file = TEST_FILE
        zztl.failure_output = 'This property contains truncated content......'
        zztl.full_failure_output = FAILURE_OUTPUT

        lgf = LinkGenerationFacade(zz)
        failure_link = lgf.github_testlog_failure_link(zztl)
        assert failure_link is None
예제 #9
0
    def _get_link_generation_facade(cls, mediator):
        """Get The instance of LinkGenerationFacade

        Args:
            mediator (ZigZag): The ZigZag mediator

        Returns:
            LinkGenerationFacade
        """
        return LinkGenerationFacade(mediator)
예제 #10
0
    def test_mk8s_diff_link(self, mocker):
        """Validate when configured with mk8s as ci-environment"""
        fork = 'rcbops'
        repo_name = 'mk8s'

        zz = mocker.MagicMock()
        zz.testsuite_props = {
            'GIT_URL': 'https://github.com/{}/{}.git'.format(fork, repo_name),
            'GIT_COMMIT': SHA,
        }

        lgf = LinkGenerationFacade(zz)
        pass_fork = 'zreichert'
        pass_base = 'master'

        diff_link = lgf.github_diff_link(pass_fork, pass_base)
        assert diff_link == ('https://github.com/'
                             '{}/'
                             '{}/'
                             'compare/'
                             '{}...{}:{}'.format(fork, repo_name, SHA,
                                                 pass_fork, pass_base))
예제 #11
0
    def test_mk8s_master_branch(self, mocker):
        """Validate when configured with mk8s as ci-environment"""

        zz = mocker.MagicMock()
        zz.ci_environment = 'mk8s'
        zz.testsuite_props = {
            'GIT_URL': 'https://github.com/rcbops/mk8s.git',
            'GIT_COMMIT': SHA,
        }

        zztl = mocker.MagicMock()
        zztl.test_file = TEST_FILE
        zztl.failure_output = 'This property contains truncated content......'
        zztl.full_failure_output = FAILURE_OUTPUT

        lgf = LinkGenerationFacade(zz)
        failure_link = lgf.github_testlog_failure_link(zztl)
        assert failure_link == ('https://github.com/'
                                'rcbops/'
                                'mk8s/'
                                'tree/{}/'
                                'tools/installer/'
                                '{}#L{}'.format(SHA, TEST_FILE, LINE_NUMBER))
예제 #12
0
    def test_mk8s_master_branch(self, mk8s_zigzag_config_file, mocker):
        """Validate when configured with a config file similar to the one used by the mk8s-team"""

        zz = mocker.MagicMock()
        testsuite_props = {
            'GIT_URL': 'https://github.com/rcbops/mk8s.git',
            'GIT_COMMIT': SHA,
        }

        zztl = mocker.MagicMock()
        zztl.test_file = TEST_FILE
        zztl.failure_output = 'This property contains truncated content......'
        zztl.full_failure_output = FAILURE_OUTPUT

        zz.config_dict = ZigZagConfig(mk8s_zigzag_config_file, testsuite_props)

        lgf = LinkGenerationFacade(zz)
        failure_link = lgf.github_testlog_failure_link(zztl)
        assert failure_link == ('https://github.com/'
                                'rcbops/'
                                'mk8s/'
                                'tree/{}/'
                                'tools/installer/tests/'
                                '{}#L{}'.format(SHA, TEST_FILE, LINE_NUMBER))