forked from ungleich-public/cdist
Merge remote-tracking branch 'ungleich/master' into parallel-global-explorers-execution
This commit is contained in:
commit
f858191976
127 changed files with 2156 additions and 238 deletions
|
|
@ -37,7 +37,11 @@ class CdistTestCase(unittest.TestCase):
|
|||
remote_exec = os.path.join(global_fixtures_dir, "remote", "exec")
|
||||
remote_copy = os.path.join(global_fixtures_dir, "remote", "copy")
|
||||
|
||||
target_host = 'cdisttesthost'
|
||||
target_host = (
|
||||
'cdisttesthost',
|
||||
'cdisttesthost',
|
||||
'cdisttesthost',
|
||||
)
|
||||
|
||||
def mkdtemp(self, **kwargs):
|
||||
return tempfile.mkdtemp(prefix='tmp.cdist.test.', **kwargs)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class CodeTestCase(test.CdistTestCase):
|
|||
|
||||
def setUp(self):
|
||||
self.local_dir = self.mkdtemp()
|
||||
self.hostdir = cdist.str_hash(self.target_host)
|
||||
self.hostdir = cdist.str_hash(self.target_host[0])
|
||||
self.host_base_path = os.path.join(self.local_dir, self.hostdir)
|
||||
|
||||
self.local = local.Local(
|
||||
|
|
@ -83,7 +83,12 @@ class CodeTestCase(test.CdistTestCase):
|
|||
junk, value = line.split(': ')
|
||||
key = junk.split(' ')[1]
|
||||
output_dict[key] = value
|
||||
self.assertEqual(output_dict['__target_host'], self.local.target_host)
|
||||
self.assertEqual(output_dict['__target_host'],
|
||||
self.local.target_host[0])
|
||||
self.assertEqual(output_dict['__target_hostname'],
|
||||
self.local.target_host[1])
|
||||
self.assertEqual(output_dict['__target_fqdn'],
|
||||
self.local.target_host[2])
|
||||
self.assertEqual(output_dict['__global'], self.local.base_path)
|
||||
self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path)
|
||||
self.assertEqual(output_dict['__object'],
|
||||
|
|
@ -101,7 +106,12 @@ class CodeTestCase(test.CdistTestCase):
|
|||
junk, value = line.split(': ')
|
||||
key = junk.split(' ')[1]
|
||||
output_dict[key] = value
|
||||
self.assertEqual(output_dict['__target_host'], self.local.target_host)
|
||||
self.assertEqual(output_dict['__target_host'],
|
||||
self.local.target_host[0])
|
||||
self.assertEqual(output_dict['__target_hostname'],
|
||||
self.local.target_host[1])
|
||||
self.assertEqual(output_dict['__target_fqdn'],
|
||||
self.local.target_host[2])
|
||||
self.assertEqual(output_dict['__global'], self.local.base_path)
|
||||
self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path)
|
||||
self.assertEqual(output_dict['__object'],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "echo __target_host: $__target_host"
|
||||
echo "echo __target_hostname: $__target_hostname"
|
||||
echo "echo __target_fqdn: $__target_fqdn"
|
||||
echo "echo __global: $__global"
|
||||
echo "echo __type: $__type"
|
||||
echo "echo __object: $__object"
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class ConfigRunTestCase(test.CdistTestCase):
|
|||
self.temp_dir = self.mkdtemp()
|
||||
|
||||
self.local_dir = os.path.join(self.temp_dir, "local")
|
||||
self.hostdir = cdist.str_hash(self.target_host)
|
||||
self.hostdir = cdist.str_hash(self.target_host[0])
|
||||
self.host_base_path = os.path.join(self.local_dir, self.hostdir)
|
||||
os.makedirs(self.host_base_path)
|
||||
self.local = cdist.exec.local.Local(
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ 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)
|
||||
hostdir = cdist.str_hash(self.target_host[0])
|
||||
host_base_path = os.path.join(base_path, hostdir)
|
||||
|
||||
self.local = local.Local(
|
||||
|
|
@ -151,7 +151,7 @@ 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)
|
||||
hostdir = cdist.str_hash(self.target_host[0])
|
||||
host_base_path = os.path.join(base_path, hostdir)
|
||||
|
||||
self.local = local.Local(
|
||||
|
|
@ -241,7 +241,7 @@ 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)
|
||||
hostdir = cdist.str_hash(self.target_host[0])
|
||||
host_base_path = os.path.join(base_path, hostdir)
|
||||
|
||||
self.local = local.Local(
|
||||
|
|
@ -274,7 +274,7 @@ 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)
|
||||
hostdir = cdist.str_hash(self.target_host[0])
|
||||
host_base_path = os.path.join(base_path, hostdir)
|
||||
|
||||
self.local = local.Local(
|
||||
|
|
@ -315,7 +315,7 @@ class ArgumentsTestCase(test.CdistTestCase):
|
|||
def setUp(self):
|
||||
self.temp_dir = self.mkdtemp()
|
||||
base_path = self.temp_dir
|
||||
hostdir = cdist.str_hash(self.target_host)
|
||||
hostdir = cdist.str_hash(self.target_host[0])
|
||||
host_base_path = os.path.join(base_path, hostdir)
|
||||
handle, self.script = self.mkstemp(dir=self.temp_dir)
|
||||
os.close(handle)
|
||||
|
|
@ -440,7 +440,7 @@ 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)
|
||||
hostdir = cdist.str_hash(self.target_host[0])
|
||||
host_base_path = os.path.join(base_path, hostdir)
|
||||
|
||||
self.local = local.Local(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "echo __target_host: $__target_host"
|
||||
echo "echo __target_hostname: $__target_hostname"
|
||||
echo "echo __target_fqdn: $__target_fqdn"
|
||||
echo "echo __global: $__global"
|
||||
echo "echo __type: $__type"
|
||||
echo "echo __object: $__object"
|
||||
|
|
|
|||
|
|
@ -44,10 +44,14 @@ class LocalTestCase(test.CdistTestCase):
|
|||
|
||||
def setUp(self):
|
||||
|
||||
target_host = 'localhost'
|
||||
target_host = (
|
||||
'localhost',
|
||||
'localhost',
|
||||
'localhost',
|
||||
)
|
||||
self.temp_dir = self.mkdtemp()
|
||||
self.out_parent_path = self.temp_dir
|
||||
self.hostdir = cdist.str_hash(target_host)
|
||||
self.hostdir = cdist.str_hash(target_host[0])
|
||||
self.host_base_path = op.join(self.out_parent_path, self.hostdir)
|
||||
self.out_path = op.join(self.host_base_path, "data")
|
||||
|
||||
|
|
@ -111,7 +115,11 @@ class LocalTestCase(test.CdistTestCase):
|
|||
test_type = "__file"
|
||||
|
||||
link_test_local = local.Local(
|
||||
target_host='localhost',
|
||||
target_host=(
|
||||
'localhost',
|
||||
'localhost',
|
||||
'localhost',
|
||||
),
|
||||
base_root_path=self.host_base_path,
|
||||
host_dir_name=self.hostdir,
|
||||
exec_path=test.cdist_exec_path,
|
||||
|
|
@ -130,7 +138,11 @@ class LocalTestCase(test.CdistTestCase):
|
|||
test_type = "__cdist_test_type"
|
||||
|
||||
link_test_local = local.Local(
|
||||
target_host='localhost',
|
||||
target_host=(
|
||||
'localhost',
|
||||
'localhost',
|
||||
'localhost',
|
||||
),
|
||||
base_root_path=self.host_base_path,
|
||||
host_dir_name=self.hostdir,
|
||||
exec_path=test.cdist_exec_path,
|
||||
|
|
@ -152,7 +164,11 @@ class LocalTestCase(test.CdistTestCase):
|
|||
os.environ['CDIST_PATH'] = conf_dir
|
||||
|
||||
link_test_local = local.Local(
|
||||
target_host='localhost',
|
||||
target_host=(
|
||||
'localhost',
|
||||
'localhost',
|
||||
'localhost',
|
||||
),
|
||||
base_root_path=self.host_base_path,
|
||||
host_dir_name=self.hostdir,
|
||||
exec_path=test.cdist_exec_path,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,11 @@ class RemoteTestCase(test.CdistTestCase):
|
|||
|
||||
def setUp(self):
|
||||
self.temp_dir = self.mkdtemp()
|
||||
self.target_host = 'localhost'
|
||||
self.target_host = (
|
||||
'localhost',
|
||||
'localhost',
|
||||
'localhost',
|
||||
)
|
||||
self.base_path = self.temp_dir
|
||||
user = getpass.getuser()
|
||||
remote_exec = "ssh -o User=%s -q" % user
|
||||
|
|
@ -153,7 +157,7 @@ class RemoteTestCase(test.CdistTestCase):
|
|||
r = remote.Remote(self.target_host, base_path=self.base_path,
|
||||
remote_exec=remote_exec, remote_copy=remote_copy)
|
||||
self.assertEqual(r.run('true', return_output=True),
|
||||
"%s\n" % self.target_host)
|
||||
"%s\n" % self.target_host[0])
|
||||
|
||||
def test_run_script_target_host_in_env(self):
|
||||
handle, remote_exec_path = self.mkstemp(dir=self.temp_dir)
|
||||
|
|
@ -168,7 +172,7 @@ class RemoteTestCase(test.CdistTestCase):
|
|||
with os.fdopen(handle, "w") as fd:
|
||||
fd.writelines(["#!/bin/sh\n", "true"])
|
||||
self.assertEqual(r.run_script(script, return_output=True),
|
||||
"%s\n" % self.target_host)
|
||||
"%s\n" % self.target_host[0])
|
||||
|
||||
def test_run_script_with_env_target_host_in_env(self):
|
||||
handle, script = self.mkstemp(dir=self.temp_dir)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ 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)
|
||||
hostdir = cdist.str_hash(self.target_host[0])
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class ManifestTestCase(test.CdistTestCase):
|
|||
self.temp_dir = self.mkdtemp()
|
||||
|
||||
out_path = self.temp_dir
|
||||
hostdir = cdist.str_hash(self.target_host)
|
||||
hostdir = cdist.str_hash(self.target_host[0])
|
||||
base_root_path = os.path.join(out_path, hostdir)
|
||||
self.local = local.Local(
|
||||
target_host=self.target_host,
|
||||
|
|
@ -60,7 +60,7 @@ class ManifestTestCase(test.CdistTestCase):
|
|||
self.local.create_files_dirs()
|
||||
|
||||
self.manifest = manifest.Manifest(self.target_host, self.local)
|
||||
self.log = logging.getLogger(self.target_host)
|
||||
self.log = logging.getLogger(self.target_host[0])
|
||||
|
||||
def tearDown(self):
|
||||
os.environ = self.orig_environ
|
||||
|
|
@ -82,7 +82,12 @@ class ManifestTestCase(test.CdistTestCase):
|
|||
key, value = line.split(': ')
|
||||
output_dict[key] = value
|
||||
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
|
||||
self.assertEqual(output_dict['__target_host'], self.local.target_host)
|
||||
self.assertEqual(output_dict['__target_host'],
|
||||
self.local.target_host[0])
|
||||
self.assertEqual(output_dict['__target_hostname'],
|
||||
self.local.target_host[1])
|
||||
self.assertEqual(output_dict['__target_fqdn'],
|
||||
self.local.target_host[2])
|
||||
self.assertEqual(output_dict['__global'], self.local.base_path)
|
||||
self.assertEqual(output_dict['__cdist_type_base_path'],
|
||||
self.local.type_path)
|
||||
|
|
@ -107,7 +112,12 @@ class ManifestTestCase(test.CdistTestCase):
|
|||
key, value = line.split(': ')
|
||||
output_dict[key] = value
|
||||
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
|
||||
self.assertEqual(output_dict['__target_host'], self.local.target_host)
|
||||
self.assertEqual(output_dict['__target_host'],
|
||||
self.local.target_host[0])
|
||||
self.assertEqual(output_dict['__target_hostname'],
|
||||
self.local.target_host[1])
|
||||
self.assertEqual(output_dict['__target_fqdn'],
|
||||
self.local.target_host[2])
|
||||
self.assertEqual(output_dict['__global'], self.local.base_path)
|
||||
self.assertEqual(output_dict['__cdist_type_base_path'],
|
||||
self.local.type_path)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
cat > $__cdist_test_out << DONE
|
||||
PATH: $PATH
|
||||
__target_host: $__target_host
|
||||
__target_hostname: $__target_hostname
|
||||
__target_fqdn: $__target_fqdn
|
||||
__global: $__global
|
||||
__cdist_type_base_path: $__cdist_type_base_path
|
||||
__manifest: $__manifest
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
cat > $__cdist_test_out << DONE
|
||||
PATH: $PATH
|
||||
__target_host: $__target_host
|
||||
__target_hostname: $__target_hostname
|
||||
__target_fqdn: $__target_fqdn
|
||||
__global: $__global
|
||||
__cdist_type_base_path: $__cdist_type_base_path
|
||||
__type: $__type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue