Multiple cherrypicks to cord-tester 4.0 branch
Change-Id: Ibbeaef75635e697ad52da7ee23b77b353ab48ad7
diff --git a/src/test/cord-api/Framework/utils/onosUtils.py b/src/test/cord-api/Framework/utils/onosUtils.py
new file mode 100644
index 0000000..06420a6
--- /dev/null
+++ b/src/test/cord-api/Framework/utils/onosUtils.py
@@ -0,0 +1,45 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+import paramiko
+
+def onos_command_execute(host, portNum, cmd, user='karaf', passwd='karaf'):
+ """
+ :param host: onos-cord or onos-fabric
+ :param portNum: 8102 or 8101
+ :param cmd: command to execute
+ :param user: onos/karaf
+ :param passwd: onos/karaf
+ :return: output of command executed inside onos karaf (shell)
+ """
+ try:
+ client = paramiko.SSHClient()
+ client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+ client.connect(host, port=int(portNum), username=user, password=passwd)
+ stdin, stdout, stderr = client.exec_command(cmd)
+ while not stdout.channel.exit_status_ready():
+ if stdout.channel.recv_ready():
+ return stdout.read()
+ finally:
+ client.close()
+
+def get_compute_node_ip(compute_node):
+ """
+ :param compute_node: one compute node information from output of 'cordvtn-nodes'
+ :return: data_ip of that compute node
+ """
+ for line in compute_node.splitlines():
+ columns = line.split()
+ if len(columns) >= 2:
+ return columns[2].split("/")[0]
\ No newline at end of file
diff --git a/src/test/cord-api/Framework/utils/utils.py b/src/test/cord-api/Framework/utils/utils.py
index c5586fe..bb825a0 100644
--- a/src/test/cord-api/Framework/utils/utils.py
+++ b/src/test/cord-api/Framework/utils/utils.py
@@ -26,6 +26,7 @@
import random
import re
import yaml
+import glob
class utils(object):
@@ -41,6 +42,19 @@
dataList = data[strListName]
return dataList
+ def readFile(self, path, single=True):
+ dataDict = {}
+ for fileName in glob.glob(path):
+ print "Reading ", fileName
+ data = open(fileName).read()
+ dataDict[fileName] = data
+ if bool(single):
+ return data
+ return dataDict
+
+ def readFiles(self, path):
+ return self.readFile(path, single=False)
+
'''
@method compare_dict
@Description: validates if contents of dict1 exists in dict2
@@ -260,37 +274,3 @@
names['name']=i
dnames.append(names.copy())
return dnames
-
-'''
-#Test
-dict_list = {
- "humanReadableName": "cordSubscriber-17",
- "id": 17,
- "features": {
- "uplink_speed": 1000000000,
- "downlink_speed": 1000000000,
- "status": "enabled"
- },
- "identity": {
- "account_num": "20",
- "name": "My House"
- },
- "related": {}
- }
-input_dict = {
- "s_tag" : "111",
- "c_tag" : "222",
- "subscriber" : ""
- }
-new_value = 3
-test = utils()
-#data=test.jsonToList("Subscribers.json","SubscriberInfo")
-#print test.jsonToList("Subscribers.json","SubscriberInfo")
-#print "index 1...",test.listToDict(data,1)
-#result = test.getDictFromListOfDict(dict_list,"email",21)
-#result = test.getFieldValueFromDict(dict_list,"id")
-#result = test.getDictFromListOfDict(dict_list,"account_num",21)
-#result = test.setFieldValueInDict(input_dict,"subscriber",new_value)
-result = test.getAllFieldValues(list1,"instance_name")
-print "finalllllll result....", result
-'''
diff --git a/src/test/cord-api/Framework/utils/utils.robot b/src/test/cord-api/Framework/utils/utils.robot
index 2bf46f8..db559e5 100644
--- a/src/test/cord-api/Framework/utils/utils.robot
+++ b/src/test/cord-api/Framework/utils/utils.robot
@@ -89,10 +89,18 @@
${output}= Run ${cmd}
[Return] ${output}
+Execute ONOS Command
+ [Arguments] ${onos} ${port} ${cmd} ${user}=karaf ${pass}=karaf
+ ${conn_id}= SSHLibrary.Open Connection ${onos} port=${port} prompt=onos> timeout=300s
+ SSHLibrary.Login ${user} ${pass}
+ ${output}= SSHLibrary.Execute Command ${cmd}
+ SSHLibrary.Close Connection
+ [Return] ${output}
+
Get Docker Container ID
- [Arguments] ${system} ${container_name} ${user}=${USER} ${password}=${PASSWD}
- [Documentation] Retrieves the id of the requested docker container running inside given ${HOST}
- ${container_id}= Execute Command on CIAB Server in Specific VM ${system} head1 docker ps | grep ${container_name} | awk '{print $1}' ${user} ${password}
+ [Arguments] ${container_name}
+ [Documentation] Retrieves the id of the requested docker container running inside headnode
+ ${container_id}= Run docker ps | grep ${container_name} | awk '{print $1}'
Log ${container_id}
[Return] ${container_id}
@@ -114,8 +122,16 @@
Remove Value From List
[Arguments] ${list} ${val}
${length}= Get Length ${list}
- : FOR ${INDEX} IN RANGE 0 ${length}-1
+ : FOR ${INDEX} IN RANGE 0 ${length}
\ Log ${list[${INDEX}]}
\ ${value}= Get Dictionary Values ${list[${INDEX}]}
\ Log ${value[0]}
\ Run Keyword If '${value[0]}' == '${val}' Remove From List ${list} ${INDEX}
+ \ Run Keyword If '${value[0]}' == '${val}' Exit For Loop
+
+Test Ping
+ [Arguments] ${interface} ${host}
+ [Documentation] Ping hosts to check connectivity
+ ${result}= Run ping -I ${interface} -c 5 ${host}
+ Should Contain ${result} 64 bytes
+ Should Not Contain ${result} Destination Host Unreachable
\ No newline at end of file
diff --git a/src/test/cord-api/Tests/Ch_DefaultServiceCheck.txt b/src/test/cord-api/Tests/Ch_DefaultServiceCheck.txt
index 2613475..6b73369 100644
--- a/src/test/cord-api/Tests/Ch_DefaultServiceCheck.txt
+++ b/src/test/cord-api/Tests/Ch_DefaultServiceCheck.txt
@@ -29,6 +29,7 @@
##need to remove openstack and onos from xos_services list in each manifest as these services arent treated as typical xos synchronizers
utils.Remove Value From List ${dynamicServiceList} openstack
utils.Remove Value From List ${dynamicServiceList} onos
+ utils.Remove Value From List ${dynamicServiceList} exampleservice
Log ${dynamicServiceList}
Verify Service Sanity