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
1diff --git a/tests/cloud_tests/bddeb.py b/tests/cloud_tests/bddeb.py
2index a6d5069..b9cfcfa 100644
3--- a/tests/cloud_tests/bddeb.py
4+++ b/tests/cloud_tests/bddeb.py
5@@ -16,7 +16,7 @@ pre_reqs = ['devscripts', 'equivs', 'git', 'tar']
6
7 def _out(cmd_res):
8 """Get clean output from cmd result."""
9- return cmd_res[0].strip()
10+ return cmd_res[0].decode("utf-8").strip()
11
12
13 def build_deb(args, instance):
14diff --git a/tests/cloud_tests/platforms/platforms.py b/tests/cloud_tests/platforms/platforms.py
15index 1542b3b..abbfebb 100644
16--- a/tests/cloud_tests/platforms/platforms.py
17+++ b/tests/cloud_tests/platforms/platforms.py
18@@ -2,12 +2,15 @@
19
20 """Base platform class."""
21 import os
22+import shutil
23
24 from simplestreams import filters, mirrors
25 from simplestreams import util as s_util
26
27 from cloudinit import util as c_util
28
29+from tests.cloud_tests import util
30+
31
32 class Platform(object):
33 """Base class for platforms."""
34@@ -17,7 +20,14 @@ class Platform(object):
35 def __init__(self, config):
36 """Set up platform."""
37 self.config = config
38- self._generate_ssh_keys(config['data_dir'])
39+ self.tmpdir = util.mkdtemp()
40+ if 'data_dir' in config:
41+ self.data_dir = config['data_dir']
42+ else:
43+ self.data_dir = os.path.join(self.tmpdir, "data_dir")
44+ os.mkdir(self.data_dir)
45+
46+ self._generate_ssh_keys(self.data_dir)
47
48 def get_image(self, img_conf):
49 """Get image using specified image configuration.
50@@ -29,7 +39,7 @@ class Platform(object):
51
52 def destroy(self):
53 """Clean up platform data."""
54- pass
55+ shutil.rmtree(self.tmpdir)
56
57 def _generate_ssh_keys(self, data_dir):
58 """Generate SSH keys to be used with image."""
59diff --git a/tests/cloud_tests/util.py b/tests/cloud_tests/util.py
60index 6ff285e..3dd4996 100644
61--- a/tests/cloud_tests/util.py
62+++ b/tests/cloud_tests/util.py
63@@ -460,6 +460,10 @@ class PlatformError(IOError):
64 IOError.__init__(self, message)
65
66
67+def mkdtemp(prefix='cloud_test_data'):
68+ return tempfile.mkdtemp(prefix=prefix)
69+
70+
71 class TempDir(object):
72 """Configurable temporary directory like tempfile.TemporaryDirectory."""
73
74@@ -480,7 +484,7 @@ class TempDir(object):
75 @return_value: tempdir path
76 """
77 if not self.tmpdir:
78- self.tmpdir = tempfile.mkdtemp(prefix=self.prefix)
79+ self.tmpdir = mkdtemp(prefix=self.prefix)
80 LOG.debug('using tmpdir: %s', self.tmpdir)
81 return self.tmpdir
82

Subscribers

People subscribed via source and target branches