Modify CSIT tests for VTN Coordinator of audit feature
[integration/test.git] / csit / libraries / VtnCoKeywords.robot
index 937640137f91665dc0476c356916a9ef3819d59d..05695e8dfc935dc57a7702969ac96ede8ab5b8ea 100644 (file)
@@ -11,7 +11,7 @@ Variables         ../variables/Variables.py
 Resource          ./Utils.robot
 
 *** variable ***
-${vlan_topo}=   sudo mn --controller=remote,ip=${CONTROLLER} --custom vlan_vtn_test.py --topo vlantopo
+${vlan_topo}      sudo mn --controller=remote,ip=${CONTROLLER} --custom vlan_vtn_test.py --topo vlantopo
 
 *** Keywords ***
 Get VtnCo
@@ -30,23 +30,26 @@ Get VtnCo
 Start SuiteVtnCo
     [Documentation]    Download and startup the VTN Coordinator.
     Log    Start the VTN Coordinator
-    Get VtnCo
-    ${vtnc_conn_id}=    Open Connection    ${MININET}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=30s
+    #Get VtnCo
+    ${vtnc_conn_id}=    SSHLibrary.Open Connection    ${CONTROLLER}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=30s
     Set Suite Variable    ${vtnc_conn_id}
-    Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
-    ${VTNC_FILENAME}=    Catenate    SEPARATOR=/    ${WORKSPACE}    vtn_coordinator.tar.bz2
-    Execute Command    tar -C/ -jxvf ${VTNC_FILENAME}
-    Execute Command    /usr/local/vtn/sbin/db_setup
-    Execute Command    /usr/local/vtn/bin/vtn_start
-    Execute Command    /usr/local/vtn/bin/unc_dmctl status
-    Execute Command    /usr/local/vtn/sbin/db_setup
-    Execute Command    sed -i 's/odcdrv_ping_interval = 30/odcdrv_ping_interval = 10/g' /usr/local/vtn/modules/odcdriver.conf
-    Execute Command    sed -i 's/physical_attributes_read_interval = 40/physical_attributes_read_interval = 15/g' /usr/local/vtn/modules/vtndrvintf.conf
-    Execute Command    /usr/local/vtn/bin/vtn_start
-    Execute Command    /usr/local/vtn/bin/unc_dmctl status
-    Execute Command    /usr/local/vtn/bin/drvodc_control loglevel trace
-    Execute Command    /usr/local/vtn/bin/lgcnw_control loglevel trace
-    Execute Command    exit
+    SSHLibrary.Login_With_Public_Key    ${CONTROLLER_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
+    SSHLibrary.Execute Command    sudo mkdir -p /usr/local/vtn
+    SSHLibrary.Execute Command    sudo chown jenkins /usr/local/vtn
+    SSHLibrary.Execute Command    sudo yum install -q -y http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-1.noarch.rpm
+    SSHLibrary.Execute Command    sudo yum install -q -y postgresql93-libs postgresql93 postgresql93-server postgresql93-contrib postgresql93-odbc
+    SSHLibrary.Execute Command    tar -C/ -jxvf ${WORKSPACE}/${BUNDLEFOLDER}/externalapps/*vtn-coordinator*-bin.tar.bz2
+    SSHLibrary.Execute Command    /usr/local/vtn/sbin/db_setup
+    SSHLibrary.Execute Command    /usr/local/vtn/bin/vtn_start
+    SSHLibrary.Execute Command    /usr/local/vtn/bin/unc_dmctl status
+    SSHLibrary.Execute Command    /usr/local/vtn/sbin/db_setup
+    SSHLibrary.Execute Command    sed -i 's/odcdrv_ping_interval = 30/odcdrv_ping_interval = 10/g' /usr/local/vtn/modules/odcdriver.conf
+    SSHLibrary.Execute Command    sed -i 's/physical_attributes_read_interval = 40/physical_attributes_read_interval = 15/g' /usr/local/vtn/modules/vtndrvintf.conf
+    SSHLibrary.Execute Command    /usr/local/vtn/bin/vtn_start
+    SSHLibrary.Execute Command    /usr/local/vtn/bin/unc_dmctl status
+    SSHLibrary.Execute Command    /usr/local/vtn/bin/drvodc_control loglevel trace
+    SSHLibrary.Execute Command    /usr/local/vtn/bin/lgcnw_control loglevel trace
+    SSHLibrary.Execute Command    exit
 
 Stop SuiteVtnCo
     [Documentation]    Exit the Launch Test
@@ -54,7 +57,7 @@ Stop SuiteVtnCo
 
 Start SuiteVtnCoTest
     [Documentation]    Start the VTNCo Test
-    Create Session    session    http://${MININET}:8083    headers=${VTNC_HEADERS}
+    Create Session    session    http://${CONTROLLER}:8083    headers=${VTNC_HEADERS}
 
 Stop SuiteVtnCoTest
     [Documentation]    Exit the VtnCo Test
@@ -68,7 +71,7 @@ Get Coordinator Version
 Add a Controller
     [Arguments]    ${ctrlname}    ${ctrlip}
     [Documentation]    Create a controller
-    ${controllerinfo}    Create Dictionary    controller_id=${ctrlname}    type=odc    ipaddr=${CONTROLLER}    version=1.0
+    ${controllerinfo}    Create Dictionary    controller_id=${ctrlname}    type=odc    ipaddr=${ctrlip}    version=1.0
     ${controllercreate}    Create Dictionary    controller=${controllerinfo}
     ${controllercreate_json}=    json.dumps    ${controllercreate}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${CTRLS_CREATE}    data=${controllercreate_json}
@@ -95,7 +98,7 @@ Audit Controller
     ${auditinfo}    Create Dictionary    force=false    real-network_audit=false
     ${auditupdate}    Create Dictionary    audit=${auditinfo}
     ${auditupdate_json}=    json.dumps    ${auditupdate}
-    ${resp}    RequestsLibrary.Put    session    ${VTNWEBAPI}/${CTRLS}/${ctrlname}/audit.json   data=${auditupdate_json}
+    ${resp}    RequestsLibrary.Put    session    ${VTNWEBAPI}/${CTRLS}/${ctrlname}/audit.json    data=${auditupdate_json}
     Should Be Equal As Strings    ${resp.status_code}    204
 
 Check Controller Status
@@ -129,7 +132,8 @@ Create VBR in VTN
     ${vbrcreate}    Create Dictionary    vbridge=${vbrinfo}
     ${vbrcreate_json}=    json.dumps    ${vbrcreate}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS_CREATE}    data=${vbrcreate_json}
-    Should Be Equal As Strings    ${resp.status_code}    201
+    Run Keyword If    '${vbrname}' == 'Vbr_audit'    Should Be Equal As Strings    ${resp.status_code}    202
+    ...    ELSE     Should Be Equal As Strings    ${resp.status_code}    201
 
 Create VBRIF in VBR
     [Arguments]    ${vtnname}    ${vbrname}    ${vbrifname}    ${ifdescription}    ${retcode}
@@ -152,32 +156,31 @@ Define Portmap for VBRIF
 Add a FLOWLIST
     [Arguments]    ${flowlistname}    ${ipversion}
     [Documentation]    Create FLOWLIST in Coordinator
-    ${flowlistinfo}    Create Dictionary   fl_name=${flowlistname}    ip_version=${ipversion}
+    ${flowlistinfo}    Create Dictionary    fl_name=${flowlistname}    ip_version=${ipversion}
     ${flowlistcreate}    Create Dictionary    flowlist=${flowlistinfo}
     ${flowlistcreate_json}=    json.dumps    ${flowlistcreate}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${FLOWLISTS_CREATE}    data=${flowlistcreate_json}
     Should Be Equal As Strings    ${resp.status_code}    201
 
-
 Create FLOWLISTENTRY
-    [Arguments]   ${flowlistname}
-    [Documentation]    Create Flowlistentry for  Coordinator
-    ${flowlistentryinfo}    Create Dictionary   seqnum=233    macethertype=0x800    ipdstaddr=10.0.0.1   ipdstaddrprefix=32   ipsrcaddr=10.0.0.3   ipsrcaddrprefix=32   ipproto=1
+    [Arguments]    ${flowlistname}
+    [Documentation]    Create Flowlistentry for Coordinator
+    ${flowlistentryinfo}    Create Dictionary    seqnum=233    macethertype=0x800    ipdstaddr=10.0.0.1    ipdstaddrprefix=32    ipsrcaddr=10.0.0.3
+    ...    ipsrcaddrprefix=32    ipproto=1
     ${flowlistentrycreate}    Create Dictionary    flowlistentry=${flowlistentryinfo}
     ${flowlistentrycreate_json}=    json.dumps    ${flowlistentrycreate}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}/${FLOWLISTENTRIES_CREATE}    data=${flowlistentrycreate_json}
     Should Be Equal As Strings    ${resp.status_code}    201
 
 Create FLOWLISTENTRY_ANY in FLOWLIST
-    [Arguments]   ${flowlistname}
-    [Documentation]    Create Flowlistentry_any for  Coordinator
-    ${flowlistentryinfo}    Create Dictionary   seqnum=1
+    [Arguments]    ${flowlistname}
+    [Documentation]    Create Flowlistentry_any for Coordinator
+    ${flowlistentryinfo}    Create Dictionary    seqnum=1
     ${flowlistentrycreate}    Create Dictionary    flowlistentry=${flowlistentryinfo}
     ${flowlistentrycreate_json}=    json.dumps    ${flowlistentrycreate}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${FLOWLISTS}/${flowlistname}/${FLOWLISTENTRIES_CREATE}    data=${flowlistentrycreate_json}
     Should Be Equal As Strings    ${resp.status_code}    201
 
-
 Create VBRIF in FLOWFILTER
     [Arguments]    ${vtnname}    ${vbrname}    ${vbrifname}    ${ff_type}
     [Documentation]    create vbridge interface flowfilter
@@ -188,18 +191,18 @@ Create VBRIF in FLOWFILTER
     Should Be Equal As Strings    ${resp.status_code}    201
 
 Create FLOWFILTERENTRY DROP In VBRIFFLOWFILTER
-    [Arguments]   ${vtnname}  ${vbrname}    ${vbrifname}   ${actiontype}
-    [Documentation]   create domonstration with pass actiontype
-    ${flowfilterentryinfo}     Create Dictionary    seqnum=233   fl_name=Flowlist1  action_type=${actiontype}  priority=3   dscp=55
+    [Arguments]    ${vtnname}    ${vbrname}    ${vbrifname}    ${actiontype}
+    [Documentation]    create domonstration with pass actiontype
+    ${flowfilterentryinfo}    Create Dictionary    seqnum=233    fl_name=Flowlist1    action_type=${actiontype}    priority=3    dscp=55
     ${flowfilterentrycreate}    Create Dictionary    flowfilterentry=${flowfilterentryinfo}
     ${flowfilterentrycreate_json}=    json.dumps    ${flowfilterentrycreate}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE}    data=${flowfilterentrycreate_json}
     Should Be Equal As Strings    ${resp.status_code}    201
 
 Create FLOWFILTERENTRY PASS In VBRIFFLOWFILTER
-    [Arguments]   ${vtnname}   ${vbrname}    ${vbrifname}    ${actiontype}   ${seqnum}
-    [Documentation]   create domonstration with pass actiontype
-    ${flowfilterentryinfo}     Create Dictionary    fl_name=Flowlist1  action_type=${actiontype}  priority=3   dscp=55
+    [Arguments]    ${vtnname}    ${vbrname}    ${vbrifname}    ${actiontype}    ${seqnum}
+    [Documentation]    create domonstration with pass actiontype
+    ${flowfilterentryinfo}    Create Dictionary    fl_name=Flowlist1    action_type=${actiontype}    priority=3    dscp=55
     ${flowfilterentrycreate}    Create Dictionary    flowfilterentry=${flowfilterentryinfo}
     ${flowfilterentrycreate_json}=    json.dumps    ${flowfilterentrycreate}
     ${resp}    RequestsLibrary.Put    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${FLOWFILTERS}/${FLOWFILTERS_UPDATE}/${seqnum}    data=${flowfilterentrycreate_json}
@@ -209,16 +212,16 @@ Create FLOWFILTER in VBR
     [Arguments]    ${vtnname}    ${vbrname}    ${ff_type}
     [Documentation]    create vtn flowfilter
     ${flowfilters_info}    Create Dictionary    ff_type=${ff_type}
-    ${flowfiltersdefine}    Create Dictionary   flowfilter=${flowfilters_info}
+    ${flowfiltersdefine}    Create Dictionary    flowfilter=${flowfilters_info}
     ${flowfiltersdefine_json}=    json.dumps    ${flowfiltersdefine}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS_CREATE}    data=${flowfiltersdefine_json}
     Should Be Equal As Strings    ${resp.status_code}    201
 
 Create FLOWFILTERENTRY PASS in VBRFLOWFILTER
-    [Arguments]   ${vtnname}   ${vbrname}   ${actiontype}
-    [Documentation]   create domonstration with pass actiontype
-    ${flowfilterentryinfo}     Create Dictionary    seqnum=233   fl_name=Flowlist1  action_type=${actiontype}  priority=3   dscp=55
-    ${flowfilterentryinfo_1}    Create Dictionary   vnode_name=${vbrname}    fl_name=Flowlist1    direction=in
+    [Arguments]    ${vtnname}    ${vbrname}    ${actiontype}
+    [Documentation]    create domonstration with pass actiontype
+    ${flowfilterentryinfo}    Create Dictionary    seqnum=233    fl_name=Flowlist1    action_type=${actiontype}    priority=3    dscp=55
+    ${flowfilterentryinfo_1}    Create Dictionary    vnode_name=${vbrname}    fl_name=Flowlist1    direction=in
     ${flowfilterentrycreate}    Create Dictionary    flowfilterentry=${flowfilterentryinfo}
     ${flowfilterentrycreate_json}=    json.dumps    ${flowfilterentrycreate}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE}    data=${flowfilterentrycreate_json}
@@ -228,25 +231,24 @@ Create FLOWFILTER in VTN
     [Arguments]    ${vtnname}    ${ff_type}
     [Documentation]    create vtn flowfilter
     ${flowfilters_info}    Create Dictionary    ff_type=${ff_type}
-    ${flowfiltersdefine}    Create Dictionary   flowfilter=${flowfilters_info}
+    ${flowfiltersdefine}    Create Dictionary    flowfilter=${flowfilters_info}
     ${flowfiltersdefine_json}=    json.dumps    ${flowfiltersdefine}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS_CREATE}    data=${flowfiltersdefine_json}
     Should Be Equal As Strings    ${resp.status_code}    201
 
 Create FLOWFILTERENTRY PASS in VTNFLOWFILTER
-    [Arguments]   ${vtnname}  ${actiontype}
-    [Documentation]   create domonstration with pass actiontype
-    ${flowfilterentryinfo}     Create Dictionary    seqnum=233   fl_name=Flowlist1  action_type=${actiontype}  priority=3   dscp=55
+    [Arguments]    ${vtnname}    ${actiontype}
+    [Documentation]    create domonstration with pass actiontype
+    ${flowfilterentryinfo}    Create Dictionary    seqnum=233    fl_name=Flowlist1    action_type=${actiontype}    priority=3    dscp=55
     ${flowfilterentrycreate}    Create Dictionary    flowfilterentry=${flowfilterentryinfo}
     ${flowfilterentrycreate_json}=    json.dumps    ${flowfilterentrycreate}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${FLOWFILTERS}/${FLOWFILTERENTRIES_CREATE}    data=${flowfilterentrycreate_json}
     Should Be Equal As Strings    ${resp.status_code}    201
 
-
 Create VLANMAP in VBRIDGE
     [Arguments]    ${vtnname}    ${vbrname}    ${vlanid}
     [Documentation]    Create VLANMAP for VBRIDGE in Coordinator
-    ${vlaninfo}    Create Dictionary      vlan_id=${vlanid}
+    ${vlaninfo}    Create Dictionary    vlan_id=${vlanid}
     ${vlancreate}    Create Dictionary    vlanmap=${vlaninfo}
     ${vlancreate_json}=    json.dumps    ${vlancreate}
     ${resp}    RequestsLibrary.Post    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VLANMAP_CREATE }    data=${vlancreate_json}
@@ -254,8 +256,7 @@ Create VLANMAP in VBRIDGE
 
 Start vlan_topo
     [Documentation]    This will start mininet with custom topology on both the Virtual Machines
-    Start Mininet    ${MININET}    ${vlan_topo}   ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
-
+    Start Mininet    ${MININET}    ${vlan_topo}    ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
 
 Delete a FLOWLIST
     [Arguments]    ${flowlistname}
@@ -266,7 +267,7 @@ Delete a FLOWLIST
 Test Ping
     [Arguments]    ${host1}    ${host2}
     [Documentation]    Ping hosts to check connectivity
-    Write    ${host1} ping -c 4 ${host2}
+    Write    ${host1} ping -c 1 ${host2}
     ${result}    Read Until    mininet>
     Should Contain    ${result}    64 bytes
 
@@ -284,4 +285,3 @@ Verify SwitchPort
     [Documentation]    Get switch
     ${resp}    RequestsLibrary.Get    session    ${VTNWEBAPI}/${CTRLS}/${ctrlname}/${SW}/${switch_id}/${PORTS}
     Should Be Equal As Strings    ${resp.status_code}    200
-