示例#1
0
文件: test_scm.py 项目: joyxu/koji
    def test_checkout_svn_ssh(self):

        url = "svn+ssh://user@nocommon/dist?rpms/foo/EL3#revision"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir,
                     session=self.session,
                     uploadpath=self.uploadpath,
                     logfile=self.logfile)
        self.assertEqual(scm.use_common, False)
        self.symlink.assert_not_called()
        # expected commands
        cmd = [
            'svn', 'checkout', '-r', 'revision',
            'svn+ssh://user@nocommon/dist/rpms/foo/EL3', 'rpms/foo/EL3'
        ]
        call1 = mock.call(self.session,
                          cmd[0],
                          cmd,
                          self.logfile,
                          self.uploadpath,
                          cwd=self.tempdir,
                          logerror=1,
                          append=False,
                          env=None)
        self.log_output.assert_has_calls([call1])
示例#2
0
文件: test_scm.py 项目: joyxu/koji
    def test_checkout_error_in_command(self):

        url = "git://nocommon/koji.git#asdasd"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        self.log_output.return_value = 1
        with self.assertRaises(koji.BuildError):
            scm.checkout(self.tempdir,
                         session=self.session,
                         uploadpath=self.uploadpath,
                         logfile=self.logfile)
        self.assertEqual(scm.use_common, False)
        self.symlink.assert_not_called()
        # expected commands
        cmd = [
            'git', 'clone', '-n', 'git://nocommon/koji.git',
            self.tempdir + '/koji'
        ]
        call1 = mock.call(self.session,
                          cmd[0],
                          cmd,
                          self.logfile,
                          self.uploadpath,
                          cwd=self.tempdir,
                          logerror=1,
                          append=False,
                          env=None)
        # should have errored after first command
        self.log_output.assert_has_calls([call1])
    def test_get_source_git(self, popen):
        popen.return_value.wait.return_value = 0
        popen.return_value.communicate = mock.MagicMock()
        popen.return_value.communicate.return_value = (six.b('hash '),
                                                       six.b('any'))

        url = "git://default/koji.git#asdasd"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir,
                     session=self.session,
                     uploadpath=self.uploadpath,
                     logfile=self.logfile)

        source = scm.get_source()
        self.assertEqual(source, {
            'url': url,
            'source': 'git://default/koji.git#hash'
        })

        popen.return_value.wait.return_value = 1
        with self.assertRaises(koji.GenericError) as cm:
            source = scm.get_source()
        self.assertEqual(cm.exception.args[0],
                         'Error getting commit hash for git')
示例#4
0
文件: test_scm.py 项目: joyxu/koji
    def test_checkout_cvs_ssh(self):

        url = "cvs+ssh://user@nocommon/cvsisdead?rpms/foo/EL3#sometag"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir,
                     session=self.session,
                     uploadpath=self.uploadpath,
                     logfile=self.logfile)
        self.assertEqual(scm.use_common, False)
        self.symlink.assert_not_called()
        # expected commands
        cmd = [
            'cvs', '-d', ':ext:user@nocommon:/cvsisdead', 'checkout', '-r',
            'sometag', 'rpms/foo/EL3'
        ]
        call1 = mock.call(self.session,
                          cmd[0],
                          cmd,
                          self.logfile,
                          self.uploadpath,
                          cwd=self.tempdir,
                          logerror=1,
                          append=False,
                          env={'CVS_RSH': 'ssh'})
        self.log_output.assert_has_calls([call1])
示例#5
0
    def test_get_source_other(self, popen):
        popen.return_value.wait.return_value = 0
        popen.return_value.communicate = mock.MagicMock()
        popen.return_value.communicate.return_value = ('hash ', 'any')

        url = "svn+ssh://user@nocommon/dist?rpms/foo/EL3#revision"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                     uploadpath=self.uploadpath, logfile=self.logfile)

        source = scm.get_source()
        self.assertEqual(source, {'url': url, 'source': url})
示例#6
0
    def test_get_source_other(self, popen):
        popen.return_value.wait.return_value = 0
        popen.return_value.communicate = mock.MagicMock()
        popen.return_value.communicate.return_value = ('hash ', 'any')

        url = "svn+ssh://user@nocommon/dist?rpms/foo/EL3#revision"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                     uploadpath=self.uploadpath, logfile=self.logfile)

        source = scm.get_source()
        self.assertEqual(source, {'url': url, 'source': url})
    def fetchDockerfile(self, src, build_tag):
        """
        Gets Dockerfile. Roughly corresponds to getSRPM method of build task
        """
        scm = SCM(src)
        scm.assert_allowed(self.options.allowed_scms)
        scmdir = os.path.join(self.workdir, 'sources')

        koji.ensuredir(scmdir)

        logfile = os.path.join(self.workdir, 'checkout-for-labels.log')
        uploadpath = self.getUploadDir()

        koji.ensuredir(uploadpath)

        self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag,
                           scratch=self.opts.get('scratch', False))

        # Check out sources from the SCM
        sourcedir = scm.checkout(scmdir, self.session, uploadpath, logfile)

        self.run_callbacks("postSCMCheckout", scminfo=scm.get_info(), build_tag=build_tag,
                           scratch=self.opts.get('scratch', False), srcdir=sourcedir)

        fn = os.path.join(sourcedir, 'Dockerfile')
        if not os.path.exists(fn):
            raise koji.BuildError("Dockerfile file missing: %s" % fn)
        return fn
