Beispiel #1
0
    def setUp(self):
        super(TestNotifications, self).setUp()
        config = configparser.RawConfigParser()
        config.read("projects.ini")
        config.set('DEFAULT', 'datadir', tempfile.mkdtemp())
        config.set('DEFAULT', 'scriptsdir', tempfile.mkdtemp())
        config.set('DEFAULT', 'baseurl',
                   "file://%s" % config.get('DEFAULT', 'datadir'))

        self.config = ConfigOptions(config)
        self.commit = db.Commit(dt_commit=123,
                                project_name='foo',
                                commit_hash='1c67b1ab8c6fe273d4e175a14f0df5'
                                'd3cbbd0edf',
                                repo_dir='/home/dlrn/data/foo',
                                distro_hash='c31d1b18eb5ab5aed6721fc4fad06c9'
                                'bd242490f',
                                dt_distro=123,
                                distgit_dir='/home/dlrn/data/foo_distro',
                                commit_branch='master',
                                dt_build=1441245153)
        self.packages = [{
            'upstream':
            'https://github.com/openstack/foo',
            'name':
            'foo',
            'maintainers': ['*****@*****.**'],
            'master-distgit':
            'https://github.com/rdo-packages/foo-distgit.git'
        }]
Beispiel #2
0
 def setUp(self):
     super(TestProcessBuildResult, self).setUp()
     config = configparser.RawConfigParser()
     config.read("projects.ini")
     config.set('DEFAULT', 'datadir', tempfile.mkdtemp())
     config.set('DEFAULT', 'scriptsdir', tempfile.mkdtemp())
     config.set('DEFAULT', 'baseurl',
                "file://%s" % config.get('DEFAULT', 'datadir'))
     self.config = ConfigOptions(config)
     self.commit = db.Commit(dt_commit=123,
                             project_name='foo',
                             type="rpm",
                             commit_hash='1c67b1ab8c6fe273d4e175a14f0df5'
                             'd3cbbd0edf',
                             repo_dir='/home/dlrn/data/foo',
                             distro_hash='c31d1b18eb5ab5aed6721fc4fad06c9'
                             'bd242490f',
                             dt_distro=123,
                             distgit_dir='/home/dlrn/data/foo_distro',
                             commit_branch='master',
                             dt_build=1441245153)
     self.db_fd, filepath = tempfile.mkstemp()
     self.session = mocked_session("sqlite:///%s" % filepath)
     self.packages = [{
         'upstream': 'https://github.com/openstack/foo',
         'name': 'foo',
         'maintainers': '*****@*****.**'
     }, {
         'upstream': 'https://github.com/openstack/test',
         'name': 'test',
         'maintainers': '*****@*****.**'
     }]
