Commit Graph

93 Commits

Author SHA1 Message Date
Jean-Paul Calderone
1fdb13579a Oops. Testtools doesn't have these. 2019-03-07 18:56:37 -05:00
Jean-Paul Calderone
b2afe86b84 These tests leak resources. Clean them up. 2019-03-07 18:56:25 -05:00
Jean-Paul Calderone
19666c4c91 This class doesn't use poll. 2019-03-07 18:38:52 -05:00
Jean-Paul Calderone
bbd3b200cb Use our base TestCase classes for these introducer tests
They gain free tempfile cleanup as a result.
2019-03-07 18:38:52 -05:00
Jean-Paul Calderone
cb9ad3faa5 supercall tearDown *synchronously*
It doesn't like it if it only happens later, I guess.
2019-03-07 18:34:59 -05:00
Jean-Paul Calderone
3814ccb947 Fix some setUp and tearDown 2019-03-07 14:04:17 -05:00
meejah
768eceacf2 unused var 2018-09-11 11:38:56 -06:00
meejah
1ad2174df9 windows yaml.safe_load returns None on unreadable files.. 2018-09-11 11:14:41 -06:00
meejah
7d34f8f1a1 test case when safe_load fails 2018-09-10 21:58:28 -06:00
meejah
71484b4a12 upgrade create_introducer 2018-09-10 21:58:27 -06:00
meejah
d478cf3831 add some docstrings, fix comments 2018-08-25 02:10:44 -06:00
meejah
dd2209a96c tests to cover config changes 2018-08-25 02:10:44 -06:00
meejah
d544284f92 introduce create_node_dir 2018-08-25 02:10:44 -06:00
Jean-Paul Calderone
1911b35499 Get the fcntl import up to the top as well 2018-06-08 13:15:19 -04:00
Jean-Paul Calderone
97e0ad627b explain the buried reactor import, just in case 2018-06-08 13:13:26 -04:00
Jean-Paul Calderone
2c38b148bf Move the safe interface import to the top 2018-06-08 13:12:46 -04:00
Jean-Paul Calderone
d25693145c Factor a little more duplication out of the tests 2018-06-08 11:21:25 -04:00
Jean-Paul Calderone
c491b1a7d4 bring some imports up to the top 2018-06-08 10:36:45 -04:00
Jean-Paul Calderone
318eea05e3 docs 2018-05-23 10:59:42 -04:00
Jean-Paul Calderone
8a5e2edb91 Also CLOEXEC the descriptor
This avoids leaking it into any child processes that the tests might launch.
2018-05-23 10:56:26 -04:00
Jean-Paul Calderone
be6e458770 Ensure the fd will be valid by the time we listen 2018-05-23 10:50:54 -04:00
Jean-Paul Calderone
62836b6858 Switch another test to the adoption method 2018-05-23 10:47:41 -04:00
Jean-Paul Calderone
711d63960d Switch another test to the adoption method 2018-05-23 10:47:30 -04:00
Jean-Paul Calderone
277cd16594 Avoid race-prone allocate_tcp_port for some Tubs when possible
create_tub on POSIX can pre-allocate a port safely instead.
2018-05-23 10:45:15 -04:00
meejah
1b6f477549 Pull "config" handling out of Node and hide node-derivitives
This includes:

 - refactor to create_client and _Client
 - refactor to _IntroducerNode and create_introducer
2017-11-20 12:57:20 -07:00
meejah
031a88c25f simplejson -> json 2017-02-23 15:21:36 -07:00
David Stainton
4f717ba808 Add a multi-introducer implementation
this is based the previous work of warner, killyourtv and leif
 fixes ticket #68
2016-09-13 00:15:52 +00:00
Brian Warner
a1594df0a6 introclient: only give ascii key_s to storagebroker
This was triggered when the initial Introducer connection failed, so the
node read the introducer_cache.yaml from disk. That always returns
unicode strings, and the StorageFarmBroker insisted that it's
server-IDs (aka "key_s") were bytestrings.

The tests were extended to exercise the code that loads from disk and
delivers to the StorageFarmBroker, and more preconditions were put in
place to catch this sort of thing earlier next time.

closes ticket:2817
2016-09-01 20:29:52 -07:00
Brian Warner
2c5f7ed425 factor out yamlutil.py
The yaml.SafeLoader.add_constructor() should probably only be done once,
and moving this all into a module gives us an opportunity to test it
directly.
2016-07-19 17:31:41 -07:00
Brian Warner
a39270bd46 more v1-introducer cleanup: require sigs
This removes a little bit of code that tolerated unsigned announcements.
2016-07-05 16:41:15 -07:00
Brian Warner
6f1e01453e remove make_index()
index is now always (service_name, key_id)
2016-06-29 23:06:40 -07:00
Brian Warner
ae91fa9ffe require all outbound announcements to be signed 2016-06-29 23:06:40 -07:00
Brian Warner
c64ff7b310 more v1 removal cleanup
Historical note: V2 introducers have been around for three years
now (released in 1.10.0), so it's time to drop v1. This branch removes a
lot of fallback code, and tests which exercised it. refs ticket:2784

This patch removes some now-unused code: v1-related support functions on
the client, "stub-client" handlers, and v1-tolerant remote methods on
the server. The unit tests have been cleaned up a bit too, now that
there are fewer cases to exercise.
2016-06-29 22:58:14 -07:00
David Stainton
7feee8a25e Butcher unit tests until all test_introducer tests pass 2016-06-02 17:20:31 +00:00
David Stainton
ea35563b81 Remove v1 introducer code and fix tests
Fixed many of the test_introducer tests.
Work-in-progress.
2016-06-02 16:47:58 +00:00
Brian Warner
0ff00dff6f test loading the cache 2016-05-11 18:17:22 -07:00
Brian Warner
5bedca43e3 load-yaml-cache cleanups
* use yaml.safe_load and yaml.safe_dump
  * configure SafeLoader to return unicode consistently, not str
