Skip to content

Commit

Permalink
tests and docs for MaxQ
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Sep 11, 2011
1 parent d604114 commit c586138
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 26 deletions.
38 changes: 12 additions & 26 deletions master/buildbot/steps/maxq.py
Expand Up @@ -14,7 +14,6 @@
# Copyright Buildbot Team Members

from buildbot.steps.shell import ShellCommand
from buildbot.status.event import Event
from buildbot.status.results import SUCCESS, FAILURE

class MaxQ(ShellCommand):
Expand All @@ -28,33 +27,20 @@ def __init__(self, testdir=None, **kwargs):
ShellCommand.__init__(self, **kwargs)
self.addFactoryArguments(testdir=testdir)

def startStatus(self):
evt = Event("yellow", ['running', 'maxq', 'tests'],
files={'log': self.log})
self.setCurrentActivity(evt)
def commandComplete(self, cmd):
output = cmd.logs['stdio'].getText()
self.failures = output.count('\nTEST FAILURE:')


def finished(self, rc):
self.failures = 0
if rc:
def evaluateCommand(self, cmd):
# treat a nonzero exit status as a failure, if no other failures are
# detected
if not self.failures and cmd.rc != 0:
self.failures = 1
output = self.log.getAll()
self.failures += output.count('\nTEST FAILURE:')

result = (SUCCESS, ['maxq'])

if self.failures:
result = (FAILURE, [str(self.failures), 'maxq', 'failures'])
return FAILURE
return SUCCESS

return self.stepComplete(result)

def finishStatus(self, result):
def getText(self, cmd, results):
if self.failures:
text = ["maxq", "failed"]
else:
text = ['maxq', 'tests']
self.updateCurrentActivity(text=text)
self.finishStatusSummary()
self.finishCurrentActivity()


return [ str(self.failures), 'maxq', 'failures' ]
return ['maxq', 'tests']
70 changes: 70 additions & 0 deletions master/buildbot/test/unit/test_steps_maxq.py
@@ -0,0 +1,70 @@
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members

from twisted.trial import unittest
from buildbot.test.util import steps
from buildbot.status.results import SUCCESS, FAILURE
from buildbot.test.fake.remotecommand import ExpectShell
from buildbot.steps import maxq

class TestShellCommandExecution(steps.BuildStepMixin, unittest.TestCase):

def setUp(self):
return self.setUpBuildStep()

def tearDown(self):
return self.tearDownBuildStep()

def test_testdir_required(self):
self.assertRaises(TypeError, lambda : maxq.MaxQ())

def test_success(self):
self.setupStep(
maxq.MaxQ(testdir='x'))
self.expectCommands(
ExpectShell(workdir='wkdir', usePTY='slave-config',
command="run_maxq.py x")
+ ExpectShell.log('stdio', stdout='no failures\n')
+ 0
)
self.expectOutcome(result=SUCCESS, status_text=['maxq', 'tests'])
return self.runStep()

def test_nonzero_rc_no_failures(self):
self.setupStep(
maxq.MaxQ(testdir='x'))
self.expectCommands(
ExpectShell(workdir='wkdir', usePTY='slave-config',
command="run_maxq.py x")
+ ExpectShell.log('stdio', stdout='no failures\n')
+ 2
)
self.expectOutcome(result=FAILURE,
status_text=['1', 'maxq', 'failures'])
return self.runStep()

def test_failures(self):
self.setupStep(
maxq.MaxQ(testdir='x'))
self.expectCommands(
ExpectShell(workdir='wkdir', usePTY='slave-config',
command="run_maxq.py x")
+ ExpectShell.log('stdio', stdout='\nTEST FAILURE: foo\n' * 10)
+ 2
)
self.expectOutcome(result=FAILURE,
status_text=['10', 'maxq', 'failures'])
return self.runStep()

15 changes: 15 additions & 0 deletions master/docs/manual/cfg-buildsteps.rst
Expand Up @@ -2419,3 +2419,18 @@ Python executable to use to run Lore. ::
from buildbot.steps.python_twisted import HLint
f.addStep(HLint())

MaxQ
++++

.. bb:step:: MaxQ
MaxQ (http://maxq.tigris.org/) is a web testing tool that allows you to record
HTTP sessions and play them back. The :bb:step:`MaxQ` step runs this
framework. ::

from buildbot.steps.maxq import MaxQ
f.addStep(MaxQ(testdir='tests/'))

The single argument, ``testdir``, specifies where the tests should be run.
This directory will be passed to the ``run_maxq.py`` command, and the results
analyzed.

0 comments on commit c586138

Please sign in to comment.