示例#8
0
    def fetchDockerfile(self, src, build_tag):
        """
        Gets Dockerfile. Roughly corresponds to getSRPM method of build task
        """
        scm = SCM(src)
        scm.assert_allowed(self.options.allowed_scms)
        scmdir = os.path.join(self.workdir, 'sources')

        koji.ensuredir(scmdir)

        logfile = os.path.join(self.workdir, 'checkout-for-labels.log')
        uploadpath = self.getUploadDir()

        koji.ensuredir(uploadpath)

        self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag,
                           scratch=self.opts.get('scratch', False))

        # Check out sources from the SCM
        sourcedir = scm.checkout(scmdir, self.session, uploadpath, logfile)

        self.run_callbacks("postSCMCheckout", scminfo=scm.get_info(), build_tag=build_tag,
                           scratch=self.opts.get('scratch', False), srcdir=sourcedir)

        fn = os.path.join(sourcedir, 'Dockerfile')
        if not os.path.exists(fn):
            raise koji.BuildError("Dockerfile file missing: %s" % fn)
        return fn
示例#9
0
    def test_checkout_cvs_ssh(self):

        url = "cvs+ssh://user@nocommon/cvsisdead?rpms/foo/EL3#sometag"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                uploadpath=self.uploadpath, logfile=self.logfile)
        self.assertEqual(scm.use_common, False)
        self.symlink.assert_not_called()
        # expected commands
        cmd = ['cvs', '-d', ':ext:user@nocommon:/cvsisdead', 'checkout', '-r',
                'sometag', 'rpms/foo/EL3']
        call1 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir, logerror=1,
                        append=False, env={'CVS_RSH': 'ssh'})
        self.log_output.assert_has_calls([call1])
示例#10
0
    def test_checkout_svn_ssh(self):

        url = "svn+ssh://user@nocommon/dist?rpms/foo/EL3#revision"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                uploadpath=self.uploadpath, logfile=self.logfile)
        self.assertEqual(scm.use_common, False)
        self.symlink.assert_not_called()
        # expected commands
        cmd = ['svn', 'checkout', '-r', 'revision',
                'svn+ssh://user@nocommon/dist/rpms/foo/EL3', 'rpms/foo/EL3']
        call1 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir, logerror=1,
                        append=False, env=None)
        self.log_output.assert_has_calls([call1])
示例#11
0
文件: test_scm.py 项目: joyxu/koji
    def test_checkout_git_common(self):

        url = "git://default/koji.git#asdasd"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir,
                     session=self.session,
                     uploadpath=self.uploadpath,
                     logfile=self.logfile)
        self.assertEqual(scm.use_common, True)
        self.symlink.assert_called_once()
        # expected commands
        cmd = [
            'git', 'clone', '-n', 'git://default/koji.git',
            self.tempdir + '/koji'
        ]
        call1 = mock.call(self.session,
                          cmd[0],
                          cmd,
                          self.logfile,
                          self.uploadpath,
                          cwd=self.tempdir,
                          logerror=1,
                          append=False,
                          env=None)
        cmd = ['git', 'reset', '--hard', 'asdasd']
        call2 = mock.call(self.session,
                          cmd[0],
                          cmd,
                          self.logfile,
                          self.uploadpath,
                          cwd=self.tempdir + '/koji',
                          logerror=1,
                          append=True,
                          env=None)
        cmd = ['git', 'clone', 'git://default/common.git', 'common']
        call3 = mock.call(self.session,
                          cmd[0],
                          cmd,
                          self.logfile,
                          self.uploadpath,
                          cwd=self.tempdir,
                          logerror=1,
                          append=True,
                          env=None)
        self.log_output.assert_has_calls([call1, call2, call3])
示例#12
0
    def test_checkout_cvs_common(self):

        url = "cvs://default/cvsisdead?rpms/foo/EL3#sometag"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                     uploadpath=self.uploadpath, logfile=self.logfile)
        self.assertEqual(scm.use_common, True)
        self.symlink.assert_called_once()
        # expected commands
        cmd = ['cvs', '-d', ':pserver:anonymous@default:/cvsisdead', 'checkout',
               '-r', 'sometag', 'rpms/foo/EL3']
        call1 = mock.call(self.session, cmd[0], cmd, self.logfile, self.uploadpath,
                          cwd=self.tempdir, logerror=1, append=False, env=None)
        cmd = ['cvs', '-d', ':pserver:anonymous@default:/cvsisdead', 'checkout', 'common']
        call2 = mock.call(self.session, cmd[0], cmd, self.logfile, self.uploadpath,
                          cwd=self.tempdir, logerror=1, append=True, env=None)
        self.log_output.assert_has_calls([call1, call2])