* log+ignore bad cache, instead of throwing error, since we're already
  in the log+ignore chain from connect_failed()
* use a local exception type, instead of one from storage_client.py
* delegate delivery to self._deliver_announcements

Using yaml.safe_dump gives us:

- ann:
    my-version: tahoe-lafs/1.11.0.post96.dev0
    nickname: node-4

instead of:

- ann:
    !!python/unicode 'my-version': !!python/unicode 'tahoe-lafs/1.11.0.post96.dev0'
    !!python/unicode 'nickname': !!python/unicode 'node-4'

We want SafeLoader to consistently return unicode instead of sometimes
plain strings (for ASCII-safe values) and sometimes unicode
(for everything else). The data we write into the cache was all unicode
to start with (it came from a JSON parser), so it seems better to get
back unicode too.
2016-05-11 18:15:50 -07:00
Brian Warner
cfb939aa99 improve test_client_cache 2016-05-11 16:48:05 -07:00
Brian Warner
ecec58b339 test_introducer: factor out _load_cache 2016-05-11 15:03:32 -07:00
Brian Warner
155ca03174 test_introducer: cleanups
* Use tempfile for cache to avoid collisions
* Fix pyflakes complaints
* Remove test_client_cache_2, which exercises unsigned announcements.
  These are scheduled to be removed soon (see ticket:2784) and don't
  need to be tested.
2016-05-10 12:14:36 -07:00
David Stainton
ae2b82a1f0 Add IntroducerClient write-only yaml cache file
this change also includes unit tests
2016-05-10 20:19:35 +00:00
Brian Warner
22c1031d19 test_introducer: stop using tcp:0
This fixes some of the upcoming-deprecation warnings against Foolscap
(>=0.11.0). There are still a bunch related to the key-generator and the
stats gatherer.
2016-04-28 11:01:40 -07:00
Brian Warner
96c625920c Teach tub to start synchronously even with ip autodetect
* remove when_tub_ready() from all code
* synchronous-ify all node/client/introducer startup code

refs ticket:2491
2016-04-26 21:54:45 -07:00
Brian Warner
7637d70f1b test_introducer.ClientSeqnums: disable storage
This test was depending upon the storage announcement happening *after*
startup, but the upcoming synchronous-Tub-startup change will modify the
ordering. Fix it in both cases by disabling storage in the client being
tested.
2016-04-26 18:39:47 -07:00
Brian Warner
67dcedd8df introweb: fix connection hints for server announcements
A long time ago, the introducer's status web page would show the
advertised IP addresses for all published services, by parsing their
FURL's connection hints. This hasn't worked since about 12-Aug-2014 when
foolscap-0.6.5 changed the internal format of these hints (the column
has been empty this whole time).

This removes the "Advertised IPs" column from the Service Announcements
table. Instead, the service's full connection hints (not just the IP
address) is displayed in a tooltip/popup on the "Announced" timestamp
column.

The code that pulls these connection hints is now tolerant of all three
foolscap styles:

* foolscap<=0.6.4 : tuples of ("ipv4",host,port)
* 0.6.5 .. 0.8.0  : tuples of ("tcp",host,port)
* foolscap>=0.9.0 : strings

fixes ticket:2510
2015-09-22 17:19:52 -07:00
Brian Warner
597542dc77 test that web.static= is really treated as a relative path
Also ssh.authorized_keys_file .
2015-02-03 22:23:31 -08:00
Brian Warner
bda0e971f0 client.py: internal renaming, _server_key -> _node_key 2013-04-14 13:22:10 -07:00
Brian Warner
0a89b738bc Make introducer.furl unguessable. Closes #1802.
Previously, Introducers always used a swissnum of "introducer", so
anyone who could learn the (public) tubid of the introducer would be
able to connect to and use it. This changes new Introducers to use the
same randomly-generated swissnum as clients and storage servers do, so
that you absolutely must learn the introducer.furl from someone who
knows it already before you can connect.

This change also moves the location of the file that stores
introducer.furl from BASEDIR/introducer.furl to
BASEDIR/private/introducer.furl, since that's where we keep the private
things. The first time an introducer is started with the new code, it
will move any existing BASEDIR/introducer.furl into the new place.

Note that this will not change the FURL of existing introducers: it will
only affect newly created ones. When you change an introducer's FURL,
you must also update all of the nodes (clients and storage servers)
which connect to it, so upgrading it to an unguessable one isn't
something we should do automatically.
2013-03-20 22:40:33 +00:00
Brian Warner
3e26c78ee3 introducer.client: use integer seqnums, not time-based. Closes #1767.
This stores the sequence number in BASEDIR/announcement-seqnum, and
increments it each time any service is published (every service
announcement is regenerated with the new sequence number). As everyone
knows, time is an illusion, and occasionally goes backwards, so a
counter is generally safer (and reveals less information about the
node).

Later, we'll improve the introducer client to tolerate rollbacks (where,
perhaps due to a VM being restarted from an earlier checkpoint, the
stored sequence number reverts to an earlier version).
2013-03-18 17:40:56 -07:00
Brian Warner
e1093cbb33 introducer: add sequence-numbers to announcements, ignore replays
This will support revocation of Accounting recommendation records,
assuming the gossip-based broadcast channel isn't easily jammed.
2012-06-10 19:10:22 -07:00