VOL-1057: Test Case: ONU discovery
Reverse previous solution to use onos from repo with encryption disabled and use new
voltha-apps charts to load onos-apps
Instead, wtih onos encryption disabled as the outcome of VOL-1343,
the original case where we use all locally built voltha images including onos
will now work

Change-Id: I3f5ac9e511e33cca0eee53f8d8fae53819586354
diff --git a/tests/atests/build/Makefile b/tests/atests/build/Makefile
index 0041222..f18c6c2 100644
--- a/tests/atests/build/Makefile
+++ b/tests/atests/build/Makefile
@@ -125,9 +125,16 @@
 	done
 	rm /tmp/pon0_group_fwd_mask
 	touch $@
-
+	
 $(M)/voltha_ponsim_running: | $(M)/pon0_fwd
 	$(HOME)/cord/helm-charts/scripts/wait_for_pods.sh
+	until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \
+	do \
+		sleep 5; \
+	done
+	http -a karaf:karaf --ignore-stdin POST http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt defaultVlan=65535
+	timeout 1m bash -c "until http GET http://127.0.0.1:30125/health|jq '.state'|grep -q HEALTHY; do echo 'Waiting for VOLTHA to be HEALTHY'; sleep 10; done"
+	echo "[passed] VOLTHA is HEALTHY"
 	touch $@
 	echo "Voltha Test Framework Ready!"
 
@@ -153,7 +160,7 @@
 
 remove-chart-milestones:
 	cd $(M); sudo rm -f setup kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \
-		pon0_fwd voltha-running ponsim voltha_ponsim_running
+		voltha-running ponsim pon0_fwd voltha_ponsim_running
 remove-kube-milestones:
 	cd $(M); sudo rm -f kubeadm helm-init
 
diff --git a/tests/atests/build/sadis_json b/tests/atests/build/sadis_json
index 43838a1..fc613b7 100644
--- a/tests/atests/build/sadis_json
+++ b/tests/atests/build/sadis_json
@@ -10,10 +10,10 @@
          },
          "entries":[  
             {  
-               "id":"00:26:F2:F3:17:B0",
+               "id":"PSMO12345678",
                "cTag":33,
                "sTag":44,
-               "nasPortId":"uni-128"
+               "nasPortId":"PSMO12345678"
             },
             {  
                "id":"1d1d1d1d1d1d11",
@@ -23,7 +23,7 @@
             },
             {  
                "id":"olt.voltha.svc:50060",
-	       "uplinkPort":2
+               "uplinkPort":2
             }
          ]
       }
diff --git a/tests/atests/common/auto_test.py b/tests/atests/common/auto_test.py
index 709d218..e6d21db 100755
--- a/tests/atests/common/auto_test.py
+++ b/tests/atests/common/auto_test.py
@@ -24,12 +24,15 @@
 import argparse
 import volthaMngr
 import preprovisioning
+import discovery
+import logging
 
 DEFAULT_LOG_DIR = '/tmp/voltha_test_results'
+logging.basicConfig(level=logging.INFO)
 
 def dirInit(logDir=DEFAULT_LOG_DIR,
          volthaDir=os.environ['VOLTHA_BASE']):
