Robot test suite to verify DIDM discovery feature. 26/31026/15
authorLinh <linh.pham@hpe.com>
Tue, 8 Dec 2015 22:51:27 +0000 (14:51 -0800)
committerJamo Luhrsen <jluhrsen@redhat.com>
Tue, 22 Dec 2015 00:30:04 +0000 (16:30 -0800)
The suite installs DIDM features, connects to the device and
starts it, makes RestConf calls for operational node inventory,
verifies the device's information, and closes the connection to
the device and exit.

Change-Id: If3a47eae0d16f9bb847670dccaf617733b426c79
Signed-off-by: Linh <linh.pham@hpe.com>
Signed-off-by: Jamo Luhrsen <jluhrsen@redhat.com>
csit/libraries/DIDMKeywords.robot [new file with mode: 0644]
csit/suites/didm/discovery/device_discovery.robot [new file with mode: 0644]
csit/testplans/didm-discovery.txt [new file with mode: 0644]
csit/variables/Variables.robot [new file with mode: 0644]

diff --git a/csit/libraries/DIDMKeywords.robot b/csit/libraries/DIDMKeywords.robot
new file mode 100644 (file)
index 0000000..6a69d48
--- /dev/null
@@ -0,0 +1,107 @@
+*** Settings ***
+Documentation     Keywords for DIDM suites
+Library           SSHLibrary
+Library           Collections
+Library           RequestsLibrary
+Variables         ../variables/Variables.py
+Resource          ./Utils.robot
+
+*** Keywords ***
+Check DIDM Registered With Device
+    [Documentation]    Check for DIDM registered with the device
+    ${resp}=    RequestsLibrary.Get    session    ${OPERATIONAL_NODES_API}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    Log    ${resp.content}
+    Should Contain    ${resp.content}    didm
+    [Return]    ${resp.content}
+
+Find Device Data
+    [Documentation]    Extract device information
+    ${resp.content}=    Check DIDM Registered With Device
+    ${json_resp}=    RequestsLibrary.To_Json    ${resp.content}
+    ${nodes_resp}=    Get From Dictionary    ${json_resp}    nodes
+    ${node_resp}=    Get From Dictionary    ${nodes_resp}    node
+    ${node_data}=    Get From List    ${node_resp}    0
+    Log    ${node_data}
+    Set Suite Variable    ${node_data}
+    [Return]    ${node_data}
+
+Check Device IP
+    [Documentation]    Check for the device IP address
+    ${dev_ip}=    Set Variable    flow-node-inventory:ip-address
+    ${node_data}=    Find Device Data
+    ${device_keys}=    Get Dictionary Keys    ${node_data}
+    Log    ${device_keys}
+    ${length}=    Get Length    ${device_keys}
+    : FOR    ${index}    IN RANGE    0    ${length}
+    \    ${line}=    Get From List    ${device_keys}    ${index}
+    \    Run Keyword And Return If    '${dev_ip}' == '${line}'    Get From Dictionary    ${node_data}    ${dev_ip}
+    [Return]    ${dev_ip}
+
+Find Device Type
+    [Documentation]    Look for the device type
+    ${device_type}=    Set Variable    didm-identification:device-type
+    ${device_ip}=    Check Device IP
+    Should Match    ${DEVICE_IP}    ${device_ip}
+    ${device_keys}=    Get Dictionary Keys    ${node_data}
+    Log    ${device_keys}
+    ${length}=    Get Length    ${device_keys}
+    : FOR    ${index}    IN RANGE    0    ${length}
+    \    ${line}=    Get From List    ${device_keys}    ${index}
+    \    Run Keyword And Return If    '${device_type}' == '${line}'    Get From Dictionary    ${node_data}    ${device_type}
+    [Return]    ${device_type}
+
+Find Device Hardware
+    [Documentation]    Look for the device hardware information
+    ${device_hw}=    Set Variable    flow-node-inventory:hardware
+    ${device_keys}=    Get Dictionary Keys    ${node_data}
+    Log    ${device_keys}
+    ${length}=    Get Length    ${device_keys}
+    : FOR    ${index}    IN RANGE    0    ${length}
+    \    ${line}=    Get From List    ${device_keys}    ${index}
+    \    Run Keyword And Return If    '${device_hw}' == '${line}'    Get From Dictionary    ${node_data}    ${device_hw}
+    [Return]    ${device_hw}
+
+Find Device Software
+    [Documentation]    Look for the device software information
+    ${device_sw}=    Set Variable    flow-node-inventory:software
+    ${device_keys}=    Get Dictionary Keys    ${node_data}
+    Log    ${device_keys}
+    ${length}=    Get Length    ${device_keys}
+    : FOR    ${index}    IN RANGE    0    ${length}
+    \    ${line}=    Get From List    ${device_keys}    ${index}
+    \    Run Keyword And Return If    '${device_sw}' == '${line}'    Get From Dictionary    ${node_data}    ${device_sw}
+    [Return]    ${device_sw}
+
+Find Device Manufacturer
+    [Documentation]    Look for the device manufacture
+    ${manufacture}=    Set Variable    flow-node-inventory:manufacturer
+    ${device_keys}=    Get Dictionary Keys    ${node_data}
+    Log    ${device_keys}
+    ${length}=    Get Length    ${device_keys}
+    : FOR    ${index}    IN RANGE    0    ${length}
+    \    ${line}=    Get From List    ${device_keys}    ${index}
+    \    Run Keyword And Return If    '${manufacture}' == '${line}'    Get From Dictionary    ${node_data}    ${manufacture}
+    [Return]    ${manufacture}
+
+Find Serial Number
+    [Documentation]    Look for the device serial number
+    ${serial_number}=    Set Variable    flow-node-inventory:serial-number
+    ${device_keys}=    Get Dictionary Keys    ${node_data}
+    Log    ${device_keys}
+    ${length}=    Get Length    ${device_keys}
+    : FOR    ${index}    IN RANGE    0    ${length}
+    \    ${line}=    Get From List    ${device_keys}    ${index}
+    \    Run Keyword And Return If    '${serial_number}' == '${line}'    Get From Dictionary    ${node_data}    ${serial_number}
+    [Return]    ${serial_number}
+
+Find Device Description
+    [Documentation]    Look for the device description
+    ${description}=    Set Variable    flow-node-inventory:description
+    ${device_keys}=    Get Dictionary Keys    ${node_data}
+    Log    ${device_keys}
+    ${length}=    Get Length    ${device_keys}
+    : FOR    ${index}    IN RANGE    0    ${length}
+    \    ${line}=    Get From List    ${device_keys}    ${index}
+    \    Run Keyword And Return If    '${description}' == '${line}'    Get From Dictionary    ${node_data}    ${description}
+    [Return]    ${description}
diff --git a/csit/suites/didm/discovery/device_discovery.robot b/csit/suites/didm/discovery/device_discovery.robot
new file mode 100644 (file)
index 0000000..39fd919
--- /dev/null
@@ -0,0 +1,95 @@
+*** Settings ***
+Documentation     Basic Tests for DIDM in Beryllium.
+...
+...               Copyright (c) 2015 Hewlett Packard Enterprise Development LP 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/ep1-v10.html
+Suite Setup       Setup DIDM Environment
+Suite Teardown    DIDM Suite Teardown
+Library           SSHLibrary
+Library           Collections
+Library           RequestsLibrary
+Resource          ../../../variables/Variables.robot
+Variables         ../../../variables/Variables.py
+Resource          ../../../libraries/Utils.robot
+Resource          ../../../libraries/MininetKeywords.robot
+Resource          ../../../libraries/DIDMKeywords.robot
+Resource          ../../../libraries/KarafKeywords.robot
+
+*** Test Cases ***
+Identifying Unknown Device
+    [Documentation]    Verify other devices are identified as unknown
+    [Tags]    DIDM
+    ${unknown_device_ip}=    Set Variable    1.1.1.1
+    ${device_ip}=    Check Device IP
+    Should Not Match    ${device_ip}    ${unknown_device_ip}
+
+Identifying Device Type
+    [Documentation]    Verify device type
+    [Tags]    DIDM
+    ${device_type}=    Find Device Type
+    Log    ${device_type}
+    Should Match    ${DEVICE_TYPE}    ${device_type}
+
+Identifying Hardware Information
+    [Documentation]    Verify device hardware information
+    [Tags]    DIDM
+    ${device_hw}=    Find Device Hardware
+    Log    ${device_hw}
+    Should Match    ${DEVICE_HW_INFO}    ${device_hw}
+
+Identifying Manufacturer
+    [Documentation]    Verify device manufacturer
+    [Tags]    DIDM
+    ${manufacture}=    Find Device Manufacturer
+    Log    ${manufacture}
+    Should Match    ${DEVICE_MANUFACTURE}    ${manufacture}
+
+Identifying Serial Number
+    [Documentation]    Verify device serial number
+    [Tags]    DIDM
+    ${serial_number}=    Find Serial Number
+    Log    ${serial_number}
+    Should Match    ${DEVICE_SERIAL_NUMBER}    ${serial_number}
+
+Identifying Software Information
+    [Documentation]    Verify device software information
+    [Tags]    DIDM
+    ${device_sw}=    Find Device Software
+    Log    ${device_sw}
+    Should Match    ${DEVICE_SW_INFO}    ${device_sw}
+
+Identifying Description
+    [Documentation]    Verify device description
+    [Tags]    DIDM
+    ${device_description}=    Find Device Description
+    Log    ${device_description}
+    Should Match    ${DEVICE_DESCRIPTION}    ${device_description}
+
+*** Keywords ***
+DIDM Suite Teardown
+    [Documentation]    Cleanup and exit device
+    Stop Mininet And Exit    ${mininet_conn_id}
+
+Setup DIDM Environment
+    [Documentation]    Install DIDM Karaf feature. Wait for DIDM Listener to register.
+    ...    Wait for DIDM Listener is registered. Create REST session to the controller.
+    ...    Start the device.
+    Install a Feature    odl-didm-all
+    Verify Feature Is Installed    odl-didm-all
+    Verify Feature Is Installed    odl-didm-identification
+    Verify Feature Is Installed    odl-didm-drivers
+    Verify Feature Is Installed    odl-didm-hp-all
+    Verify Feature Is Installed    odl-didm-hp-impl
+    Verify Feature Is Installed    odl-didm-ovs-all
+    Verify Feature Is Installed    odl-didm-ovs-impl
+    Verify Feature Is Installed    odl-openflowplugin-all-li
+    ${message}=    Set Variable    org.opendaylight.didm.ovs - 0.2.0.SNAPSHOT | Device-type Listener registered
+    Wait For Karaf Log    ${message}
+    Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
+    Log    Start device
+    ${mininet_topo_opt}=    Set Variable    --topo linear,1 --switch ovsk,protocols=OpenFlow13
+    ${mininet_conn_id}=    Start Mininet Single Controller    ${DEVICE_IP}    ${CONTROLLER}    ${mininet_topo_opt}
+    Wait Until Keyword Succeeds    11s    1s    Check DIDM Registered With Device
+    Set Suite Variable    ${mininet_conn_id}
diff --git a/csit/testplans/didm-discovery.txt b/csit/testplans/didm-discovery.txt
new file mode 100644 (file)
index 0000000..3f66c1c
--- /dev/null
@@ -0,0 +1,8 @@
+# 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
+
+# Place the suites in run order:
+integration/test/csit/suites/didm/discovery
diff --git a/csit/variables/Variables.robot b/csit/variables/Variables.robot
new file mode 100644 (file)
index 0000000..29b678c
--- /dev/null
@@ -0,0 +1,15 @@
+*** Variables ***
+# DIDM suite variables
+${DEVICE_IP}      ${TOOLS_SYSTEM_IP}
+${MININET}        ${DEVICE_IP}
+${DEVICE_USER}    ${TOOLS_SYSTEM_USER}
+${MININET_USER}    ${DEVICE_USER}
+${DEVICE_PASSWORD}    ${TOOLS_SYSTEM_PASSWORD}
+${MININET_PASSWORD}    ${DEVICE_PASSWORD}
+${MININET_PROMPT}    ${TOOLS_SYSTEM_PROMPT}
+${DEVICE_TYPE}    mininet
+${DEVICE_DESCRIPTION}    None
+${DEVICE_HW_INFO}    Open vSwitch
+${DEVICE_SW_INFO}    2.3.1
+${DEVICE_MANUFACTURE}    Nicira, Inc.
+${DEVICE_SERIAL_NUMBER}    None