Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 1 | # 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 | # onos common functions |
| 16 | |
| 17 | *** Settings *** |
| 18 | Documentation Library for various utilities |
| 19 | Library SSHLibrary |
| 20 | Library HttpLibrary.HTTP |
| 21 | Library String |
| 22 | Library DateTime |
| 23 | Library Process |
| 24 | Library Collections |
| 25 | Library RequestsLibrary |
| 26 | Library OperatingSystem |
| 27 | |
| 28 | *** Keywords *** |
| 29 | Execute ONOS Command |
| 30 | [Arguments] ${host} ${port} ${cmd} |
| 31 | [Documentation] Establishes an ssh connection to the onos contoller and executes a command |
| 32 | ${conn_id}= SSHLibrary.Open Connection ${host} port=${port} prompt=onos> timeout=300s |
| 33 | SSHLibrary.Login karaf karaf |
| 34 | ${output}= SSHLibrary.Execute Command ${cmd} |
| 35 | SSHLibrary.Close Connection |
| 36 | [Return] ${output} |
| 37 | |
| 38 | Validate OLT Device in ONOS |
| 39 | [Documentation] Checks if olt has been connected to ONOS |
| 40 | [Arguments] ${serial_number} |
| 41 | ${resp}= Get Request ONOS onos/v1/devices |
| 42 | ${jsondata}= To Json ${resp.content} |
| 43 | Should Not Be Empty ${jsondata['devices']} |
| 44 | ${length}= Get Length ${jsondata['devices']} |
| 45 | @{serial_numbers}= Create List |
| 46 | : FOR ${INDEX} IN RANGE 0 ${length} |
| 47 | \ ${value}= Get From List ${jsondata['devices']} ${INDEX} |
| 48 | \ ${sn}= Get From Dictionary ${value} serial |
| 49 | \ ${of_id}= Get From Dictionary ${value} id |
| 50 | Should Be Equal As Strings ${sn} ${serial_number} |
Kailash | 57210eb | 2019-08-30 13:27:19 -0700 | [diff] [blame] | 51 | [Return] ${of_id} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 52 | |
| 53 | Verify Eapol Flows Added |
Andy Bavier | b0c0623 | 2019-08-29 12:58:53 -0700 | [diff] [blame] | 54 | [Arguments] ${ip} ${port} ${expected_flows} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 55 | [Documentation] Matches for number of eapol flows based on number of onus |
Andy Bavier | b0c0623 | 2019-08-29 12:58:53 -0700 | [diff] [blame] | 56 | ${eapol_flows_added}= Execute ONOS Command ${ip} ${port} flows -s -f ADDED | grep eapol | wc -l |
| 57 | Should Contain ${eapol_flows_added} ${expected_flows} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 58 | |
| 59 | Verify Number of AAA-Users |
Kailash | 2b963f0 | 2019-08-28 22:46:33 -0700 | [diff] [blame] | 60 | [Arguments] ${ip} ${port} ${expected_onus} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 61 | [Documentation] Matches for number of aaa-users authorized based on number of onus |
Kailash | 57210eb | 2019-08-30 13:27:19 -0700 | [diff] [blame] | 62 | ##TODO: filter by onu serial number instead of count |
Kailash | 2b963f0 | 2019-08-28 22:46:33 -0700 | [diff] [blame] | 63 | ${aaa_users}= Execute ONOS Command ${ip} ${port} aaa-users | grep AUTHORIZED | wc -l |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 64 | Should Contain ${aaa_users} ${expected_onus} |
| 65 | |
| 66 | Validate DHCP Allocations |
Kailash | 2b963f0 | 2019-08-28 22:46:33 -0700 | [diff] [blame] | 67 | [Arguments] ${ip} ${port} ${expected_onus} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 68 | [Documentation] Matches for number of dhcpacks based on number of onus |
Kailash | 57210eb | 2019-08-30 13:27:19 -0700 | [diff] [blame] | 69 | ##TODO: filter by onu serial number instead of count |
Kailash | 2b963f0 | 2019-08-28 22:46:33 -0700 | [diff] [blame] | 70 | ${allocations}= Execute ONOS Command ${ip} ${port} dhcpl2relay-allocations | grep DHCPACK | wc -l |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 71 | Should Contain ${allocations} ${expected_onus} |