diff --git a/modules/test/conn/conf/module_config.json b/modules/test/conn/conf/module_config.json index 0f599c5d3..4053b4e26 100644 --- a/modules/test/conn/conf/module_config.json +++ b/modules/test/conn/conf/module_config.json @@ -12,6 +12,11 @@ "timeout": 30 }, "tests": [ + { + "name": "connection.dhcp_address", + "description": "The device under test has received an IP address from the DHCP server and responds to an ICMP echo (ping) request", + "expected_behavior": "The device is not setup with a static IP address. The device accepts an IP address from a DHCP server (RFC 2131) and responds succesfully to an ICMP echo (ping) request." + }, { "name": "connection.mac_address", "description": "Check and note device physical address.", diff --git a/modules/test/conn/python/src/connection_module.py b/modules/test/conn/python/src/connection_module.py index a1727df23..5b3bf7038 100644 --- a/modules/test/conn/python/src/connection_module.py +++ b/modules/test/conn/python/src/connection_module.py @@ -62,6 +62,25 @@ def __init__(self, module): # response = self.dhcp1_client.set_dhcp_range('10.10.10.20','10.10.10.30') # print("Set Range: " + str(response)) + def _connection_dhcp_address(self): + LOGGER.info("Running connection.dhcp_address") + response = self.dhcp1_client.get_lease(self._device_mac) + LOGGER.info("DHCP Lease resolved:\n" + str(response)) + if response.code == 200: + lease = eval(response.message) + if 'ip' in lease: + ip_addr = lease['ip'] + LOGGER.info("IP Resolved: " + ip_addr) + LOGGER.info("Attempting to ping device..."); + ping_success = self._ping(self._device_ipv4_addr) + LOGGER.info("Ping Success: " + str(ping_success)) + if ping_success: + return True, "Device responded to leased ip address" + else: + return False, "Device did not respond to leased ip address" + else: + LOGGER.info("No DHCP lease found for: " + self._device_mac) + return False, "No DHCP lease found for: " + self._device_mac def _connection_mac_address(self): LOGGER.info("Running connection.mac_address")