Exemple #1
0
    def setUp(self):
        config = """
from buildbot.status import html
from buildbot.process.factory import BasicBuildFactory
from buildbot.buildslave import BuildSlave
f1 = BasicBuildFactory('cvsroot', 'cvsmodule')
BuildmasterConfig = {
    'slaves': [BuildSlave('bot1', 'passwd1')],
    'schedulers': [],
    'builders': [{'name': 'builder1', 'slavename': 'bot1',
                  'builddir':'workdir', 'factory':f1}],
    'slavePortnum': 0,
    'status': [html.WebStatus(http_port=0)],
    }
"""
        if os.path.exists("test_logfile"):
            shutil.rmtree("test_logfile")
        os.mkdir("test_logfile")
        self.master = m = ConfiguredMaster("test_logfile", config)
        m.startService()
        # hack to find out what randomly-assigned port it is listening on
        port = self.find_webstatus(m).getPortnum()
        self.port = port
        # insert an event

        req = base.BuildRequest("reason", sourcestamp.SourceStamp())
        build1 = base.Build([req])
        bs = m.status.getBuilder("builder1").newBuild()
        bs.setReason("reason")
        bs.buildStarted(build1)

        step1 = BuildStep(name="setup")
        step1.setBuild(build1)
        bss = bs.addStepWithName("setup")
        step1.setStepStatus(bss)
        bss.stepStarted()

        log1 = step1.addLog("output")
        log1.addStdout("some stdout\n")
        log1.finish()

        log2 = step1.addHTMLLog("error", "<html>ouch</html>")

        log3 = step1.addLog("big")
        log3.addStdout("big log\n")
        for i in range(1000):
            log3.addStdout("a" * 500)
            log3.addStderr("b" * 500)
        log3.finish()

        log4 = step1.addCompleteLog("bigcomplete",
                                    "big2 log\n" + "a" * 1 * 1000 * 1000)

        step1.step_status.stepFinished(builder.SUCCESS)
        bs.buildFinished()
    def setUp(self):
        config = """
from buildbot.status import html
from buildbot.process.factory import BasicBuildFactory
from buildbot.buildslave import BuildSlave
f1 = BasicBuildFactory('cvsroot', 'cvsmodule')
BuildmasterConfig = {
    'slaves': [BuildSlave('bot1', 'passwd1')],
    'schedulers': [],
    'builders': [{'name': 'builder1', 'slavename': 'bot1',
                  'builddir':'workdir', 'factory':f1}],
    'slavePortnum': 0,
    'status': [html.WebStatus(http_port=0)],
    }
"""
        if os.path.exists("test_logfile"):
            shutil.rmtree("test_logfile")
        os.mkdir("test_logfile")
        self.master = m = ConfiguredMaster("test_logfile", config)
        m.startService()
        # hack to find out what randomly-assigned port it is listening on
        port = self.find_webstatus(m).getPortnum()
        self.port = port
        # insert an event

        req = base.BuildRequest("reason", sourcestamp.SourceStamp())
        build1 = base.Build([req])
        bs = m.status.getBuilder("builder1").newBuild()
        bs.setReason("reason")
        bs.buildStarted(build1)

        step1 = BuildStep(name="setup")
        step1.setBuild(build1)
        bss = bs.addStepWithName("setup")
        step1.setStepStatus(bss)
        bss.stepStarted()

        log1 = step1.addLog("output")
        log1.addStdout("some stdout\n")
        log1.finish()

        log2 = step1.addHTMLLog("error", "<html>ouch</html>")

        log3 = step1.addLog("big")
        log3.addStdout("big log\n")
        for i in range(1000):
            log3.addStdout("a" * 500)
            log3.addStderr("b" * 500)
        log3.finish()

        log4 = step1.addCompleteLog("bigcomplete",
                                    "big2 log\n" + "a" * 1*1000*1000)

        step1.step_status.stepFinished(builder.SUCCESS)
        bs.buildFinished()
