Merge ~smoser/cloud-init:fix/test-run_tree-fixes into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Scott Moser
Approved revision: 27fd0d9a7ff489b4db0b7e7747ae6abaf3502f21
Merge reported by: Scott Moser
Merged at revision: 2f5d4cebb243cf2f30c665f034668ba4b14178f9
Proposed branch: ~smoser/cloud-init:fix/test-run_tree-fixes
Merge into: cloud-init:master
Diff against target: 81 lines (+18/-4)
3 files modified
tests/cloud_tests/bddeb.py (+1/-1)
tests/cloud_tests/platforms/platforms.py (+12/-2)
tests/cloud_tests/util.py (+5/-1)
Reviewer Review Type Date Requested Status
Joshua Powers (community) Approve
Ryan Harper Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+341045@code.launchpad.net

Commit message

tests: fix run_tree and bddeb

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.

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:2abbfe1faef809a56cbfeb6f5f5a50300e6e66c4
https://jenkins.ubuntu.com/server/job/cloud-init-ci/823/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/823/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:27fd0d9a7ff489b4db0b7e7747ae6abaf3502f21
https://jenkins.ubuntu.com/server/job/cloud-init-ci/824/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/824/rebuild

review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

LGTM

review: Approve
Revision history for this message
Joshua Powers (powersj) wrote :

LGTM thanks

Tried using ec2 + tree_run

review: Approve
Revision history for this message
do3meli (d-info-e) wrote :

i tested the run_tree call locally with ubuntu 16 + lxd and it seems to work again with this patch.

as this seems to be approved now can it be merged to prod to allow easier integration testing on local machines?

thanks

Revision history for this message
Scott Moser (smoser) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=2f5d4ceb

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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']
1616
17def _out(cmd_res):17def _out(cmd_res):
18 """Get clean output from cmd result."""18 """Get clean output from cmd result."""
19 return cmd_res[0].strip()19 return cmd_res[0].decode("utf-8").strip()
2020
2121
22def build_deb(args, instance):22def build_deb(args, instance):
diff --git a/tests/cloud_tests/platforms/platforms.py b/tests/cloud_tests/platforms/platforms.py
index 1542b3b..abbfebb 100644
--- a/tests/cloud_tests/platforms/platforms.py
+++ b/tests/cloud_tests/platforms/platforms.py
@@ -2,12 +2,15 @@
22
3"""Base platform class."""3"""Base platform class."""
4import os4import os
5import shutil
56
6from simplestreams import filters, mirrors7from simplestreams import filters, mirrors
7from simplestreams import util as s_util8from simplestreams import util as s_util
89
9from cloudinit import util as c_util10from cloudinit import util as c_util
1011
12from tests.cloud_tests import util
13
1114
12class Platform(object):15class Platform(object):
13 """Base class for platforms."""16 """Base class for platforms."""
@@ -17,7 +20,14 @@ class Platform(object):
17 def __init__(self, config):20 def __init__(self, config):
18 """Set up platform."""21 """Set up platform."""
19 self.config = config22 self.config = config
20 self._generate_ssh_keys(config['data_dir'])23 self.tmpdir = util.mkdtemp()
24 if 'data_dir' in config:
25 self.data_dir = config['data_dir']
26 else:
27 self.data_dir = os.path.join(self.tmpdir, "data_dir")
28 os.mkdir(self.data_dir)
29
30 self._generate_ssh_keys(self.data_dir)
2131
22 def get_image(self, img_conf):32 def get_image(self, img_conf):
23 """Get image using specified image configuration.33 """Get image using specified image configuration.
@@ -29,7 +39,7 @@ class Platform(object):
2939
30 def destroy(self):40 def destroy(self):
31 """Clean up platform data."""41 """Clean up platform data."""
32 pass42 shutil.rmtree(self.tmpdir)
3343
34 def _generate_ssh_keys(self, data_dir):44 def _generate_ssh_keys(self, data_dir):
35 """Generate SSH keys to be used with image."""45 """Generate SSH keys to be used with image."""
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):
460 IOError.__init__(self, message)460 IOError.__init__(self, message)
461461
462462
463def mkdtemp(prefix='cloud_test_data'):
464 return tempfile.mkdtemp(prefix=prefix)
465
466
463class TempDir(object):467class TempDir(object):
464 """Configurable temporary directory like tempfile.TemporaryDirectory."""468 """Configurable temporary directory like tempfile.TemporaryDirectory."""
465469
@@ -480,7 +484,7 @@ class TempDir(object):
480 @return_value: tempdir path484 @return_value: tempdir path
481 """485 """
482 if not self.tmpdir:486 if not self.tmpdir:
483 self.tmpdir = tempfile.mkdtemp(prefix=self.prefix)487 self.tmpdir = mkdtemp(prefix=self.prefix)
484 LOG.debug('using tmpdir: %s', self.tmpdir)488 LOG.debug('using tmpdir: %s', self.tmpdir)
485 return self.tmpdir489 return self.tmpdir
486490

Subscribers

People subscribed via source and target branches