Skip to content

Commit 3d84ba9

Browse files
committed
More test setup and teardown functionality.
- Legacy-Id: 204
1 parent 27edcb2 commit 3d84ba9

6 files changed

Lines changed: 312 additions & 28 deletions

File tree

test/buildbot-master.cfg

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# -*- python -*-
2+
# ex: set syntax=python:
3+
4+
# This is a sample buildmaster config file. It must be installed as
5+
# 'master.cfg' in your buildmaster's base directory (although the filename
6+
# can be changed with the --basedir option to 'mktap buildbot master').
7+
8+
# It has one job: define a dictionary named BuildmasterConfig. This
9+
# dictionary has a variety of keys to control different aspects of the
10+
# buildmaster. They are documented in docs/config.xhtml .
11+
12+
13+
# This is the dictionary that the buildmaster pays attention to. We also use
14+
# a shorter alias to save typing.
15+
c = BuildmasterConfig = {}
16+
17+
####### BUILDSLAVES
18+
19+
# the 'bots' list defines the set of allowable buildslaves. Each element is a
20+
# tuple of bot-name and bot-password. These correspond to values given to the
21+
# buildslave's mktap invocation.
22+
c['bots'] = [("merlot", "U-Xmpr"),
23+
]
24+
25+
26+
# 'slavePortnum' defines the TCP port to listen on. This must match the value
27+
# configured into the buildslaves (with their --master option)
28+
29+
c['slavePortnum'] = 2718
30+
31+
32+
####### CHANGESOURCES
33+
34+
# the 'sources' list tells the buildmaster how it should find out about
35+
# source code changes. Any class which implements IChangeSource can be added
36+
# to this list: there are several in buildbot/changes/*.py to choose from.
37+
38+
c['sources'] = []
39+
40+
# For example, if you had CVSToys installed on your repository, and your
41+
# CVSROOT/freshcfg file had an entry like this:
42+
#pb = ConfigurationSet([
43+
# (None, None, None, PBService(userpass=('foo', 'bar'), port=4519)),
44+
# ])
45+
46+
# then you could use the following buildmaster Change Source to subscribe to
47+
# the FreshCVS daemon and be notified on every commit:
48+
#
49+
#from buildbot.changes.freshcvs import FreshCVSSource
50+
#fc_source = FreshCVSSource("cvs.example.com", 4519, "foo", "bar")
51+
#c['sources'].append(fc_source)
52+
53+
# or, use a PBChangeSource, and then have your repository's commit script run
54+
# 'buildbot sendchange', or contrib/svn_buildbot.py, or
55+
# contrib/arch_buildbot.py :
56+
#
57+
from buildbot.changes.pb import PBChangeSource
58+
c['sources'].append(PBChangeSource())
59+
60+
61+
####### SCHEDULERS
62+
63+
## configure the Schedulers
64+
65+
from buildbot.scheduler import Scheduler
66+
c['schedulers'] = []
67+
c['schedulers'].append(Scheduler(name="all", branch=None,
68+
treeStableTimer=2*60,
69+
builderNames=["merlot-builder-1"]))
70+
71+
72+
####### BUILDERS
73+
74+
# the 'builders' list defines the Builders. Each one is configured with a
75+
# dictionary, using the following keys:
76+
# name (required): the name used to describe this bilder
77+
# slavename (required): which slave to use, must appear in c['bots']
78+
# builddir (required): which subdirectory to run the builder in
79+
# factory (required): a BuildFactory to define how the build is run
80+
# periodicBuildTime (optional): if set, force a build every N seconds
81+
82+
# buildbot/process/factory.py provides several BuildFactory classes you can
83+
# start with, which implement build processes for common targets (GNU
84+
# autoconf projects, CPAN perl modules, etc). The factory.BuildFactory is the
85+
# base class, and is configured with a series of BuildSteps. When the build
86+
# is run, the appropriate buildslave is told to execute each Step in turn.
87+
88+
# the first BuildStep is typically responsible for obtaining a copy of the
89+
# sources. There are source-obtaining Steps in buildbot/process/step.py for
90+
# CVS, SVN, and others.
91+
92+
from buildbot.process import factory
93+
from buildbot.steps.source import SVN
94+
from buildbot.steps.dummy import Dummy
95+
from buildbot.steps.python import PyFlakes
96+
from buildbot.steps.shell import ShellCommand as BaseShellCommand
97+
from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE
98+
99+
class ShellCommand(BaseShellCommand):
100+
def evaluateCommand(self, cmd):
101+
if cmd.rc == 0:
102+
return SUCCESS
103+
if cmd.rc == 1:
104+
return WARNINGS
105+
else:
106+
return FAILURE
107+
108+
f1 = factory.BuildFactory()
109+
f1.addStep(SVN, svnurl="http://svn.tools.ietf.org/svn/tools/ietfdb/trunk/", username="buildbot@tools.ietf.org", password="U64#GUxr")
110+
f1.addStep(ShellCommand, command=["test/test-setup"])
111+
f1.addStep(PyFlakes, command=["pyflakes", "ietf"], warnOnFailure=True)
112+
f1.addStep(ShellCommand, command=["python", "ietf/manage.py", "test"], env={'PYTHONPATH': ["test/lib",]} )
113+
f1.addStep(ShellCommand, command=["test/test-teardown"])
114+
f1.addStep(Dummy, timeout=10)
115+
116+
b1 = {'name': "merlot-builder-1",
117+
'slavename': "merlot",
118+
'builddir': "builder1",
119+
'factory': f1,
120+
}
121+
c['builders'] = [b1]
122+
123+
124+
####### STATUS TARGETS
125+
126+
# 'status' is a list of Status Targets. The results of each build will be
127+
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
128+
# including web pages, email senders, and IRC bots.
129+
130+
c['status'] = []
131+
132+
#from buildbot.status import html
133+
#c['status'].append(html.Waterfall(http_port=8010))
134+
135+
import trac_buildbot_html as trac_html
136+
c['status'].append(trac_html.Waterfall(http_port=8010))
137+
138+
import trac_buildbot_html_dev as trac_html_dev
139+
c['status'].append(trac_html_dev.Waterfall(http_port=8011))
140+
141+
# from buildbot.status import mail
142+
# c['status'].append(mail.MailNotifier(fromaddr="buildbot@tools.ietf.org",
143+
# extraRecipients=["django-project@ietf.org"],
144+
# mode="problem",
145+
# mode="failing",
146+
# sendToInterestedUsers=True))
147+
148+
# from buildbot.status import words
149+
# c['status'].append(words.IRC(host="irc.example.com", nick="bb",
150+
# channels=["#example"]))
151+
#
152+
# from buildbot.status import client
153+
# c['status'].append(client.PBListener(9988))
154+
155+
156+
####### DEBUGGING OPTIONS
157+
158+
# if you set 'debugPassword', then you can connect to the buildmaster with
159+
# the diagnostic tool in contrib/debugclient.py . From this tool, you can
160+
# manually force builds and inject changes, which may be useful for testing
161+
# your buildmaster without actually commiting changes to your repository (or
162+
# before you have a functioning 'sources' set up). The debug tool uses the
163+
# same port number as the slaves do: 'slavePortnum'.
164+
165+
#c['debugPassword'] = "debugpassword"
166+
167+
# if you set 'manhole', you can ssh into the buildmaster and get an
168+
# interactive python shell, which may be useful for debugging buildbot
169+
# internals. It is probably only useful for buildbot developers. You can also
170+
# use an authorized_keys file, or plain telnet.
171+
#from buildbot import manhole
172+
#c['manhole'] = manhole.PasswordManhole("tcp:9999:interface=127.0.0.1",
173+
# "admin", "password")
174+
175+
176+
####### PROJECT IDENTITY
177+
178+
# the 'projectName' string will be used to describe the project that this
179+
# buildbot is working on. For example, it is used as the title of the
180+
# waterfall HTML page. The 'projectURL' string will be used to provide a link
181+
# from buildbot HTML pages to your project's home page.
182+
183+
c['projectName'] = "IETFdb"
184+
c['projectURL'] = "http://merlot.tools.ietf.org/tools/ietfdb/"
185+
186+
# the 'buildbotURL' string should point to the location where the buildbot's
187+
# internal web server (usually the html.Waterfall page) is visible. This
188+
# typically uses the port number set in the Waterfall 'status' entry, but
189+
# with an externally-visible host name which the buildbot cannot figure out
190+
# without some help.
191+
192+
c['buildbotURL'] = "http://merlot.tools.ietf.org:8010/"

