Skip to content

Commit

Permalink
[DHCP Relay Test]: Obtain DHCP servers and their count from minigraph (
Browse files Browse the repository at this point in the history
  • Loading branch information
jleveque authored Mar 16, 2017
1 parent b41b9da commit 65765a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
6 changes: 0 additions & 6 deletions ansible/roles/sonic-common/tasks/dhcp_relay.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
- name: Copy DHCP relay docker config file to device
become: true
template: src=dhcp_relay.yml.j2
dest=/etc/sonic/dhcp_relay.yml
mode=0644

- name: Ensure DHCP Relay container started
include: sonicdocker.yml
vars:
Expand Down
14 changes: 5 additions & 9 deletions ansible/roles/test/files/ptftests/dhcp_relay_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ class DHCPTest(DataplaneBaseTest):
DHCP_LEASE_TIME_LEN = 6
LEASE_TIME = 86400

# Number of DHCP servers relay is forwarding to
# Currently this is the number of DHCP servers specified in str.yml
# TODO: Calculate this number dynamically
NUM_DHCP_SERVERS = 48

def __init__(self):
DataplaneBaseTest.__init__(self)

Expand All @@ -107,6 +102,7 @@ def setUp(self):

# These are the interfaces we are injected into that link to out leaf switches
self.server_port_indices = ast.literal_eval(self.test_params['leaf_port_indices'])
self.num_dhcp_servers = int(self.test_params['num_dhcp_servers'])
self.server_ip = self.test_params['server_ip']

self.relay_iface_name = self.test_params['relay_iface_name']
Expand Down Expand Up @@ -290,8 +286,8 @@ def verify_relayed_discover(self):

# Count the number of these packets received on the ports connected to our leaves
discover_count = testutils.count_matched_packets_all_ports(self, masked_discover, self.server_port_indices)
self.assertTrue(discover_count == self.NUM_DHCP_SERVERS,
"Failed: Discover count of %d != %d (NUM_DHCP_SERVERS)" % (discover_count, self.NUM_DHCP_SERVERS))
self.assertTrue(discover_count == self.num_dhcp_servers,
"Failed: Discover count of %d != %d (num_dhcp_servers)" % (discover_count, self.num_dhcp_servers))

# Simulate a DHCP server sending a DHCPOFFER message to client.
# We do this by injecting a DHCPOFFER message on the link connected to one
Expand Down Expand Up @@ -357,8 +353,8 @@ def verify_relayed_request(self):

# Count the number of these packets received on the ports connected to our leaves
request_count = testutils.count_matched_packets_all_ports(self, masked_request, self.server_port_indices)
self.assertTrue(request_count == self.NUM_DHCP_SERVERS,
"Failed: Request count of %d != %d (NUM_DHCP_SERVERS)" % (request_count, self.NUM_DHCP_SERVERS))
self.assertTrue(request_count == self.num_dhcp_servers,
"Failed: Request count of %d != %d (num_dhcp_servers)" % (request_count, self.num_dhcp_servers))

# Simulate a DHCP server sending a DHCPOFFER message to client from one of our leaves
def server_send_ack(self):
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/test/tasks/dhcp_relay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
ptf_test_params:
- client_port_index=\"{{ client_port_index }}\"
- leaf_port_indices=\"{{ leaf_port_indices }}\"
- num_dhcp_servers=\"{{ dhcp_servers | length }}\"
- server_ip=\"{{ dhcp_servers[0] }}\"
- relay_iface_name=\"{{ minigraph_vlan_interfaces[0]['name'] }}\"
- relay_iface_ip=\"{{ minigraph_vlan_interfaces[0]['addr'] }}\"
Expand Down

0 comments on commit 65765a4

Please sign in to comment.