cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #04306
[Merge] ~smoser/cloud-init:fix/test-run_tree-fixes into cloud-init:master
Scott Moser has proposed merging ~smoser/cloud-init:fix/test-run_tree-fixes into cloud-init:master.
Commit message:
tests: fix run_tree
This was broken probably when we inserted the ssh keys into Platform.
tox -e citest tree_run
would fail with KeyError in Platform.init due to lack of a data_dir.
Also here are a few fixes found from attempting to make it work.
Requested reviews:
cloud-init commiters (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/341045
see commit message
--
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:fix/test-run_tree-fixes into cloud-init:master.
diff --git a/tests/cloud_tests/bddeb.py b/tests/cloud_tests/bddeb.py
index a6d5069..b9cfcfa 100644
--- a/tests/cloud_tests/bddeb.py
+++ b/tests/cloud_tests/bddeb.py
@@ -16,7 +16,7 @@ pre_reqs = ['devscripts', 'equivs', 'git', 'tar']
def _out(cmd_res):
"""Get clean output from cmd result."""
- return cmd_res[0].strip()
+ return cmd_res[0].decode("utf-8").strip()
def build_deb(args, instance):
diff --git a/tests/cloud_tests/platforms/platforms.py b/tests/cloud_tests/platforms/platforms.py
index 1542b3b..0c6539b 100644
--- a/tests/cloud_tests/platforms/platforms.py
+++ b/tests/cloud_tests/platforms/platforms.py
@@ -8,6 +8,8 @@ from simplestreams import util as s_util
from cloudinit import util as c_util
+from tests.cloud_tests import util
+
class Platform(object):
"""Base class for platforms."""
@@ -17,7 +19,14 @@ class Platform(object):
def __init__(self, config):
"""Set up platform."""
self.config = config
- self._generate_ssh_keys(config['data_dir'])
+ self.tmpdir = util.mkdtemp()
+ if 'data_dir' in config:
+ self.data_dir = config['data_dir']
+ else:
+ self.data_dir = os.path.join(self.tmpdir, "data_dir")
+ os.mkdir(self.data_dir)
+
+ self._generate_ssh_keys(self.data_dir)
def get_image(self, img_conf):
"""Get image using specified image configuration.
diff --git a/tests/cloud_tests/util.py b/tests/cloud_tests/util.py
index 6ff285e..3dd4996 100644
--- a/tests/cloud_tests/util.py
+++ b/tests/cloud_tests/util.py
@@ -460,6 +460,10 @@ class PlatformError(IOError):
IOError.__init__(self, message)
+def mkdtemp(prefix='cloud_test_data'):
+ return tempfile.mkdtemp(prefix=prefix)
+
+
class TempDir(object):
"""Configurable temporary directory like tempfile.TemporaryDirectory."""
@@ -480,7 +484,7 @@ class TempDir(object):
@return_value: tempdir path
"""
if not self.tmpdir:
- self.tmpdir = tempfile.mkdtemp(prefix=self.prefix)
+ self.tmpdir = mkdtemp(prefix=self.prefix)
LOG.debug('using tmpdir: %s', self.tmpdir)
return self.tmpdir
Follow ups