test/patch-django

Lines changed: 0 additions & 15 deletions
This file was deleted.

test/settings_local_test.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11

2-
# Make this unique, and don't share it with anybody.
3-
SECRET_KEY = 'oa0w4@r(=_0qvlnt#9c*_)3rclq4m^zd+19z)zk!=fo=d!ibyw'
4-
5-
DATABASE_NAME = 'ietfdb' # Or path to database file if using sqlite3.
6-
DATABASE_USER = 'django' # Not used with sqlite3.
7-
DATABASE_PASSWORD = 'zappa00' # Not used with sqlite3.
8-
9-
USE_I18N = False
10-
11-
TIME_ZONE = 'Europe/Stockholm'
12-
132
SERVER_MODE = 'test'
143

test/shell-utils

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# -*- shell -*-
2+
3+
# ----------------------------------------------------------------------
4+
# Helpers
5+
#
6+
7+
[ "$program" ] || program=${0##*/}
8+
9+
function err() {
10+
echo "$program: Error: $*" 1>&2;
11+
exit 2
12+
}
13+
14+
function warn() {
15+
echo "$program: Warning: $*" 1>&2;
16+
warnings=1
17+
}
18+
19+
function note() {
20+
if [ -n "$OPT_VERBOSE" ]; then say $*; fi
21+
}
22+
23+
function say() {
24+
echo -e "$program: $*" 1>&2;
25+
}
26+
27+
function version() {
28+
echo -e "$program: v$version\n\nRunning as $(id -urn) on $(date +'%Y-%m-%d %H:%M')"
29+
}
30+
31+
function filedate() {
32+
ls --full-time "$1" | tr ":." " " | awk '{printf "%sT%s:%s:%s%s:%s\n", $6, $7, $8, $9, substr($11,1,3), substr($11,4,2)}';
33+
}
34+
35+
function py_module_path() {
36+
module=$1
37+
python -c "import $module, os.path; print os.path.realpath($module.__path__[0])"
38+
}
39+
40+
function py_module_file() {
41+
module=$1
42+
python -c "import $module, os.path; print os.path.realpath($module.__file__)[:-4] + '.py'"
43+
}
44+
45+
46+
trap 'echo "$program($LINENO): Command failed with error code $? ($0 $*)"; exit 1' ERR
47+

test/test-setup

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,55 @@
11
#!/bin/bash
22
#
3-
# put in place a suitable settings_local.py for our application to find
3+
# This script expects to be started by a Buildbot slave with PWD set to the build
4+
# directory.
45

5-
cp test/settings_local_test.py ietf/settings_local.py
6+
# Script Setup
7+
# ============
68

9+
program=${0##*/}
10+
progdir=${0%/*}
11+
build=$PWD
12+
13+
. $progdir/shell-utils
14+
15+
# Patch Django
16+
# ============
17+
#
18+
# Assuming we check out trunk or branch-XXX with the command
19+
# 'svn co URL/BRANCH/'
20+
# then this script will be $PWD/test/patch-django and we will place our patched
21+
# django in $PWD/test/lib/django
22+
#
23+
24+
say "Setting up a local Django for the test suite"
25+
cd $build
26+
27+
django=$(py_module_path "django")
28+
rsync -av $django $build/test/lib/
29+
cd $build/test/lib
30+
for patch in $build/test/*.patch; do
31+
patch -p 3 -t -N < $patch
32+
done
33+
34+
# Database setup
35+
# ==============
36+
37+
#say "Setting up a database for the test suite"
38+
39+
# Project Setup
40+
# =============
41+
# put in place a suitable settings_local.py for our application to find. This should
42+
# be based on the local settings_local.py, but should add test-specific settings, and
43+
# should set things up so that we use the patched Django, not the system's default
44+
# Django.
45+
46+
say "Setting up the Django settings for the test suite"
47+
cd $build
48+
49+
settings_local=$(py_module_file "settings_local")
50+
[ "$settings_local" ] || err
51+
52+
cat $settings_local test/settings_local_test.py - > ietf/settings_local.py
53+
54+
55+
exit $warnings

test/test-teardown

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
#
3+
# This script expects to be started by a Buildbot slave with PWD set to the build
4+
# directory.
5+
6+
# Script Setup
7+
# ============
8+
9+
program=${0##*/}
10+
progdir=${0%/*}
11+
build=$PWD
12+
13+
. $progdir/shell-utils
14+
15+
# Database Cleanup
16+
# Make sure the test database has been removed
17+
python ietf/manage.py dbshell <<-EOT
18+
drop database test_ietf;
19+
exit;
20+
EOT
21+
22+
exit $warnings

0 commit comments

Comments
 (0)