justification Adds tests according to the CI wiki specifically the standard test interface in the spec. The playbook includes Tier1 level test cases that have been tested in the following contexts and is passing reliably: Classic. Test logs are stored in the artifacts directory. The following steps are used to execute the tests using the standard test interface: Test enveronment Make sure you have installed packages from the spec ``` ansible-2.4.1.0-2.fc28.noarch python2-dnf-2.7.5-1.fc28.noarch libselinux-python-2.7-2.fc28.x86_64 standard-test-roles-2.5-1.fc28.noarch Run tests for Classic Snip of the example test run for Classic tests: ``` :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Setup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: dhcpcd-6.11.3-5.fc28.x86_64 :: [ 20:04:13 ] :: [ PASS ] :: Checking for the presence of dhcpcd rpm :: [ 20:04:13 ] :: [ LOG ] :: Package versions: :: [ 20:04:13 ] :: [ LOG ] :: dhcpcd-6.11.3-5.fc28.x86_64 :: [ 20:04:13 ] :: [ BEGIN ] :: Running 'cp dhcpcd-tests.py /usr/bin/' :: [ 20:04:13 ] :: [ PASS ] :: Command 'cp dhcpcd-tests.py /usr/bin/' (Expected 0, got 0) :: [ 20:04:13 ] :: [ BEGIN ] :: Running 'cp /etc/resolv.conf /var/run/resolv.conf' :: [ 20:04:13 ] :: [ PASS ] :: Command 'cp /etc/resolv.conf /var/run/resolv.conf' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 3 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:04:13 ] :: [ LOG ] :: Starting dhcpcd tests ... :: [ 20:04:13 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/dhcpcd-tests.py' test_dhcpcd_clientid_vendorclassid_userclass (__main__.DhcpcdTests) verify dhcpcd sends custom clientid vendor class id and userclass ... reading from file /tmp/dhcpcd-tcp-dump.pcap, link-type EN10MB (Ethernet) ok test_dhcpcd_dns_domain (__main__.DhcpcdTests) dhcpcd request DNS and domain name ... ok test_dhcpcd_ipv4 (__main__.DhcpcdTests) dhcpcd gets address ... ok test_dhcpcd_mtu (__main__.DhcpcdTests) dhcpcd gets MTU 1492 ... ok ---------------------------------------------------------------------- Ran 4 tests in 207.483s OK :: [ 20:07:41 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/dhcpcd-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 208s :: Assertions: 1 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Cleanup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:07:41 ] :: [ BEGIN ] :: Running 'rm /usr/bin/dhcpcd-tests.py' :: [ 20:07:41 ] :: [ PASS ] :: Command 'rm /usr/bin/dhcpcd-tests.py' (Expected 0, got 0) :: [ 20:07:41 ] :: [ BEGIN ] :: Running 'cp /var/run/resolv.conf /etc/resolv.conf' :: [ 20:07:41 ] :: [ PASS ] :: Command 'cp /var/run/resolv.conf /etc/resolv.conf' (Expected 0, got 0) :: [ 20:07:41 ] :: [ LOG ] :: dhcpcd tests done :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 2 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: TEST PROTOCOL :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Package : dhcpcd Installed : dhcpcd-6.11.3-5.fc28.x86_64 beakerlib RPM : beakerlib-1.17-13.fc28.noarch Test started : 2018-05-22 20:04:11 IST Test finished : 2018-05-22 20:07:41 IST (still running) Test duration : 210 seconds Test name : unknown Distro : Fedora release 28 (Twenty Eight) Hostname : Zeus Architecture : x86_64 CPUs : 8 x Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz RAM size : 15731 MB HDD size : 226.83 GB :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Setup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:04:13 ] :: [ PASS ] :: Checking for the presence of dhcpcd rpm :: [ 20:04:13 ] :: [ LOG ] :: Package versions: :: [ 20:04:13 ] :: [ LOG ] :: dhcpcd-6.11.3-5.fc28.x86_64 :: [ 20:04:13 ] :: [ PASS ] :: Command 'cp dhcpcd-tests.py /usr/bin/' (Expected 0, got 0) :: [ 20:04:13 ] :: [ PASS ] :: Command 'cp /etc/resolv.conf /var/run/resolv.conf' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 3 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:04:13 ] :: [ LOG ] :: Starting dhcpcd tests ... :: [ 20:07:41 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/dhcpcd-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 208s :: Assertions: 1 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Cleanup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:07:41 ] :: [ PASS ] :: Command 'rm /usr/bin/dhcpcd-tests.py' (Expected 0, got 0) :: [ 20:07:41 ] :: [ PASS ] :: Command 'cp /var/run/resolv.conf /etc/resolv.conf' (Expected 0, got 0) :: [ 20:07:41 ] :: [ LOG ] :: dhcpcd tests done :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 2 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: unknown :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:07:41 ] :: [ LOG ] :: JOURNAL XML: /var/tmp/beakerlib-yayPLF0/journal.xml :: [ 20:07:41 ] :: [ LOG ] :: JOURNAL TXT: /var/tmp/beakerlib-yayPLF0/journal.txt :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 210s :: Phases: 3 good, 0 bad :: OVERALL RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Setup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: dhcpcd-6.11.3-5.fc28.x86_64 :: [ 20:08:23 ] :: [ PASS ] :: Checking for the presence of dhcpcd rpm :: [ 20:08:23 ] :: [ LOG ] :: Package versions: :: [ 20:08:23 ] :: [ LOG ] :: dhcpcd-6.11.3-5.fc28.x86_64 :: [ 20:08:23 ] :: [ BEGIN ] :: Running 'cp /etc/dhcpcd.duid /var/run/dhcpcd.duid' :: [ 20:08:23 ] :: [ PASS ] :: Command 'cp /etc/dhcpcd.duid /var/run/dhcpcd.duid' (Expected 0, got 0) :: [ 20:08:23 ] :: [ BEGIN ] :: Running 'cp /etc/resolv.conf /var/run/resolv.conf' :: [ 20:08:23 ] :: [ PASS ] :: Command 'cp /etc/resolv.conf /var/run/resolv.conf' (Expected 0, got 0) :: [ 20:08:23 ] :: [ BEGIN ] :: Running 'cp dhcpcd-tests.py /usr/bin/' :: [ 20:08:23 ] :: [ PASS ] :: Command 'cp dhcpcd-tests.py /usr/bin/' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 4 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:08:23 ] :: [ LOG ] :: Starting dhcpcd tests ... :: [ 20:08:23 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/dhcpcd-tests.py' test_dhcp6s_assigns_static_address_using_duid1 (__main__.DhcpcdTests) DHCP6c gets the (static) addresses to hosts using known DUID value 00:01:00:01:22:8a:88:26:08:00:27:87:00:7e ... veth-test: DHCPv6 REPLY: Not On Link ok test_dhcp6s_assigns_static_address_using_duid2 (__main__.DhcpcdTests) DHCP6c gets the (static) addresses to hosts using known DUID value 00:01:00:01:22:8d:cb:58:0a:00:27:00:00:00 ... veth-test: DHCPv6 REPLY: Not On Link ok test_dhcp6s_gets_rdnss_dnssl (__main__.DhcpcdTests) DHCP6c gets the RDNSS DNSSL ... veth-test: DHCPv6 REPLY: Not On Link ok ---------------------------------------------------------------------- Ran 3 tests in 47.880s OK :: [ 20:09:11 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/dhcpcd-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 48s :: Assertions: 1 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Cleanup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:09:11 ] :: [ BEGIN ] :: Running 'rm /usr/bin/dhcpcd-tests.py' :: [ 20:09:11 ] :: [ PASS ] :: Command 'rm /usr/bin/dhcpcd-tests.py' (Expected 0, got 0) :: [ 20:09:11 ] :: [ BEGIN ] :: Running 'mv /var/run/dhcpcd.duid /etc/dhcpcd.duid' :: [ 20:09:11 ] :: [ PASS ] :: Command 'mv /var/run/dhcpcd.duid /etc/dhcpcd.duid' (Expected 0, got 0) :: [ 20:09:11 ] :: [ BEGIN ] :: Running 'cp /var/run/resolv.conf /etc/resolv.conf' :: [ 20:09:11 ] :: [ PASS ] :: Command 'cp /var/run/resolv.conf /etc/resolv.conf' (Expected 0, got 0) :: [ 20:09:11 ] :: [ LOG ] :: dhcpcd tests done :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 3 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: TEST PROTOCOL :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Package : dhcpcd Installed : dhcpcd-6.11.3-5.fc28.x86_64 beakerlib RPM : beakerlib-1.17-13.fc28.noarch Test started : 2018-05-22 20:08:21 IST Test finished : 2018-05-22 20:09:11 IST (still running) Test duration : 50 seconds Test name : unknown Distro : Fedora release 28 (Twenty Eight) Hostname : Zeus Architecture : x86_64 CPUs : 8 x Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz RAM size : 15731 MB HDD size : 226.83 GB :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Setup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:08:23 ] :: [ PASS ] :: Checking for the presence of dhcpcd rpm :: [ 20:08:23 ] :: [ LOG ] :: Package versions: :: [ 20:08:23 ] :: [ LOG ] :: dhcpcd-6.11.3-5.fc28.x86_64 :: [ 20:08:23 ] :: [ PASS ] :: Command 'cp /etc/dhcpcd.duid /var/run/dhcpcd.duid' (Expected 0, got 0) :: [ 20:08:23 ] :: [ PASS ] :: Command 'cp /etc/resolv.conf /var/run/resolv.conf' (Expected 0, got 0) :: [ 20:08:23 ] :: [ PASS ] :: Command 'cp dhcpcd-tests.py /usr/bin/' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 4 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:08:23 ] :: [ LOG ] :: Starting dhcpcd tests ... :: [ 20:09:11 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/dhcpcd-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 48s :: Assertions: 1 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Cleanup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:09:11 ] :: [ PASS ] :: Command 'rm /usr/bin/dhcpcd-tests.py' (Expected 0, got 0) :: [ 20:09:11 ] :: [ PASS ] :: Command 'mv /var/run/dhcpcd.duid /etc/dhcpcd.duid' (Expected 0, got 0) :: [ 20:09:11 ] :: [ PASS ] :: Command 'cp /var/run/resolv.conf /etc/resolv.conf' (Expected 0, got 0) :: [ 20:09:11 ] :: [ LOG ] :: dhcpcd tests done :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 3 good, 0 bad :: RESULT: PASS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: unknown :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 20:09:11 ] :: [ LOG ] :: JOURNAL XML: /var/tmp/beakerlib-KThVq51/journal.xml :: [ 20:09:11 ] :: [ LOG ] :: JOURNAL TXT: /var/tmp/beakerlib-KThVq51/journal.txt :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 50s :: Phases: 3 good, 0 bad :: OVERALL RESULT: PASS
214 lines
7.4 KiB
Python
Executable File
214 lines
7.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: LGPL-2.1+
|
|
# ~~~
|
|
# Description: Tests for dhcpcd - a DHCP client
|
|
#
|
|
# Author: Susant Sahani <susant@redhat.com>
|
|
# Copyright (c) 2018 Red Hat, Inc.
|
|
# ~~~
|
|
|
|
import errno
|
|
import os
|
|
import sys
|
|
import time
|
|
import unittest
|
|
import subprocess
|
|
import signal
|
|
import shutil
|
|
import psutil
|
|
import socket
|
|
from pyroute2 import IPRoute
|
|
|
|
DHCPCD_CI_DIR="/var/run/dhcpcd-ci"
|
|
DHCPCD_LOG_FILE='/var/run/dhcpcd-ci/dhcpcd-test-log'
|
|
DHCPCD_PID_FILE='/var/run/dhcpcd.pid'
|
|
|
|
DHCPCD_TCP_DUMP_FILE='/tmp/dhcpcd-tcp-dump.pcap'
|
|
|
|
DNSMASQ_PID_FILE='/var/run/dhcpcd-ci/test-dnsmasq.pid'
|
|
DNSMASQ_LOG_FILE='/var/run/dhcpcd-ci/dnsmasq-log-file'
|
|
|
|
def setUpModule():
|
|
"""Initialize the environment, and perform sanity checks on it."""
|
|
|
|
if shutil.which('dhcpcd') is None:
|
|
raise OSError(errno.ENOENT, 'dhcpcd not found')
|
|
|
|
if shutil.which('dnsmasq') is None:
|
|
raise OSError(errno.ENOENT, 'dnsmasq not found')
|
|
|
|
|
|
def tearDownModule():
|
|
pass
|
|
|
|
class GenericUtilities():
|
|
"""Provide a set of utility functions start stop daemons. write config files etc """
|
|
|
|
def StartDnsMasq(self, conf):
|
|
"""Start DnsMasq"""
|
|
|
|
conf_file=os.path.join(DHCPCD_CI_DIR, conf)
|
|
|
|
subprocess.check_output(['dnsmasq', '-8', DNSMASQ_LOG_FILE, '--log-dhcp', '--pid-file=/var/run/dhcpcd-ci/test-dnsmasq.pid',
|
|
'-C', conf_file, '-i', 'veth-peer', '-R'])
|
|
|
|
def StartDhcpcd(self, conf):
|
|
""" Start dnsmaq """
|
|
|
|
conf_file=os.path.join(DHCPCD_CI_DIR, conf)
|
|
subprocess.check_output(['dhcpcd', '-4', '-M', '-d', '--logfile', DHCPCD_LOG_FILE, '-f', conf_file, 'veth-test'])
|
|
|
|
def StopDaemon(self, pid_file):
|
|
|
|
with open(pid_file, 'r') as f:
|
|
pid = f.read().rstrip(' \t\r\n\0')
|
|
os.kill(int(pid), signal.SIGTERM)
|
|
|
|
os.remove(pid_file)
|
|
|
|
def findTextInDaemonLogs(self, log_file, **kwargs):
|
|
"""dnsmasq server logs."""
|
|
|
|
if kwargs is not None:
|
|
with open (log_file, 'rt') as in_file:
|
|
contents = in_file.read()
|
|
for key in kwargs:
|
|
self.assertRegex(contents, kwargs[key])
|
|
|
|
def FindProtocolFieldsinTCPDump(self, **kwargs):
|
|
"""Look attributes in tcpdump."""
|
|
|
|
contents = subprocess.check_output(['tcpdump', '-vv', '-r', DHCPCD_TCP_DUMP_FILE]).rstrip().decode('utf-8')
|
|
if kwargs is not None:
|
|
for key in kwargs:
|
|
self.assertRegex(contents, kwargs[key])
|
|
|
|
def SetupVethInterface(self):
|
|
"""Setup veth interface"""
|
|
|
|
ip = IPRoute()
|
|
|
|
ip.link('add', ifname='veth-test', peer='veth-peer', kind='veth')
|
|
idx_veth_test = ip.link_lookup(ifname='veth-test')[0]
|
|
idx_veth_peer = ip.link_lookup(ifname='veth-peer')[0]
|
|
|
|
ip.link('set', index=idx_veth_test, address='02:01:02:03:04:08')
|
|
ip.link('set', index=idx_veth_peer, address='02:01:02:03:04:09')
|
|
ip.link('set', index=idx_veth_test, state='up')
|
|
ip.link('set', index=idx_veth_peer, state='up')
|
|
ip.addr('add', index=idx_veth_peer, address='192.168.111.50')
|
|
ip.close()
|
|
|
|
def TearDownVethInterface(self):
|
|
|
|
ip = IPRoute()
|
|
ip.link('del', index=ip.link_lookup(ifname='veth-test')[0])
|
|
ip.close()
|
|
|
|
def StartCaptureBOOTPPackets(self):
|
|
"""Start tcpdump to capture dhcp packets"""
|
|
|
|
subprocess.check_output(['systemctl','restart', 'tcpdumpd.service'])
|
|
|
|
def StopCapturingPackets(self):
|
|
subprocess.check_output(['systemctl', 'stop', 'tcpdumpd.service'])
|
|
time.sleep(3);
|
|
|
|
class DhcpcdTests(unittest.TestCase, GenericUtilities):
|
|
|
|
def setUp(self):
|
|
""" setup veth and write radvd and dhcpv6configs """
|
|
self.SetupVethInterface()
|
|
|
|
def tearDown(self):
|
|
self.StopDaemon(DHCPCD_PID_FILE)
|
|
self.StopDaemon(DNSMASQ_PID_FILE)
|
|
|
|
self.TearDownVethInterface()
|
|
|
|
def test_dhcpcd_ipv4(self):
|
|
""" dhcpcd gets address """
|
|
|
|
self.StartDnsMasq('dnsmasq-ipv4.conf')
|
|
time.sleep(1)
|
|
self.StartDhcpcd('dhcpcd-domain-dns.conf')
|
|
|
|
time.sleep(5)
|
|
output=subprocess.check_output(['ip','address', 'show', 'veth-test']).rstrip().decode('utf-8')
|
|
|
|
# Address prefix
|
|
self.assertRegex(output, "192.168.111.*")
|
|
|
|
# Default route
|
|
output=subprocess.check_output(['ip','route', 'show', 'dev', 'veth-test']).rstrip().decode('utf-8')
|
|
self.assertRegex(output, "default via 192.168.1.1*")
|
|
|
|
def test_dhcpcd_dns_domain(self):
|
|
""" dhcpcd request DNS and domain name """
|
|
|
|
self.StartDnsMasq('dnsmasq-ipv4.conf')
|
|
time.sleep(1)
|
|
self.StartDhcpcd('dhcpcd-domain-dns.conf')
|
|
|
|
output=subprocess.check_output(['ip','address', 'show', 'veth-test']).rstrip().decode('utf-8')
|
|
|
|
# Address prefix
|
|
self.assertRegex(output, "192.168.111.*")
|
|
|
|
# Default route
|
|
output=subprocess.check_output(['ip','route', 'show', 'dev', 'veth-test']).rstrip().decode('utf-8')
|
|
self.assertRegex(output, "default via 192.168.1.1*")
|
|
|
|
# Dump the lease file
|
|
output=subprocess.check_output(['dhcpcd','-U', '-4', 'veth-test'], stderr=subprocess.STDOUT).rstrip().decode('utf-8')
|
|
self.assertRegex(output, 'domain_name=example-test.com')
|
|
self.assertRegex(output, 'domain_name_servers=\'8.8.8.8 8.8.4.4\'')
|
|
self.assertRegex(output, 'routers=192.168.1.1')
|
|
|
|
def test_dhcpcd_mtu(self):
|
|
""" dhcpcd gets MTU 1492 """
|
|
|
|
self.StartDnsMasq('dnsmasq-mtu.conf')
|
|
time.sleep(1)
|
|
|
|
self.StartDhcpcd('dhcpcd-mtu.conf')
|
|
time.sleep(5)
|
|
output=subprocess.check_output(['ip','address', 'show', 'veth-test']).rstrip().decode('utf-8')
|
|
|
|
# Address prefix
|
|
self.assertRegex(output, "192.168.111.*")
|
|
|
|
# Dump the lease file
|
|
output=subprocess.check_output(['dhcpcd','-U', '-4', 'veth-test'], stderr=subprocess.STDOUT).rstrip().decode('utf-8')
|
|
self.assertRegex(output, 'interface_mtu=1492')
|
|
|
|
def test_dhcpcd_clientid_vendorclassid_userclass(self):
|
|
""" verify dhcpcd sends custom clientid vendor class id and userclass """
|
|
|
|
self.StartDnsMasq('dnsmasq-vendorclass.conf')
|
|
time.sleep(1)
|
|
|
|
self.StartCaptureBOOTPPackets()
|
|
|
|
self.StartDhcpcd('dhcpcd-vendorclass.conf')
|
|
time.sleep(5)
|
|
self.StopCapturingPackets()
|
|
|
|
output=subprocess.check_output(['ip','address', 'show', 'veth-test']).rstrip().decode('utf-8')
|
|
# Address prefix
|
|
self.assertRegex(output, "192.168.111.*")
|
|
|
|
self.findTextInDaemonLogs(DNSMASQ_LOG_FILE, vendor_class='vendor class: Zeus_dhcpcd_vendorclass_id',
|
|
user_class='user class: AAAA BBBB CCCC DDDD',
|
|
host_name='client provides name: Zeus')
|
|
self.findTextInDaemonLogs(DHCPCD_LOG_FILE, client_id='using ClientID 00:11:11:12:12:13:13:14:14:15:15:16:16')
|
|
self.FindProtocolFieldsinTCPDump(vendor='Vendor-Option Option 43, length 11: 104.101.108.108.111.32.119.111.114.108.100',
|
|
user_class='instance#1:.*AAAA BBBB CCCC DDDD", length 19',
|
|
vendor_class='Vendor-Class Option 60, length 26:.*Zeus_dhcpcd_vendorclass_id',
|
|
host_name='Hostname.*Zeus')
|
|
os.remove(DHCPCD_TCP_DUMP_FILE)
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
|
|
verbosity=3))
|