Exemple #3
0
        def _started(ign):
            # hack to find out what randomly-assigned port it is listening on
            port = self.find_webstatus(m).getPortnum()
            self.port = port
            # insert an event

            req = BuildRequest("reason", sourcestamp.SourceStamp(), 'test_builder')
            build1 = base.Build([req])
            bs = m.status.getBuilder("builder1").newBuild()
            bs.setReason("reason")
            bs.buildStarted(build1)

            step1 = BuildStep(name="setup")
            step1.setBuild(build1)
            bss = bs.addStepWithName("setup")
            step1.setStepStatus(bss)
            bss.stepStarted()

            log1 = step1.addLog("output")
            log1.addStdout(u"s\N{LATIN CAPITAL LETTER O WITH GRAVE}me stdout\n".encode("utf-8"))
            log1.finish()

            log2 = step1.addHTMLLog("error", "<html>ouch</html>")
            del log2

            log3 = step1.addLog("big")
            log3.addStdout("big log\n")
            for i in range(1000):
                log3.addStdout("a" * 500)
                log3.addStderr("b" * 500)
            log3.finish()

            log4 = step1.addCompleteLog("bigcomplete",
                                        "big2 log\n" + "a" * 1*1000*1000)
            del log4

            log5 = step1.addLog("mixed")
            log5.addHeader("header content")
            log5.addStdout("this is stdout content")
            log5.addStderr("errors go here")
            log5.addEntry(5, "non-standard content on channel 5")
            log5.addStderr(" and some trailing stderr")

            d1 = defer.maybeDeferred(step1.step_status.stepFinished,
                                     builder.SUCCESS)
            bs.buildFinished()
            return d1
Exemple #4
0
        def _started(ign):
            # hack to find out what randomly-assigned port it is listening on
            port = self.find_webstatus(m).getPortnum()
            self.port = port
            # insert an event

            req = BuildRequest("reason", sourcestamp.SourceStamp(), 'test_builder')
            build1 = base.Build([req])
            bs = m.status.getBuilder("builder1").newBuild()
            bs.setReason("reason")
            bs.buildStarted(build1)

            step1 = BuildStep(name="setup")
            step1.setBuild(build1)
            bss = bs.addStepWithName("setup")
            step1.setStepStatus(bss)
            bss.stepStarted()

            log1 = step1.addLog("output")
            log1.addStdout(u"s\N{LATIN CAPITAL LETTER O WITH GRAVE}me stdout\n".encode("utf-8"))
            log1.finish()

            log2 = step1.addHTMLLog("error", "<html>ouch</html>")
            del log2

            log3 = step1.addLog("big")
            log3.addStdout("big log\n")
            for i in range(1000):
                log3.addStdout("a" * 500)
                log3.addStderr("b" * 500)
            log3.finish()

            log4 = step1.addCompleteLog("bigcomplete",
                                        "big2 log\n" + "a" * 1*1000*1000)
            del log4

            log5 = step1.addLog("mixed")
            log5.addHeader("header content")
            log5.addStdout("this is stdout content")
            log5.addStderr("errors go here")
            log5.addEntry(5, "non-standard content on channel 5")
            log5.addStderr(" and some trailing stderr")

            d1 = defer.maybeDeferred(step1.step_status.stepFinished,
                                     builder.SUCCESS)
            bs.buildFinished()
            return d1