-    print(__file__)
+    logging.info(__file__)
     """
     Init automated testing environment and return three directories: root dir,
     voltha sources dir and log dir
@@ -45,7 +48,7 @@
     
     os.system('mkdir -p ' + logDir + ' > /dev/null 2>&1')
     os.system('rm -rf %s/*' % logDir)
-    print('Start Provisioning Test at: %s\nRoot Directory: %s\n'
+    logging.info('Start Provisioning Test at: %s\nRoot Directory: %s\n'
           'VOLTHA Directory: %s\nLog Directory: %s' %
           (currentTime, rootDir, volthaDir, logDir))
 
@@ -70,5 +73,7 @@
     volthaMngr.voltha_Initialize(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
 
     preprovisioning.runTest('olt.voltha.svc', 50060, 'ponsim_olt', 'ponsim_onu', LOG_DIR)
+    
+    discovery.runTest('ponsim_olt', 'ponsim_onu', LOG_DIR)
 
     time.sleep(5)
diff --git a/tests/atests/common/build.sh b/tests/atests/common/build.sh
index 203f59b..23e9adb 100755
--- a/tests/atests/common/build.sh
+++ b/tests/atests/common/build.sh
@@ -33,6 +33,7 @@
     sudo make reset-kubeadm
 elif [ $1 == "start" ]
   then
+    sudo service docker restart
     sudo make -f Makefile
 elif [ $1 == "stop" ]
   then
diff --git a/tests/atests/common/discovery.py b/tests/atests/common/discovery.py
new file mode 100755
index 0000000..0015e5a
--- /dev/null
+++ b/tests/atests/common/discovery.py
@@ -0,0 +1,156 @@
+#
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+vOLT-HA Discovery Test Case module
+"""
+
+import time
+import os
+import commands
+import testCaseUtils
+import logging
+
+class Discovery(object):
+
+    """
+    This class implements voltha discovery test
+    """
+    
+    def __init__(self):
+        self.dirs = {}
+        self.dirs ['log'] = None
+        self.dirs ['root'] = None
+        self.dirs ['voltha'] = None
+        
+        self.__oltType = None
+        self.__onuType = None
+        self.__fields = []
+        self.__oltDeviceId = None
+        self.__onuDeviceIds = []
+        self.__peers = None
+        
+    def dSetLogDirs(self, logDir):
+        testCaseUtils.configDirs(self, logDir)
+
+    def dConfigure(self, oltType, onuType):
+        self.__oltType = oltType
+        self.__onuType = onuType
+
+    def oltDiscovery(self):
+        logging.info('Olt Discovery')
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__oltType, 'voltha_devices_after_enable.log')
+        assert statusLines, 'No Olt listed under devices'
+        self.__fields = testCaseUtils.parseFields(statusLines)
+        self.__oltDeviceId = self.__fields[1].strip()
+        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
+            'voltha_olt_device.log', 'device ' + self.__oltDeviceId, 'voltha_olt_ports.log', 'ports', 'voltha_olt_flows.log', 'flows')
+        testCaseUtils.printLogFile (self, 'voltha_olt_ports.log')
+        testCaseUtils.printLogFile (self, 'voltha_olt_flows.log')
+            
+    def onuDiscovery(self):
+        logging.info('Onu Discovery')
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__onuType, 'voltha_devices_after_enable.log')
+        assert statusLines, 'No Onu listed under devices'
+        lines = statusLines.splitlines()
+        for line in lines:
+            self.__fields = testCaseUtils.parseFields(line)
+            onuDeviceId = self.__fields[1].strip()
+            self.__onuDeviceIds.append(onuDeviceId)
+            testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
+            'voltha_onu_device_' + str(self.__onuDeviceIds.index(onuDeviceId)) + '.log', 'device ' + onuDeviceId, 
+            'voltha_onu_ports_' +  str(self.__onuDeviceIds.index(onuDeviceId)) + '.log', 'ports', 
+            'voltha_onu_flows_' + str(self.__onuDeviceIds.index(onuDeviceId)) + '.log', 'flows')
+            testCaseUtils.printLogFile (self, 'voltha_onu_ports_' + str(self.__onuDeviceIds.index(onuDeviceId)) + '.log')
+            testCaseUtils.printLogFile (self, 'voltha_onu_flows_' + str(self.__onuDeviceIds.index(onuDeviceId)) + '.log')
+                
+    def olt_ports_should_be_enabled_and_active(self):
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__oltDeviceId, 'voltha_olt_ports.log')
+        assert statusLines, 'No Olt device listed under ports'
+        lines = statusLines.splitlines()
+        for line in lines:
+            self.__fields = testCaseUtils.parseFields(line)
+            assert self.check_states(self.__oltDeviceId) == True, 'States of %s does match expected ' % self.__oltDeviceId
+            portType = self.__fields[3].strip()
+            assert (portType == 'ETHERNET_NNI' or portType == 'PON_OLT'),\
+            'Port type for %s does not match expected ETHERNET_NNI or PON_OLT' % self.__oltDeviceId
+            if portType == 'PON_OLT':
+                self.__peers = self.__fields[7].strip()
+                peerFields = self.__peers.split(',')
+                peerDevices = peerFields[1::2]
+                for peerDevice in peerDevices:
+                    deviceFields = peerDevice.split(':')
+                    deviceId = deviceFields[1].replace("'","").replace('u','').rstrip("}]").strip()
+                    assert deviceId in self.__onuDeviceIds, 'ONU Device %s not found as Peer' % deviceId
+                    
+    def onu_ports_should_be_enabled_and_active(self):
+        for onuDeviceId in self.__onuDeviceIds:
+            statusLines = testCaseUtils.get_fields_from_grep_command(self, onuDeviceId, 'voltha_onu_ports_' + \
+            str(self.__onuDeviceIds.index(onuDeviceId)) + '.log')
+            assert statusLines, 'No Onu device listed under ports'
+            lines = statusLines.splitlines()
+            for line in lines:
+                self.__fields = testCaseUtils.parseFields(line)
+                assert self.check_states(onuDeviceId) == True, 'States of %s does match expected ' % onuDeviceId
+                portType = self.__fields[3].strip()
+                assert (portType == 'ETHERNET_UNI' or portType == 'PON_ONU'),\
+                'Port type for %s does not match expected ETHERNET_UNI or PON_ONU' % onuDeviceId
+                if portType == 'PON_ONU':
+                    self.__peers = self.__fields[7].strip()
+                    peerFields = self.__peers.split(',')
+                    peerDevice = peerFields[1]
+                    deviceFields = peerDevice.split(':')
+                    deviceId = deviceFields[1].replace("'","").replace('u','').rstrip("}]").strip()
+                    assert deviceId == self.__oltDeviceId, 'OLT Device %s not found as Peer' % deviceId
+                    
+                           
+    def check_states(self, deviceId):
+        result = True
+        adminState = self.__fields[4].strip()
+        assert adminState == 'ENABLED', 'Admin State of %s not ENABLED' % deviceId
+        operStatus = self.__fields[5].strip()
+        assert operStatus == 'ACTIVE', 'Oper Status of %s not ACTIVE' % deviceId
+        return result
+
+    def olt_should_have_at_least_one_flow(self):
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, 'Flows', 'voltha_olt_flows.log')
+        assert statusLines, 'No Olt flows under device %s' % self.__oltDeviceId
+        before, flows, numFlows = statusLines.partition('Flows')
+        plainNumber = numFlows.strip().strip('():')
+        if plainNumber.isdigit():
+            assert int(plainNumber) > 0, 'Zero number of flows for Olt %s' % self.__oltDeviceId
+            
+    def onu_should_have_at_least_one_flow(self):
+        for onuDeviceId in self.__onuDeviceIds:
+            statusLines = testCaseUtils.get_fields_from_grep_command(self, 'Flows', 'voltha_onu_flows_' + \
+            str(self.__onuDeviceIds.index(onuDeviceId)) + '.log')
+            assert statusLines, 'No Onu flows under device %s' % onuDeviceId
+            before, flows, numFlows = statusLines.partition('Flows')
+            plainNumber = numFlows.strip().strip('():')
+            if plainNumber.isdigit():
+                assert int(plainNumber) > 0, 'Zero number of flows for Onu %s' % onuDeviceId
+                      
+
+def runTest(oltType, onuType, logDir):
+    discovery = Discovery()
+    discovery.dSetLogDirs(logDir)
+    discovery.dConfigure(oltType, onuType)
+    discovery.oltDiscovery()
+    discovery.onuDiscovery()
+    discovery.olt_ports_should_be_enabled_and_active()                                      
+    discovery.onu_ports_should_be_enabled_and_active()
+    discovery.olt_should_have_at_least_one_flow()
+    discovery.onu_should_have_at_least_one_flow()
diff --git a/tests/atests/common/preprovisioning.py b/tests/atests/common/preprovisioning.py
index 86c2048..81cfd8a 100755
--- a/tests/atests/common/preprovisioning.py
+++ b/tests/atests/common/preprovisioning.py
@@ -15,13 +15,14 @@
 #
 
 """
-vOLT-HA Pre-provisioning Test module
+vOLT-HA Pre-provisioning Test Case module
 """
 
 import time
 import os
 import commands
 import testCaseUtils
