Add SXP performance measuring suite 24/43524/33
authorMartin Mihálek <mamihale@cisco.com>
Mon, 21 Nov 2016 20:13:33 +0000 (21:13 +0100)
committerVratko Polák <vrpolak@cisco.com>
Fri, 25 Nov 2016 11:35:44 +0000 (11:35 +0000)
Added Bindings exchange measuring tests

Change-Id: I91020e9458626b3ae8ca6d8373c337a57aadb7f9
Signed-off-by: Martin Mihálek <mamihale@cisco.com>
csit/libraries/Sxp.py
csit/libraries/SxpLib.robot
csit/suites/sxp/performance/020_BindingExportTests.robot [new file with mode: 0644]
csit/testplans/sxp-performance.txt [new file with mode: 0644]

index 13fc7c2b8aa01db533a27de25708b85b961e3e97..3b9b0f50842150a79f4f7be80edd0d66f2bcea4f 100644 (file)
@@ -1,5 +1,5 @@
 import json
-from ipaddr import IPAddress
+from netaddr import IPAddress
 from string import Template
 
 
@@ -16,6 +16,16 @@ def mod(num, base):
     return int(num) % int(base)
 
 
+def get_average_of_items(items):
+    """Gets average of items in provided list
+
+    :param items: To be proceed
+    :return: Average value
+
+    """
+    return sum(items) / len(items)
+
+
 def get_opposing_mode(mode):
     """Generate string representing opposing SXP peer mode
 
@@ -31,15 +41,31 @@ def get_opposing_mode(mode):
     return 'both'
 
 
-def get_ip_from_number(n):
-    """Generate string representing Ipv4 from specified number that is added number 2130706432
+def get_ip_from_number(n, base=2130706432):
+    """Generate string representing Ipv4 from specified number plus base value
+
+    :param n: Number to be converted
+    :type n: int
+    :param base: Starting index
+    :type base: int
+    :returns: String containing Ipv4.
+
+    """
+    ip = IPAddress(int(base) + n)
+    return str(ip)
+
+
+def get_ip_from_number_and_ip(n, ip_address):
+    """Generate string representing Ipv4 from specified number and IPAddress
 
     :param n: Number to be converted
     :type n: int
+    :param ip_address: Base address
+    :type ip_address: string
     :returns: String containing Ipv4.
 
     """
-    ip = IPAddress(2130706432 + n)
+    ip = IPAddress(int(IPAddress(ip_address)) + n)
     return str(ip)
 
 