Exemple #5
0
    def setUp(self):
        config = """
from buildbot.status import html
from buildbot.process.factory import BasicBuildFactory
from buildbot.buildslave import BuildSlave
from buildbot.config import BuilderConfig

f1 = BasicBuildFactory('cvsroot', 'cvsmodule')
BuildmasterConfig = c = {
    'slaves': [BuildSlave('bot1', 'passwd1')],
    'schedulers': [],
    'slavePortnum': 0,
    'status': [html.WebStatus(http_port=0)],
    }
c['builders'] = [
    BuilderConfig(name='builder1', slavename='bot1', factory=f1),
]
"""
        if os.path.exists("test_logfile"):
            shutil.rmtree("test_logfile")
        os.mkdir("test_logfile")
        self.master = m = ConfiguredMaster("test_logfile", config)
        m.startService()
        # hack to find out what randomly-assigned port it is listening on
        port = self.find_webstatus(m).getPortnum()
        self.port = port
        # insert an event

        req = base.BuildRequest("reason", sourcestamp.SourceStamp(),
                                'test_builder')
        build1 = base.Build([req])
        bs = m.status.getBuilder("builder1").newBuild()
        bs.setReason("reason")
        bs.buildStarted(build1)

        step1 = BuildStep(name="setup")
        step1.setBuild(build1)
        bss = bs.addStepWithName("setup")
        step1.setStepStatus(bss)
        bss.stepStarted()

        log1 = step1.addLog("output")
        log1.addStdout(u"sÒme stdout\n")
        log1.finish()

        log2 = step1.addHTMLLog("error", "<html>ouch</html>")

        log3 = step1.addLog("big")
        log3.addStdout("big log\n")
        for i in range(1000):
            log3.addStdout("a" * 500)
            log3.addStderr("b" * 500)
        log3.finish()

        log4 = step1.addCompleteLog("bigcomplete",
                                    "big2 log\n" + "a" * 1 * 1000 * 1000)

        log5 = step1.addLog("mixed")
        log5.addHeader("header content")
        log5.addStdout("this is stdout content")
        log5.addStderr("errors go here")
        log5.addEntry(5, "non-standard content on channel 5")
        log5.addStderr(" and some trailing stderr")

        d = defer.maybeDeferred(step1.step_status.stepFinished,
                                builder.SUCCESS)
        bs.buildFinished()
        return d
Exemple #6
0
    def create_status(self):
        for i in range(5):
            if i % 2 == 0:
                branch = "release"
            else:
                branch = None
            c = Change("user", ["foo.c"] * i, "see ticket #%i" % i,
                       revision=str(42+i), when=0.1*i, branch=branch)
            self.master.change_svc.addChange(c)

        ss = sourcestamp.SourceStamp(revision=42)
        req = BuildRequest("reason", ss, 'test_builder')
        build1 = base.Build([req])
        bs = self.master.status.getBuilder("builder1").newBuild()
        bs.setReason("reason")
        bs.buildStarted(build1)

        bs.setSourceStamp(ss)

        bs.setProperty("revision", "42", "testcase")
        bs.setProperty("got_revision", "47", "testcase")
        bs.setProperty("branch", "release", "testcase")

        step1 = BuildStep(name="setup")
        step1.setBuild(build1)
        bss = bs.addStepWithName("setup")
        step1.setStepStatus(bss)
        bss.stepStarted()

        step2 = BuildStep(name="build")
        step2.setBuild(build1)
        bss = bs.addStepWithName("build")
        step2.setStepStatus(bss)
        bss.stepStarted()

        step1.addURL("url1", "http://logurl.net/1")
        step1.addURL("url2", "http://logurl.net/2")
        step1.addURL("url3", "http://logurl.net/3")

        log1 = step1.addLog("output")
        log1.addStdout(u"some stdout\n") # FIXME: Unicode here fails validation
        log1.finish()

        # this has to validate too for the test to pass
        log2 = step1.addHTMLLog("error", '''
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html>
                <head><title>Teh Log</title></head>
                <body>Aaaiight</body>
            </html>''')
        del log2

        log3 = step1.addLog("big")
        log3.addStdout("somewhat big log\n")
        for i in range(50):
            log3.addStdout("a" * 50 + "\n")
            log3.addStderr("b" * 50 + "\n")
        log3.finish()

        log5 = step1.addLog("mixed")
        log5.addHeader("header content")
        log5.addStdout("this is stdout content")
        log5.addStderr("errors go here")
        log5.addEntry(5, "non-standard content on channel 5")
        log5.addStderr(" and some trailing stderr")


        d = defer.succeed(None)

        for i in range(1,3):
            ss = sourcestamp.SourceStamp(revision=42+i, branch='release')
            req = BuildRequest("reason", ss, 'test_builder')
            build = base.Build([req] * i)
            bs = self.master.status.getBuilder("builder%i" % i).newBuild()
            bs.setReason("reason")
            bs.buildStarted(build)
            bs.setSourceStamp(ss)

            s = BuildStep(name="setup")
            s.setBuild(build1)
            bss = bs.addStepWithName("setup")
            s.setStepStatus(bss)
            bss.stepStarted()
            log = s.addLog("stdio")
            log.finish()


        d.chainDeferred(defer.maybeDeferred(step1.step_status.stepFinished,
                                builder.SUCCESS))
        bs.buildFinished()
        return d
