From 36ccf81f88a39fb8049f7638856e628b3ab87501 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sun, 18 Dec 2016 03:38:18 +0200 Subject: [PATCH] - Provide a range statement in the dhcpd.conf test template so that the service will stay up (not correct in any way but enough for these tests). - The service doesn't always on TCP ports so can't count on that for waiting for it to come online, use pid file instead. - Corrected tests. - Updated TODO list (logs to syslog anyway). --- README.rst | 9 --------- tasks/main.yml | 2 +- tests/templates/dhcpd.conf.j2 | 1 + tests/test_dhcp.py | 4 ++-- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index c874821..2fc717c 100644 --- a/README.rst +++ b/README.rst @@ -59,12 +59,3 @@ Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website <https://www.shore.co.il/>`_. Patches are welcome via `git send-email <http://git-scm.com/book/en/v2/Git-Commands-Email>`_. The repository is located at: https://www.shore.co.il/git/. - -TODO ----- - -- Flush handlers at the end of the role and wait for the service to come online. -- Assertions, tests. -- Log to syslog. -- Alias email to root. -- Flush handlers and wait for service to come up. diff --git a/tasks/main.yml b/tasks/main.yml index 3f198b6..8d92dec 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -47,4 +47,4 @@ - name: Wait for service to come online wait_for: - port: 67 + path: /var/run/dhcp-server/dhcpd.pid diff --git a/tests/templates/dhcpd.conf.j2 b/tests/templates/dhcpd.conf.j2 index a9da453..57045b6 100644 --- a/tests/templates/dhcpd.conf.j2 +++ b/tests/templates/dhcpd.conf.j2 @@ -1,4 +1,5 @@ authoritative; subnet {{ ansible_default_ipv4.network }} netmask {{ ansible_default_ipv4.netmask }} { + range {{ (ansible_default_ipv4.address|ipaddr('int') + 1) | ipaddr }} {{ (ansible_default_ipv4.address|ipaddr('int') + 2) | ipaddr }}; } diff --git a/tests/test_dhcp.py b/tests/test_dhcp.py index f898616..64b2c37 100644 --- a/tests/test_dhcp.py +++ b/tests/test_dhcp.py @@ -6,11 +6,11 @@ testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') def test_dhcp_service(Service, Socket, SystemInfo): if SystemInfo.type == 'openbsd': service = Service('dhcpd') - elif SystemInfo.type == 'debian': + elif SystemInfo.type == 'linux': service = Service('isc-dhcp-server') assert service.is_running try: assert service.is_enabled except NotImplementedError: pass - assert Socket('tcp://0.0.0.0:80').is_listening + assert Socket('udp://0.0.0.0:67').is_listening -- GitLab