mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-01-30 14:45:37 +02:00
[cdc_stream] Use ephemeral ports (#100)
Instead of running netstat/ss on local and remote systems, just bind with port 0 to find an ephemeral port. This is much more robust, simpler and a bit faster. Since the remote port is only known after running cdc_fuse_fs, port forwarding has to be set up after running cdc_fuse_fs.
This commit is contained in:
@@ -109,12 +109,14 @@ class GeneralTest(test_base.CdcStreamTest):
|
||||
self._test_dir_content(files=[], dirs=[])
|
||||
self.assertGreater(self._get_cache_size_in_bytes(), cache_size)
|
||||
|
||||
def test_rename_file(self):
|
||||
filename = 'file1.txt'
|
||||
file_local_path = os.path.join(self.local_base_dir, filename)
|
||||
utils.create_test_file(file_local_path, 1024)
|
||||
self._start()
|
||||
self._test_dir_content(files=[filename], dirs=[])
|
||||
cache_size = self._get_cache_size_in_bytes()
|
||||
original = utils.get_ssh_command_output(self.ls_cmd)
|
||||
|
||||
# After a file is renamed, the manifest is updated.
|
||||
renamed_filename = 'file2.txt'
|
||||
|
||||
@@ -129,17 +129,17 @@ class CdcStreamTest(unittest.TestCase):
|
||||
utils.target(self.remote_base_dir),
|
||||
self.service_port_arg)
|
||||
self._assert_stream_success(res)
|
||||
CdcStreamTest.service_running = True
|
||||
|
||||
def _stop(self, ignore_not_found=False):
|
||||
"""Stops streaming to the target
|
||||
|
||||
Args:
|
||||
local_dir (string): Directory to stream. Defaults to local_base_dir.
|
||||
ignore_not_found (bool): True to ignore if there's nothing to stop.
|
||||
"""
|
||||
if not self.service_running:
|
||||
if not CdcStreamTest.service_running:
|
||||
return
|
||||
res = utils.run_stream('stop', utils.target(self.remote_base_dir),
|
||||
self.service_port_arg)
|
||||
res = utils.run_stream('stop', '*', self.service_port_arg)
|
||||
if ignore_not_found and res.returncode == self.NOT_FOUND:
|
||||
return
|
||||
self._assert_stream_success(res)
|
||||
|
||||
Reference in New Issue
Block a user