Exemple #7
0
    def setUp(self):
        config = """
from buildbot.status import html
from buildbot.process.factory import BasicBuildFactory
from buildbot.buildslave import BuildSlave
from buildbot.config import BuilderConfig

f1 = BasicBuildFactory('cvsroot', 'cvsmodule')
BuildmasterConfig = c = {
    'slaves': [BuildSlave('bot1', 'passwd1')],
    'schedulers': [],
    'slavePortnum': 0,
    'status': [html.WebStatus(http_port=0)],
    }
c['builders'] = [
    BuilderConfig(name='builder1', slavename='bot1', factory=f1),
]
"""
        if os.path.exists("test_logfile"):
            shutil.rmtree("test_logfile")
        os.mkdir("test_logfile")
        self.master = m = ConfiguredMaster("test_logfile", config)
        m.startService()
        # hack to find out what randomly-assigned port it is listening on
        port = self.find_webstatus(m).getPortnum()
        self.port = port
        # insert an event

        req = base.BuildRequest("reason", sourcestamp.SourceStamp(), "test_builder")
        build1 = base.Build([req])
        bs = m.status.getBuilder("builder1").newBuild()
        bs.setReason("reason")
        bs.buildStarted(build1)

        step1 = BuildStep(name="setup")
        step1.setBuild(build1)
        bss = bs.addStepWithName("setup")
        step1.setStepStatus(bss)
        bss.stepStarted()

        log1 = step1.addLog("output")
        log1.addStdout(u"sÒme stdout\n")
        log1.finish()

        log2 = step1.addHTMLLog("error", "<html>ouch</html>")

        log3 = step1.addLog("big")
        log3.addStdout("big log\n")
        for i in range(1000):
            log3.addStdout("a" * 500)
            log3.addStderr("b" * 500)
        log3.finish()

        log4 = step1.addCompleteLog("bigcomplete", "big2 log\n" + "a" * 1 * 1000 * 1000)

        log5 = step1.addLog("mixed")
        log5.addHeader("header content")
        log5.addStdout("this is stdout content")
        log5.addStderr("errors go here")
        log5.addEntry(5, "non-standard content on channel 5")
        log5.addStderr(" and some trailing stderr")

        d = defer.maybeDeferred(step1.step_status.stepFinished, builder.SUCCESS)
        bs.buildFinished()
        return d
