From 2f5d4cebb243cf2f30c665f034668ba4b14178f9 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 15 Mar 2018 12:39:32 -0400 Subject: tests: fix run_tree and bddeb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was broken probably when we inserted the ssh keys into Platform.   tox -e citest tree_run and   tox -e citest bddeb 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. --- tests/cloud_tests/platforms/platforms.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/cloud_tests/platforms/platforms.py') diff --git a/tests/cloud_tests/platforms/platforms.py b/tests/cloud_tests/platforms/platforms.py index 1542b3be..abbfebba 100644 --- a/tests/cloud_tests/platforms/platforms.py +++ b/tests/cloud_tests/platforms/platforms.py @@ -2,12 +2,15 @@ """Base platform class.""" import os +import shutil from simplestreams import filters, mirrors 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 +20,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. @@ -29,7 +39,7 @@ class Platform(object): def destroy(self): """Clean up platform data.""" - pass + shutil.rmtree(self.tmpdir) def _generate_ssh_keys(self, data_dir): """Generate SSH keys to be used with image.""" -- cgit v1.2.3