Beispiel #3
0
    def test_build_package_rhpkg(self, ki_mock, tm_mock, rh_mock, rn_mock,
                                 ld_mock, env_mock, rc_mock):
        self.config.koji_use_rhpkg = True
        commit = db.Commit(dt_commit=123,
                           project_name='python-pysaml2',
                           commit_hash='1234567890abcdef',
                           distro_hash='1234567890abcdef',
                           extended_hash='1234567890abcdef',
                           dt_distro=123,
                           dt_extended=123)

        driver = KojiBuildDriver(cfg_options=self.config)
        driver.build_package(output_directory=self.temp_dir,
                             package_name='python-pysaml2',
                             commit=commit)

        expected_env = [
            mock.call(['koji', 'download-task', '--logs', '5678'],
                      _err=driver._process_koji_output,
                      _out=driver._process_koji_output,
                      _cwd=self.rhpkg_extra_dir,
                      _env={'PATH': '/usr/bin/'})
        ]

        pkg_date = strftime("%Y-%m-%d-%H%M%S", localtime(_mocked_time()))
        expected_rh = [
            mock.call(
                '%s/rhpkg' % self.temp_dir, 'import', '--skip-diff',
                '%s/python-pysaml2-3.0-1a.el7.centos.src'
                '.rpm' % self.temp_dir),
            mock.call(
                '%s/rhpkg' % self.temp_dir, 'commit', '-p', '-m',
                'DLRN build at %s\n\n'
                'Source SHA: 1234567890abcdef\n'
                'Dist SHA: 1234567890abcdef\n'
                'NVR: python-pysaml2-3.0-1a.el7.centos\n' % pkg_date),
            mock.call('/usr/bin/git log', '--pretty=format:%H %ct', '-1', '.'),
            mock.call('%s/rhpkg' % self.temp_dir,
                      'build',
                      '--skip-nvr-check',
                      scratch=True)
        ]

        # 1- kinit (handled by kb_mock)
        # 2- rhpkg import (handled by rh_mock)
        # 3- rhpkg commit (handled by rh_mock)
        # 4- git log (handled by rh_mock)
        # 5- rename (handled by rn_mock)
        # 5- rhpkg build (handled by rh_mock)
        # 6- koji download (handled by env_mock)
        # 7- restorecon (handled by rc_mock)
        self.assertEqual(ki_mock.call_count, 1)
        self.assertEqual(rh_mock.call_count, 4)
        self.assertEqual(env_mock.call_count, 1)
        self.assertEqual(rc_mock.call_count, 1)
        self.assertEqual(rn_mock.call_count, 1)
        self.assertEqual(env_mock.call_args_list, expected_env)
        self.assertEqual(rh_mock.call_args_list, expected_rh)
Beispiel #4
0
    def setUp(self):
        super(TestSyncRepo, self).setUp()
        config = configparser.RawConfigParser(default_options)
        config.read("projects.ini")
        config.set('DEFAULT', 'datadir', tempfile.mkdtemp())
        config.set('DEFAULT', 'scriptsdir', tempfile.mkdtemp())
        config.set('DEFAULT', 'baseurl', "file://%s" % config.get('DEFAULT',
                                                                  'datadir'))
        config.set('DEFAULT', 'rsyncport', '30000')
        config.set('DEFAULT', 'rsyncdest', 'user@host:/directory')

        self.config = ConfigOptions(config)
        self.commit = db.Commit(dt_commit=123, project_name='foo',
                                commit_hash='1c67b1ab8c6fe273d4e175a14f0df5'
                                            'd3cbbd0edf',
                                repo_dir='/home/dlrn/data/foo',
                                distro_hash='c31d1b18eb5ab5aed6721fc4fad06c9'
                                            'bd242490f',
                                dt_distro=123,
                                distgit_dir='/home/dlrn/data/foo_distro',
                                commit_branch='master', dt_build=1441245153)
Beispiel #5
0
    def test_is_commit_in_dirs_component(self, ex_mock):
        commit = db.Commit(dt_commit=123,
                           project_name='foo',
                           type="rpm",
                           component='bar',
                           commit_hash='1c67b1ab8c6fe273d4e175a14f0df5'
                           'd3cbbd0edf',
                           repo_dir='/home/dlrn/data/foo',
                           distro_hash='c31d1b18eb5ab5aed6721fc4fad06c9'
                           'bd242490f',
                           dt_distro=123,
                           distgit_dir='/home/dlrn/data/foo_distro',
                           commit_branch='master',
                           dt_build=1441245153,
                           artifacts='foo-1.0.0.rpm')

        dirlist = ('/home/dlrn/data/repos/consistent,'
                   '/home/dlrn/data/repos/foo-ci')
        basedir = '/home/dlrn/data/repos/'
        expected = [
            mock.call('/home/dlrn/data/repos/consistent/'
                      'foo-1.0.0.rpm'),
            mock.call('/home/dlrn/data/repos/component/bar/consistent/'
                      'foo-1.0.0.rpm'),
            mock.call('/home/dlrn/data/repos/foo-ci/'
                      'foo-1.0.0.rpm'),
            mock.call('/home/dlrn/data/repos/component/bar/foo-ci/'
                      'foo-1.0.0.rpm')
        ]

        purge.is_commit_in_dirs(commit,
                                dirlist,
                                basedir,
                                component_list=['bar'])

        self.assertEqual(ex_mock.call_args_list, expected)