Exemple #8
0
    def create_status(self):
        for i in range(5):
            if i % 2 == 0:
                branch = "release"
            else:
                branch = None
            c = Change("user", ["foo.c"] * i,
                       "see ticket #%i" % i,
                       revision=str(42 + i),
                       when=0.1 * i,
                       branch=branch)
            self.master.change_svc.addChange(c)

        ss = sourcestamp.SourceStamp(revision=42)
        req = BuildRequest("reason", ss, 'test_builder')
        build1 = base.Build([req])
        bs = self.master.status.getBuilder("builder1").newBuild()
        bs.setReason("reason")
        bs.buildStarted(build1)

        bs.setSourceStamp(ss)

        bs.setProperty("revision", "42", "testcase")
        bs.setProperty("got_revision", "47", "testcase")
        bs.setProperty("branch", "release", "testcase")

        step1 = BuildStep(name="setup")
        step1.setBuild(build1)
        bss = bs.addStepWithName("setup")
        step1.setStepStatus(bss)
        bss.stepStarted()

        step2 = BuildStep(name="build")
        step2.setBuild(build1)
        bss = bs.addStepWithName("build")
        step2.setStepStatus(bss)
        bss.stepStarted()

        step1.addURL("url1", "http://logurl.net/1")
        step1.addURL("url2", "http://logurl.net/2")
        step1.addURL("url3", "http://logurl.net/3")

        log1 = step1.addLog("output")
        log1.addStdout(
            u"some stdout\n")  # FIXME: Unicode here fails validation
        log1.finish()

        # this has to validate too for the test to pass
        log2 = step1.addHTMLLog(
            "error", '''
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html>
                <head><title>Teh Log</title></head>
                <body>Aaaiight</body>
            </html>''')
        del log2

        log3 = step1.addLog("big")
        log3.addStdout("somewhat big log\n")
        for i in range(50):
            log3.addStdout("a" * 50 + "\n")
            log3.addStderr("b" * 50 + "\n")
        log3.finish()

        log5 = step1.addLog("mixed")
        log5.addHeader("header content")
        log5.addStdout("this is stdout content")
        log5.addStderr("errors go here")
        log5.addEntry(5, "non-standard content on channel 5")
        log5.addStderr(" and some trailing stderr")

        d = defer.succeed(None)

        for i in range(1, 3):
            ss = sourcestamp.SourceStamp(revision=42 + i, branch='release')
            req = BuildRequest("reason", ss, 'test_builder')
            build = base.Build([req] * i)
            bs = self.master.status.getBuilder("builder%i" % i).newBuild()
            bs.setReason("reason")
            bs.buildStarted(build)
            bs.setSourceStamp(ss)

            s = BuildStep(name="setup")
            s.setBuild(build1)
            bss = bs.addStepWithName("setup")
            s.setStepStatus(bss)
            bss.stepStarted()
            log = s.addLog("stdio")
            log.finish()

        d.chainDeferred(
            defer.maybeDeferred(step1.step_status.stepFinished,
                                builder.SUCCESS))
        bs.buildFinished()
        return d