@@ -934,7 +960,7 @@ def delete_domain_xml(node_id, name):
     :returns: String containing xml data for request
 
     """
-    return add_domain_xml(name, node_id)
+    return add_domain_xml(node_id, name)
 
 
 def get_domain_name(domain_name):
@@ -1012,7 +1038,7 @@ def prefix_range(start, end):
     index = 0
     prefixes = ''
     while index < end:
-        prefixes += get_ip_from_number(start + index) + '/32'
+        prefixes += get_ip_from_number(index, start) + '/32'
         index += 1
         if index < end:
             prefixes += ','
index 413ebf95bfedd132cb4867c82219fd2795146816..e5b99194b007c425a1962764ed3df7ae1e857258 100644 (file)
@@ -67,7 +67,7 @@ Clean Connections
     ${resp}    Get Connections    ${node}    ${session}    ${domain}
     @{connections}    Parse Connections    ${resp}
     : FOR    ${connection}    IN    @{connections}
-    \    Delete Connections    ${connection['peer-address']}    ${connection['tcp-port']}    ${node}    ${session}
+    \    Delete Connections    ${connection['peer-address']}    ${connection['tcp-port']}    ${node}    ${session}    ${domain}
 
 Verify Connection
     [Arguments]    ${version}    ${mode}    ${ip}    ${port}=64999    ${node}=127.0.0.1    ${state}=on
@@ -272,19 +272,19 @@ Delete Bindings
     Post To Controller    ${session}    delete-bindings    ${DATA}
 
 Add Bindings Range
-    [Arguments]    ${sgt}    ${start}    ${size}    ${node}
+    [Arguments]    ${sgt}    ${start}    ${size}    ${node}=127.0.0.1
     [Documentation]    Add Bindings to Node specified by range
     ${prefixes}    Prefix Range    ${start}    ${size}
     Add Bindings    ${sgt}    ${prefixes}    ${node}
 
 Delete Bindings Range
-    [Arguments]    ${sgt}    ${start}    ${size}    ${node}
+    [Arguments]    ${sgt}    ${start}    ${size}    ${node}=127.0.0.1
     [Documentation]    Delete Bindings to Node specified by range
     ${prefixes}    Prefix Range    ${start}    ${size}
     Delete Bindings    ${sgt}    ${prefixes}    ${node}
 
 Check Binding Range
-    [Arguments]    ${sgt}    ${start}    ${end}    ${node}
+    [Arguments]    ${sgt}    ${start}    ${end}    ${node}=127.0.0.1
     [Documentation]    Check if Node contains Bindings specified by range
     ${resp}    Get Bindings    ${node}
     : FOR    ${num}    IN RANGE    ${start}    ${end}
@@ -292,7 +292,7 @@ Check Binding Range
     \    Should Contain Binding    ${resp}    ${sgt}    ${ip}/32
 
 Check Binding Range Negative
-    [Arguments]    ${sgt}    ${start}    ${end}    ${node}
+    [Arguments]    ${sgt}    ${start}    ${end}    ${node}=127.0.0.1
     [Documentation]    Check if Node does not contains Bindings specified by range
     ${resp}    Get Bindings    ${node}
     : FOR    ${num}    IN RANGE    ${start}    ${end}
diff --git a/csit/suites/sxp/performance/020_BindingExportTests.robot b/csit/suites/sxp/performance/020_BindingExportTests.robot
new file mode 100644 (file)
index 0000000..23c6c16
--- /dev/null
@@ -0,0 +1,206 @@
+*** Settings ***
+Documentation     Test suite measuring binding export and forwarding speed.
+Test Setup        Setup SXP Environment
+Test Teardown     Clean SXP Environment
+Library           ../../../libraries/Sxp.py
+Resource          ../../../libraries/SxpLib.robot
+Library           Remote    http://${ODL_SYSTEM_IP}:8270/ExportTestLibrary    WITH NAME    ExportLibrary
+
+*** Variables ***
+# Tested Nodes IPs
+${SOURCE_IP}      127.1.0.1
+${DESTINATION_IP}    127.2.0.1
+# Testing variables
+${EXPORT_AMOUNT}    65536
+${TEST_SAMPLES}    5
+${MINIMAL_SPEED}    2000
+# Testing Domains
+${DOMAIN_0}       global
+${DOMAIN_1}       test-domain
+
+*** Test Cases ***
+Binding Export Test
+    [Documentation]    Test binding export speed without any filters
+    Add Bindings Range    112    84213760    ${EXPORT_AMOUNT}
+    ${export_speed}    Simple Export    ${EXPORT_AMOUNT}    ${TEST_SAMPLES}
+    Log    Average export speed ${export_speed} bindings/s.
+    Should Be True    ${export_speed} > ${MINIMAL_SPEED}
+
+Binding Forwarding Export Test
+    [Documentation]    Test binding forwarding speed without any filters
+    ${export_speed}    Forwarding Export    ${EXPORT_AMOUNT}    ${TEST_SAMPLES}
+    Log    Average export speed ${export_speed} bindings/s.
+    Should Be True    ${export_speed} > ${MINIMAL_SPEED}
+
+Binding Outbound Filter Export Test
+    [Documentation]    Test binding export speed with Outbound filter and multiple passrates.
+    Add Bindings Range    112    84213760    ${EXPORT_AMOUNT}
+    : FOR    ${num}    IN RANGE    16    20
+    \    ${passrate}    Evaluate    100.0/(2**(${num} - 16))
+    \    ${exported_bindings}    Evaluate    int(math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 ))    modules=math
+    \    ${exported_bindings}    Convert To String    ${exported_bindings}
+    \    Setup Filter    ${num}    outbound
+    \    ${export_speed}    Simple Export    ${exported_bindings}    ${TEST_SAMPLES}
+    \    Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
+    \    Should Be True    ${export_speed} > ${MINIMAL_SPEED}
+
+Binding Inbound Filter Forwarding Export Test
+    [Documentation]    Test binding forwarding speed with Inbound filter and multiple passrates.
+    : FOR    ${num}    IN RANGE    16    20
+    \    ${passrate}    Evaluate    100.0/(2**(${num} - 16))
+    \    ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
+    \    ${exported_bindings}    Convert To String    ${exported_bindings}
+    \    Setup Filter    ${num}    inbound-discarding
+    \    ${export_speed}    Forwarding Export    ${exported_bindings}    ${TEST_SAMPLES}
+    \    Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
+    \    Should Be True    ${export_speed} > ${MINIMAL_SPEED}
+
+Binding Inbound-Discarding Filter Forwarding Export Test
+    [Documentation]    Test binding forwarding speed with Inbound-discarding filter and multiple passrates.
+    : FOR    ${num}    IN RANGE    16    20
+    \    ${passrate}    Evaluate    100.0/(2**(${num} - 16))
+    \    ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
+    \    ${exported_bindings}    Convert To String    ${exported_bindings}
+    \    Setup Filter    ${num}    inbound-discarding
+    \    ${export_speed}    Forwarding Export    ${exported_bindings}    ${TEST_SAMPLES}
+    \    Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
+    \    Should Be True    ${export_speed} > ${MINIMAL_SPEED}
+
+Binding Domain Filter Export Test
+    [Documentation]    Test binding export speed with domain filter and multiple passrates.
+    Add Bindings Range    112    84213760    ${EXPORT_AMOUNT}
+    : FOR    ${num}    IN RANGE    16    20
+    \    ${passrate}    Evaluate    100.0/(2**(${num} - 16))
+    \    ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
+    \    ${exported_bindings}    Convert To String    ${exported_bindings}
+    \    Run Keyword And Ignore Error    Setup Domain Filter    ${num}    ${DOMAIN_1}
+    \    ${export_speed}    Simple Export    ${exported_bindings}    ${TEST_SAMPLES}    ${DOMAIN_1}
+    \    Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
+    \    Should Be True    ${export_speed} > ${MINIMAL_SPEED}
+
+Binding Domain Filter Forwarding Export Test
+    [Documentation]    Test binding forward speed with domain filter and multiple passrates.
+    : FOR    ${num}    IN RANGE    16    20
+    \    ${passrate}    Evaluate    100.0/(2**(${num} - 16))
+    \    ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
+    \    ${exported_bindings}    Convert To String    ${exported_bindings}
+    \    Run Keyword And Ignore Error    Setup Domain Filter    ${num}    ${DOMAIN_1}
+    \    ${export_speed}    Forwarding Export    ${exported_bindings}    ${TEST_SAMPLES}    ${DOMAIN_1}
+    \    Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
+    \    Should Be True    ${export_speed} > ${MINIMAL_SPEED}
+
+Binding Combined Filter Export Test
+    [Documentation]    Test binding export speed with domain filter, Outbound filter and multiple passrates.
+    Add Bindings Range    112    84213760    ${EXPORT_AMOUNT}
+    : FOR    ${num}    IN RANGE    16    20
+    \    ${passrate}    Evaluate    100.0/(2**(${num} - 16))
+    \    ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
+    \    ${exported_bindings}    Convert To String    ${exported_bindings}
+    \    Run Keyword And Ignore Error    Setup Domain Filter    ${num}    ${DOMAIN_1}
+    \    Setup Filter    ${num}    outbound
+    \    ${export_speed}    Simple Export    ${exported_bindings}    ${TEST_SAMPLES}    ${DOMAIN_1}
+    \    Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
+    \    Should Be True    ${export_speed} > ${MINIMAL_SPEED}
+
+Binding Combined Filter Forwarding Export Test
+    [Documentation]    Test binding forward speed with domain filter, Inbound-discarding filter and multiple passrates.
+    : FOR    ${num}    IN RANGE    16    20
+    \    ${passrate}    Evaluate    100.0/(2**(${num} - 16))
+    \    ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
+    \    ${exported_bindings}    Convert To String    ${exported_bindings}
+    \    Run Keyword And Ignore Error    Setup Domain Filter    ${num}    ${DOMAIN_1}
+    \    Setup Filter    ${num}    inbound-discarding
+    \    ${export_speed}    Forwarding Export    ${exported_bindings}    ${TEST_SAMPLES}    ${DOMAIN_1}
+    \    Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
+    \    Should Be True    ${export_speed} > ${MINIMAL_SPEED}
+
+*** Keywords ***
+Setup Binding Export Topology
+    [Arguments]    ${version}=version4    ${PASSWORD}=${EMPTY}    ${destination_nodes}=3    ${destination_domain}=global
+    [Documentation]    Adds connections to local and remote nodes and wait until they are connected
+    Setup Simple Binding Export Topology    ${version}    ${PASSWORD}    ${destination_nodes}    1    ${destination_domain}
+    : FOR    ${num}    IN RANGE    0    ${destination_nodes}
+    \    ${DESTINATION_NODE}    Get Ip From Number And Ip    ${num}    ${DESTINATION_IP}
+    \    ExportLibrary.Add Connection    ${version}    listener    127.0.0.1    64999    ${PASSWORD}
+    \    ...    ${DESTINATION_NODE}
+    \    Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker
+    \    ...    ${DESTINATION_NODE}    64999    domain=${destination_domain}
+
+Setup Simple Binding Export Topology
+    [Arguments]    ${version}=version4    ${PASSWORD}=${EMPTY}    ${destination_nodes}=3    ${source_nodes}=1    ${destination_domain}=global
+    [Documentation]    Adds connections to local and remote nodes and wait until they are connected
+    : FOR    ${num}    IN RANGE    0    ${source_nodes}
+    \    ${SOURCE_NODE}    Get Ip From Number And Ip    ${num}    ${SOURCE_IP}
+    \    ExportLibrary.Add Node    ${SOURCE_NODE}    ${version}    64999    ${PASSWORD}
+    \    ExportLibrary.Add Connection    ${version}    speaker    127.0.0.1    64999    ${PASSWORD}
+    \    ...    ${SOURCE_NODE}
+    : FOR    ${num}    IN RANGE    0    ${destination_nodes}
+    \    ${DESTINATION_NODE}    Get Ip From Number And Ip    ${num}    ${DESTINATION_IP}
+    \    ExportLibrary.Add Destination Node    ${DESTINATION_NODE}    ${version}    64999    ${PASSWORD}
+    \    Add Connection    ${version}    speaker    ${DESTINATION_NODE}    64999    password=${PASSWORD}
+    \    ...    domain=${destination_domain}
+    ExportLibrary.Start Nodes
+    : FOR    ${num}    IN RANGE    0    ${source_nodes}
+    \    ${SOURCE_NODE}    Get Ip From Number And Ip    ${num}    ${SOURCE_IP}
+    \    Add Connection    ${version}    listener    ${SOURCE_NODE}    64999    password=${PASSWORD}
+    \    Wait Until Keyword Succeeds    60    2    Verify Connection    ${version}    listener
+    \    ...    ${SOURCE_NODE}    64999
+
+Simple Export
+    [Arguments]    ${check_amount}    ${samples}=10    ${destination_domain}=global
+    [Documentation]    Starts SXP nodes and checks if bindings are already exported, this is repeated N times
+    @{ITEMS}    Create List
+    : FOR    ${num}    IN RANGE    0    ${samples}
+    \    Setup Simple Binding Export Topology    destination_domain=${destination_domain}
+    \    ExportLibrary.Set Export Amount    ${check_amount}
+    \    ExportLibrary.Initiate Simple Export    127.0.0.1
+    \    ${ELEMENT}    Wait Until Keyword Succeeds    120    1    Check Bindings Exported
+    \    Append To List    ${ITEMS}    ${ELEMENT}
+    \    Test Clean
+    ${export_speed}    Get Average Of Items    ${ITEMS}
+    [Return]    ${export_speed}
+
+Forwarding Export
+    [Arguments]    ${check_amount}    ${samples}=10    ${destination_domain}=global
+    [Documentation]    Starts SXP nodes and checks if bindings are already forwarded, this is repeated N times
+    @{ITEMS}    Create List
+    : FOR    ${num}    IN RANGE    0    ${samples}
+    \    Setup Binding Export Topology    destination_domain=${destination_domain}
+    \    ExportLibrary.Set Export Amount    ${check_amount}
+    \    ExportLibrary.Initiate Export    5.5.0.0/16    112
+    \    ${ELEMENT}    Wait Until Keyword Succeeds    360    1    Check Bindings Exported
+    \    Append To List    ${ITEMS}    ${ELEMENT}
+    \    Test Clean
+    ${export_speed}    Get Average Of Items    ${ITEMS}
+    [Return]    ${export_speed}
+
+Check Bindings Exported
+    [Documentation]    Checking if bindings were exported and return export speed
+    ${all_exported}    ExportLibrary.All Exported
+    ${bindings_exported}    ExportLibrary.Get Bindings Exchange Count
+    Log    ${bindings_exported}
+    Should Be True    ${all_exported}
+    ${export_time}    ExportLibrary.Get Export Time
+    ${export_speed}    Evaluate    ${bindings_exported}/${export_time}
+    [Return]    ${export_speed}
+
+Setup Filter
+    [Arguments]    ${bits}    ${type}
+    [Documentation]    Creates peer-group and its filter with specific matching.
+    Add PeerGroup    GROUP    ${EMPTY}
+    ${entry}    Get Filter Entry    10    permit    pl=5.5.0.0/${bits}
+    Add Filter    GROUP    ${type}    ${entry}
+
+Setup Domain Filter
+    [Arguments]    ${bits}    ${domain}
+    [Documentation]    Creates domain and its filter with specific matching.
+    Add Domain    ${domain}
+    ${domains}    Add Domains    ${domain}
+    ${entry}    Get Filter Entry    10    permit    pl=5.5.0.0/${bits}
+    Add Domain Filter    ${DOMAIN_0}    ${domains}    ${entry}
+
+Test Clean
+    ExportLibrary.Clean Library
+    Clean Connections
+    Clean Connections    domain=${DOMAIN_1}
+    Clean Peer Groups
diff --git a/csit/testplans/sxp-performance.txt b/csit/testplans/sxp-performance.txt
new file mode 100644 (file)
index 0000000..4707174
--- /dev/null
@@ -0,0 +1,2 @@
+# Place the suites in run order:
+integration/test/csit/suites/sxp/performance/
\ No newline at end of file