diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
new file mode 100755
index 0000000..5ac0a55
--- /dev/null
+++ b/src/test/setup/cord-test.py
@@ -0,0 +1,396 @@
+#!/usr/bin/env python
+from argparse import ArgumentParser
+import os,sys,time
+import io
+import yaml
+from pyroute2 import IPRoute
+from itertools import chain
+from nsenter import Namespace
+from docker import Client
+from shutil import copy
+sys.path.append('../utils')
+from OnosCtrl import OnosCtrl
+
+class docker_netns(object):
+
+    dckr = Client()
+    def __init__(self, name):
+        pid = int(self.dckr.inspect_container(name)['State']['Pid'])
+        if pid == 0:
+            raise Exception('no container named {0}'.format(name))
+        self.pid = pid
+
+    def __enter__(self):
+        pid = self.pid
+        if not os.path.exists('/var/run/netns'):
+            os.mkdir('/var/run/netns')
+        os.symlink('/proc/{0}/ns/net'.format(pid), '/var/run/netns/{0}'.format(pid))
+        return str(pid)
+
+    def __exit__(self, type, value, traceback):
+        pid = self.pid
+        os.unlink('/var/run/netns/{0}'.format(pid))
+
+flatten = lambda l: chain.from_iterable(l)
+
+class Container(object):
+    dckr = Client()
+    def __init__(self, name, image, tag = 'latest', command = 'bash', quagga_config = None):
+        self.name = name
+        self.image = image
+        self.tag = tag
+        self.image_name = image + ':' + tag
+        self.id = None
+        self.command = command
+        if quagga_config is not None:
+            self.bridge = quagga_config['bridge']
+            self.ipaddress = quagga_config['ip']
+            self.mask = quagga_config['mask']
+        else:
+            self.bridge = None
+            self.ipaddress = None
+            self.mask = None
+
+    @classmethod
+    def build_image(cls, dockerfile, tag, force=True, nocache=False):
+        f = io.BytesIO(dockerfile.encode('utf-8'))
+        if force or not cls.image_exists(tag):
+            print('Build {0}...'.format(tag))
+            for line in cls.dckr.build(fileobj=f, rm=True, tag=tag, decode=True, nocache=nocache):
+                if 'stream' in line:
+                    print(line['stream'].strip())
+
+    @classmethod
+    def image_exists(cls, name):
+        return name in [ctn['RepoTags'][0] for ctn in cls.dckr.images()]
+
+    @classmethod
+    def create_host_config(cls, port_list = None, host_guest_map = None, privileged = False):
+        port_bindings = None
+        binds = None
+        if port_list:
+            port_bindings = {}
+            for p in port_list:
+                port_bindings[str(p)] = str(p)
+
+        if host_guest_map:
+            binds = []
+            for h, g in host_guest_map:
+                binds.append('{0}:{1}'.format(h, g))
+
+        return cls.dckr.create_host_config(binds = binds, port_bindings = port_bindings, privileged = privileged)
+
+    @classmethod
+    def cleanup(cls, image):
+        cnt_list = filter(lambda c: c['Image'] == image, cls.dckr.containers())
+        for cnt in cnt_list:
+            print('Cleaning container %s' %cnt['Id'])
+            cls.dckr.kill(cnt['Id'])
+            cls.dckr.remove_container(cnt['Id'], force=True)
+
+    def exists(self):
+        return '/{0}'.format(self.name) in list(flatten(n['Names'] for n in self.dckr.containers()))
+
+    def img_exists(self):
+        return self.image_name in [ctn['RepoTags'][0] for ctn in self.dckr.images()]
+
+    def ip(self):
+        cnt_list = filter(lambda c: c['Image'] == self.image_name, self.dckr.containers())
+        cnt_settings = cnt_list.pop()
+        return cnt_settings['NetworkSettings']['Networks']['bridge']['IPAddress']
+
+    def kill(self, remove = True):
+        self.dckr.kill(self.name)
+        self.dckr.remove_container(self.name, force=True)
+
+    def start(self, rm = True, ports = None, volumes = None, host_config = None, 
+              environment = None, tty = False, stdin_open = True):
+
+        if rm and self.exists():
+            print('Removing container:', self.name)
+            self.dckr.remove_container(self.name, force=True)
+
+        ctn = self.dckr.create_container(image=self.image_name, ports = ports, command=self.command, 
+                                         detach=True, name=self.name,
+                                         environment = environment, 
+                                         volumes = volumes, 
+                                         host_config = host_config, stdin_open=stdin_open, tty = tty)
+        self.dckr.start(container=self.name)
+        if self.bridge:
+            self.connect_to_br()
+        self.id = ctn['Id']
+        return ctn
+
+    def connect_to_br(self):
+        with docker_netns(self.name) as pid:
+            ip = IPRoute()
+            br = ip.link_lookup(ifname=self.bridge)
+            if len(br) == 0:
+                ip.link_create(ifname=self.bridge, kind='bridge')
+                br = ip.link_lookup(ifname=self.bridge)
+            br = br[0]
+            ip.link('set', index=br, state='up')
+
+            ifs = ip.link_lookup(ifname=self.name)
+            if len(ifs) > 0:
+               ip.link_remove(ifs[0])
+
+            ip.link_create(ifname=self.name, kind='veth', peer=pid)
+            host = ip.link_lookup(ifname=self.name)[0]
+            ip.link('set', index=host, master=br)
+            ip.link('set', index=host, state='up')
+            guest = ip.link_lookup(ifname=pid)[0]
+            ip.link('set', index=guest, net_ns_fd=pid)
+            with Namespace(pid, 'net'):
+                ip = IPRoute()
+                ip.link('set', index=guest, ifname='eth1')
+                ip.link('set', index=guest, state='up')
+                ip.addr('add', index=guest, address=self.ipaddress, mask=self.mask)
+
+    def execute(self, cmd, tty = True, stream = False, shell = False):
+        res = 0
+        if type(cmd) == str:
+            cmds = (cmd,)
+        else:
+            cmds = cmd
+        if shell:
+            for c in cmds:
+                res += os.system('docker exec {0} {1}'.format(self.name, c))
+            return res
+        for c in cmds:
+            i = self.dckr.exec_create(container=self.name, cmd=c, tty = tty, privileged = True)
+            self.dckr.exec_start(i['Id'], stream = stream)
+            result = self.dckr.exec_inspect(i['Id'])
+            res += 0 if result['ExitCode'] == None else result['ExitCode']
+        return res
+
+class Onos(Container):
+
+    quagga_config = { 'bridge' : 'quagga-br', 'ip': '10.10.0.4', 'mask' : 16 }
+    env = { 'ONOS_APPS' : 'drivers,openflow,proxyarp,aaa,igmp,vrouter' }
+    ports = [ 8181, 8101, 9876, 6653, 6633, 2000, 2620 ]
+
+    def __init__(self, name = 'cord-onos', image = 'onosproject/onos', tag = 'latest', boot_delay = 60):
+        super(Onos, self).__init__(name, image, tag = tag, quagga_config = self.quagga_config)
+        if not self.exists():
+            host_config = self.create_host_config(port_list = self.ports)
+            print('Starting ONOS container %s' %self.name)
+            self.start(ports = self.ports, environment = self.env, 
+                       host_config = host_config, tty = True)
+            print('Waiting %d seconds for ONOS to boot' %(boot_delay))
+            time.sleep(boot_delay)
+
+class Radius(Container):
+    ports = [ 1812, 1813 ]
+    env = {'TIMEZONE':'America/Los_Angeles', 
+           'DEBUG': 'true', 'cert_password':'whatever', 'primary_shared_secret':'radius_password'
+           }
+    host_db_dir = os.path.join(os.getenv('HOME'), 'services', 'radius', 'data', 'db')
+    guest_db_dir = os.path.join(os.path.sep, 'opt', 'db')
+    host_config_dir = os.path.join(os.getenv('HOME'), 'services', 'radius', 'freeradius')
+    guest_config_dir = os.path.join(os.path.sep, 'etc', 'freeradius')
+    start_command = '/root/start-radius.py'
+    host_guest_map = ( (host_db_dir, guest_db_dir),
+                       (host_config_dir, guest_config_dir)
+                       )
+    def __init__(self, name = 'cord-radius', image = 'freeradius', tag = 'podd'):
+        super(Radius, self).__init__(name, image, tag = tag, command = self.start_command)
+        if not self.exists():
+            host_config = self.create_host_config(port_list = self.ports,
+                                                  host_guest_map = self.host_guest_map)
+            volumes = []
+            for h,g in self.host_guest_map:
+                volumes.append(g)
+            self.start(ports = self.ports, environment = self.env, 
+                       volumes = volumes, 
+                       host_config = host_config, tty = True)
+
+class CordTester(Container):
+
+    sandbox = '/root/test'
+    sandbox_host = os.path.join(os.getenv('HOME'), 'nose_exp')
+
+    host_guest_map = ( (sandbox_host, sandbox),
+                      ('/lib/modules', '/lib/modules')
+                       )
+    basename = 'cord-tester'
+
+    def __init__(self, image = 'cord-test/nose', tag = 'latest', env = None, rm = False, boot_delay=2):
+        copy('of-bridge.sh', self.sandbox_host)
+        self.rm = rm
+        self.name = self.get_name()
+        super(CordTester, self).__init__(self.name, image = image, tag = tag)
+        host_config = self.create_host_config(host_guest_map = self.host_guest_map, privileged = True)
+        volumes = []
+        for h, g in self.host_guest_map:
+            volumes.append(g)
+        print('Starting test container %s, image %s, tag %s' %(self.name, self.image, self.tag))
+        self.start(rm = False, volumes = volumes, environment = env, 
+                   host_config = host_config, tty = True)
+        ovs_cmd = os.path.join(self.sandbox, 'of-bridge.sh') + ' br0'
+        print('Starting OVS on test container %s' %self.name)
+        self.execute(ovs_cmd)
+        status = 1
+        ## Wait for the LLDP flows to be added to the switch
+        tries = 0
+        while status != 0 and tries < 100:
+            cmd = 'ovs-ofctl dump-flows br0 | grep \"type=0x8942\"'
+            status = self.execute(cmd, shell = True)
+            tries += 1
+            if tries % 10 == 0:
+                print('Waiting for test switch to be connected to ONOS controller ...')
+
+        if status != 0:
+            print('Test Switch not connected to ONOS container.'
+                  'Please remove ONOS container and restart the test')
+            if self.rm:
+                self.kill()
+            sys.exit(1)
+
+        time.sleep(boot_delay)
+
+    @classmethod
+    def get_name(cls):
+        cnt_name = '/{0}'.format(cls.basename)
+        cnt_name_len = len(cnt_name)
+        names = list(flatten(n['Names'] for n in cls.dckr.containers(all=True)))
+        test_names = filter(lambda n: n.startswith(cnt_name), names)
+        last_cnt_number = 0
+        if test_names:
+            last_cnt_name = reduce(lambda n1, n2: n1 if int(n1[cnt_name_len:]) > \
+                                       int(n2[cnt_name_len:]) else n2,
+                                   test_names)
+            last_cnt_number = int(last_cnt_name[cnt_name_len:])
+        test_cnt_name = cls.basename + str(last_cnt_number+1)
+        return test_cnt_name
+
+    @classmethod
+    def build_image(cls, image):
+        print('Building test container docker image %s' %image)
+        dockerfile = '''
+FROM ubuntu:14.04
+MAINTAINER chetan@ciena.com
+RUN apt-get update 
+RUN apt-get -y install git python python-pip python-setuptools python-scapy tcpdump doxygen doxypy wget
+RUN easy_install nose
+RUN apt-get -y install openvswitch-common openvswitch-switch
+RUN mkdir -p /root/ovs
+WORKDIR /root
+RUN wget http://openvswitch.org/releases/openvswitch-2.4.0.tar.gz -O /root/ovs/openvswitch-2.4.0.tar.gz && \
+(cd /root/ovs && tar zxpvf openvswitch-2.4.0.tar.gz && \
+ cd openvswitch-2.4.0 && \
+ ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-ssl && make && make install)
+RUN service openvswitch-switch restart || /bin/true
+RUN apt-get -y install python-twisted python-sqlite sqlite3
+RUN pip install scapy-ssl_tls
+RUN pip install -U scapy
+RUN pip install monotonic
+RUN mv /usr/sbin/tcpdump /sbin/
+RUN ln -sf /sbin/tcpdump /usr/sbin/tcpdump
+CMD ["/bin/bash"]
+'''
+        super(CordTester, cls).build_image(dockerfile, image)
+        print('Done building docker image %s' %image)
+
+    def run_tests(self, tests):
+        '''Run the list of tests'''
+        for t in tests:
+            test = t.split(':')[0]
+            if test == 'tls':
+                test_file = test + 'AuthTest.py'
+            else:
+                test_file = test + 'Test.py'
+
+            if t.find(':') >= 0:
+                test_case = test_file + ':' + t.split(':')[1]
+            else:
+                test_case = test_file
+            cmd = 'nosetests -v {0}/git/cord-tester/src/test/{1}/{2}'.format(self.sandbox, test, test_case)
+            status = self.execute(cmd, shell = True)
+            print('Test %s %s' %(test_case, 'Success' if status == 0 else 'Failure'))
+        print('Done running tests')
+        if self.rm:
+            print('Removing test container %s' %self.name)
+            self.kill(remove=True)
+
+
+##default onos/radius/test container images and names
+onos_image_default='onosproject/onos:latest'
+nose_image_default='cord-test/nose:latest'
+test_type_default='dhcp'
+onos_app_version = '1.0-SNAPSHOT'
+onos_app_file = os.path.abspath('../apps/ciena-cordigmp-' + onos_app_version + '.oar')
+zebra_quagga_config = { 'bridge' : 'quagga-br', 'ip': '10.10.0.1', 'mask': 16 }
+
+def runTest(args):
+    onos_cnt = {'tag':'latest'}
+    radius_cnt = {'tag':'latest'}
+    nose_cnt = {'image': 'cord-test/nose','tag': 'latest'}
+
+    #print('Test type %s, onos %s, radius %s, app %s, olt %s, cleanup %s, kill flag %s, build image %s'
+    #      %(args.test_type, args.onos, args.radius, args.app, args.olt, args.cleanup, args.kill, args.build))
+    if args.cleanup:
+        cleanup_container = args.cleanup
+        if cleanup_container.find(':') < 0:
+            cleanup_container += ':latest'
+        print('Cleaning up containers %s' %cleanup_container)
+        Container.cleanup(cleanup_container)
+        sys.exit(0)
+
+    onos_cnt['image'] = args.onos.split(':')[0]
+    if args.onos.find(':') >= 0:
+        onos_cnt['tag'] = args.onos.split(':')[1]
+
+    onos = Onos(image = onos_cnt['image'], tag = onos_cnt['tag'], boot_delay = 60)
+    onos_ip = onos.ip()
+
+    ##Start Radius container if specified
+    if args.radius:
+        radius_cnt['image'] = args.radius.split(':')[0]
+        if args.radius.find(':') >= 0:
+            radius_cnt['tag'] = args.radius.split(':')[1]
+        radius = Radius(image = radius_cnt['image'], tag = radius_cnt['tag'])
+        radius_ip = radius.ip()
+        print('Started Radius server with IP %s' %radius_ip)
+    else:
+        radius_ip = None
+
+    print('Onos IP %s, Test type %s' %(onos_ip, args.test_type))
+    print('Installing ONOS app %s' %onos_app_file)
+
+    OnosCtrl.install_app(args.app)
+
+    build_cnt_image = args.build.strip()
+    if build_cnt_image:
+        CordTester.build_image(build_cnt_image)
+        nose_cnt['image']= build_cnt_image.split(':')[0]
+        if build_cnt_image.find(':') >= 0:
+            nose_cnt['tag'] = build_cnt_image.split(':')[1]
+
+    test_cnt_env = { 'ONOS_CONTROLLER_IP' : onos_ip,
+                     'ONOS_AAA_IP' : radius_ip,
+                   }
+    if args.olt:
+        olt_conf_loc = os.path.abspath('.')
+        olt_conf_test_loc=olt_conf_loc.replace(os.getenv('HOME'), CordTester.sandbox)
+        test_cnt_env['OLT_CONFIG'] = olt_conf_test_loc
+
+    test_cnt = CordTester(image = nose_cnt['image'], tag = nose_cnt['tag'],
+                          env = test_cnt_env,
+                          rm = args.kill)
+    tests = args.test_type.split('-')
+    test_cnt.run_tests(tests)
+
+if __name__ == '__main__':
+    parser = ArgumentParser(description='Cord Tester for ONOS')
+    parser.add_argument('-t', '--test-type', default=test_type_default, type=str)
+    parser.add_argument('-o', '--onos', default=onos_image_default, type=str, help='ONOS container image')
+    parser.add_argument('-r', '--radius',default='',type=str, help='Radius container image')
+    parser.add_argument('-a', '--app', default=onos_app_file, type=str, help='Cord ONOS app filename')
+    parser.add_argument('-l', '--olt', action='store_true', help='Use OLT config')
+    parser.add_argument('-c', '--cleanup', default='', type=str, help='Cleanup test containers')
+    parser.add_argument('-k', '--kill', action='store_true', help='Remove test container after tests')
+    parser.add_argument('-b', '--build', default='', type=str)
+    parser.set_defaults(func=runTest)
+    args = parser.parse_args()
+    args.func(args)
diff --git a/src/test/setup/of-bridge.sh b/src/test/setup/of-bridge.sh
new file mode 100755
index 0000000..749d02e
--- /dev/null
+++ b/src/test/setup/of-bridge.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+bridge="$1"
+controller="$2"
+if [ x"$bridge" = "x" ]; then
+  bridge="br0"
+fi
+if [ x"$controller" = "x" ]; then
+  controller=$ONOS_CONTROLLER_IP
+fi
+service openvswitch-switch restart
+num_ports=200
+ports=$(($num_ports-1))
+for vports in $(seq 0 2 $ports); do
+   echo "Deleting veth$vports"
+   ip link del veth$vports
+done
+for vports in $(seq 0 2 $ports); do
+  ip link add type veth
+  ifconfig veth$vports up
+  ifconfig veth$(($vports+1)) up
+done
+echo "Configuring ovs bridge $bridge"
+ovs-vsctl del-br $bridge
+ovs-vsctl add-br $bridge
+for i in $(seq 1 2 $ports); do
+  ovs-vsctl add-port $bridge veth$i
+done
+my_ip=`ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d":" -f2 |cut -d" " -f1`
+ovs-vsctl set-controller $bridge ptcp:6653:$my_ip tcp:$controller:6633
+ovs-vsctl set controller $bridge max_backoff=1000
+ovs-vsctl set bridge $bridge protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13
+ovs-vsctl show
+ovs-ofctl show $bridge
diff --git a/src/test/setup/test_docker/Dockerfile b/src/test/setup/test_docker/Dockerfile
index 29e25c7..e5c72a7 100644
--- a/src/test/setup/test_docker/Dockerfile
+++ b/src/test/setup/test_docker/Dockerfile
@@ -1,9 +1,6 @@
-FROM ubuntu
+FROM ubuntu:14.04
 MAINTAINER chetan@ciena.com
 
