コード例 #1
0
def handler(req):
    """
    The presence of this function in the module allows it to be added directly
    into apache as a mod_python handler.

    The function is for testing purposes only.
    """
    coveragehook.install()
    mintCfgPath = os.path.join(req.document_root(), '..', '..', 'mint.conf')
    mintcfg = config.getConfig(mintCfgPath)
    mintdb = Database(mintcfg)
    restdb = RestDatabase(mintcfg, mintdb)

    topLevel = os.path.join(mintcfg.basePath)

    _handler = ApacheRESTHandler(topLevel, restdb)
    return _handler.handle(req)
コード例 #2
0
def handler(req):
    """
    The presence of this function in the module allows it to be added directly
    into apache as a mod_python handler.

    The function is for testing purposes only.
    """
    coveragehook.install()
    mintCfgPath = os.path.join(req.document_root(), "..", "..", "mint.conf")
    mintcfg = config.getConfig(mintCfgPath)
    mintdb = Database(mintcfg)
    restdb = RestDatabase(mintcfg, mintdb)

    topLevel = os.path.join(mintcfg.basePath)

    _handler = ApacheRESTHandler(topLevel, restdb)
    return _handler.handle(req)
コード例 #3
0
ファイル: rbuilderaction.py プロジェクト: pombredanne/mint
def process(repos, cfg, commitList, srcMap, pkgMap, grpMap, argv, otherArgs):
    coveragehook.install()
    if not len(argv) and not len(otherArgs):
        return 1

    mintutils.setupLogging(consoleLevel=logging.WARNING,
            consoleFormat='apache')
    
    argDef = {
        'config' : options.ONE_PARAM,
        'user': options.ONE_PARAM,
        'hostname': options.ONE_PARAM,
    }

    # create an argv[0] for processArgs to ignore
    argv[0:0] = ['']
    argSet, someArgs = options.processArgs(argDef, {}, cfg, '', argv=argv)
    # and now remove argv[0] again
    argv.pop(0)
    if len(someArgs):
        someArgs.pop(0)
    otherArgs.extend(someArgs)

    # Double-fork so the commit hook doesn't block the caller.
    if os.fork():
        return 0

    try:
        if not os.fork():
            try:
                registerCommits(argSet, commitList)
            except:
                e_type, e_value, e_tb = sys.exc_info()
                logErrorAndEmail(None, e_type, e_value, e_tb, 'commit hook',
                        argSet)
    finally:
        os._exit(0)
コード例 #4
0
ファイル: apachehooks.py プロジェクト: fedora-conary/conary
def handler(req):
    coveragehook.install()
    try:
        return _handler(req)
    finally:
        coveragehook.save()
コード例 #5
0
ファイル: rootserver.py プロジェクト: pombreda/rmake
#


import errno
import os
import select
import signal
import socket
import sys
import time

if __name__ == '__main__':
    rootPath = os.environ.get('RMAKE_ROOT', '/')
    sys.path.insert(0, rootPath + '/usr/share/rmake')
from conary.lib import coveragehook
coveragehook.install()

from conary.lib import util
from conary import checkin
from conary import conarycfg
from conary import conaryclient


from rmake.worker.chroot import cook

from rmake import constants
from rmake.lib.apiutils import api, api_parameters, api_return, freeze, thaw
from rmake.lib import apirpc, daemon, logger, repocache, telnetserver

class ChrootServer(apirpc.XMLApiServer):
コード例 #6
0
# limitations under the License.
#

import errno
import os
import select
import signal
import socket
import sys
import time

if __name__ == '__main__':
    rootPath = os.environ.get('RMAKE_ROOT', '/')
    sys.path.insert(0, rootPath + '/usr/share/rmake')
from conary.lib import coveragehook
coveragehook.install()

from conary.lib import util
from conary import checkin
from conary import conarycfg
from conary import conaryclient

from rmake.worker.chroot import cook

from rmake import constants
from rmake.lib.apiutils import api, api_parameters, api_return, freeze, thaw
from rmake.lib import apirpc, daemon, logger, repocache, telnetserver


class ChrootServer(apirpc.XMLApiServer):
    def _setProcessTitle(self, name):
