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
diff --git a/debian/changelog b/debian/changelog
index d0a08a0..23a279d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
1launchpad-buildd (203) UNRELEASED; urgency=medium
2
3 * Remove some more "slave" terminology from tests.
4
5 -- Colin Watson <cjwatson@ubuntu.com> Fri, 01 Oct 2021 13:43:31 +0100
6
1launchpad-buildd (202) bionic; urgency=medium7launchpad-buildd (202) bionic; urgency=medium
28
3 [ Thomas Bechtold ]9 [ Thomas Bechtold ]
diff --git a/lpbuildd/tests/harness.py b/lpbuildd/tests/harness.py
index 9bc1a5d..bd85753 100644
--- a/lpbuildd/tests/harness.py
+++ b/lpbuildd/tests/harness.py
@@ -46,27 +46,27 @@ class BuilddTestCase(unittest.TestCase):
46 conf.read(test_conffile)46 conf.read(test_conffile)
47 conf.set("builder", "filecache", tempfile.mkdtemp())47 conf.set("builder", "filecache", tempfile.mkdtemp())
4848
49 self.slave = Builder(conf)49 self.builder = Builder(conf)
50 self.slave._log = True50 self.builder._log = True
51 self.slave.manager = MockBuildManager()51 self.builder.manager = MockBuildManager()
5252
53 self.here = os.path.abspath(os.path.dirname(__file__))53 self.here = os.path.abspath(os.path.dirname(__file__))
5454
55 def tearDown(self):55 def tearDown(self):
56 """Remove the 'filecache' directory used for the tests."""56 """Remove the 'filecache' directory used for the tests."""
57 shutil.rmtree(self.slave._cachepath)57 shutil.rmtree(self.builder._cachepath)
5858
59 def makeLog(self, size):59 def makeLog(self, size):
60 """Inject data into the default buildlog file."""60 """Inject data into the default buildlog file."""
61 f = open(self.slave.cachePath('buildlog'), 'w')61 f = open(self.builder.cachePath('buildlog'), 'w')
62 f.write("x" * size)62 f.write("x" * size)
63 f.close()63 f.close()
6464
6565
66class BuilddSlaveTestSetup(TacTestFixture):66class BuilddTestSetup(TacTestFixture):
67 r"""Setup Builder for use by functional tests67 r"""Setup Builder for use by functional tests
6868
69 >>> fixture = BuilddSlaveTestSetup()69 >>> fixture = BuilddTestSetup()
70 >>> fixture.setUp()70 >>> fixture.setUp()
7171
72 Make sure the server is running72 Make sure the server is running
diff --git a/lpbuildd/tests/test_buildd_slave.py b/lpbuildd/tests/test_buildd.py
73similarity index 82%73similarity index 82%
74rename from lpbuildd/tests/test_buildd_slave.py74rename from lpbuildd/tests/test_buildd_slave.py
75rename to lpbuildd/tests/test_buildd.py75rename to lpbuildd/tests/test_buildd.py
index f59b1b7..777868b 100644
--- a/lpbuildd/tests/test_buildd_slave.py
+++ b/lpbuildd/tests/test_buildd.py
@@ -13,7 +13,7 @@ This file contains the following tests:
1313
14__metaclass__ = type14__metaclass__ = type
1515
16__all__ = ['LaunchpadBuilddSlaveTests']16__all__ = ['LaunchpadBuilddTests']
1717
18import difflib18import difflib
19import os19import os
@@ -27,8 +27,8 @@ from six.moves.xmlrpc_client import ServerProxy
27import twisted27import twisted
2828
29from lpbuildd.tests.harness import (29from lpbuildd.tests.harness import (
30 BuilddSlaveTestSetup,
31 BuilddTestCase,30 BuilddTestCase,
31 BuilddTestSetup,
32 MockBuildManager,32 MockBuildManager,
33 )33 )
3434
@@ -39,7 +39,7 @@ def read_file(path):
39 return file_object.read()39 return file_object.read()
4040
4141
42class LaunchpadBuilddSlaveTests(BuilddTestCase):42class LaunchpadBuilddTests(BuilddTestCase):
43 """Unit tests for scrubbing (removal of passwords) of buildlog files."""43 """Unit tests for scrubbing (removal of passwords) of buildlog files."""
4444
45 def testBasicAuth(self):45 def testBasicAuth(self):
@@ -48,7 +48,7 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
48 user = "myuser"48 user = "myuser"
49 password = "fakepassword"49 password = "fakepassword"
5050
51 opener = self.slave.setupAuthHandler(url, user, password)51 opener = self.builder.setupAuthHandler(url, user, password)
5252
53 # Inspect the openers and ensure the wanted handler is installed.53 # Inspect the openers and ensure the wanted handler is installed.
54 basic_auth_handler = None54 basic_auth_handler = None
@@ -68,17 +68,17 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
68 def testBuildlogScrubbing(self):68 def testBuildlogScrubbing(self):
69 """Tests the buildlog scrubbing (removal of passwords from URLs)."""69 """Tests the buildlog scrubbing (removal of passwords from URLs)."""
70 # This is where the buildlog file lives.70 # This is where the buildlog file lives.
71 log_path = self.slave.cachePath('buildlog')71 log_path = self.builder.cachePath('buildlog')
7272
73 # This is where the builder leaves the original/unsanitized73 # This is where the builder leaves the original/unsanitized
74 # buildlog file after scrubbing.74 # buildlog file after scrubbing.
75 unsanitized_path = self.slave.cachePath('buildlog.unsanitized')75 unsanitized_path = self.builder.cachePath('buildlog.unsanitized')
7676
77 # Copy the fake buildlog file to the cache path.77 # Copy the fake buildlog file to the cache path.
78 shutil.copy(os.path.join(self.here, 'buildlog'), log_path)78 shutil.copy(os.path.join(self.here, 'buildlog'), log_path)
7979
80 # Invoke the builder's buildlog scrubbing method.80 # Invoke the builder's buildlog scrubbing method.
81 self.slave.sanitizeBuildlog(log_path)81 self.builder.sanitizeBuildlog(log_path)
8282
83 # Read the unsanitized original content.83 # Read the unsanitized original content.
84 unsanitized = read_file(unsanitized_path).splitlines()84 unsanitized = read_file(unsanitized_path).splitlines()
@@ -104,7 +104,7 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
104 """Test the scrubbing of the builder's getLogTail() output."""104 """Test the scrubbing of the builder's getLogTail() output."""
105105
106 # This is where the buildlog file lives.106 # This is where the buildlog file lives.
107 log_path = self.slave.cachePath('buildlog')107 log_path = self.builder.cachePath('buildlog')
108108
109 # Copy the prepared, longer buildlog file so we can test lines109 # Copy the prepared, longer buildlog file so we can test lines
110 # that are chopped off in the middle.110 # that are chopped off in the middle.
@@ -113,13 +113,13 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
113 # First get the unfiltered log tail output (which is the default113 # First get the unfiltered log tail output (which is the default
114 # behaviour because the BuildManager's 'is_archive_private'114 # behaviour because the BuildManager's 'is_archive_private'
115 # property is initialized to False).115 # property is initialized to False).
116 self.slave.manager.is_archive_private = False116 self.builder.manager.is_archive_private = False
117 unsanitized = self.slave.getLogTail().decode('UTF-8').splitlines()117 unsanitized = self.builder.getLogTail().decode('UTF-8').splitlines()
118118
119 # Make the builder believe we are building in a private archive to119 # Make the builder believe we are building in a private archive to
120 # obtain the scrubbed log tail output.120 # obtain the scrubbed log tail output.
121 self.slave.manager.is_archive_private = True121 self.builder.manager.is_archive_private = True
122 clean = self.slave.getLogTail().decode('UTF-8').splitlines()122 clean = self.builder.getLogTail().decode('UTF-8').splitlines()
123123
124 # Get the differences ..124 # Get the differences ..
125 differences = '\n'.join(difflib.unified_diff(unsanitized, clean))125 differences = '\n'.join(difflib.unified_diff(unsanitized, clean))
@@ -142,27 +142,27 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
142 'getLogTail' return up to 2 KiB text from the current 'buildlog' file.142 'getLogTail' return up to 2 KiB text from the current 'buildlog' file.
143 """143 """
144 self.makeLog(0)144 self.makeLog(0)
145 log_tail = self.slave.getLogTail()145 log_tail = self.builder.getLogTail()
146 self.assertEqual(len(log_tail), 0)146 self.assertEqual(len(log_tail), 0)
147147
148 self.makeLog(1)148 self.makeLog(1)
149 log_tail = self.slave.getLogTail()149 log_tail = self.builder.getLogTail()
150 self.assertEqual(len(log_tail), 1)150 self.assertEqual(len(log_tail), 1)
151151
152 self.makeLog(2048)152 self.makeLog(2048)
153 log_tail = self.slave.getLogTail()153 log_tail = self.builder.getLogTail()
154 self.assertEqual(len(log_tail), 2048)154 self.assertEqual(len(log_tail), 2048)
155155
156 self.makeLog(2049)156 self.makeLog(2049)
157 log_tail = self.slave.getLogTail()157 log_tail = self.builder.getLogTail()
158 self.assertEqual(len(log_tail), 2048)158 self.assertEqual(len(log_tail), 2048)
159159
160 self.makeLog(4096)160 self.makeLog(4096)
161 log_tail = self.slave.getLogTail()161 log_tail = self.builder.getLogTail()
162 self.assertEqual(len(log_tail), 2048)162 self.assertEqual(len(log_tail), 2048)
163163
164 def testLogtailWhenLogFileVanishes(self):164 def testLogtailWhenLogFileVanishes(self):
165 """Slave.getLogTail doesn't get hurt if the logfile has vanished.165 """Builder.getLogTail doesn't get hurt if the logfile has vanished.
166166
167 This is a common race-condition in our builders, since they get167 This is a common race-condition in our builders, since they get
168 polled all the time when they are building.168 polled all the time when they are building.
@@ -173,47 +173,47 @@ class LaunchpadBuilddSlaveTests(BuilddTestCase):
173 """173 """
174 # Create some log content and read it.174 # Create some log content and read it.
175 self.makeLog(2048)175 self.makeLog(2048)
176 log_tail = self.slave.getLogTail()176 log_tail = self.builder.getLogTail()
177 self.assertEqual(len(log_tail), 2048)177 self.assertEqual(len(log_tail), 2048)
178178
179 # Read it again for luck.179 # Read it again for luck.
180 log_tail = self.slave.getLogTail()180 log_tail = self.builder.getLogTail()
181 self.assertEqual(len(log_tail), 2048)181 self.assertEqual(len(log_tail), 2048)
182182
183 # Remove the buildlog file183 # Remove the buildlog file
184 os.remove(self.slave.cachePath('buildlog'))184 os.remove(self.builder.cachePath('buildlog'))
185185
186 # Instead of shocking the getLogTail call, return an empty string.186 # Instead of shocking the getLogTail call, return an empty string.
187 log_tail = self.slave.getLogTail()187 log_tail = self.builder.getLogTail()
188 self.assertEqual(len(log_tail), 0)188 self.assertEqual(len(log_tail), 0)
189189
190 def testCleanDuplicateFiles(self):190 def testCleanDuplicateFiles(self):
191 """The clean method copes with duplicate waiting files."""191 """The clean method copes with duplicate waiting files."""
192 workdir = tempfile.mkdtemp()192 workdir = tempfile.mkdtemp()
193 self.addCleanup(shutil.rmtree, workdir)193 self.addCleanup(shutil.rmtree, workdir)
194 self.slave._log = None194 self.builder._log = None
195 self.slave.startBuild(MockBuildManager())195 self.builder.startBuild(MockBuildManager())
196 self.slave.buildComplete()196 self.builder.buildComplete()
197 paths = [os.path.join(workdir, name) for name in ('a', 'b')]197 paths = [os.path.join(workdir, name) for name in ('a', 'b')]
198 for path in paths:198 for path in paths:
199 with open(path, 'w') as f:199 with open(path, 'w') as f:
200 f.write('data')200 f.write('data')
201 self.slave.addWaitingFile(path)201 self.builder.addWaitingFile(path)
202 self.slave.clean()202 self.builder.clean()
203 self.assertEqual([], os.listdir(self.slave._cachepath))203 self.assertEqual([], os.listdir(self.builder._cachepath))
204204
205205
206class XMLRPCBuildDSlaveTests(unittest.TestCase):206class XMLRPCBuilderTests(unittest.TestCase):
207207
208 def setUp(self):208 def setUp(self):
209 super(XMLRPCBuildDSlaveTests, self).setUp()209 super(XMLRPCBuilderTests, self).setUp()
210 self.slave = BuilddSlaveTestSetup()210 self.builder = BuilddTestSetup()
211 self.slave.setUp()211 self.builder.setUp()
212 self.server = ServerProxy('http://localhost:8321/rpc/')212 self.server = ServerProxy('http://localhost:8321/rpc/')
213213
214 def tearDown(self):214 def tearDown(self):
215 self.slave.tearDown()215 self.builder.tearDown()
216 super(XMLRPCBuildDSlaveTests, self).tearDown()216 super(XMLRPCBuilderTests, self).tearDown()
217217
218 @unittest.skipIf(218 @unittest.skipIf(
219 sys.version >= '3' and219 sys.version >= '3' and

Subscribers

People subscribed via source and target branches