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