Adding init.py for the test dirs to append path to enable import of test modules
Modifying dhcp, igmp, tls test cases to activate, configure app, and other changes
diff --git a/src/test/dhcp/dhcpTest.py b/src/test/dhcp/dhcpTest.py
index 5be99b7..db21c3b 100644
--- a/src/test/dhcp/dhcpTest.py
+++ b/src/test/dhcp/dhcpTest.py
@@ -4,14 +4,9 @@
from twisted.internet import defer
from scapy.all import *
import time
-import os, sys
import copy
-CORD_TEST_UTILS = 'utils'
-test_root = os.getenv('CORD_TEST_ROOT') or './'
-sys.path.append(test_root + CORD_TEST_UTILS)
from DHCP import DHCPTest
from OnosCtrl import OnosCtrl
-
log.setLevel('INFO')
class dhcp_exchange(unittest.TestCase):
@@ -59,7 +54,7 @@
self.onos_load_config(dhcp_dict)
def send_recv(self, update_seed = False):
- cip, sip = self.dhcp.send(update_seed = update_seed)
+ cip, sip = self.dhcp.discover(update_seed = update_seed)
assert_not_equal(cip, None)
assert_not_equal(sip, None)
log.info('Got dhcp client IP %s from server %s for mac %s' %
@@ -87,3 +82,46 @@
log.info('IP %s given out multiple times' %cip)
assert_equal(False, ip_map.has_key(cip))
ip_map[cip] = sip
+
+ def test_dhcp_1release(self, iface = 'veth0'):
+ config = {'startip':'10.10.10.20', 'endip':'10.10.10.69',
+ 'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe",
+ 'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'}
+ self.onos_dhcp_table_load(config)
+ self.dhcp = DHCPTest(seed_ip = '10.10.10.10', iface = iface)
+ cip, sip = self.send_recv()
+ log.info('Releasing ip %s to server %s' %(cip, sip))
+ assert_equal(self.dhcp.release(cip), True)
+ log.info('Triggering DHCP discover again after release')
+ cip2, sip2 = self.send_recv(update_seed = True)
+ log.info('Verifying released IP was given back on rediscover')
+ assert_equal(cip, cip2)
+ log.info('Test done. Releasing ip %s to server %s' %(cip2, sip2))
+ assert_equal(self.dhcp.release(cip2), True)
+
+ def test_dhcp_Nrelease(self, iface = 'veth0'):
+ config = {'startip':'192.168.1.20', 'endip':'192.168.1.69',
+ 'ip':'192.168.1.2', 'mac': "ca:fe:ca:fe:cc:fe",
+ 'subnet': '255.255.255.0', 'broadcast':'192.168.1.255', 'router': '192.168.1.1'}
+ self.onos_dhcp_table_load(config)
+ self.dhcp = DHCPTest(seed_ip = '192.169.1.10', iface = iface)
+ ip_map = {}
+ for i in range(10):
+ cip, sip = self.send_recv(update_seed = True)
+ if ip_map.has_key(cip):
+ log.info('IP %s given out multiple times' %cip)
+ assert_equal(False, ip_map.has_key(cip))
+ ip_map[cip] = sip
+
+ for ip in ip_map.keys():
+ log.info('Releasing IP %s' %ip)
+ assert_equal(self.dhcp.release(ip), True)
+
+ ip_map2 = {}
+ log.info('Triggering DHCP discover again after release')
+ for i in range(len(ip_map.keys())):
+ cip, sip = self.send_recv(update_seed = True)
+ ip_map2[cip] = sip
+
+ log.info('Verifying released IPs were given back on rediscover')
+ assert_equal(ip_map, ip_map2)
diff --git a/src/test/dns/dnsTest.py b/src/test/dns/dnsTest.py
deleted file mode 100644
index ee3d321..0000000
--- a/src/test/dns/dnsTest.py
+++ /dev/null
@@ -1,50 +0,0 @@
-import unittest
-import os,sys
-CORD_TEST_UTILS = 'utils'
-test_root = os.getenv('CORD_TEST_ROOT') or './'
-sys.path.append(test_root + CORD_TEST_UTILS)
-from Dns_new import DNSTest
-class dns_exchange(unittest.TestCase):
-
- def test_dns_ptr_query(self):
- obj=DNSTest()
- t = obj._dns_snd_ptr()
-
- def test_dns_A(self):
- obj=DNSTest()
- t = obj._dns_snd_rec()
- def test_dns_invalid_url(self):
- obj=DNSTest()
- t = obj._dns_snd_inv()
-
- def test_dns_invalid_reverse_query(self):
- obj=DNSTest()
- t = obj._dns_snd_ptr_inv()
- def test_dns_AAAA(self):
- obj=DNSTest()
- t = obj._dns_snd_AAAA()
-
- def test_dns_CNAME(self):
- obj=DNSTest()
- t = obj._dns_snd_CNAME()
-
- def test_dns_ptr_query(self):
- obj=DNSTest()
- t = obj._dns_snd_ptr()
-
-
-
-
-if __name__ == '__main__':
- t = DNSTest()
- t._dns_snd_ptr()
- t._dns_snd_rec()
- t._dns_snd_inv()
- t._dns_snd_ptr_inv()
- t._dns_snd_AAAA()
- t._dns_snd_CNAME()
- t._dns_snd_ptr()
-
-
-
-
diff --git a/src/test/fsm/noseDnsHolder.py b/src/test/fsm/noseDnsHolder.py
deleted file mode 100644
index cde1a44..0000000
--- a/src/test/fsm/noseDnsHolder.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env python
-
-def initDnsHolderFsmTable(obj,St,Ev):
- return {
-
- ## CurrentState Event Actions NextState
-
- (St.ST_DNS_SND_REC, Ev.EVT_DNS_SND_REC ):( (obj._dns_snd_rec,), St.ST_DNS_FINAL),
-
-}
-
diff --git a/src/test/igmp/igmpTest.py b/src/test/igmp/igmpTest.py
index bc3463b..50063b7 100644
--- a/src/test/igmp/igmpTest.py
+++ b/src/test/igmp/igmpTest.py
@@ -8,10 +8,6 @@
import tempfile
import random
import threading
-
-CORD_TEST_UTILS = 'utils'
-test_root = os.getenv('CORD_TEST_ROOT') or './'
-sys.path.append(test_root + CORD_TEST_UTILS)
from IGMP import *
from McastTraffic import *
from Stats import Stats
@@ -50,6 +46,7 @@
class igmp_exchange(unittest.TestCase):
IGMP_TEST_TIMEOUT = 5
+ IGMP_QUERY_TIMEOUT = 30
MCAST_TRAFFIC_TIMEOUT = 10
max_packets = 100
app = 'org.onosproject.igmp'
@@ -329,3 +326,40 @@
self.group_latency_check(groups)
+ def test_igmp_join_rover(self):
+ '''Keep sending joins across multicast range of addresses'''
+ '''For now, restricting it to 50/100'''
+ s = (224 << 24) | 1
+ #e = (225 << 24) | (255 << 16) | (255 << 16) | 255
+ e = (224 << 24) | 50
+ for i in xrange(s, e+1):
+ if i&0xff:
+ ip = '%d.%d.%d.%d'%((i>>24)&0xff, (i>>16)&0xff, (i>>8)&0xff, i&0xff)
+ self.send_igmp_join([ip], delay = 0)
+
+ @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
+ def test_igmp_query(self):
+ groups = ['224.0.0.1'] ##igmp query group
+ df = defer.Deferred()
+ self.df = df
+ self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
+
+ def igmp_query_timeout():
+
+ def igmp_query_cb(pkt):
+ if pkt.haslayer(IP):
+ if pkt[IP].dst == '224.0.0.1':
+ log.info('Got IGMP query packet from %s' %pkt[IP].src)
+ else:
+ assert_equal(pkt[IP].dst, '224.0.0.1')
+ else:
+ log.info('Got unknown packet for %s' %pkt[IP].dst)
+ assert_equal(pkt.haslayer(IP), True)
+ sniff(prn = igmp_query_cb, opened_socket = self.recv_socket)
+ self.recv_socket.close()
+ self.df.callback(0)
+
+ self.send_igmp_join(groups)
+ self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
+ return df
+
diff --git a/src/test/tls/tlsAuthTest.py b/src/test/tls/tlsAuthTest.py
index 22d1c76..f39f116 100644
--- a/src/test/tls/tlsAuthTest.py
+++ b/src/test/tls/tlsAuthTest.py
@@ -1,11 +1,34 @@
import unittest
-import os,sys
-CORD_TEST_UTILS = 'utils'
-test_root = os.getenv('CORD_TEST_ROOT') or './'
-sys.path.append(test_root + CORD_TEST_UTILS)
+import time
+import os
+from nose.tools import *
from EapTLS import TLSAuthTest
+from OnosCtrl import OnosCtrl
class eap_auth_exchange(unittest.TestCase):
+
+ app = 'org.onosproject.aaa'
+
+ def setUp(self):
+ self.onos_ctrl = OnosCtrl(self.app)
+ self.onos_aaa_config()
+
+ def onos_aaa_config(self):
+ aaa_dict = {'apps' : { 'org.onosproject.aaa' : { 'AAA' : { 'radiusSecret': 'radius_password',
+ 'radiusIp': '172.17.0.2' } } } }
+ radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
+ aaa_dict['apps']['org.onosproject.aaa']['AAA']['radiusIp'] = radius_ip
+ self.onos_ctrl.activate()
+ time.sleep(2)
+ self.onos_load_config(aaa_dict)
+
+ def onos_load_config(self, config):
+ status, code = self.onos_ctrl.config(config)
+ if status is False:
+ log.info('Configure request for AAA returned status %d' %code)
+ assert_equal(status, True)
+ time.sleep(2)
+
def test_eap_tls(self):
tls = TLSAuthTest()
tls.runTest()
diff --git a/src/test/utils/DHCP.py b/src/test/utils/DHCP.py
index cafa95e..64ae753 100644
--- a/src/test/utils/DHCP.py
+++ b/src/test/utils/DHCP.py
@@ -16,7 +16,7 @@
mcast_octet = (atol(ip) >> 24) & 0xff
return True if mcast_octet >= 224 and mcast_octet <= 239 else False
- def send(self, mac = None, update_seed = False):
+ def discover(self, mac = None, update_seed = False):
'''Send a DHCP discover/offer'''
if mac is None:
@@ -57,10 +57,27 @@
self.mac_inverse_map[srcIP] = (mac, serverIP)
return (srcIP, serverIP)
- def send_next(self):
+ def discover_next(self):
'''Send next dhcp discover/request with updated mac'''
+ return self.discover(update_seed = True)
- return self.send(update_seed = True)
+ def release(self, ip):
+ '''Send a DHCP discover/offer'''
+ if ip is None:
+ return False
+ if not self.mac_inverse_map.has_key(ip):
+ return False
+ mac, server_ip = self.mac_inverse_map[ip]
+ chmac = self.macToChaddr(mac)
+ L2 = Ether(dst="ff:ff:ff:ff:ff:ff", src=mac)
+ L3 = IP(src="0.0.0.0", dst="255.255.255.255")
+ L4 = UDP(sport=68, dport=67)
+ L5 = BOOTP(chaddr=chmac, ciaddr = ip)
+ L6 = DHCP(options=[("message-type","release"), ("server_id", server_ip), "end"])
+ sendp(L2/L3/L4/L5/L6, iface = self.iface)
+ del self.mac_map[mac]
+ del self.mac_inverse_map[ip]
+ return True
def macToChaddr(self, mac):
rv = []
diff --git a/src/test/utils/EapPAP.py b/src/test/utils/EapPAP.py
index a40ae9d..48b75a8 100644
--- a/src/test/utils/EapPAP.py
+++ b/src/test/utils/EapPAP.py
@@ -1,7 +1,4 @@
import sys, os
-cord_root = os.getenv('CORD_TEST_ROOT') or './'
-CORD_TEST_FSM = 'fsm'
-sys.path.append(cord_root + CORD_TEST_FSM)
from EapolAAA import *
from enum import *
import nosePAPAuthHolder as PAPAuthHolder
diff --git a/src/test/utils/EapTLS.py b/src/test/utils/EapTLS.py
index d6b6b7e..a34c749 100644
--- a/src/test/utils/EapTLS.py
+++ b/src/test/utils/EapTLS.py
@@ -1,7 +1,4 @@
import sys, os
-cord_root = os.getenv('CORD_TEST_ROOT') or './'
-CORD_TEST_FSM = 'fsm'
-sys.path.append(cord_root + CORD_TEST_FSM)
from EapolAAA import *
from enum import *
import noseTlsAuthHolder as tlsAuthHolder