summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorSalvatore Orlando <salvatore.orlando@eu.citrix.com>2011-03-14 16:49:46 +0000
committerSalvatore Orlando <salvatore.orlando@eu.citrix.com>2011-03-14 16:49:46 +0000
commit3a4f5de30362bb32846db69b98cda16eae88ee99 (patch)
tree5119f974973c3d7e94e7d103e646f93dba1aab9b /nova/tests
parent4f2d48eeffc79333afae829ea31f7eae0549b40a (diff)
parent7fde254ec53aeb88301e5592853961b2b9c87ef4 (diff)
merge trunk
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_network.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py
index 53e35ce7e..1e634b388 100644
--- a/nova/tests/test_network.py
+++ b/nova/tests/test_network.py
@@ -20,6 +20,7 @@ Unit Tests for network code
"""
import IPy
import os
+import time
from nova import context
from nova import db
@@ -463,6 +464,31 @@ class NetworkTestCase(test.TestCase):
network['id'])
self.assertEqual(ip_count, num_available_ips)
+ def test_dhcp_lease_output(self):
+ admin_ctxt = context.get_admin_context()
+ address = self._create_address(0, self.instance_id)
+ lease_ip(address)
+ network_ref = db.network_get_by_instance(admin_ctxt, self.instance_id)
+ leases = linux_net.get_dhcp_leases(context.get_admin_context(),
+ network_ref['id'])
+ for line in leases.split('\n'):
+ seconds, mac, ip, hostname, client_id = line.split(' ')
+ self.assertTrue(int(seconds) > time.time(), 'Lease expires in '
+ 'the past')
+ octets = mac.split(':')
+ self.assertEqual(len(octets), 6, "Wrong number of octets "
+ "in %s" % (max,))
+ for octet in octets:
+ self.assertEqual(len(octet), 2, "Oddly sized octet: %s"
+ % (octet,))
+ # This will throw an exception if the octet is invalid
+ int(octet, 16)
+
+ # And this will raise an exception in case of an invalid IP
+ IPy.IP(ip)
+
+ release_ip(address)
+
def is_allocated_in_project(address, project_id):
"""Returns true if address is in specified project"""