Exemple #9
0
    def setUp(self):
        try:
            from lxml import etree
        except ImportError:
            raise unittest.SkipTest("lxml not installed")

        class CustomResolver(etree.Resolver):
            '''Cache DTDs to avoid w3.org blocking

               from http://www.hoboes.com/Mimsy/hacks/caching-dtds-using-lxml-and-etree/
            '''

            import tempfile
            cache = '%s/buildbot-test-dtd-cache' % tempfile.gettempdir()

            if WebpartsRecursive.log:
                print "\nCaching DTDs in: %s" % cache

            def resolve(self, URL, id, context):
                import urllib
                import urlparse

                #determine cache path
                url = urlparse.urlparse(URL)
                filefolder, filename = os.path.split(url.path)
                filefolder = url.hostname + filefolder
                dtdFolder = os.path.join(self.cache, filefolder)
                dtdPath = os.path.join(dtdFolder, filename)

                #cache if necessary
                if not os.path.exists(dtdPath):
                    print "CREATING CACHE FOR", URL
                    if not os.path.exists(dtdFolder):
                        os.makedirs(dtdFolder)
                    filename, headers = urllib.urlretrieve(URL, dtdPath)

                #resolve the cached file
                return self.resolve_file(open(dtdPath), context, base_url=URL)

        self.CustomResolver = CustomResolver

        extraconfig = """
from buildbot.status import html
from buildbot.changes import mail
from buildbot.process import factory
from buildbot.steps import dummy
from buildbot.scheduler import Scheduler
from buildbot.changes.base import ChangeSource
from buildbot.buildslave import BuildSlave
from buildbot.config import BuilderConfig
s = factory.s

class DiscardScheduler(Scheduler):
    def addChange(self, change):
        pass
class DummyChangeSource(ChangeSource):
    def describe(self):
        return "dummy"

ws = html.WebStatus(http_port=0, allowForce=True,
                    revlink="http://server.net/webrepo/%s",
                    changecommentlink=(r"#(\\d+)", r"http://server.net/trac/ticket/\\1"))
c['status'] = [ws]

c['slaves'] = [BuildSlave('bot1', 'sekrit'), BuildSlave('bot2', 'sekrit')]
c['change_source'] = DummyChangeSource()
c['schedulers'] = [DiscardScheduler('discard1', None, 60, ['builder1']),
                   DiscardScheduler('discard2', 'release', 30, ['builder1'])]
c['slavePortnum'] = 0

f = factory.BuildFactory([s(dummy.RemoteDummy, timeout=1)])

c['builders'] = [
    BuilderConfig(name='builder1', slavenames=['bot1', 'bot2'], factory=f),
    BuilderConfig(name='builder2', slavenames=['bot1'], factory=f),
    BuilderConfig(name='builder3', slavenames=['bot2'], factory=f),
]
c['buildbotURL'] = 'http://dummy.example.org:8010/'
c['projectName'] = 'BuildBot Trial Test'
c['projectURL'] = 'http://server.net/home'

"""
        self.startMaster(extraconfig)

        for i in range(5):
            if i % 2 == 0:
                branch = "release"
            else:
                branch = None
            c = Change("user", ["foo.c"] * i, "see ticket #%i" % i,
                       revision=str(42+i), when=0.1*i, branch=branch)
            self.master.change_svc.addChange(c)

        ss = sourcestamp.SourceStamp(revision=42)
        req = base.BuildRequest("reason", ss, 'test_builder')
        build1 = base.Build([req])
        bs = self.master.status.getBuilder("builder1").newBuild()
        bs.setReason("reason")
        bs.buildStarted(build1)

        bs.setSourceStamp(ss)

        bs.setProperty("revision", "42", "testcase")
        bs.setProperty("got_revision", "47", "testcase")
        bs.setProperty("branch", "release", "testcase")

        step1 = BuildStep(name="setup")
        step1.setBuild(build1)
        bss = bs.addStepWithName("setup")
        step1.setStepStatus(bss)
        bss.stepStarted()

        step2 = BuildStep(name="build")
        step2.setBuild(build1)
        bss = bs.addStepWithName("build")
        step2.setStepStatus(bss)
        bss.stepStarted()

        step1.addURL("url1", "http://logurl.net/1")
        step1.addURL("url2", "http://logurl.net/2")
        step1.addURL("url3", "http://logurl.net/3")

        log1 = step1.addLog("output")
        log1.addStdout(u"some stdout\n") # FIXME: Unicode here fails validation
        log1.finish()

        # this has to validate too for the test to pass
        log2 = step1.addHTMLLog("error", '''
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html>
                <head><title>Teh Log</title></head>
                <body>Aaaiight</body>
            </html>''')

        log3 = step1.addLog("big")
        log3.addStdout("somewhat big log\n")
        for i in range(50):
            log3.addStdout("a" * 50 + "\n")
            log3.addStderr("b" * 50 + "\n")
        log3.finish()

        log5 = step1.addLog("mixed")
        log5.addHeader("header content")
        log5.addStdout("this is stdout content")
        log5.addStderr("errors go here")
        log5.addEntry(5, "non-standard content on channel 5")
        log5.addStderr(" and some trailing stderr")


        d = defer.succeed(None)

        for i in range(1,3):
            ss = sourcestamp.SourceStamp(revision=42+i, branch='release')
            req = base.BuildRequest("reason", ss, 'test_builder')
            build = base.Build([req] * i)
            bs = self.master.status.getBuilder("builder%i" % i).newBuild()
            bs.setReason("reason")
            bs.buildStarted(build)
            bs.setSourceStamp(ss)

            s = BuildStep(name="setup")
            s.setBuild(build1)
            bss = bs.addStepWithName("setup")
            s.setStepStatus(bss)
            bss.stepStarted()
            log = s.addLog("stdio")
            log.finish()


        d.chainDeferred(defer.maybeDeferred(step1.step_status.stepFinished,
                                builder.SUCCESS))
        bs.buildFinished()
        return d