-*** Settings ***
-Documentation Test suite for Subnet Gateway
-Suite Setup Create Session session http://${CONTROLLER}:${RESTPORT} auth=${AUTH} headers=${HEADERS}
-Suite Teardown Delete All Sessions
-Library SSHLibrary
-Library Collections
-Library ../../../libraries/RequestsLibrary.py
-Library ../../../libraries/Common.py
-Variables ../../../variables/Variables.py
-
-*** Variables ***
-${name} test
-${key} subnetConfig
-${REST_CONTEXT} /controller/nb/v2/subnetservice
-${REST_CONTEXT_HT} /controller/nb/v2/hosttracker
-
-*** Test Cases ***
-List Subnets
- [Documentation] List subnets and verify default is there
- [Tags] apps
- ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/${CONTAINER}/subnets
- Should Be Equal As Strings ${resp.status_code} 200
- ${result} To JSON ${resp.content}
- ${subnet} Get From Dictionary ${result} ${key}
- ${content} Get From List ${subnet} 0
- Dictionary Should Contain Value ${content} 0.0.0.0/0
-
-Ping h1 to h4
- [Documentation] Ping h1 to h4, verify no packet loss
- [Tags] apps
- Write h1 ping -w 6 h4
- Sleep 6
- Write h4 ping -w 6 h1
- Sleep 6
- ${result} Read
- Should Contain ${result} 64 bytes
-
-List hosts
- [Documentation] List hosts and verify h1 and h4
- [Tags] apps
- ${resp} RequestsLibrary.Get session ${REST_CONTEXT_HT}/${CONTAINER}/hosts/active
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} 10.0.0.1
- Should Contain ${resp.content} 10.0.0.4
-
-Add a subnet
- [Documentation] Add a subnet, list to validate the result.
- [Tags] apps
- ${body} Create Dictionary name ${name} subnet 11.0.0.254/8
- ${resp} RequestsLibrary.Put session ${REST_CONTEXT}/${CONTAINER}/subnet/${name} data=${body}
- Should Be Equal As Strings ${resp.status_code} 201
- ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/${CONTAINER}/subnets
- Should Be Equal As Strings ${resp.status_code} 200
- ${result} To JSON ${resp.content}
- ${content} Get From Dictionary ${result} ${key}
- List Should Contain Value ${content} ${body}
-
-Remove a subnet
- [Documentation] Remove a subnet, list to validate the result.
- [Tags] apps
- ${body} Create Dictionary name ${name} subnet 11.0.0.254/8
- ${resp} RequestsLibrary.Delete session ${REST_CONTEXT}/${CONTAINER}/subnet/${name}
- Should Be Equal As Strings ${resp.status_code} 204
- ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/${CONTAINER}/subnets
- Should Be Equal As Strings ${resp.status_code} 200
- ${result} To JSON ${resp.content}
- ${content} Get From Dictionary ${result} ${key}
- List Should Not Contain Value ${content} ${body}