Merge ~raharper/cloud-init:fix/debian-ntp-template into cloud-init:master

Proposed by Ryan Harper
Status: Merged
Approved by: Ryan Harper
Approved revision: d55a60ead5e1e9d17ff5a39d5cdb515d2d305131
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/cloud-init:fix/debian-ntp-template
Merge into: cloud-init:master
Diff against target: 51 lines (+17/-11)
2 files modified
templates/ntp.conf.debian.tmpl (+2/-1)
tests/unittests/test_handler/test_handler_ntp.py (+15/-10)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Dan Watkins Approve
Review via email: mp+370213@code.launchpad.net

Commit message

templates/ntp.conf.debian.tmpl: fix missing newline for pools

The debian ntp.conf template did not contain a newline for the
comment used to mark the rendered ntp pools configured. This
resulted in an invalid line:

'# poolspool 0.int.pool.ntp.org iburst'

rather than:

'# pools
 pool 0.int.pool.ntp.org iburst'

This patch fixes the template and updates the unittest to
verify that the rendered templates puts servers and pools
at the beginning of a line.

LP: #1836598

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

FAILED: Continuous integration, rev:fb7ba3846df45ae252d055a2f43bd1e730e3a25c
https://jenkins.ubuntu.com/server/job/cloud-init-ci/790/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

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

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

LGTM, thanks!

review: Approve
d55a60e... by Ryan Harper

Fix pycodestyle

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

PASSED: Continuous integration, rev:d55a60ead5e1e9d17ff5a39d5cdb515d2d305131
https://jenkins.ubuntu.com/server/job/cloud-init-ci/791/
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/791/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/templates/ntp.conf.debian.tmpl b/templates/ntp.conf.debian.tmpl
2index 3f07eea..affe983 100644
3--- a/templates/ntp.conf.debian.tmpl
4+++ b/templates/ntp.conf.debian.tmpl
5@@ -19,7 +19,8 @@ filegen clockstats file clockstats type day enable
6 # pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
7 # pick a different set every time it starts up. Please consider joining the
8 # pool: <http://www.pool.ntp.org/join.html>
9-{% if pools -%}# pools{% endif %}
10+{% if pools %}# pools
11+{% endif %}
12 {% for pool in pools -%}
13 pool {{pool}} iburst
14 {% endfor %}
15diff --git a/tests/unittests/test_handler/test_handler_ntp.py b/tests/unittests/test_handler/test_handler_ntp.py
16index 0f22e57..463d892 100644
17--- a/tests/unittests/test_handler/test_handler_ntp.py
18+++ b/tests/unittests/test_handler/test_handler_ntp.py
19@@ -268,17 +268,22 @@ class TestNtp(FilesystemMockingTestCase):
20 template_fn=template_fn)
21 content = util.load_file(confpath)
22 if client in ['ntp', 'chrony']:
23- expected_servers = '\n'.join([
24- 'server {0} iburst'.format(srv) for srv in servers])
25+ content_lines = content.splitlines()
26+ expected_servers = [
27+ 'server {0} iburst'.format(srv) for srv in servers]
28 print('distro=%s client=%s' % (distro, client))
29- self.assertIn(expected_servers, content,
30- ('failed to render {0} conf'
31- ' for distro:{1}'.format(client, distro)))
32- expected_pools = '\n'.join([
33- 'pool {0} iburst'.format(pool) for pool in pools])
34- self.assertIn(expected_pools, content,
35- ('failed to render {0} conf'
36- ' for distro:{1}'.format(client, distro)))
37+ for sline in expected_servers:
38+ self.assertIn(sline, content_lines,
39+ ('failed to render {0} conf'
40+ ' for distro:{1}'.format(client,
41+ distro)))
42+ expected_pools = [
43+ 'pool {0} iburst'.format(pool) for pool in pools]
44+ for pline in expected_pools:
45+ self.assertIn(pline, content_lines,
46+ ('failed to render {0} conf'
47+ ' for distro:{1}'.format(client,
48+ distro)))
49 elif client == 'systemd-timesyncd':
50 expected_content = (
51 "# cloud-init generated file\n" +

Subscribers

People subscribed via source and target branches