+import logging
 
 class Preprovisioning(object):
 
@@ -39,48 +40,41 @@
         self.__oltPort = None
         self.__oltType = None
         self.__onuType = None
-        self.__statusLines = ""
         self.__fields = []
         self.__oltDeviceId = None
         
     def pSetLogDirs(self, logDir):
         testCaseUtils.configDirs(self, logDir)
 
-    def configure(self, oltIpAddress, oltPort, oltType, onuType):
+    def pConfigure(self, oltIpAddress, oltPort, oltType, onuType):
         self.__oltIpAddress = oltIpAddress       
         self.__oltPort = oltPort
         self.__oltType = oltType
         self.__onuType = onuType
 
-    def get_fields_from_grep_command(self, searchWord, logFile):
-        grepCommand =\
-            "grep %s %s/%s" % (searchWord, testCaseUtils.getDir(self, 'log'), logFile)  
-        self.__statusLines = commands.getstatusoutput(grepCommand)[1]
-        
     def preprovisionOlt(self):
-        print('Do PROVISIONING')
+        logging.info('Do PROVISIONING')
         testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
-            'preprovision_olt -t ponsim_olt -H %s:%s' %
-            (self.__oltIpAddress, self.__oltPort),
-            'voltha_preprovision_olt.log')
+            'voltha_preprovision_olt.log', 'preprovision_olt -t ponsim_olt -H %s:%s' %
+            (self.__oltIpAddress, self.__oltPort))
         time.sleep(5)
         
     def status_should_be_success_after_preprovision_command(self):
