Add Tests for VTN Renderer feature of NIC. 81/23981/18
authorkavitha.ma <kavitha.ma@hcl.com>
Fri, 10 Jul 2015 02:42:26 +0000 (08:12 +0530)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 20 Aug 2015 23:44:31 +0000 (23:44 +0000)
Change-Id: Icda97dedd24c3c4cc02b616fbe77a92a673e861b
Signed-off-by: kavitha.ma <kavitha.ma@hcl.com>
test/csit/libraries/NicKeywords.robot [new file with mode: 0644]
test/csit/suites/nic/vtn_renderer/__init__.robot [new file with mode: 0644]
test/csit/suites/nic/vtn_renderer/vtn_renderer_nic_cli_test.robot [new file with mode: 0644]
test/csit/suites/nic/vtn_renderer/vtn_renderer_nic_rest_test.robot [new file with mode: 0644]
test/csit/testplans/nic-vtnrenderer.txt [new file with mode: 0644]

diff --git a/test/csit/libraries/NicKeywords.robot b/test/csit/libraries/NicKeywords.robot
new file mode 100644 (file)
index 0000000..14f42a4
--- /dev/null
@@ -0,0 +1,98 @@
+*** Settings ***
+Library           SSHLibrary
+Library           String
+Library           DateTime
+Library           Collections
+Library           json
+Library           RequestsLibrary
+Variables         ../variables/Variables.py
+Resource          ./Utils.robot
+Resource          Scalability.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://${CONTROLLER}:${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://${CONTROLLER}:${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    ${mininet_conn_id}
+
+Fetch Intent List
+    [Documentation]    Check if VTN Renderer feature is installed.
+    ${resp}=    RequestsLibrary.Get    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    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    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    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    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: "
+    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 10 ${host2}
+    ${result}    Read Until    mininet>
+    Should Not Contain    ${result}    64 bytes
diff --git a/test/csit/suites/nic/vtn_renderer/__init__.robot b/test/csit/suites/nic/vtn_renderer/__init__.robot
new file mode 100644 (file)
index 0000000..714cde2
--- /dev/null
@@ -0,0 +1,6 @@
+*** Settings ***
+Documentation     Test suite for NIC VTN Renderer(OF13)
+Suite Setup       Start NIC VTN Renderer Suite
+Suite Teardown    Stop NIC VTN Renderer Suite
+Library           SSHLibrary
+Resource          ../../../libraries/NicKeywords.robot
diff --git a/test/csit/suites/nic/vtn_renderer/vtn_renderer_nic_cli_test.robot b/test/csit/suites/nic/vtn_renderer/vtn_renderer_nic_cli_test.robot
new file mode 100644 (file)
index 0000000..58a8342
--- /dev/null
@@ -0,0 +1,68 @@
+*** Settings ***
+Documentation     Basic Tests for VTN Renderer using NIC CLI.
+...
+...               Copyright (c) 2015 NEC. 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
+Suite Teardown    Stop NIC Vtn Rest Test Suite
+Library           SSHLibrary
+Library           Collections
+Library           ../../../libraries/Common.py
+Resource          ../../../libraries/NicKeywords.robot
+Resource          ../../../libraries/Scalability.robot
+
+*** Variables ***
+${switches}       8
+@{valid_intent1}    10.0.0.1    10.0.0.2    ALLOW
+@{valid_intent2}    10.0.0.2    10.0.0.4    BLOCK
+@{valid_intent3}    10.0.0.3    10.0.0.5    ALLOW
+@{invalid_Intent1}    10.0.3.4.5    10.0.0.3    ALLOW
+@{invalid_Intent2}    10.0.3.5    10.0.0.3    ALLOW
+@{all_invalid_Intent}    ${invalid_Intent1}    ${invalid_Intent2}
+@{all_valid_intent}    ${valid_intent1}    ${valid_intent2}    ${valid_intent3}
+@{all_intents_ids}
+
+*** Test Cases ***
+Verify VTN Install
+    [Documentation]    Verify if VTN manager bundles are installed.
+    Wait Until Keyword Succeeds    1000s    10s    Verify VTNBundle
+
+Verify VTN Renderer Command Add and Remove in CLI
+    [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.
+    [Tags]    NIC
+    : FOR    ${intent}    IN    @{all_valid_intent}
+    \    ${id}=    Add Intent From Karaf Console    @{intent}
+    \    Append To List    ${all_intents_ids}    ${id}
+    Switch Connection    ${mininet_conn_id}
+    Mininet Ping Should Succeed    h1    h2
+    Mininet Ping Should Succeed    h3    h5
+    Mininet Ping Should Not Succeed    h2    h4
+    : FOR    ${intent_id}    IN    @{all_intents_ids}
+    \    Remove Intent From Karaf Console    ${intent_id}
+
+Verify Invalid VTN Renderer Command Add and Remove in CLI
+    [Documentation]    Invalid IP address for intent creation It first creates the intents
+    ...    and stores the intent ids, but flow condition and flowfilter was not created.
+    [Tags]    NIC
+    : FOR    ${intent}    IN    @{all_invalid_Intent}
+    \    ${id}=    Add Intent From Karaf Console    @{intent}
+    \    ${output}=    Issue Command On Karaf Console    log:display |grep "Invalid Address"
+    \    Should Contain    ${output}    Invalid Address
+
+*** Keywords ***
+Verify VTNBundle
+    ${output}=    Issue Command On Karaf Console    bundle:list |grep vtn-renderer
+    Should Contain    ${output}    Active
+
+Setup NIC Console Environment
+    [Documentation]    Installing NIC Console related features (odl-nic-core, odl-nic-console)
+    Verify Feature Is Installed    odl-nic-core
+    Verify Feature Is Installed    odl-nic-console
+    Verify Feature Is Installed    odl-nic-renderer-vtn
+    Clean Mininet System
+    Start Mininet Linear    ${switches}
diff --git a/test/csit/suites/nic/vtn_renderer/vtn_renderer_nic_rest_test.robot b/test/csit/suites/nic/vtn_renderer/vtn_renderer_nic_rest_test.robot
new file mode 100644 (file)
index 0000000..ca5f202
--- /dev/null
@@ -0,0 +1,27 @@
+*** Settings ***
+Documentation     Test suite for NIC VTN Renderer
+Suite Setup       Start NIC VTN Rest Test Suite
+Suite Teardown    Stop NIC Vtn Rest Test Suite
+Resource          ../../../libraries/NicKeywords.robot
+
+*** Test Cases ***
+Add Intent
+    [Documentation]    Create a new intent .
+    Add Intent Using RestConf    ${INTENT_ID}    { "intent:intent" : { "intent:id": ${INTENT_ID} , "intent:actions" : [ { "order" : 1, "block" : {} } ],"intent:subjects" : [ { "order":1 , "end-point-group" : {name:"10.0.0.1"} }, { "order":2 , "end-point-group" : {name:"10.0.0.2"}} ] } }
+
+Verify Intent
+    [Documentation]    Verify the Intent created.
+    Verify Intent Using RestConf    ${INTENT_ID}
+
+Update Intent
+    [Documentation]    Update the Intent created.
+    Update Intent Using RestConf    ${INTENT_ID}    { "intent:intent" : { "intent:id": ${INTENT_ID} , "intent:actions" : [ { "order" : 2, "allow" : {} } ],"intent:subjects" : [ { "order":1 , "end-point-group" : {name:"10.0.0.1"} }, { "order":2 , "end-point-group" : {name:"10.0.0.2"}} ] } }
+
+Verify Ping
+    [Documentation]    Ping h1 to h2, to verify no packet loss
+    Mininet Ping Should Succeed    h1    h2
+
+Delete Intent
+    [Documentation]    Delete the intent created.
+    Delete Intent Using RestConf    ${INTENT_ID}
+    Mininet Ping Should Not Succeed    h1    h2
diff --git a/test/csit/testplans/nic-vtnrenderer.txt b/test/csit/testplans/nic-vtnrenderer.txt
new file mode 100644 (file)
index 0000000..70f6b77
--- /dev/null
@@ -0,0 +1,2 @@
+# Place the suites in run order:
+integration/test/csit/suites/nic/vtn_renderer