示例#13
0
    def test_checkout_error_in_command(self):

        url = "git://nocommon/koji.git#asdasd"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        self.log_output.return_value = 1
        with self.assertRaises(koji.BuildError):
            scm.checkout(self.tempdir, session=self.session,
                    uploadpath=self.uploadpath, logfile=self.logfile)
        self.assertEqual(scm.use_common, False)
        self.symlink.assert_not_called()
        # expected commands
        cmd = ['git', 'clone', '-n', 'git://nocommon/koji.git',
                self.tempdir + '/koji']
        call1 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir, logerror=1,
                        append=False, env=None)
        # should have errored after first command
        self.log_output.assert_has_calls([call1])
示例#14
0
    def test_get_source_git(self, popen):
        popen.return_value.wait.return_value = 0
        popen.return_value.communicate = mock.MagicMock()
        popen.return_value.communicate.return_value = (six.b('hash '), six.b('any'))

        url = "git://default/koji.git#asdasd"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                uploadpath=self.uploadpath, logfile=self.logfile)

        source = scm.get_source()
        self.assertEqual(source, {'url': url,
                                  'source': 'git://default/koji.git#hash'})

        popen.return_value.wait.return_value = 1
        with self.assertRaises(koji.GenericError) as cm:
            source = scm.get_source()
        self.assertEqual(cm.exception.args[0],
                         'Error getting commit hash for git')
示例#15
0
    def test_checkout_gitssh_nocommon(self):

        url = "git+ssh://user@nocommon/koji.git#asdasd"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                uploadpath=self.uploadpath, logfile=self.logfile)
        self.assertEqual(scm.use_common, False)
        self.symlink.assert_not_called()
        # expected commands
        cmd = ['git', 'clone', '-n', 'git+ssh://user@nocommon/koji.git',
                self.tempdir + '/koji']
        call1 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir, logerror=1,
                        append=False, env=None)
        cmd = ['git', 'reset', '--hard', 'asdasd']
        call2 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir + '/koji',
                        logerror=1, append=True, env=None)
        self.log_output.assert_has_calls([call1, call2])
示例#16
0
    def test_checkout_cvs_common(self):

        url = "cvs://default/cvsisdead?rpms/foo/EL3#sometag"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                uploadpath=self.uploadpath, logfile=self.logfile)
        self.assertEqual(scm.use_common, True)
        self.symlink.assert_called_once()
        # expected commands
        cmd = ['cvs', '-d', ':pserver:anonymous@default:/cvsisdead', 'checkout',
                '-r', 'sometag', 'rpms/foo/EL3']
        call1 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir, logerror=1,
                        append=False, env=None)
        cmd = ['cvs', '-d', ':pserver:anonymous@default:/cvsisdead', 'checkout',
                'common']
        call2 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir, logerror=1,
                        append=True, env=None)
        self.log_output.assert_has_calls([call1, call2])
    def fetchDockerfile(self, src):
        """
        Gets Dockerfile. Roughly corresponds to getSRPM method of build task
        """
        scm = SCM(src)
        scm.assert_allowed(self.options.allowed_scms)
        scmdir = os.path.join(self.workdir, 'sources')

        koji.ensuredir(scmdir)

        logfile = os.path.join(self.workdir, 'checkout-for-labels.log')
        uploadpath = self.getUploadDir()

        koji.ensuredir(uploadpath)

        # Check out sources from the SCM
        sourcedir = scm.checkout(scmdir, self.session, uploadpath, logfile)

        fn = os.path.join(sourcedir, 'Dockerfile')
        if not os.path.exists(fn):
            raise koji.BuildError, "Dockerfile file missing: %s" % fn
        return fn
    def fetchDockerfile(self, src):
        """
        Gets Dockerfile. Roughly corresponds to getSRPM method of build task
        """
        scm = SCM(src)
        scm.assert_allowed(self.options.allowed_scms)
        scmdir = os.path.join(self.workdir, 'sources')

        koji.ensuredir(scmdir)

        logfile = os.path.join(self.workdir, 'checkout-for-labels.log')
        uploadpath = self.getUploadDir()

        koji.ensuredir(uploadpath)

        # Check out sources from the SCM
        sourcedir = scm.checkout(scmdir, self.session, uploadpath, logfile)

        fn = os.path.join(sourcedir, 'Dockerfile')
        if not os.path.exists(fn):
            raise koji.BuildError, "Dockerfile file missing: %s" % fn
        return fn