-        self.get_fields_from_grep_command('success', 'voltha_preprovision_olt.log')
-        assert self.__statusLines, 'Preprovision Olt command should have returned success but did not'
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, 'success', 'voltha_preprovision_olt.log')
+        assert statusLines, 'Preprovision Olt command should have returned success but did not'
         
     def query_devices_before_enabling(self):
-        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'), 'devices',
-                                        'voltha_devices_before_enable.log')
+        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'), 
+                    'voltha_devices_before_enable.log', 'devices')
+        testCaseUtils.printLogFile (self, 'voltha_devices_before_enable.log')
         time.sleep(5)
         
     def check_olt_fields_before_enabling(self):
-        result = True
-        self.get_fields_from_grep_command(self.__oltType, 'voltha_devices_before_enable.log')
-        assert self.__statusLines, 'No Olt listed under devices'
-        self.__fields = testCaseUtils.parseFields(self.__statusLines)
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__oltType, 'voltha_devices_before_enable.log')
+        assert statusLines, 'No Olt listed under devices'
+        self.__fields = testCaseUtils.parseFields(statusLines)
         self.__oltDeviceId = self.__fields[1].strip()
-        print ("OLT device id = %s" % self.__oltDeviceId)
+        logging.debug("OLT device id = %s" % self.__oltDeviceId)
         adminState = self.__fields[3].strip()
         assert adminState == 'PREPROVISIONED', 'Admin State not PREPROVISIONED'
         hostPort = self.__fields[4].strip()
@@ -100,9 +94,9 @@
         return result
 
     def check_olt_fields_after_enabling(self):
-        self.get_fields_from_grep_command(self.__oltType, 'voltha_devices_after_enable.log')
-        assert self.__statusLines, 'No Olt listed under devices'
-        self.__fields = testCaseUtils.parseFields(self.__statusLines)
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__oltType, 'voltha_devices_after_enable.log')
+        assert statusLines, 'No Olt listed under devices'
+        self.__fields = testCaseUtils.parseFields(statusLines)
         assert self.check_states(self.__oltType), 'States of %s does match expected' % self.__oltType
         hostPort = self.__fields[11].strip()
         assert hostPort, 'hostPort field is empty'
@@ -111,9 +105,9 @@
             'Olt IP or Port does not match'
                       
     def check_onu_fields_after_enabling(self):        
-        self.get_fields_from_grep_command(self.__onuType, 'voltha_devices_after_enable.log')
-        assert self.__statusLines, 'No Onu listed under devices'
-        lines = self.__statusLines.splitlines()
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__onuType, 'voltha_devices_after_enable.log')
+        assert statusLines, 'No Onu listed under devices'
+        lines = statusLines.splitlines()
         lenLines = len(lines)
         assert lenLines == 1, 'Fixed single onu does not match, ONU Count was %d' % lenLines
         for line in lines:
