Merge ~cjwatson/launchpad-buildd:test-slave-terminology into launchpad-buildd:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 95ff65fcb156dd46fd831b1e79113a244426252d
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad-buildd:test-slave-terminology
Merge into: launchpad-buildd:master
Diff against target: 243 lines (+47/-41)
3 files modified
debian/changelog (+6/-0)
lpbuildd/tests/harness.py (+7/-7)
lpbuildd/tests/test_buildd.py (+34/-34)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+409507@code.launchpad.net

Commit message

Remove some more "slave" terminology from tests

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index d0a08a0..23a279d 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,9 @@
6+launchpad-buildd (203) UNRELEASED; urgency=medium
7+
8+ * Remove some more "slave" terminology from tests.
9+
10+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 01 Oct 2021 13:43:31 +0100
11+
12 launchpad-buildd (202) bionic; urgency=medium
13
14 [ Thomas Bechtold ]
15diff --git a/lpbuildd/tests/harness.py b/lpbuildd/tests/harness.py
16index 9bc1a5d..bd85753 100644
17--- a/lpbuildd/tests/harness.py
18+++ b/lpbuildd/tests/harness.py
19@@ -46,27 +46,27 @@ class BuilddTestCase(unittest.TestCase):
20 conf.read(test_conffile)
21 conf.set("builder", "filecache", tempfile.mkdtemp())
22
23- self.slave = Builder(conf)
24- self.slave._log = True
25- self.slave.manager = MockBuildManager()
26+ self.builder = Builder(conf)
27+ self.builder._log = True
28+ self.builder.manager = MockBuildManager()
29
30 self.here = os.path.abspath(os.path.dirname(__file__))
31
32 def tearDown(self):
33 """Remove the 'filecache' directory used for the tests."""
34- shutil.rmtree(self.slave._cachepath)
35+ shutil.rmtree(self.builder._cachepath)
36
37 def makeLog(self, size):
38 """Inject data into the default buildlog file."""
39- f = open(self.slave.cachePath('buildlog'), 'w')
40+ f = open(self.builder.cachePath('buildlog'), 'w')
41 f.write("x" * size)
42 f.close()
43
44
45-class BuilddSlaveTestSetup(TacTestFixture):
46+class BuilddTestSetup(TacTestFixture):
47 r"""Setup Builder for use by functional tests
48
49- >>> fixture = BuilddSlaveTestSetup()
50+ >>> fixture = BuilddTestSetup()
51 >>> fixture.setUp()
52
53 Make sure the server is running
54diff --git a/lpbuildd/tests/test_buildd_slave.py b/lpbuildd/tests/test_buildd.py
55similarity index 82%
56rename from lpbuildd/tests/test_buildd_slave.py
57rename to lpbuildd/tests/test_buildd.py
58index f59b1b7..777868b 100644
59--- a/lpbuildd/tests/test_buildd_slave.py
60+++ b/lpbuildd/tests/test_buildd.py
61@@ -13,7 +13,7 @@ This file contains the following tests:
62
63 __metaclass__ = type
64
65-__all__ = ['LaunchpadBuilddSlaveTests']
66+__all__ = ['LaunchpadBuilddTests']
67
68 import difflib
69 import os
70@@ -27,8 +27,8 @@ from six.moves.xmlrpc_client import ServerProxy
71 import twisted
72
73 from lpbuildd.tests.harness import (
74- BuilddSlaveTestSetup,
75 BuilddTestCase,
76+ BuilddTestSetup,
77 MockBuildManager,
78 )
79
80@@ -39,7 +39,7 @@ def read_file(path):
81 return file_object.read()
82
83
84-class LaunchpadBuilddSlaveTests(BuilddTestCase):
85+class LaunchpadBuilddTests(BuilddTestCase):
86 """Unit tests for scrubbing (removal of passwords) of buildlog files."""
87
88 def testBasicAuth(self):
89@@ -48,7 +48,7 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
90 user = "myuser"
91 password = "fakepassword"
92
93- opener = self.slave.setupAuthHandler(url, user, password)
94+ opener = self.builder.setupAuthHandler(url, user, password)
95
96 # Inspect the openers and ensure the wanted handler is installed.
97 basic_auth_handler = None
98@@ -68,17 +68,17 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
99 def testBuildlogScrubbing(self):
100 """Tests the buildlog scrubbing (removal of passwords from URLs)."""
101 # This is where the buildlog file lives.
102- log_path = self.slave.cachePath('buildlog')
103+ log_path = self.builder.cachePath('buildlog')
104
105 # This is where the builder leaves the original/unsanitized
106 # buildlog file after scrubbing.
107- unsanitized_path = self.slave.cachePath('buildlog.unsanitized')
108+ unsanitized_path = self.builder.cachePath('buildlog.unsanitized')
109
110 # Copy the fake buildlog file to the cache path.
111 shutil.copy(os.path.join(self.here, 'buildlog'), log_path)
112
113 # Invoke the builder's buildlog scrubbing method.
114- self.slave.sanitizeBuildlog(log_path)
115+ self.builder.sanitizeBuildlog(log_path)
116
117 # Read the unsanitized original content.
118 unsanitized = read_file(unsanitized_path).splitlines()
119@@ -104,7 +104,7 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
120 """Test the scrubbing of the builder's getLogTail() output."""
121
122 # This is where the buildlog file lives.
123- log_path = self.slave.cachePath('buildlog')
124+ log_path = self.builder.cachePath('buildlog')
125
126 # Copy the prepared, longer buildlog file so we can test lines
127 # that are chopped off in the middle.
128@@ -113,13 +113,13 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
129 # First get the unfiltered log tail output (which is the default
130 # behaviour because the BuildManager's 'is_archive_private'
131 # property is initialized to False).
132- self.slave.manager.is_archive_private = False
133- unsanitized = self.slave.getLogTail().decode('UTF-8').splitlines()
134+ self.builder.manager.is_archive_private = False
135+ unsanitized = self.builder.getLogTail().decode('UTF-8').splitlines()
136
137 # Make the builder believe we are building in a private archive to
138 # obtain the scrubbed log tail output.
139- self.slave.manager.is_archive_private = True
140- clean = self.slave.getLogTail().decode('UTF-8').splitlines()
141+ self.builder.manager.is_archive_private = True
142+ clean = self.builder.getLogTail().decode('UTF-8').splitlines()
143
144 # Get the differences ..
145 differences = '\n'.join(difflib.unified_diff(unsanitized, clean))
146@@ -142,27 +142,27 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
147 'getLogTail' return up to 2 KiB text from the current 'buildlog' file.
148 """
149 self.makeLog(0)
150- log_tail = self.slave.getLogTail()
151+ log_tail = self.builder.getLogTail()
152 self.assertEqual(len(log_tail), 0)
153
154 self.makeLog(1)
155- log_tail = self.slave.getLogTail()
156+ log_tail = self.builder.getLogTail()
157 self.assertEqual(len(log_tail), 1)
158
159 self.makeLog(2048)
160- log_tail = self.slave.getLogTail()
161+ log_tail = self.builder.getLogTail()
162 self.assertEqual(len(log_tail), 2048)
163
164 self.makeLog(2049)
165- log_tail = self.slave.getLogTail()
166+ log_tail = self.builder.getLogTail()
167 self.assertEqual(len(log_tail), 2048)
168
169 self.makeLog(4096)
170- log_tail = self.slave.getLogTail()
171+ log_tail = self.builder.getLogTail()
172 self.assertEqual(len(log_tail), 2048)
173
174 def testLogtailWhenLogFileVanishes(self):
175- """Slave.getLogTail doesn't get hurt if the logfile has vanished.
176+ """Builder.getLogTail doesn't get hurt if the logfile has vanished.
177
178 This is a common race-condition in our builders, since they get
179 polled all the time when they are building.
180@@ -173,47 +173,47 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
181 """
182 # Create some log content and read it.
183 self.makeLog(2048)
184- log_tail = self.slave.getLogTail()
185+ log_tail = self.builder.getLogTail()
186 self.assertEqual(len(log_tail), 2048)
187
188 # Read it again for luck.
189- log_tail = self.slave.getLogTail()
190+ log_tail = self.builder.getLogTail()
191 self.assertEqual(len(log_tail), 2048)
192
193 # Remove the buildlog file
194- os.remove(self.slave.cachePath('buildlog'))
195+ os.remove(self.builder.cachePath('buildlog'))
196
197 # Instead of shocking the getLogTail call, return an empty string.
198- log_tail = self.slave.getLogTail()
199+ log_tail = self.builder.getLogTail()
200 self.assertEqual(len(log_tail), 0)
201
202 def testCleanDuplicateFiles(self):
203 """The clean method copes with duplicate waiting files."""
204 workdir = tempfile.mkdtemp()
205 self.addCleanup(shutil.rmtree, workdir)
206- self.slave._log = None
207- self.slave.startBuild(MockBuildManager())
208- self.slave.buildComplete()
209+ self.builder._log = None
210+ self.builder.startBuild(MockBuildManager())
211+ self.builder.buildComplete()
212 paths = [os.path.join(workdir, name) for name in ('a', 'b')]
213 for path in paths:
214 with open(path, 'w') as f:
215 f.write('data')
216- self.slave.addWaitingFile(path)
217- self.slave.clean()
218- self.assertEqual([], os.listdir(self.slave._cachepath))
219+ self.builder.addWaitingFile(path)
220+ self.builder.clean()
221+ self.assertEqual([], os.listdir(self.builder._cachepath))
222
223
224-class XMLRPCBuildDSlaveTests(unittest.TestCase):
225+class XMLRPCBuilderTests(unittest.TestCase):
226
227 def setUp(self):
228- super(XMLRPCBuildDSlaveTests, self).setUp()
229- self.slave = BuilddSlaveTestSetup()
230- self.slave.setUp()
231+ super(XMLRPCBuilderTests, self).setUp()
232+ self.builder = BuilddTestSetup()
233+ self.builder.setUp()
234 self.server = ServerProxy('http://localhost:8321/rpc/')
235
236 def tearDown(self):
237- self.slave.tearDown()
238- super(XMLRPCBuildDSlaveTests, self).tearDown()
239+ self.builder.tearDown()
240+ super(XMLRPCBuilderTests, self).tearDown()
241
242 @unittest.skipIf(
243 sys.version >= '3' and

Subscribers

People subscribed via source and target branches