Support for per test case configuration.
The test case needs to import setup_module from CordTestConfig.
See the igmp test case example.
The test case config file is a json file that should be named as:
$testmodulename.json

Eg: if test module name is igmpTest.py, the config file should be named as:
igmpTest.json

The default test configuration variables should be placed under the class variables.
The cord tester classes should subclass unittest.TestCase and should be ideally suffixed with _exchange.

The import of setup_module function from CordTestConfig for a test case would automatically
assign/overwrite the configuration parameters (json key,value pairs) for the class to be accessed by the test cases.

Change-Id: Iae6f993a149b4547388b86245663f24bb0e2b86b
diff --git a/src/test/igmp/igmpTest.json b/src/test/igmp/igmpTest.json
new file mode 100644
index 0000000..1cba515
--- /dev/null
+++ b/src/test/igmp/igmpTest.json
@@ -0,0 +1,21 @@
+{
+    "V_INF1" : "veth0",
+    "V_INF2" : "veth1",
+    "MGROUP1" : "239.1.2.3",
+    "MGROUP2" : "239.2.2.3",
+    "MINVALIDGROUP1" : "255.255.255.255",
+    "MINVALIDGROUP2" : "239.255.255.255",
+    "IGMP_DST_MAC" : "01:00:5e:00:00:16",
+    "IGMP_SRC_MAC" : "5a:e1:ac:ec:4d:a1",
+    "IP_SRC" : "1.2.3.4",
+    "IP_DST" : "224.0.0.22",
+    "NEGATIVE_TRAFFIC_STATUS" : 1,
+    "IGMP_TEST_TIMEOUT" : 5,
+    "IGMP_QUERY_TIMEOUT" : 60,
+    "MCAST_TRAFFIC_TIMEOUT" : 10,
+    "PORT_TX_DEFAULT" : 2,
+    "PORT_RX_DEFAULT" : 1,
+    "ROVER_TEST_TIMEOUT" : 300,
+    "ROVER_TIMEOUT" : 200,
+    "ROVER_JOIN_TIMEOUT" : 60
+}
diff --git a/src/test/igmp/igmpTest.py b/src/test/igmp/igmpTest.py
index 2ada533..19e10dc 100644
--- a/src/test/igmp/igmpTest.py
+++ b/src/test/igmp/igmpTest.py
@@ -28,6 +28,8 @@
 from OltConfig import OltConfig
 from Channels import IgmpChannel
 from CordLogger import CordLogger
+from CordTestConfig import setup_module
+
 log.setLevel('INFO')
 
 class IGMPTestState:
@@ -2180,4 +2182,3 @@
             log.info('onos load config is %s'%ssm_dict)
             status, code = OnosCtrl.config(ssm_dict)
             assert_equal(status,False)
-
diff --git a/src/test/utils/CordTestConfig.py b/src/test/utils/CordTestConfig.py
new file mode 100644
index 0000000..0e369d9
--- /dev/null
+++ b/src/test/utils/CordTestConfig.py
@@ -0,0 +1,29 @@
+import inspect
+import unittest
+import json
+import os
+from nose.tools import assert_not_equal
+
+def setup_module(module):
+    class_found = None
+    for name, obj in inspect.getmembers(module):
+        if inspect.isclass(obj) and issubclass(obj, unittest.TestCase):
+            if obj.__name__.endswith('exchange'):
+                class_found = obj
+                break
+            else:
+                class_found = obj
+
+    assert_not_equal(class_found, None)
+    try:
+        module_name = module.__name__.split('.')[-1]
+    except:
+        module_name = module.__name__
+
+    cfg = '{}.json'.format(module_name)
+    module_config = os.path.join(os.path.dirname(module.__file__), cfg)
+    if os.access(module_config, os.F_OK):
+        with open(module_config) as f:
+            json_data = json.load(f)
+            for k, v in json_data.iteritems():
+                setattr(class_found, k, v)