-LABEL RUN docker pull ubuntu:14.04
-LABEL RUN docker run -it --name nosetest ubuntu:14.04
-
 RUN apt-get update 
 RUN apt-get -y install git python python-pip python-setuptools python-scapy tcpdump doxygen doxypy
 RUN easy_install nose
diff --git a/src/test/utils/OnosCtrl.py b/src/test/utils/OnosCtrl.py
index bad2016..86954f8 100644
--- a/src/test/utils/OnosCtrl.py
+++ b/src/test/utils/OnosCtrl.py
@@ -7,6 +7,7 @@
     auth = ('karaf', 'karaf')
     controller = os.getenv('ONOS_CONTROLLER_IP') or 'localhost'
     cfg_url = 'http://%s:8181/onos/v1/network/configuration/' %(controller)
+    applications_url = 'http://%s:8181/onos/v1/applications' %(controller)
 
     def __init__(self, app, controller = None):
         self.app = app
@@ -68,3 +69,13 @@
 
         ##configure the device list with access information
         return cls.config(config)
+
+    @classmethod
+    def install_app(cls, app_file):
+        params = {'activate':'true'}
+        headers = {'content-type':'application/octet-stream'}
+        with open(app_file, 'rb') as payload:
+            result = requests.post(cls.applications_url, auth = cls.auth,
+                                   params = params, headers = headers,
+                                   data = payload)
+        return result.ok, result.status_code
