+++ /dev/null
-*** Settings ***
-Library SSHLibrary
-Library String
-Library DateTime
-Library Collections
-Library json
-Library RequestsLibrary
-Variables ../variables/Variables.py
-Resource Utils.robot
-Resource MininetKeywords.robot
-
-*** Variables ***
-${switches} 2
-${REST_CONTEXT_INTENT} restconf/config/intent:intents/intent
-${INTENTS} restconf/config/intent:intents
-${VTN_INVENTORY} restconf/operational/vtn-inventory:vtn-nodes
-${INTENT_ID} b9a13232-525e-4d8c-be21-cd65e3436033
-
-*** Keywords ***
-Start NIC VTN Renderer Suite
- [Documentation] Start Nic VTN Renderer Init Test Suite
- Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
- BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch Intent List
-
-Stop NIC VTN Renderer Suite
- [Documentation] Stop Nic VTN Renderer Test Suite
- Delete All Sessions
-
-Start NIC VTN Rest Test Suite
- [Documentation] Start Nic VTN Renderer Rest Test Suite
- Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
- Clean Mininet System
- Start Mininet Linear ${switches}
-
-Stop NIC VTN Rest Test Suite
- [Documentation] Stop Nic VTN Renderer Test Suite
- Stop Mininet And Exit ${mininet_conn_id}
-
-Fetch Intent List
- [Documentation] Check if VTN Renderer feature is installed.
- ${resp}= RequestsLibrary.Get Request session ${INTENTS}
- Should Be Equal As Strings ${resp.status_code} 200
-
-Add Intent Using RestConf
- [Arguments] ${intent_id} ${intent_data}
- [Documentation] Create a intent with specified parameters.
- ${resp}= RequestsLibrary.put Request session ${REST_CONTEXT_INTENT}/${intent_id} data=${intent_data}
- Should Be Equal As Strings ${resp.status_code} 200
-
-Verify Intent Using RestConf
- [Arguments] ${intent_id}
- [Documentation] Verify If intent is created.
- ${resp}= RequestsLibrary.Get Request session ${REST_CONTEXT_INTENT}/${intent_id}
- Should Be Equal As Strings ${resp.status_code} 200
-
-Update Intent Using RestConf
- [Arguments] ${intent_id} ${intent_data}
- [Documentation] Update a intent with specified parameters.
- ${resp}= RequestsLibrary.put Request session ${REST_CONTEXT_INTENT}/${intent_id} data=${intent_data}
- Should Be Equal As Strings ${resp.status_code} 200
-
-Delete Intent Using RestConf
- [Arguments] ${intent_id}
- [Documentation] Delete a intent with specified parameters.
- ${resp}= RequestsLibrary.Delete Request session ${REST_CONTEXT_INTENT}/${intent_id}
- Should Be Equal As Strings ${resp.status_code} 200
-
-Add Intent From Karaf Console
- [Arguments] ${intent_from} ${intent_to} ${intent_permission}
- [Documentation] Adds an intent to the controller, and returns the id of the intent created.
- ${output}= Issue Command On Karaf Console intent:add -f ${intent_from} -t ${intent_to} -a ${intent_permission}
- Should Contain ${output} Intent created
- ${output}= Fetch From Left ${output} )
- ${output_split}= Split String ${output} ${SPACE}
- ${id}= Get From List ${output_split} 3
- [Return] ${id}
-
-Remove Intent From Karaf Console
- [Arguments] ${id}
- [Documentation] Removes an intent from the controller via the provided intent id.
- ${output}= Issue Command On Karaf Console intent:remove ${id}
- Should Contain ${output} Intent successfully removed
- ${output}= Issue Command On Karaf Console log:display | grep "Removed VTN configuration associated with the deleted Intent: "
- #The below log statements has changed an info to trace mode in Beryllium, and in future release will roll back in same.
- #Should Contain ${output} Removed VTN configuration associated with the deleted Intent ${id}
-
-Mininet Ping Should Succeed
- [Arguments] ${host1} ${host2}
- [Timeout] 2 minute
- Write ${host1} ping -c 10 ${host2}
- ${result} Read Until mininet>
- Should Contain ${result} 64 bytes
-
-Mininet Ping Should Not Succeed
- [Arguments] ${host1} ${host2}
- [Timeout] 2 minute
- Write ${host1} ping -c 3 ${host2}
- ${result} Read Until mininet>
- Should Not Contain ${result} 64 bytes
+++ /dev/null
-*** Settings ***
-Documentation Test suite to verify Restconf is OK
-Suite Setup Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_XML}
-Suite Teardown Delete All Sessions
-Library RequestsLibrary
-Library Collections
-Library HttpLibrary.HTTP
-Variables ../../../variables/Variables.py
-Resource ../../../libraries/Utils.robot
-
-*** Variables ***
-${REST_CONTEXT} /restconf/modules
-${INTENT_CONTEXT} /restconf/config/intent:intents
-@{intent1_correct} 10.0.0.5 10.0.0.2,10.0.0.3 allow
-@{intent2_correct} 10.0.0.5 10.0.0.2,10.0.0.10 block
-@{intent3_correct} 10.0.0.1,10.0.0.4 10.0.0.2 allow
-@{all_intents_correct} ${intent1_correct} ${intent2_correct} ${intent3_correct}
-@{intent1_bad} 10.0.0.3 10.0.0.22,10.0.0.33 allow
-@{intent2_bad} 10.0.0.1 10.0.0.12,10.0.0.102 block
-@{intent3_bad} 10.0.0.2,10.0.0.10 10.0.0.42 allow
-@{all_intents_bad} ${intent1_bad} ${intent2_bad} ${intent3_bad}
-@{all_intents_ids}
-
-*** Test Cases ***
-Get Controller Modules
- [Documentation] Get the controller modules via Restconf
- ${resp} RequestsLibrary.Get Request session ${REST_CONTEXT}
- Log ${resp.content}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} ietf-restconf
-
-Verify REST Command Add, Update and Remove
- FOR ${intent} IN @{all_intents_bad}
- ${intent_id}= REST Add Intent @{intent}
- Append To List ${all_intents_ids} ${intent_id}
- END
- ${resp}= REST Get List of Intents
- FOR ${intent_id} IN @{all_intents_ids}
- Should Contain ${resp} ${intent_id}
- END
- ${size}= Get Length ${all_intents_correct}
- FOR ${index} IN RANGE ${size}
- ${intent}= Get From List ${all_intents_correct} ${index}
- ${intent_id}= Get From List ${all_intents_ids} ${index}
- REST Update Intent By Id ${intent_id} @{intent}
- ${intent_from}= Get From List ${intent} 0
- ${intent_to}= Get From List ${intent} 1
- ${intent_permission}= Get From List ${intent} 2
- ${resp}= REST Get Intent From Id ${intent_id}
- Should Contain ${resp} ${intent_from}
- Should Contain ${resp} ${intent_to}
- Should Contain ${resp} ${intent_permission}
- END
- FOR ${id} IN @{all_intents_ids}
- REST Delete Intent By Id ${id}
- END
-
-*** Keywords ***
-REST Get List of Intents
- [Documentation] Get the list of intents configured
- ${resp} RequestsLibrary.Get Request session ${INTENT_CONTEXT}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} "intents"
- [Return] ${resp.content}
-
-REST Get Intent From Id
- [Arguments] ${id}
- [Documentation] Get the intent detail from id
- ${resp} RequestsLibrary.Get Request session ${INTENT_CONTEXT}/intent/${id}
- Log Json ${resp.content}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} ${id}
- [Return] ${resp.content}
-
-Generate Random UUID
- [Documentation] Generates random UUID for use with creating intents on REST API. Has the format
- ... (alphanumeric) 8-4-4-4-12.
- ${id1}= Generate Random String 8 [NUMBERS]abcdef
- ${id2}= Generate Random String 4 [NUMBERS]abcdef
- ${id3}= Generate Random String 4 [NUMBERS]abcdef
- ${id4}= Generate Random String 4 [NUMBERS]abcdef
- ${id5}= Generate Random String 12 [NUMBERS]abcdef
- ${id}= Catenate SEPARATOR=- ${id1} ${id2} ${id3} ${id4}
- ... ${id5}
- [Return] ${id}
-
-REST Add Intent
- [Arguments] ${intent_from} ${intent_to} ${intent_permission}
- [Documentation] Make an Intent and return the id of the new intent
- ${headers}= Create Dictionary Content-Type=application/json
- ${id}= Generate Random UUID
- ${data}= Catenate {"intent":{"id": "${id}","subjects":[{"order": 1,"end-point-group": {"name": "${intent_from}"}},{"order": 2,"end-point-group": { "name": "${intent_to}"}}],"actions": [{"order": 1,"${intent_permission}": {}}]}}
- ${resp} RequestsLibrary.Post Request session ${INTENT_CONTEXT} headers=${headers} data=${data}
- Should Be Equal As Strings ${resp.status_code} 204
- [Return] ${id}
-
-REST Update Intent By Id
- [Arguments] ${id} ${intent_from} ${intent_to} ${intent_permission}
- [Documentation] Make an Intent and return the id of the new intent
- ${headers}= Create Dictionary Content-Type=application/json
- ${data}= Catenate {"intent":{"id": "${id}","subjects":[{"order": 1,"end-point-group": {"name": "${intent_from}"}},{"order": 2,"end-point-group": { "name": "${intent_to}"}}],"actions": [{"order": 1,"${intent_permission}": {}}]}}
- ${resp} RequestsLibrary.Put Request session ${INTENT_CONTEXT}/intent/${id} headers=${headers} data=${data}
- Should Be Equal As Strings ${resp.status_code} 200
- [Return] ${resp}
-
-REST Delete All Intents
- [Documentation] Delete all of the Intents
- ${headers}= Create Dictionary Content-Type=application/json
- ${resp} RequestsLibrary.Delete Request session ${INTENT_CONTEXT} headers=${headers}
- Log ${resp}
- Should Be Equal As Strings ${resp.status_code} 200
- [Return] ${resp.content}
-
-REST Delete Intent By Id
- [Arguments] ${id}
- [Documentation] Delete Intent by Id
- ${headers}= Create Dictionary Content-Type=application/json
- ${resp} RequestsLibrary.Delete Request session ${INTENT_CONTEXT}/intent/${id} headers=${headers}
- Log ${resp}
- Should Be Equal As Strings ${resp.status_code} 200
- [Return] ${resp.content}
+++ /dev/null
-*** Settings ***
-Documentation Basic Tests for NIC Console Commands.
-...
-... Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
-...
-... This program and the accompanying materials are made available under the
-... terms of the Eclipse Public License v1.0 which accompanies this distribution,
-... and is available at http://www.eclipse.org/legal/epl-v10.html
-Suite Setup Setup NIC Console Environment
-Library SSHLibrary
-Library Collections
-Library OperatingSystem
-Library ../../../libraries/Common.py
-Resource ../../../libraries/KarafKeywords.robot
-Resource ../../../libraries/Utils.robot
-Variables ../../../variables/Variables.py
-
-*** Variables ***
-@{intent1} 10.0.0.5 10.0.0.2,10.0.0.3 ALLOW
-@{intent2} 10.0.0.5 10.0.0.2,10.0.0.10 BLOCK
-@{intent3} 10.0.0.1,10.0.0.4 10.0.0.2 ALLOW
-@{all_intents} ${intent1} ${intent2} ${intent3}
-@{all_intents_ids}
-${intent_validation1} from [10.0.0.1, 10.0.0.4] to [10.0.0.2]
-${intent_validation2} from [10.0.0.5] to [10.0.0.2]
-${intent_validation3} from [10.0.0.5] to [10.0.0.3]
-${intent_validation4} from [10.0.0.5] to [10.0.0.10]
-${intent_validation_policy1} ALLOW
-${intent_validation_policy2} BLOCK
-${intent_validation_policy3} ALLOW
-${intent_validation_policy4} BLOCK
-@{all_intent_validations} ${intent_validation1} ${intent_validation2} ${intent_validation3} ${intent_validation4}
-@{all_intent_validations_policies} ${intent_validation_policy1} ${intent_validation_policy2} ${intent_validation_policy3} ${intent_validation_policy4}
-
-*** Test Cases ***
-Verify NIC Command Add and Remove
- [Documentation] Verification of NIC Console command add and remove. It first creates the intents
- ... and stores the intent ids, then verifies that the intents were added. Finally, it compiles the intents
- ... to verify that intents were properly merged and also validates intents were removed at the end per the cleanup procedure.
- ... The command "Wait Until Keyword Succeeds" is used to poll for 10 minutes
- ... until the intent:add command is available for the test case to be run.
- [Tags] NIC
- Wait Until Keyword Succeeds 1 min 5 sec Verify Intent:Add Command is Available
- FOR ${intent} IN @{all_intents}
- ${id}= Add Intent @{intent}
- Append To List ${all_intents_ids} ${id}
- END
- ${size}= Get Length ${all_intents}
- FOR ${index} IN RANGE ${size}
- ${intent}= Get From List ${all_intents} ${index}
- ${intent_id}= Get From List ${all_intents_ids} ${index}
- Verify Intent Added ${intent_id} ${intent}
- END
- ${output}= Issue Command On Karaf Console intent:compile
- ${size}= Get Length ${all_intent_validations}
- FOR ${index} IN RANGE ${size}
- ${compiled_intent_validation}= Get From List ${all_intent_validations} ${index}
- ${intent_validation_line}= Get Lines Containing String ${output} ${compiled_intent_validation}
- ${policy}= Get From List ${all_intent_validations_policies} ${index}
- Should Contain ${intent_validation_line} ${policy}
- END
- FOR ${intent_id} IN @{all_intents_ids}
- Remove Intent ${intent_id}
- END
- ${output}= Issue Command On Karaf Console intent:list -c
- FOR ${intent_id} IN @{all_intents_ids}
- Should Not Contain ${output} ${id}
- END
-
-*** Keywords ***
-Setup NIC Console Environment
- [Documentation] Installing NIC Console related features (odl-nic-core-mdsal)
- Start Mininet
- Verify Feature Is Installed odl-nic-core-mdsal
-
-Add Intent
- [Arguments] ${intent_from} ${intent_to} ${intent_permission}
- [Documentation] Adds an intent to the controller, and returns the id of the intent created.
- ${output}= Issue Command On Karaf Console intent:add -f ${intent_from} -t ${intent_to} -a ${intent_permission}
- Should Contain ${output} Intent created
- ${output}= Fetch From Left ${output} )
- ${output_split}= Split String ${output} ${SPACE}
- ${id}= Get From List ${output_split} 3
- [Return] ${id}
-
-Verify Intent:Add Command is Available
- [Documentation] Verifies that intent:add command is available to be used.
- ... Should be used with the command "Wait Until Keyword Succeeds" to poll until command is available.
- ${output}= Issue Command On Karaf Console intent:add
- Should Not Contain ${output} Command not found
-
-Verify Intent Added
- [Arguments] ${id} ${intent}
- [Documentation] This will check if the id exists via intent:list -c, then compares intent details with arguments passed in with Add Intent
- ${output}= Issue Command On Karaf Console intent:list -c
- Should Contain ${output} ${id}
- ${output}= Issue Command On Karaf Console intent:show ${id}
- ${out}= Get Lines Containing String ${output} Value:
- ${out_intent_from}= Get Line ${out} 0
- ${out_intent_to}= Get Line ${out} 1
- ${out_intent_permission}= Get Line ${out} 2
- ${intent_from}= Get From List ${intent} 0
- ${intent_to}= Get From List ${intent} 1
- ${intent_permission}= Get From List ${intent} 2
- Should Contain ${out_intent_from} ${intent_from}
- Should Contain ${out_intent_to} ${intent_to}
- Should Contain ${out_intent_permission} ${intent_permission}
-
-Remove Intent
- [Arguments] ${id}
- [Documentation] Removes an intent from the controller via the provided intent id.
- ${output}= Issue Command On Karaf Console intent:remove ${id}
- Should Contain ${output} Intent successfully removed