def _cleanup_flocker(self): """ Cleanup any Flocker volumes that were created during the tests. """ local_certs_path = FilePath(self.mktemp()) # Download the Flocker certificates from the client node so that we can # connect to the control service from the machine running the tests. # XXX Perhaps it'd be better to have a cluster cleanup tool available # on the client which can also be run by people who are attempting the # tutorial. d = download( reactor=reactor, username=b'ubuntu', host=self.client_node_ip.encode('ascii'), remote_path=FilePath('/etc/flocker'), local_path=local_certs_path ) d.addCallback( lambda ignored: connected_cluster( reactor=reactor, control_node=self.control_node_ip.encode('ascii'), certificates_path=local_certs_path, num_agent_nodes=2, hostname_to_public_address={}, username=b'user1', ) ) d.addCallback( lambda cluster: cluster.clean_nodes( remove_foreign_containers=False ) ) return d
def assert_upload(self, local_path, matcher): """ Assert that the ``local_path`` can be uploaded to and then downloaded from a remote SSH server and that the contents are preserved. :param FilePath local_path: The local file or directory to upload. :param matcher: A ``testtools`` matcher which will be compared to the downloaded ``FilePath.path``. :returns: A ``Deferred`` that fires when the assertion is complete. """ self.ssh_server = create_ssh_server(base_path=self.make_temporary_directory()) self.addCleanup(self.ssh_server.restore) username = u"root" host = bytes(self.ssh_server.ip) remote_file = self.ssh_server.home.child(random_name(self)) d = upload( reactor=reactor, username=username, host=host, local_path=local_path, remote_path=remote_file, port=self.ssh_server.port, identity_file=self.ssh_server.key_path, ) download_directory = self.make_temporary_directory() download_path = download_directory.child("download") d.addCallback( lambda ignored: download( reactor=reactor, username=username, host=host, remote_path=remote_file, local_path=download_path, port=self.ssh_server.port, identity_file=self.ssh_server.key_path, ) ) def check(ignored): self.assertThat(download_path.path, matcher) d.addCallback(check) return d