Merge ~oddbloke/cloud-init/+git/cloud-init:tests into cloud-init:master

Proposed by Dan Watkins
Status: Merged
Approved by: Dan Watkins
Approved revision: 32ae9940b2a50a1dc259a577e32417a637addf72
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~oddbloke/cloud-init/+git/cloud-init:tests
Merge into: cloud-init:master
Diff against target: 49 lines (+4/-1)
4 files modified
cloudinit/net/tests/test_dhcp.py (+1/-0)
cloudinit/tests/helpers.py (+1/-0)
tests/unittests/test_datasource/test_azure.py (+1/-0)
tests/unittests/test_ds_identify.py (+1/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Ryan Harper Approve
Review via email: mp+363633@code.launchpad.net

Commit message

tests: fix some slow tests and some leaking state

In test_ds_identify, don't mutate otherwise-static test data. When
running tests in a random order, this was causing failures due to
breaking preconditions for other tests.

In tests/helpers, reset logging level in tearDown. Some of the CLI
tests set the level of the root logger in a way that isn't correctly
reset.

For test_poll_imds_re_dhcp_on_timeout and
test_dhcp_discovery_run_in_sandbox_warns_invalid_pid, mock out
time.sleep; this saves ~11 seconds (or ~40% of previous test time!).

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:911030b3d8f9f1a1d31f002552529b77331524f4
https://jenkins.ubuntu.com/server/job/cloud-init-ci/596/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

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

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

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

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

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

PASSED: Continuous integration, rev:32ae9940b2a50a1dc259a577e32417a637addf72
https://jenkins.ubuntu.com/server/job/cloud-init-ci/598/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

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

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

Nice!

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

FAILED: Autolanding.
More details in the following jenkins job:
https://jenkins.ubuntu.com/server/job/cloud-init-autoland-test/173/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    FAILED: Ubuntu LTS: Integration

review: Needs Fixing (continuous-integration)
Revision history for this message
Dan Watkins (oddbloke) wrote :

This looks like an ephemeral test failure to me, trying again.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/tests/test_dhcp.py b/cloudinit/net/tests/test_dhcp.py
2index 79e8842..5139024 100644
3--- a/cloudinit/net/tests/test_dhcp.py
4+++ b/cloudinit/net/tests/test_dhcp.py
5@@ -117,6 +117,7 @@ class TestDHCPDiscoveryClean(CiTestCase):
6 self.assertEqual('eth9', call[0][1])
7 self.assertIn('/var/tmp/cloud-init/cloud-init-dhcp-', call[0][2])
8
9+ @mock.patch('time.sleep', mock.MagicMock())
10 @mock.patch('cloudinit.net.dhcp.os.kill')
11 @mock.patch('cloudinit.net.dhcp.util.subp')
12 def test_dhcp_discovery_run_in_sandbox_warns_invalid_pid(self, m_subp,
13diff --git a/cloudinit/tests/helpers.py b/cloudinit/tests/helpers.py
14index 2eb7b0c..46a4941 100644
15--- a/cloudinit/tests/helpers.py
16+++ b/cloudinit/tests/helpers.py
17@@ -207,6 +207,7 @@ class CiTestCase(TestCase):
18 if self.with_logs:
19 # Remove the handler we setup
20 logging.getLogger().handlers = self.old_handlers
21+ logging.getLogger().level = None
22 util.subp = _real_subp
23 super(CiTestCase, self).tearDown()
24
25diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
26index 417d86a..5edf36e 100644
27--- a/tests/unittests/test_datasource/test_azure.py
28+++ b/tests/unittests/test_datasource/test_azure.py
29@@ -1692,6 +1692,7 @@ class TestPreprovisioningPollIMDS(CiTestCase):
30 self.paths = helpers.Paths({'cloud_dir': self.tmp})
31 dsaz.BUILTIN_DS_CONFIG['data_dir'] = self.waagent_d
32
33+ @mock.patch('time.sleep', mock.MagicMock())
34 @mock.patch(MOCKPATH + 'EphemeralDHCPv4')
35 def test_poll_imds_re_dhcp_on_timeout(self, m_dhcpv4, report_ready_func,
36 fake_resp, m_media_switch, m_dhcp,
37diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
38index 756b4fb..d00c1b4 100644
39--- a/tests/unittests/test_ds_identify.py
40+++ b/tests/unittests/test_ds_identify.py
41@@ -441,7 +441,7 @@ class TestDsIdentify(DsIdentifyBase):
42 nova does not identify itself on platforms other than intel.
43 https://bugs.launchpad.net/cloud-init/+bugs?field.tag=dsid-nova"""
44
45- data = VALID_CFG['OpenStack'].copy()
46+ data = copy.deepcopy(VALID_CFG['OpenStack'])
47 del data['files'][P_PRODUCT_NAME]
48 data.update({'policy_dmi': POLICY_FOUND_OR_MAYBE,
49 'policy_no_dmi': POLICY_FOUND_OR_MAYBE})

Subscribers

People subscribed via source and target branches