コード例 #7
0
    def testChrootManagementMultinode(self):
        def _getChroot(helper):
            data = helper.listChroots()
            started = time.time()
            while not data:
                if time.time() - started > 60:
                    raise RuntimeError("timeout waiting for chroot to appear")
                time.sleep(.2)
                data = helper.listChroots()
            chroot, = data
            return chroot

        self.openRmakeRepository()
        client = self.startRmakeServer(multinode=True)
        helper = self.getRmakeHelper(client.uri)
        self.startNode()

        self.buildCfg.cleanAfterCook = False
        trv = self.addComponent('simple:source', '1-1', '',
                                [('simple.recipe', recipes.simpleRecipe)])
        jobId = self.discardOutput(helper.buildTroves, ['simple'])
        helper.waitForJob(jobId)
        chroot = helper.listChroots()[0]
        assert (chroot.path == 'simple')
        assert (chroot.jobId == jobId)
        self.stopNodes()
        self.startNode()
        chroot = _getChroot(helper)
        assert (chroot.path == 'simple')
        assert (chroot.jobId == jobId)

        self.stopNodes()
        self.stopRmakeServer()
        client = self.startRmakeServer(multinode=True)
        self.startNode()
        helper = self.getRmakeHelper(client.uri)

        chroot = _getChroot(helper)
        assert (chroot.path == 'simple')
        assert (chroot.jobId == jobId)

        self.captureOutput(helper.archiveChroot, self.nodeCfg.name, 'simple',
                           'foo')
        archivedPath = self.nodeCfg.getChrootArchiveDir() + '/foo'
        assert (os.path.exists(archivedPath))
        archivedChroot = helper.listChroots()[0]
        assert (archivedChroot.path == 'archive/foo')

        self.stopNodes()
        self.stopRmakeServer()
        client = self.startRmakeServer(multinode=True)
        helper = self.getRmakeHelper(client.uri)
        self.startNode()
        archivedChroot = _getChroot(helper)
        assert (archivedChroot.path == 'archive/foo')
        pid, master_fd = os.forkpty()
        if not pid:
            try:
                coveragehook.install()
                helper.startChrootSession(jobId, 'simple', ['/bin/sh'])
                sys.stdout.flush()
                coveragehook.save()
            finally:
                os._exit(0)
        try:
            count = 0
            data = ''
            while not data and count < 60:
                data = _readIfReady(master_fd)
                count += 1
            assert (data)
            os.write(master_fd, 'exit\n')
            data = _readIfReady(master_fd)
            while True:
                try:
                    data += _readIfReady(master_fd)
                except OSError:
                    os.waitpid(pid, 0)
                    break
        finally:
            os.close(master_fd)
コード例 #8
0
    def testChrootSession(self):
        # NOTE: This test is prone to race conditions. The chroot
        # process will occasionally quit right away, probably due to
        # a (hidden) error.
        self.openRmakeRepository()
        client = self.startRmakeServer()
        helper = self.getRmakeHelper(client.uri)

        oldStdin = sys.stdin
        self.buildCfg.cleanAfterCook = False
        self.buildCfg.configLine('[context1]')
        try:
            trv = self.addComponent('simple:source', '1-1', '',
                                    [('simple.recipe', recipes.simpleRecipe)])
            jobId = self.discardOutput(helper.buildTroves,
                                       ['simple{context1}'])
            helper.waitForJob(jobId)
        finally:
            self.buildCfg.cleanAfterCook = True

        pid, master_fd = os.forkpty()
        if not pid:
            try:
                coveragehook.install()
                helper.startChrootSession(jobId, 'simple', ['/bin/sh'])
                sys.stdout.flush()
                coveragehook.save()
            finally:
                os._exit(0)
        try:
            count = 0
            data = ''
            while not data and count < 30:
                try:
                    data = _readIfReady(master_fd)
                except OSError, err:
                    if err.errno == errno.EIO:
                        os.waitpid(pid, 0)
                        raise testsuite.SkipTestException(
                            "testChrootSession failed yet again")
                    raise
                count += 1
            assert (data)
            os.write(master_fd, 'echo "this is a test"\n')
            data = ''
            # White out bash version
            r = re.compile(r"sh-[^$]*\$")
            expected = 'echo "this is a test"\r\r\nthis is a test\r\r\nsh-X.XX$ '
            count = 0
            while not data == expected and count < 60:
                data += r.sub("sh-X.XX$", str(_readIfReady(master_fd)), 1)
                count += 1
            self.assertEquals(data, expected)
            os.write(master_fd, 'exit\n')
            data = _readIfReady(master_fd)
            while True:
                try:
                    data += _readIfReady(master_fd)
                except OSError:
                    os.waitpid(pid, 0)
                    break
            expected = 'exit\r\r\nexit\r\r\n*** Connection closed by remote host ***\r\n'
            count = 0
            while not data == expected and count < 60:
                try:
                    data += _readIfReady(master_fd)
                except OSError:
                    break
                count += 1

            self.assertEquals(data, expected)
