Fix ssh mux socket file error.

ssh ControlPath socket file needs to be unique for each host.
To avoid using ssh ControlPath option placeholders move socket file
to host's temp directory. Since each host has unique temp
directory then, although file name for socket file is fixed, its path
is unique.
This commit is contained in:
Darko Poljak 2016-07-23 16:13:59 +02:00
commit 6f28fc2db2
9 changed files with 221 additions and 160 deletions

View file

@ -41,10 +41,13 @@ class CodeTestCase(test.CdistTestCase):
def setUp(self):
self.local_dir = self.mkdtemp()
self.hostdir = cdist.str_hash(self.target_host)
self.host_base_path = os.path.join(self.local_dir, self.hostdir)
self.local = local.Local(
target_host=self.target_host,
base_path=self.local_dir,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir,
exec_path=cdist.test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()

View file

@ -55,10 +55,13 @@ class ConfigRunTestCase(test.CdistTestCase):
self.temp_dir = self.mkdtemp()
self.local_dir = os.path.join(self.temp_dir, "local")
os.mkdir(self.local_dir)
self.hostdir = cdist.str_hash(self.target_host)
self.host_base_path = os.path.join(self.local_dir, self.hostdir)
os.makedirs(self.host_base_path)
self.local = cdist.exec.local.Local(
target_host=self.target_host,
base_path=self.local_dir)
base_root_path=self.host_base_path,
host_dir_name=self.hostdir)
# Setup test objects
self.object_base_path = op.join(self.temp_dir, 'object')
@ -161,7 +164,8 @@ class ConfigRunTestCase(test.CdistTestCase):
"""Test if the dryrun option is working like expected"""
drylocal = cdist.exec.local.Local(
target_host=self.target_host,
base_path=self.local_dir,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir,
# exec_path can not derivated from sys.argv in case of unittest
exec_path=os.path.abspath(os.path.join(
my_dir, '../../../scripts/cdist')),
@ -184,3 +188,8 @@ class ConfigRunTestCase(test.CdistTestCase):
# first.requirements = ['__singleton_test/foo']
# with self.assertRaises(cdist.core.?????):
# self.config.iterate_until_finished()
if __name__ == "__main__":
import unittest
unittest.main()

View file

@ -48,10 +48,13 @@ class EmulatorTestCase(test.CdistTestCase):
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
base_path = self.temp_dir
hostdir = cdist.str_hash(self.target_host)
host_base_path = os.path.join(base_path, hostdir)
self.local = local.Local(
target_host=self.target_host,
base_path=base_path,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -148,10 +151,13 @@ class EmulatorConflictingRequirementsTestCase(test.CdistTestCase):
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
base_path = self.temp_dir
hostdir = cdist.str_hash(self.target_host)
host_base_path = os.path.join(base_path, hostdir)
self.local = local.Local(
target_host=self.target_host,
base_path=base_path,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -235,10 +241,13 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
base_path = os.path.join(self.temp_dir, "out")
hostdir = cdist.str_hash(self.target_host)
host_base_path = os.path.join(base_path, hostdir)
self.local = local.Local(
target_host=self.target_host,
base_path=base_path,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -265,10 +274,13 @@ class OverrideTestCase(test.CdistTestCase):
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
base_path = self.temp_dir
hostdir = cdist.str_hash(self.target_host)
host_base_path = os.path.join(base_path, hostdir)
self.local = local.Local(
target_host=self.target_host,
base_path=base_path,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -303,12 +315,15 @@ class ArgumentsTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
base_path = self.temp_dir
hostdir = cdist.str_hash(self.target_host)
host_base_path = os.path.join(base_path, hostdir)
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
self.local = local.Local(
target_host=self.target_host,
base_path=base_path,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -425,10 +440,13 @@ class StdinTestCase(test.CdistTestCase):
self.temp_dir = self.mkdtemp()
base_path = os.path.join(self.temp_dir, "out")
hostdir = cdist.str_hash(self.target_host)
host_base_path = os.path.join(base_path, hostdir)
self.local = local.Local(
target_host=self.target_host,
base_path=base_path,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])

View file

@ -47,11 +47,14 @@ class LocalTestCase(test.CdistTestCase):
target_host = 'localhost'
self.temp_dir = self.mkdtemp()
self.out_parent_path = self.temp_dir
self.out_path = op.join(self.out_parent_path, target_host)
self.hostdir = cdist.str_hash(target_host)
self.host_base_path = op.join(self.out_parent_path, self.hostdir)
self.out_path = op.join(self.host_base_path, "data")
self.local = local.Local(
target_host=target_host,
base_path=self.out_parent_path,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir,
exec_path=test.cdist_exec_path
)
@ -109,7 +112,8 @@ class LocalTestCase(test.CdistTestCase):
link_test_local = local.Local(
target_host='localhost',
base_path=self.out_parent_path,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir,
exec_path=test.cdist_exec_path,
)
@ -127,7 +131,8 @@ class LocalTestCase(test.CdistTestCase):
link_test_local = local.Local(
target_host='localhost',
base_path=self.out_parent_path,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir]
)
@ -148,7 +153,8 @@ class LocalTestCase(test.CdistTestCase):
link_test_local = local.Local(
target_host='localhost',
base_path=self.out_parent_path,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir,
exec_path=test.cdist_exec_path,
)

View file

@ -42,12 +42,15 @@ class ExplorerClassTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
self.local_path = os.path.join(self.temp_dir, "local")
hostdir = cdist.str_hash(self.target_host)
base_root_path = os.path.join(self.local_path, hostdir)
self.remote_base_path = os.path.join(self.temp_dir, "remote")
os.makedirs(self.remote_base_path)
self.local = local.Local(
target_host=self.target_host,
base_path=self.local_path,
base_root_path=base_root_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir],
)

View file

@ -49,9 +49,12 @@ class ManifestTestCase(test.CdistTestCase):
self.temp_dir = self.mkdtemp()
out_path = self.temp_dir
hostdir = cdist.str_hash(self.target_host)
base_root_path = os.path.join(out_path, hostdir)
self.local = local.Local(
target_host=self.target_host,
base_path=out_path,
base_root_path=base_root_path,
host_dir_name=hostdir,
exec_path=cdist.test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()