blob: 11888e87edb93218c39512d2b17302c20dd0e52b [file] [log] [blame]
Kailash92764922019-07-25 08:21:39 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# robot test functions
16
17*** Settings ***
18Documentation Library for various utilities
19Library SSHLibrary
20Library HttpLibrary.HTTP
21Library String
22Library DateTime
23Library Process
24Library Collections
25Library RequestsLibrary
26Library OperatingSystem
27
28*** Keywords ***
29Execute ONOS Command
30 [Arguments] ${cmd}
31 [Documentation] Establishes an ssh connection to the onos contoller and executes a command
32 ${conn_id}= SSHLibrary.Open Connection localhost port=8101 prompt=onos> timeout=300s
33 SSHLibrary.Login karaf karaf
34 ${output}= SSHLibrary.Execute Command ${cmd}
35 SSHLibrary.Close Connection
36 [Return] ${output}
37
38Validate Device
39 [Arguments] ${serial_number} ${admin_state} ${oper_status} ${connect_status}
40 [Documentation] Parses the output of "voltctl device list" and inspects device ${serial_number}
41 ... Arguments are matched for device states of: "admin_state", "oper_status", and "connect_status"
42 ${output}= Run voltctl device list -o json
43 ${jsondata}= To Json ${output}
44 Log ${jsondata}
45 ${length}= Get Length ${jsondata}
46 : FOR ${INDEX} IN RANGE 0 ${length}
47 \ ${value}= Get From List ${jsondata} ${INDEX}
48 \ ${astate}= Get From Dictionary ${value} adminstate
49 \ ${opstatus}= Get From Dictionary ${value} operstatus
50 \ ${cstatus}= Get From Dictionary ${value} connectstatus
51 \ ${sn}= Get From Dictionary ${value} serialnumber
52 \ Run Keyword If '${sn}' == '${serial_number}' Exit For Loop
53 Should Be Equal ${astate} ${admin_state} Device ${serial_number} admin_state != ENABLED values=False
54 Should Be Equal ${opstatus} ${oper_status} Device ${serial_number} oper_status != ACTIVE values=False
Kailash528f7c02019-07-31 10:55:49 -070055 Should Be Equal ${cstatus} ${connect_status} Device ${serial_number} connect_status != REACHABLE values=False
56
57Check CLI Tools Configured
58 [Documentation] Tests that use 'voltctl' and 'kubectl' should execute this keyword in suite setup
59 # check voltctl and kubectl configured
60 ${voltctl_rc}= Run And Return RC voltctl
61 ${kubectl_rc}= Run And Return RC kubectl
62 Run Keyword If ${voltctl_rc} != 1 or ${kubectl_rc} != 0 FATAL ERROR
63 ... VOLTCTL and KUBECTL not configured. Please configure before executing tests.