コード例 #9
0
ファイル: chroottest.py プロジェクト: fedora-conary/rmake-2
    def testChrootManagementMultinode(self):
        def _getChroot(helper):
            data = helper.listChroots()
            started = time.time()
            while not data:
                if time.time() - started > 60:
                    raise RuntimeError("timeout waiting for chroot to appear")
                time.sleep(.2)
                data = helper.listChroots()
            chroot, = data
            return chroot

        self.openRmakeRepository()
        client = self.startRmakeServer(multinode=True)
        helper = self.getRmakeHelper(client.uri)
        self.startNode()

        self.buildCfg.cleanAfterCook = False
        trv = self.addComponent('simple:source', '1-1', '',
                                [('simple.recipe', recipes.simpleRecipe)])
        jobId = self.discardOutput(helper.buildTroves, ['simple'])
        helper.waitForJob(jobId)
        chroot = helper.listChroots()[0]
        assert(chroot.path == 'simple')
        assert(chroot.jobId == jobId)
        self.stopNodes()
        self.startNode()
        chroot = _getChroot(helper)
        assert(chroot.path == 'simple')
        assert(chroot.jobId == jobId)


        self.stopNodes()
        self.stopRmakeServer()
        client = self.startRmakeServer(multinode=True)
        self.startNode()
        helper = self.getRmakeHelper(client.uri)

        chroot = _getChroot(helper)
        assert(chroot.path == 'simple')
        assert(chroot.jobId == jobId)

        self.captureOutput(helper.archiveChroot, self.nodeCfg.name, 'simple', 'foo')
        archivedPath = self.nodeCfg.getChrootArchiveDir() + '/foo'
        assert(os.path.exists(archivedPath))
        archivedChroot = helper.listChroots()[0]
        assert(archivedChroot.path == 'archive/foo')

        self.stopNodes()
        self.stopRmakeServer()
        client = self.startRmakeServer(multinode=True)
        helper = self.getRmakeHelper(client.uri)
        self.startNode()
        archivedChroot = _getChroot(helper)
        assert(archivedChroot.path == 'archive/foo')
        pid, master_fd = os.forkpty()
        if not pid:
            try:
                coveragehook.install()
                helper.startChrootSession(jobId, 'simple', ['/bin/sh'])
                sys.stdout.flush()
                coveragehook.save()
            finally:
                os._exit(0)
        try:
            count = 0
            data = ''
            while not data and count < 60:
                data = _readIfReady(master_fd)
                count += 1
            assert(data)
            os.write(master_fd, 'exit\n')
            data = _readIfReady(master_fd)
            while True:
                try:
                    data += _readIfReady(master_fd)
                except OSError:
                    os.waitpid(pid, 0)
                    break
        finally:
            os.close(master_fd)
コード例 #10
0
ファイル: chroottest.py プロジェクト: fedora-conary/rmake-2
    def testChrootSession(self):
        # NOTE: This test is prone to race conditions. The chroot
        # process will occasionally quit right away, probably due to
        # a (hidden) error.
        self.openRmakeRepository()
        client = self.startRmakeServer()
        helper = self.getRmakeHelper(client.uri)


        oldStdin = sys.stdin
        self.buildCfg.cleanAfterCook = False
        self.buildCfg.configLine('[context1]')
        try:
            trv = self.addComponent('simple:source', '1-1', '',
                                    [('simple.recipe', recipes.simpleRecipe)])
            jobId = self.discardOutput(helper.buildTroves, ['simple{context1}'])
            helper.waitForJob(jobId)
        finally:
            self.buildCfg.cleanAfterCook = True

        pid, master_fd = os.forkpty()
        if not pid:
            try:
                coveragehook.install()
                helper.startChrootSession(jobId, 'simple', ['/bin/sh'])
                sys.stdout.flush()
                coveragehook.save()
            finally:
                os._exit(0)
        try:
            count = 0
            data = ''
            while not data and count < 30:
                try:
                    data = _readIfReady(master_fd)
                except OSError, err:
                    if err.errno == errno.EIO:
                        os.waitpid(pid, 0)
                        raise testsuite.SkipTestException(
                                "testChrootSession failed yet again")
                    raise
                count += 1
            assert(data)
            os.write(master_fd, 'echo "this is a test"\n')
            data = ''
            # White out bash version
            r = re.compile(r"sh-[^$]*\$")
            expected = 'echo "this is a test"\r\r\nthis is a test\r\r\nsh-X.XX$ '
            count = 0
            while not data == expected and count < 60:
                data += r.sub("sh-X.XX$", str(_readIfReady(master_fd)), 1)
                count += 1
            self.assertEquals(data, expected)
            os.write(master_fd, 'exit\n')
            data = _readIfReady(master_fd)
            while True:
                try:
                    data += _readIfReady(master_fd)
                except OSError:
                    os.waitpid(pid, 0)
                    break
            expected = 'exit\r\r\nexit\r\r\n*** Connection closed by remote host ***\r\n'
            count = 0
            while not data == expected and count < 60:
                try:
                    data += _readIfReady(master_fd)
                except OSError:
                    break
                count += 1

            self.assertEquals(data, expected)
コード例 #11
0
def handler(req):
    coveragehook.install()
    try:
        return _handler(req)
    finally:
        coveragehook.save()