@@ -121,22 +115,23 @@
             assert self.check_states(self.__onuType) == True, 'States of %s does match expected' % self.__onuType
         
     def enable(self):
-        print('Enable %s OLT device' % self.__oltDeviceId)
-        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'), 'enable ' + self.__oltDeviceId,
-                                        'voltha_enable.log')
+        logging.info('Enable %s OLT device' % self.__oltDeviceId)
+        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
+              'voltha_enable.log', 'enable ' + self.__oltDeviceId)
 
     def status_should_be_success_after_enable_command(self):
-        self.get_fields_from_grep_command('success', 'voltha_enable.log')
-        assert self.__statusLines, 'Enable command should have returned success but did not'
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, 'success', 'voltha_enable.log')
+        assert statusLines, 'Enable command should have returned success but did not'
               
     def query_devices_after_enabling(self):
-        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'), 'devices',
-                                        'voltha_devices_after_enable.log')
+        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
+              'voltha_devices_after_enable.log', 'devices')
+        testCaseUtils.printLogFile (self, 'voltha_devices_after_enable.log')
 
 def runTest(oltIpAddress, oltPort, oltType, onuType, logDir):
     preprovisioning = Preprovisioning()
     preprovisioning.pSetLogDirs(logDir)
-    preprovisioning.configure(oltIpAddress, oltPort, oltType, onuType)
+    preprovisioning.pConfigure(oltIpAddress, oltPort, oltType, onuType)
     preprovisioning.preprovisionOlt()
     preprovisioning.status_should_be_success_after_preprovision_command()
     preprovisioning.query_devices_before_enabling()
diff --git a/tests/atests/common/testCaseUtils.py b/tests/atests/common/testCaseUtils.py
index 72ba087..ead244d 100755
--- a/tests/atests/common/testCaseUtils.py
+++ b/tests/atests/common/testCaseUtils.py
@@ -22,6 +22,7 @@
 import commands
 import subprocess
 import pexpect
+import sys
    
 def configDirs(self, logDir, rootDir = None, volthaDir = None):
     self.dirs ['log'] = logDir
@@ -41,30 +42,40 @@
         file.truncate()
         file.close()      
 
-def send_command_to_voltha_cli(logDir, cmd, logFile):
-    vcliIp = extractIpAddr('vcli')
-    print (vcliIp)
-    print (cmd)
-    output = open(logDir + '/' + logFile, 'w')
-    child = pexpect.spawn('ssh -p 5022 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no voltha@' + vcliIp)
+def send_command_to_voltha_cli(logDir, logFile1, cmd1, logFile2 = None, cmd2 = None, logFile3 = None, cmd3 = None):
+    output = open(logDir + '/' + logFile1, 'w')
+    child = pexpect.spawn('ssh -p 30110 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no voltha@localhost')
     child.expect('[pP]assword:')
     child.sendline('admin')
     child.expect('\((\\x1b\[\d*;?\d+m){1,2}voltha(\\x1b\[\d*;?\d+m){1,2}\)')
     time.sleep(10)
-    bytes = child.sendline(cmd)
-    child.expect('\((\\x1b\[\d*;?\d+m){1,2}voltha(\\x1b\[\d*;?\d+m){1,2}\)')
-    print (child.before)
-    output.write(child.before)
-    output.close()
-    removeLeadingLine(logDir, logFile)
+    bytes = child.sendline(cmd1)
+    i = child.expect(['\((\\x1b\[\d*;?\d+m){1,2}voltha(\\x1b\[\d*;?\d+m){1,2}\)',
+    '\((\\x1b\[\d*;?\d+m){1,2}.*device [0-9a-f]{16}(\\x1b\[\d*;?\d+m){1,2}\)'])
+    if i == 0:
+        output.write(child.before)
+        output.close()
+        removeLeadingLine(logDir, logFile1)
+    elif i == 1:
+        if logFile2 != None and cmd2 != None:
+            output = open(logDir + '/' + logFile2, 'w')
+            bytes = child.sendline(cmd2)
+            child.expect('\((\\x1b\[\d*;?\d+m){1,2}.*device [0-9a-f]{16}(\\x1b\[\d*;?\d+m){1,2}\)')
+            output.write(child.before)
+            output.close()
+            removeLeadingLine(logDir, logFile2)
+        if logFile3 != None and cmd3 != None:
+            output = open(logDir + '/' + logFile3, 'w')
+            bytes = child.sendline(cmd3)
+            child.expect('\((\\x1b\[\d*;?\d+m){1,2}.*device [0-9a-f]{16}(\\x1b\[\d*;?\d+m){1,2}\)')
+            output.write(child.before)
+            output.close()
+            removeLeadingLine(logDir, logFile3)
     child.close()
 
 def send_command_to_onos_cli(logDir, cmd, logFile):
