Merge lp:~facundo/magicicada-server/update-client-1440 into lp:magicicada-server
- update-client-1440
- Merge into trunk
Proposed by
Facundo Batista
Status: | Merged |
---|---|
Approved by: | Natalia Bidart |
Approved revision: | 84 |
Merged at revision: | 84 |
Proposed branch: | lp:~facundo/magicicada-server/update-client-1440 |
Merge into: | lp:magicicada-server |
Diff against target: |
454 lines (+69/-106) 8 files modified
Makefile.db (+3/-3) config-manager.txt (+1/-1) magicicada/server/integtests/test_action_queue.py (+0/-47) magicicada/server/integtests/test_sync.py (+48/-43) magicicada/server/server.py (+1/-1) magicicada/server/testing/aq_helpers.py (+13/-9) magicicada/server/tests/test_shutdown.py (+1/-1) magicicada/settings/__init__.py (+2/-1) |
To merge this branch: | bzr merge lp:~facundo/magicicada-server/update-client-1440 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart | Approve | ||
Review via email: mp+341765@code.launchpad.net |
Commit message
Updated magicicada client to r1440.
Description of the change
Updated magicicada client to r1440.
Had to remove everything related to DNSs rotation for server selection, and update the way the connection info is passed to the client.
Not related to new client, I also needed to change a little something about Django config: send the complain about "no importable local config" to stderr, so it can be avoided when trying to print settings in Makefile.db
Included several aesthetic changes as I need to do those for `make test` to run properly... in the next branch I'll pin the flake8 revision in the venv so no more of these "spurious fixes" bother us.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Makefile.db' | |||
2 | --- Makefile.db 2016-03-08 00:32:28 +0000 | |||
3 | +++ Makefile.db 2018-03-20 19:58:45 +0000 | |||
4 | @@ -1,7 +1,7 @@ | |||
5 | 1 | SHELL_ENV = DJANGO_SETTINGS_MODULE=$(DJANGO_SETTINGS_MODULE) PYTHONPATH=$(PYTHONPATH) | 1 | SHELL_ENV = DJANGO_SETTINGS_MODULE=$(DJANGO_SETTINGS_MODULE) PYTHONPATH=$(PYTHONPATH) |
9 | 2 | PGNAME = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print settings.DATABASES['default']['NAME']") | 2 | PGNAME = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print settings.DATABASES['default']['NAME']" 2> /dev/null) |
10 | 3 | PGHOST = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print settings.DATABASES['default']['HOST']") | 3 | PGHOST = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print settings.DATABASES['default']['HOST']" 2> /dev/null) |
11 | 4 | PGUSER = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print settings.DATABASES['default']['USER']") | 4 | PGUSER = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print settings.DATABASES['default']['USER']" 2> /dev/null) |
12 | 5 | DATA_DIR = $(PGHOST)/data | 5 | DATA_DIR = $(PGHOST)/data |
13 | 6 | LOG_FILE = $(PGHOST)/postgresql.log | 6 | LOG_FILE = $(PGHOST)/postgresql.log |
14 | 7 | CONF_FILE = $(PGHOST)/postgresql.conf | 7 | CONF_FILE = $(PGHOST)/postgresql.conf |
15 | 8 | 8 | ||
16 | === modified file 'config-manager.txt' | |||
17 | --- config-manager.txt 2017-04-22 21:07:36 +0000 | |||
18 | +++ config-manager.txt 2018-03-20 19:58:45 +0000 | |||
19 | @@ -25,5 +25,5 @@ | |||
20 | 25 | ./.sourcecode/dirspec ~ubuntuone-control-tower/dirspec/trunk;revno=14 | 25 | ./.sourcecode/dirspec ~ubuntuone-control-tower/dirspec/trunk;revno=14 |
21 | 26 | ./.sourcecode/django ~ubuntuone-pqm-team/django/stable;revno=17 | 26 | ./.sourcecode/django ~ubuntuone-pqm-team/django/stable;revno=17 |
22 | 27 | ./.sourcecode/u1sync ~facundo/u1sync/opensourcing;revno=10 | 27 | ./.sourcecode/u1sync ~facundo/u1sync/opensourcing;revno=10 |
24 | 28 | ./.sourcecode/magicicada-client ~chicharreros/magicicada-client/trunk;revno=1433 | 28 | ./.sourcecode/magicicada-client ~chicharreros/magicicada-client/trunk;revno=1440 |
25 | 29 | ./.sourcecode/magicicada-protocol ~chicharreros/magicicada-protocol/trunk;revno=169 | 29 | ./.sourcecode/magicicada-protocol ~chicharreros/magicicada-protocol/trunk;revno=169 |
26 | 30 | 30 | ||
27 | === modified file 'magicicada/server/integtests/test_action_queue.py' | |||
28 | --- magicicada/server/integtests/test_action_queue.py 2016-06-07 19:06:06 +0000 | |||
29 | +++ magicicada/server/integtests/test_action_queue.py 2018-03-20 19:58:45 +0000 | |||
30 | @@ -35,13 +35,11 @@ | |||
31 | 35 | ActionQueue, | 35 | ActionQueue, |
32 | 36 | Download, | 36 | Download, |
33 | 37 | Upload, | 37 | Upload, |
34 | 38 | dns_client, | ||
35 | 39 | ) | 38 | ) |
36 | 40 | from ubuntuone.syncdaemon.marker import MDMarker as Marker | 39 | from ubuntuone.syncdaemon.marker import MDMarker as Marker |
37 | 41 | 40 | ||
38 | 42 | from magicicada.server.testing.aq_helpers import ( | 41 | from magicicada.server.testing.aq_helpers import ( |
39 | 43 | FakeFailure, | 42 | FakeFailure, |
40 | 44 | FakeResolver, | ||
41 | 45 | NO_CONTENT_HASH, | 43 | NO_CONTENT_HASH, |
42 | 46 | NoCloseStringIO, | 44 | NoCloseStringIO, |
43 | 47 | TestBase, | 45 | TestBase, |
44 | @@ -958,48 +956,3 @@ | |||
45 | 958 | d.addBoth(lambda _: self.main.wait_for_nirvana()) | 956 | d.addBoth(lambda _: self.main.wait_for_nirvana()) |
46 | 959 | d.addBoth(lambda _: self.eq.push('SYS_USER_DISCONNECT')) | 957 | d.addBoth(lambda _: self.eq.push('SYS_USER_DISCONNECT')) |
47 | 960 | return d | 958 | return d |
48 | 961 | |||
49 | 962 | |||
50 | 963 | class SRVLookupTest(TestWithDatabase): | ||
51 | 964 | """ Test for SRV lookup in the ActionQueue. """ | ||
52 | 965 | |||
53 | 966 | @defer.inlineCallbacks | ||
54 | 967 | def setUp(self): | ||
55 | 968 | """ | ||
56 | 969 | Replace the resolver with a FakeResolver | ||
57 | 970 | """ | ||
58 | 971 | yield super(SRVLookupTest, self).setUp() | ||
59 | 972 | dns_client.theResolver = FakeResolver() | ||
60 | 973 | |||
61 | 974 | @defer.inlineCallbacks | ||
62 | 975 | def tearDown(self): | ||
63 | 976 | """ | ||
64 | 977 | By setting the resolver to None, it will be recreated next time a name | ||
65 | 978 | lookup is done. | ||
66 | 979 | """ | ||
67 | 980 | yield super(SRVLookupTest, self).tearDown() | ||
68 | 981 | dns_client.theResolver = None | ||
69 | 982 | |||
70 | 983 | def test_SRV_lookup_dev(self): | ||
71 | 984 | """Test the srv lookup in development mode (localhost:<randomport>).""" | ||
72 | 985 | |||
73 | 986 | def checkResult(result): | ||
74 | 987 | """ Verify that we are correclty doing the lookup """ | ||
75 | 988 | host, port = result | ||
76 | 989 | self.assertEqual(host, self.aq.host) | ||
77 | 990 | |||
78 | 991 | d = self.aq._lookup_srv() | ||
79 | 992 | d.addCallback(checkResult) | ||
80 | 993 | return d | ||
81 | 994 | |||
82 | 995 | def test_SRV_lookup_prod(self): | ||
83 | 996 | """ test the srv lookup using a fake resolver. """ | ||
84 | 997 | def checkResult(result): | ||
85 | 998 | """ Verify that we are correclty doing the lookup """ | ||
86 | 999 | host, port = result | ||
87 | 1000 | self.assertTrue(host in ['fs-1.server.com', 'fs-0.server.com'], | ||
88 | 1001 | host) | ||
89 | 1002 | self.assertEqual(port, 443) | ||
90 | 1003 | self.aq.dns_srv = '_http._tcp.fs.server.com' | ||
91 | 1004 | d = self.aq._lookup_srv() | ||
92 | 1005 | d.addCallback(checkResult) | ||
93 | 1006 | 959 | ||
94 | === modified file 'magicicada/server/integtests/test_sync.py' | |||
95 | --- magicicada/server/integtests/test_sync.py 2016-11-07 01:37:46 +0000 | |||
96 | +++ magicicada/server/integtests/test_sync.py 2018-03-20 19:58:45 +0000 | |||
97 | @@ -113,9 +113,14 @@ | |||
98 | 113 | self.share_source_dir = self.mktemp("source/share") | 113 | self.share_source_dir = self.mktemp("source/share") |
99 | 114 | 114 | ||
100 | 115 | self.patch(hash_queue, "HASHQUEUE_DELAY", 0.1) | 115 | self.patch(hash_queue, "HASHQUEUE_DELAY", 0.1) |
101 | 116 | connection_info = [{ | ||
102 | 117 | 'host': "localhost", | ||
103 | 118 | 'port': self.ssl_port, | ||
104 | 119 | 'use_ssl': True, | ||
105 | 120 | 'disable_ssl_verify': True, | ||
106 | 121 | }] | ||
107 | 116 | self.main = Main(root_dir, shares_dir, data_dir, partials_dir, | 122 | self.main = Main(root_dir, shares_dir, data_dir, partials_dir, |
110 | 117 | "localhost", self.ssl_port, dns_srv=None, ssl=True, | 123 | connection_info=connection_info) |
109 | 118 | disable_ssl_verify=True) | ||
111 | 119 | self.addCleanup(self.main.shutdown) | 124 | self.addCleanup(self.main.shutdown) |
112 | 120 | 125 | ||
113 | 121 | self.eq = self.main.event_q | 126 | self.eq = self.main.event_q |
114 | @@ -972,8 +977,8 @@ | |||
115 | 972 | 977 | ||
116 | 973 | # check locally and in the server | 978 | # check locally and in the server |
117 | 974 | # it should only be our file in the directory, with content ok | 979 | # it should only be our file in the directory, with content ok |
120 | 975 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 980 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
121 | 976 | self.assertEqual(l, ["foo"]) | 981 | self.assertEqual(files, ["foo"]) |
122 | 977 | self.assertEqual(open(foo_path).read(), ":)") | 982 | self.assertEqual(open(foo_path).read(), ":)") |
123 | 978 | yield self.compare_server() | 983 | yield self.compare_server() |
124 | 979 | 984 | ||
125 | @@ -1130,8 +1135,8 @@ | |||
126 | 1130 | yield self.main.wait_for_nirvana(.5) | 1135 | yield self.main.wait_for_nirvana(.5) |
127 | 1131 | 1136 | ||
128 | 1132 | # check that everything is ok: it should only be our file in the dir... | 1137 | # check that everything is ok: it should only be our file in the dir... |
131 | 1133 | l = os.listdir(dir2) | 1138 | files = os.listdir(dir2) |
132 | 1134 | self.assertEqual(l, ["test_file"]) | 1139 | self.assertEqual(files, ["test_file"]) |
133 | 1135 | 1140 | ||
134 | 1136 | # ... and our file should have the correct content | 1141 | # ... and our file should have the correct content |
135 | 1137 | f = open(filepath2) | 1142 | f = open(filepath2) |
136 | @@ -1172,8 +1177,8 @@ | |||
137 | 1172 | def local_check(_): | 1177 | def local_check(_): |
138 | 1173 | """Check that everything is ok""" | 1178 | """Check that everything is ok""" |
139 | 1174 | # it should only be our file in the directory | 1179 | # it should only be our file in the directory |
142 | 1175 | l = os.listdir(dir2) | 1180 | files = os.listdir(dir2) |
143 | 1176 | self.assertEqual(l, ["test_file"]) | 1181 | self.assertEqual(files, ["test_file"]) |
144 | 1177 | 1182 | ||
145 | 1178 | # our file should have the correct content | 1183 | # our file should have the correct content |
146 | 1179 | f = open(filepath2) | 1184 | f = open(filepath2) |
147 | @@ -1233,8 +1238,8 @@ | |||
148 | 1233 | 1238 | ||
149 | 1234 | # wait dust to settle, check locally and in the server | 1239 | # wait dust to settle, check locally and in the server |
150 | 1235 | yield self.main.wait_for_nirvana(.5) | 1240 | yield self.main.wait_for_nirvana(.5) |
153 | 1236 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1241 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
154 | 1237 | self.assertEqual(l, ["test_file"]) | 1242 | self.assertEqual(files, ["test_file"]) |
155 | 1238 | yield self.compare_server() | 1243 | yield self.compare_server() |
156 | 1239 | 1244 | ||
157 | 1240 | @defer.inlineCallbacks | 1245 | @defer.inlineCallbacks |
158 | @@ -1317,8 +1322,8 @@ | |||
159 | 1317 | yield self.main.wait_for_nirvana(0.5) | 1322 | yield self.main.wait_for_nirvana(0.5) |
160 | 1318 | 1323 | ||
161 | 1319 | # check that everything is ok | 1324 | # check that everything is ok |
164 | 1320 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1325 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
165 | 1321 | self.assertEqual(l, ["test_file"]) | 1326 | self.assertEqual(files, ["test_file"]) |
166 | 1322 | with open(self.root_dir + "/test_file") as f: | 1327 | with open(self.root_dir + "/test_file") as f: |
167 | 1323 | content = f.read() | 1328 | content = f.read() |
168 | 1324 | self.assertEqual(content, ":)") | 1329 | self.assertEqual(content, ":)") |
169 | @@ -1474,8 +1479,8 @@ | |||
170 | 1474 | 1479 | ||
171 | 1475 | def local_check(_): | 1480 | def local_check(_): |
172 | 1476 | """check that everything is in sync""" | 1481 | """check that everything is in sync""" |
175 | 1477 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1482 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
176 | 1478 | self.assertEqual(l, ["test_file"]) | 1483 | self.assertEqual(files, ["test_file"]) |
177 | 1479 | 1484 | ||
178 | 1480 | final_data = open(self.root_dir + '/test_file').read() | 1485 | final_data = open(self.root_dir + '/test_file').read() |
179 | 1481 | self.assertEqual(data, final_data) | 1486 | self.assertEqual(data, final_data) |
180 | @@ -1503,8 +1508,8 @@ | |||
181 | 1503 | 1508 | ||
182 | 1504 | def content_check(_): | 1509 | def content_check(_): |
183 | 1505 | """Check that everything is in sync.""" | 1510 | """Check that everything is in sync.""" |
186 | 1506 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1511 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
187 | 1507 | self.assertEqual(l, ["test_dir"]) | 1512 | self.assertEqual(files, ["test_dir"]) |
188 | 1508 | self.assertTrue(stat.S_ISDIR( | 1513 | self.assertTrue(stat.S_ISDIR( |
189 | 1509 | os.stat(self.root_dir + '/test_dir')[stat.ST_MODE])) | 1514 | os.stat(self.root_dir + '/test_dir')[stat.ST_MODE])) |
190 | 1510 | 1515 | ||
191 | @@ -1564,8 +1569,8 @@ | |||
192 | 1564 | yield self.main.wait_for_nirvana(.5) | 1569 | yield self.main.wait_for_nirvana(.5) |
193 | 1565 | 1570 | ||
194 | 1566 | # it should only be our file in the directory | 1571 | # it should only be our file in the directory |
197 | 1567 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1572 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
198 | 1568 | self.assertEqual(l, ["test_file"]) | 1573 | self.assertEqual(files, ["test_file"]) |
199 | 1569 | 1574 | ||
200 | 1570 | # our file should have the full content | 1575 | # our file should have the full content |
201 | 1571 | filesize = os.stat(self.root_dir + "/test_file").st_size | 1576 | filesize = os.stat(self.root_dir + "/test_file").st_size |
202 | @@ -1610,8 +1615,8 @@ | |||
203 | 1610 | yield self.main.wait_for_nirvana(.5) | 1615 | yield self.main.wait_for_nirvana(.5) |
204 | 1611 | 1616 | ||
205 | 1612 | # we should have both files... | 1617 | # we should have both files... |
208 | 1613 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1618 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
209 | 1614 | self.assertEqual(sorted(l), ["test_file", "test_file.u1conflict"]) | 1619 | self.assertEqual(sorted(files), ["test_file", "test_file.u1conflict"]) |
210 | 1615 | 1620 | ||
211 | 1616 | # ...with the respective content | 1621 | # ...with the respective content |
212 | 1617 | sanefile = open(test_file).read() | 1622 | sanefile = open(test_file).read() |
213 | @@ -1631,8 +1636,8 @@ | |||
214 | 1631 | yield self.main.wait_for_nirvana(.5) | 1636 | yield self.main.wait_for_nirvana(.5) |
215 | 1632 | 1637 | ||
216 | 1633 | # finally, only one file with right content | 1638 | # finally, only one file with right content |
219 | 1634 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1639 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
220 | 1635 | self.assertEqual(sorted(l), ["test_file"]) | 1640 | self.assertEqual(sorted(files), ["test_file"]) |
221 | 1636 | sanefile = open(test_file).read() | 1641 | sanefile = open(test_file).read() |
222 | 1637 | self.assertEqual(sanefile, data_local) | 1642 | self.assertEqual(sanefile, data_local) |
223 | 1638 | yield self.compare_server() | 1643 | yield self.compare_server() |
224 | @@ -1647,8 +1652,8 @@ | |||
225 | 1647 | yield self.main.wait_for_nirvana(.5) | 1652 | yield self.main.wait_for_nirvana(.5) |
226 | 1648 | 1653 | ||
227 | 1649 | # finally, only one file with right content | 1654 | # finally, only one file with right content |
230 | 1650 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1655 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
231 | 1651 | self.assertEqual(sorted(l), ["test_file", "test_file_new"]) | 1656 | self.assertEqual(sorted(files), ["test_file", "test_file_new"]) |
232 | 1652 | srvfile = open(test_file).read() | 1657 | srvfile = open(test_file).read() |
233 | 1653 | self.assertEqual(srvfile, data_server) | 1658 | self.assertEqual(srvfile, data_server) |
234 | 1654 | newfile = open(test_file + "_new").read() | 1659 | newfile = open(test_file + "_new").read() |
235 | @@ -1703,8 +1708,8 @@ | |||
236 | 1703 | 1708 | ||
237 | 1704 | def no_conflict_check(_): | 1709 | def no_conflict_check(_): |
238 | 1705 | """Check the absence of conflict, and the deletion of the node.""" | 1710 | """Check the absence of conflict, and the deletion of the node.""" |
241 | 1706 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1711 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
242 | 1707 | self.assertEqual(l, []) | 1712 | self.assertEqual(files, []) |
243 | 1708 | 1713 | ||
244 | 1709 | d = self.get_client() | 1714 | d = self.get_client() |
245 | 1710 | d.addCallback(self.create_and_check) | 1715 | d.addCallback(self.create_and_check) |
246 | @@ -1740,8 +1745,8 @@ | |||
247 | 1740 | self.update_state(None) | 1745 | self.update_state(None) |
248 | 1741 | yield self.main.wait_for_nirvana(.5) | 1746 | yield self.main.wait_for_nirvana(.5) |
249 | 1742 | 1747 | ||
252 | 1743 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1748 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
253 | 1744 | self.assertEqual(sorted(l), [self.dir_name_conflict]) | 1749 | self.assertEqual(sorted(files), [self.dir_name_conflict]) |
254 | 1745 | 1750 | ||
255 | 1746 | 1751 | ||
256 | 1747 | class TestConflict2(TestServerBase): | 1752 | class TestConflict2(TestServerBase): |
257 | @@ -1757,7 +1762,7 @@ | |||
258 | 1757 | os.mkdir(self.root_dir + "/test_dir/test_dir") | 1762 | os.mkdir(self.root_dir + "/test_dir/test_dir") |
259 | 1758 | try: | 1763 | try: |
260 | 1759 | yield self.client.unlink(request.ROOT, req.new_id) | 1764 | yield self.client.unlink(request.ROOT, req.new_id) |
262 | 1760 | except: | 1765 | except Exception: |
263 | 1761 | # ignore if the unlink fails | 1766 | # ignore if the unlink fails |
264 | 1762 | pass | 1767 | pass |
265 | 1763 | yield self.main.wait_for_nirvana(0.5) | 1768 | yield self.main.wait_for_nirvana(0.5) |
266 | @@ -1840,8 +1845,8 @@ | |||
267 | 1840 | yield self.wait_for_nirvana(.5) | 1845 | yield self.wait_for_nirvana(.5) |
268 | 1841 | 1846 | ||
269 | 1842 | # no conflicts, and the server with correct data | 1847 | # no conflicts, and the server with correct data |
272 | 1843 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1848 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
273 | 1844 | self.assertEqual(l, ['testfile']) | 1849 | self.assertEqual(files, ['testfile']) |
274 | 1845 | self.assertEqual(open(fname).read(), "other content") | 1850 | self.assertEqual(open(fname).read(), "other content") |
275 | 1846 | yield self.check() | 1851 | yield self.check() |
276 | 1847 | 1852 | ||
277 | @@ -1879,8 +1884,8 @@ | |||
278 | 1879 | play_hash() | 1884 | play_hash() |
279 | 1880 | 1885 | ||
280 | 1881 | # check that we don't have conflict, and all is the same with server | 1886 | # check that we don't have conflict, and all is the same with server |
283 | 1882 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1887 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
284 | 1883 | self.assertEqual(l, ['tfile']) | 1888 | self.assertEqual(files, ['tfile']) |
285 | 1884 | self.assertEqual(open(fname).read(), fcontent) | 1889 | self.assertEqual(open(fname).read(), fcontent) |
286 | 1885 | yield self.check() | 1890 | yield self.check() |
287 | 1886 | 1891 | ||
288 | @@ -1916,8 +1921,8 @@ | |||
289 | 1916 | yield self.wait_for_nirvana(.5) | 1921 | yield self.wait_for_nirvana(.5) |
290 | 1917 | 1922 | ||
291 | 1918 | # check that we don't have conflict, and all is the same with server | 1923 | # check that we don't have conflict, and all is the same with server |
294 | 1919 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1924 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
295 | 1920 | self.assertEqual(l, ['tfile']) | 1925 | self.assertEqual(files, ['tfile']) |
296 | 1921 | self.assertEqual(open(fname).read(), fcontent) | 1926 | self.assertEqual(open(fname).read(), fcontent) |
297 | 1922 | yield self.check() | 1927 | yield self.check() |
298 | 1923 | 1928 | ||
299 | @@ -1958,8 +1963,8 @@ | |||
300 | 1958 | yield self.wait_for_nirvana(.5) | 1963 | yield self.wait_for_nirvana(.5) |
301 | 1959 | 1964 | ||
302 | 1960 | # check that we don't have conflict, and all is the same with server | 1965 | # check that we don't have conflict, and all is the same with server |
305 | 1961 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 1966 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
306 | 1962 | self.assertEqual(sorted(l), ['tfile']) | 1967 | self.assertEqual(sorted(files), ['tfile']) |
307 | 1963 | self.assertEqual(open(fname).read(), 'foo') | 1968 | self.assertEqual(open(fname).read(), 'foo') |
308 | 1964 | yield self.check() | 1969 | yield self.check() |
309 | 1965 | 1970 | ||
310 | @@ -2301,8 +2306,8 @@ | |||
311 | 2301 | self.aq.get_delta(request.ROOT, 0) | 2306 | self.aq.get_delta(request.ROOT, 0) |
312 | 2302 | yield self.main.wait_for_nirvana(0) | 2307 | yield self.main.wait_for_nirvana(0) |
313 | 2303 | 2308 | ||
316 | 2304 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 2309 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
317 | 2305 | self.assertEqual(l, ["tfile"]) | 2310 | self.assertEqual(files, ["tfile"]) |
318 | 2306 | yield self.check() | 2311 | yield self.check() |
319 | 2307 | 2312 | ||
320 | 2308 | @defer.inlineCallbacks | 2313 | @defer.inlineCallbacks |
321 | @@ -2494,8 +2499,8 @@ | |||
322 | 2494 | yield wait_download | 2499 | yield wait_download |
323 | 2495 | 2500 | ||
324 | 2496 | # check the node is conflicted, both files with corerct content | 2501 | # check the node is conflicted, both files with corerct content |
327 | 2497 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 2502 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
328 | 2498 | self.assertEqual(sorted(l), ["test_file", "test_file.u1conflict"]) | 2503 | self.assertEqual(sorted(files), ["test_file", "test_file.u1conflict"]) |
329 | 2499 | with open(filepath) as f: | 2504 | with open(filepath) as f: |
330 | 2500 | self.assertEqual(f.read(), ":)") | 2505 | self.assertEqual(f.read(), ":)") |
331 | 2501 | with open(filepath + ".u1conflict") as f: | 2506 | with open(filepath + ".u1conflict") as f: |
332 | @@ -2520,8 +2525,8 @@ | |||
333 | 2520 | yield self.main.wait_for_nirvana(0.5) | 2525 | yield self.main.wait_for_nirvana(0.5) |
334 | 2521 | 2526 | ||
335 | 2522 | # check that everything is ok | 2527 | # check that everything is ok |
338 | 2523 | l = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) | 2528 | files = filter_symlinks(self.root_dir, os.listdir(self.root_dir)) |
339 | 2524 | self.assertEqual(l, ["test_file"]) | 2529 | self.assertEqual(files, ["test_file"]) |
340 | 2525 | with open(filepath) as f: | 2530 | with open(filepath) as f: |
341 | 2526 | self.assertEqual(f.read(), ":)") | 2531 | self.assertEqual(f.read(), ":)") |
342 | 2527 | 2532 | ||
343 | 2528 | 2533 | ||
344 | === modified file 'magicicada/server/server.py' | |||
345 | --- magicicada/server/server.py 2017-04-22 21:07:36 +0000 | |||
346 | +++ magicicada/server/server.py 2018-03-20 19:58:45 +0000 | |||
347 | @@ -1698,7 +1698,7 @@ | |||
348 | 1698 | self._log_exception(exc) | 1698 | self._log_exception(exc) |
349 | 1699 | yield self._send_protocol_error(failure) | 1699 | yield self._send_protocol_error(failure) |
350 | 1700 | yield self.done() | 1700 | yield self.done() |
352 | 1701 | except: | 1701 | except Exception: |
353 | 1702 | yield self.internal_error(Failure()) | 1702 | yield self.internal_error(Failure()) |
354 | 1703 | 1703 | ||
355 | 1704 | def _processMessage(self, message): | 1704 | def _processMessage(self, message): |
356 | 1705 | 1705 | ||
357 | === modified file 'magicicada/server/testing/aq_helpers.py' | |||
358 | --- magicicada/server/testing/aq_helpers.py 2017-04-22 21:07:36 +0000 | |||
359 | +++ magicicada/server/testing/aq_helpers.py 2018-03-20 19:58:45 +0000 | |||
360 | @@ -165,8 +165,7 @@ | |||
361 | 165 | class ReallyFakeMain(main.Main): | 165 | class ReallyFakeMain(main.Main): |
362 | 166 | """This main is so fake, it breaks nearly everything.""" | 166 | """This main is so fake, it breaks nearly everything.""" |
363 | 167 | 167 | ||
366 | 168 | def __init__(self, port, root_dir, data_dir, partials_dir, | 168 | def __init__(self, port, root_dir, data_dir, partials_dir): |
365 | 169 | dns_srv=None): | ||
367 | 170 | self.root_dir = root_dir | 169 | self.root_dir = root_dir |
368 | 171 | self.shares_dir = os.path.join(os.path.dirname(root_dir), 'shares_dir') | 170 | self.shares_dir = os.path.join(os.path.dirname(root_dir), 'shares_dir') |
369 | 172 | self.shares_dir_link = os.path.join(root_dir, 'shares_link') | 171 | self.shares_dir_link = os.path.join(root_dir, 'shares_link') |
370 | @@ -186,8 +185,13 @@ | |||
371 | 186 | self.event_q.subscribe(self.vm) | 185 | self.event_q.subscribe(self.vm) |
372 | 187 | self.fs.register_eq(self.event_q) | 186 | self.fs.register_eq(self.event_q) |
373 | 188 | self.sync = Sync(self) | 187 | self.sync = Sync(self) |
376 | 189 | self.action_q = ActionQueue(self.event_q, self, '127.0.0.1', port, | 188 | connection_info = [{ |
377 | 190 | dns_srv, disable_ssl_verify=True) | 189 | 'host': '127.0.0.1', |
378 | 190 | 'port': port, | ||
379 | 191 | 'use_ssl': False, | ||
380 | 192 | 'disable_ssl_verify': True, | ||
381 | 193 | }] | ||
382 | 194 | self.action_q = ActionQueue(self.event_q, self, connection_info) | ||
383 | 191 | self.state_manager = main.StateManager(self, handshake_timeout=30) | 195 | self.state_manager = main.StateManager(self, handshake_timeout=30) |
384 | 192 | self.state_manager.connection.waiting_timeout = .1 | 196 | self.state_manager.connection.waiting_timeout = .1 |
385 | 193 | self.vm.init_root() | 197 | self.vm.init_root() |
386 | @@ -353,7 +357,6 @@ | |||
387 | 353 | } | 357 | } |
388 | 354 | user = self.make_user(username=username, password=password) | 358 | user = self.make_user(username=username, password=password) |
389 | 355 | self.storage_users[username] = user | 359 | self.storage_users[username] = user |
390 | 356 | self.dns_srv = None | ||
391 | 357 | 360 | ||
392 | 358 | # override and cleanup user config | 361 | # override and cleanup user config |
393 | 359 | self.old_get_config_files = main.config.get_config_files | 362 | self.old_get_config_files = main.config.get_config_files |
394 | @@ -442,8 +445,7 @@ | |||
395 | 442 | root_dir = self.mktemp('fake_root_dir') | 445 | root_dir = self.mktemp('fake_root_dir') |
396 | 443 | data_dir = self.mktemp('fake_data_dir') | 446 | data_dir = self.mktemp('fake_data_dir') |
397 | 444 | partials = self.mktemp('partials_dir') | 447 | partials = self.mktemp('partials_dir') |
400 | 445 | self.main = ReallyFakeMain(self.port, root_dir, | 448 | self.main = ReallyFakeMain(self.port, root_dir, data_dir, partials) |
399 | 446 | data_dir, partials, self.dns_srv) | ||
401 | 447 | self.state = self.main.state_manager | 449 | self.state = self.main.state_manager |
402 | 448 | self.eq = self.main.event_q | 450 | self.eq = self.main.event_q |
403 | 449 | self.listener = ReallyAttentiveListener() | 451 | self.listener = ReallyAttentiveListener() |
404 | @@ -765,7 +767,8 @@ | |||
405 | 765 | """Nukes the method""" | 767 | """Nukes the method""" |
406 | 766 | self.old = getattr(self.obj, self.meth) | 768 | self.old = getattr(self.obj, self.meth) |
407 | 767 | if func is None: | 769 | if func is None: |
409 | 768 | def func(*args, **kwargs): return None | 770 | def func(*args, **kwargs): |
410 | 771 | return None | ||
411 | 769 | setattr(self.obj, self.meth, func) | 772 | setattr(self.obj, self.meth, func) |
412 | 770 | return info | 773 | return info |
413 | 771 | 774 | ||
414 | @@ -808,7 +811,8 @@ | |||
415 | 808 | """Nukes the method""" | 811 | """Nukes the method""" |
416 | 809 | self.old = getattr(self.aq.client, self.meth) | 812 | self.old = getattr(self.aq.client, self.meth) |
417 | 810 | if func is None: | 813 | if func is None: |
419 | 811 | def func(*args, **kwargs): return defer.Deferred | 814 | def func(*args, **kwargs): |
420 | 815 | return defer.Deferred | ||
421 | 812 | setattr(self.aq.client, self.meth, func) | 816 | setattr(self.aq.client, self.meth, func) |
422 | 813 | return info | 817 | return info |
423 | 814 | 818 | ||
424 | 815 | 819 | ||
425 | === modified file 'magicicada/server/tests/test_shutdown.py' | |||
426 | --- magicicada/server/tests/test_shutdown.py 2016-06-03 00:35:53 +0000 | |||
427 | +++ magicicada/server/tests/test_shutdown.py 2018-03-20 19:58:45 +0000 | |||
428 | @@ -99,7 +99,7 @@ | |||
429 | 99 | try: | 99 | try: |
430 | 100 | yield client.put_content(request.ROOT, mkfile_req.new_id, | 100 | yield client.put_content(request.ROOT, mkfile_req.new_id, |
431 | 101 | empty_hash, "fake_hash", 1234, 1000, None) | 101 | empty_hash, "fake_hash", 1234, 1000, None) |
433 | 102 | except: | 102 | except Exception: |
434 | 103 | client.transport.loseConnection() | 103 | client.transport.loseConnection() |
435 | 104 | 104 | ||
436 | 105 | ujobs = self.usr0.get_uploadjobs(node_id=mkfile_req.new_id) | 105 | ujobs = self.usr0.get_uploadjobs(node_id=mkfile_req.new_id) |
437 | 106 | 106 | ||
438 | === modified file 'magicicada/settings/__init__.py' | |||
439 | --- magicicada/settings/__init__.py 2017-06-28 01:37:05 +0000 | |||
440 | +++ magicicada/settings/__init__.py 2018-03-20 19:58:45 +0000 | |||
441 | @@ -32,6 +32,7 @@ | |||
442 | 32 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) | 32 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
443 | 33 | import logging | 33 | import logging |
444 | 34 | import os | 34 | import os |
445 | 35 | import sys | ||
446 | 35 | 36 | ||
447 | 36 | from psycopg2.extensions import ISOLATION_LEVEL_REPEATABLE_READ | 37 | from psycopg2.extensions import ISOLATION_LEVEL_REPEATABLE_READ |
448 | 37 | 38 | ||
449 | @@ -264,4 +265,4 @@ | |||
450 | 264 | try: | 265 | try: |
451 | 265 | from magicicada.settings.local import * # noqa | 266 | from magicicada.settings.local import * # noqa |
452 | 266 | except ImportError as err: | 267 | except ImportError as err: |
454 | 267 | print("ERROR importing local settings:", err) | 268 | print("ERROR importing local settings:", err, file=sys.stderr) |
Looks good!