-    onosIp = extractIpAddr('onos-ssh')
-    print (onosIp)
     output = open(logDir + '/' + logFile, 'w')
-    child = pexpect.spawn('ssh -p 8101 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no karaf@' + onosIp)
-    
+    child = pexpect.spawn('ssh -p 30115 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no karaf@localhost')
     child.expect('[pP]assword:')
     child.sendline('karaf')
     child.expect('(\\x1b\[\d*;?\d+m){1,2}onos>(\\x1b\[\d*;?\d+m){1,2}')
@@ -77,10 +88,23 @@
     output.close()
     child.close()
 
+def get_fields_from_grep_command(self, searchWord, logFile):
+    grepCommand =\
+        "grep %s %s/%s" % (searchWord, getDir(self, 'log'), logFile)  
+    statusLines = commands.getstatusoutput(grepCommand)[1]
+    return statusLines
+    
 def parseFields(statusLine):
     statusList = statusLine.split("|")
     return statusList
 
+def printLogFile(self, logFile):
+    with open(getDir(self, 'log') + '/' + logFile, 'r+') as file:
+        lines = file.readlines()
+        print
+        for line in lines:
+            sys.stdout.write (line)
+
 def extractIpAddr(podName):
     proc1 = subprocess.Popen(['/usr/bin/kubectl', 'get', 'svc', '--all-namespaces'],
                              stdout=subprocess.PIPE,
diff --git a/tests/atests/common/volthaMngr.py b/tests/atests/common/volthaMngr.py
index 5257dfa..1978f82 100755
--- a/tests/atests/common/volthaMngr.py
+++ b/tests/atests/common/volthaMngr.py
@@ -23,7 +23,7 @@
 import time
 import subprocess
 import testCaseUtils
-import urlparse
+import logging
 
 class VolthaMngr(object):
 
@@ -70,17 +70,20 @@
     One is to add to device list and the other is to add the missing Sadis section
     """        
     def alterOnosNetCfg(self):
-        print ('Altering the Onos NetCfg to suit Voltha\'s needs')
-        time.sleep(30)
-        onosIp = testCaseUtils.extractIpAddr("onos-ui")
-        netloc = onosIp.rstrip() + ":8181"
-        devUrl = urlparse.urlunparse(('http', netloc, '/onos/v1/network/configuration/devices/', '', '', ''))
-        sadisUrl = urlparse.urlunparse(('http', netloc, '/onos/v1/network/configuration/apps/', '', '', ''))
+        logging.info ('Altering the Onos NetCfg to suit Voltha\'s needs')
+        logging.debug ('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
+            'http://localhost:30120/onos/v1/network/configuration/devices/ -d @%s/tests/atests/build/devices_json'
+            % testCaseUtils.getDir(self, 'voltha'))
         os.system('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
-            '%s -d @%s/tests/atests/build/devices_json' % (devUrl, testCaseUtils.getDir(self, 'voltha')))
+            'http://localhost:30120/onos/v1/network/configuration/devices/ -d @%s/tests/atests/build/devices_json'
+            % testCaseUtils.getDir(self, 'voltha'))
+        logging.debug ('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
+            'http://localhost:30120/onos/v1/network/configuration/apps/ -d @%s/tests/atests/build/sadis_json'
+            % testCaseUtils.getDir(self, 'voltha'))
         os.system('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
-            '%s -d @%s/tests/atests/build/sadis_json' % (sadisUrl, testCaseUtils.getDir(self, 'voltha')))
-            
+            'http://localhost:30120/onos/v1/network/configuration/apps/ -d @%s/tests/atests/build/sadis_json'
+            % testCaseUtils.getDir(self, 'voltha'))
+                    
     def getAllRunningPods(self):
         allRunningPods = []
         proc1 = subprocess.Popen(['/usr/bin/kubectl', 'get', 'pods', '--all-namespaces'],
@@ -91,7 +94,7 @@
                                  stderr=subprocess.PIPE)
         proc1.stdout.close
         out, err = proc2.communicate()
-        print (out)
+        print(out)
         if out:
             for line in out.split('\n'):
                 items = line.split()
@@ -104,7 +107,7 @@
         return allRunningPods
  
     def collectPodLogs(self):
-        print('Collect logs from all Pods')
+        logging.info('Collect logs from all Pods')
         allRunningPods = self.getAllRunningPods()
         for nsName in allRunningPods:
             Namespace = nsName.get('NS')
diff --git a/tests/atests/robot/voltha_automated_test_suite.robot b/tests/atests/robot/voltha_automated_test_suite.robot
index 68cd305..66a15bd 100755
--- a/tests/atests/robot/voltha_automated_test_suite.robot
+++ b/tests/atests/robot/voltha_automated_test_suite.robot
@@ -18,11 +18,13 @@
 Library           ../common/auto_test.py
 Library           ../common/volthaMngr.py
 Library           ../common/preprovisioning.py
+Library           ../common/discovery.py
 Library           volthaMngr.VolthaMngr
 Library           preprovisioning.Preprovisioning
+Library           discovery.Discovery
 
-Test Setup        Start Voltha      
-Test Teardown     Stop Voltha
+Suite Setup        Start Voltha      
+Suite Teardown     Stop Voltha
 
 *** Variables ***
 ${LOG_DIR}        /tmp/voltha_test_results
@@ -35,14 +37,14 @@
 ${ONU_TYPE}       ponsim_onu
 
 *** Test Cases ***
-Provisioning
-    [Documentation]     VOLTHA Pre-provisioning
+Olt Pre Provisioning
+    [Documentation]     Olt Pre Provisioning
     ...                 This test preprovisions a ponsim-OLT with given IP address and TCP port 
     ...                 and then enables both it and a number of ponsim-ONUs with predefined IP/port
     ...                 information. It then verifies that all the physical and logical devices are ACTIVE
     ...                 and REACHEABLE
     PSet Log Dirs    ${LOG_DIR}
-    Configure   ${OLT_IP_ADDR}    ${OLT_PORT_ID}    ${OLT_TYPE}    ${ONU_TYPE} 
+    PConfigure   ${OLT_IP_ADDR}    ${OLT_PORT_ID}    ${OLT_TYPE}    ${ONU_TYPE} 
     Preprovision Olt
     Wait Until Keyword Succeeds    60s    2s    Query Devices Before Enabling
     Status Should Be Success After Preprovision Command
@@ -52,7 +54,23 @@
     Status Should Be Success After Enable Command
     Check Olt Fields After Enabling
     Check Onu Fields After Enabling
-
+    
+Olt Onu Discovery
+    [Documentation]     Olt Onu Discovery
+    ...                 This test covers both Onu Discovery and yet to be developped Olt Discovery
+    ...                 It aims to verify the integrity of all port fields under each discrete device.
+    ...                 It also insures that the peers fields contains device Id entries for the corresponding 
+    ...                 Olt or Onu device. Functionality to support multiple ONU accomodated
+    ...                 The extent of the flow validation is limited to checking whether number of Flows is > 0
+    DSet Log Dirs    ${LOG_DIR}
+    DConfigure      ${OLT_TYPE}    ${ONU_TYPE}
+    Olt Discovery
+    Onu Discovery
+    Olt Ports Should Be Enabled and Active
+    Onu Ports Should Be Enabled and Active
+    Olt Should Have At Least One Flow
+    Onu Should Have At Least One Flow
+    
 *** Keywords ***
 Start Voltha
     [Documentation]     Start Voltha infrastructure to run test(s). This includes starting all