Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / sxp / performance / 020_BindingExportTests.robot
1 *** Settings ***
2 Documentation     Test suite measuring binding export and forwarding speed.
3 Test Setup        Setup SXP Environment
4 Test Teardown     Clean Custom SXP Environment
5 Library           ../../../libraries/Sxp.py
6 Resource          ../../../libraries/SxpLib.robot
7 Library           Remote    http://${ODL_SYSTEM_IP}:8270/ExportTestLibrary    WITH NAME    ExportLibrary
8
9 *** Variables ***
10 # Tested Nodes IPs
11 ${SOURCE_IP}      127.1.0.1
12 ${DESTINATION_IP}    127.2.0.1
13 # Testing variables
14 ${EXPORT_AMOUNT}    65536
15 ${TEST_SAMPLES}    5
16 ${MINIMAL_SPEED}    2000
17 # Testing Domains
18 ${DOMAIN_0}       global
19 ${DOMAIN_1}       test-domain
20
21 *** Test Cases ***
22 Binding Export Test
23     [Documentation]    Test binding export speed without any filters
24     Add Bindings Range    112    84213760    ${EXPORT_AMOUNT}
25     ${export_speed}    Simple Export    ${EXPORT_AMOUNT}    ${TEST_SAMPLES}
26     Log    Average export speed ${export_speed} bindings/s.
27     Should Be True    ${export_speed} > ${MINIMAL_SPEED}
28
29 Binding Forwarding Export Test
30     [Documentation]    Test binding forwarding speed without any filters
31     ${export_speed}    Forwarding Export    ${EXPORT_AMOUNT}    ${TEST_SAMPLES}
32     Log    Average export speed ${export_speed} bindings/s.
33     Should Be True    ${export_speed} > ${MINIMAL_SPEED}
34
35 Binding Outbound Filter Export Test
36     [Documentation]    Test binding export speed with Outbound filter and multiple passrates.
37     Add Bindings Range    112    84213760    ${EXPORT_AMOUNT}
38     FOR    ${num}    IN RANGE    16    20
39         ${passrate}    Evaluate    100.0/(2**(${num} - 16))
40         ${exported_bindings}    Evaluate    int(math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 ))    modules=math
41         ${exported_bindings}    Convert To String    ${exported_bindings}
42         Setup Filter    ${num}    outbound
43         ${export_speed}    Simple Export    ${exported_bindings}    ${TEST_SAMPLES}
44         Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
45         Should Be True    ${export_speed} > ${MINIMAL_SPEED}
46     END
47
48 Binding Inbound Filter Forwarding Export Test
49     [Documentation]    Test binding forwarding speed with Inbound filter and multiple passrates.
50     FOR    ${num}    IN RANGE    16    20
51         ${passrate}    Evaluate    100.0/(2**(${num} - 16))
52         ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
53         ${exported_bindings}    Convert To String    ${exported_bindings}
54         Setup Filter    ${num}    inbound-discarding
55         ${export_speed}    Forwarding Export    ${exported_bindings}    ${TEST_SAMPLES}
56         Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
57         Should Be True    ${export_speed} > ${MINIMAL_SPEED}
58     END
59
60 Binding Inbound-Discarding Filter Forwarding Export Test
61     [Documentation]    Test binding forwarding speed with Inbound-discarding filter and multiple passrates.
62     FOR    ${num}    IN RANGE    16    20
63         ${passrate}    Evaluate    100.0/(2**(${num} - 16))
64         ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
65         ${exported_bindings}    Convert To String    ${exported_bindings}
66         Setup Filter    ${num}    inbound-discarding
67         ${export_speed}    Forwarding Export    ${exported_bindings}    ${TEST_SAMPLES}
68         Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
69         Should Be True    ${export_speed} > ${MINIMAL_SPEED}
70     END
71
72 Binding Domain Filter Export Test
73     [Documentation]    Test binding export speed with domain filter and multiple passrates.
74     Add Bindings Range    112    84213760    ${EXPORT_AMOUNT}
75     FOR    ${num}    IN RANGE    16    20
76         ${passrate}    Evaluate    100.0/(2**(${num} - 16))
77         ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
78         ${exported_bindings}    Convert To String    ${exported_bindings}
79         Run Keyword And Ignore Error    Setup Domain Filter    ${num}    ${DOMAIN_1}
80         ${export_speed}    Simple Export    ${exported_bindings}    ${TEST_SAMPLES}    ${DOMAIN_1}
81         Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
82         Should Be True    ${export_speed} > ${MINIMAL_SPEED}
83     END
84
85 Binding Domain Filter Forwarding Export Test
86     [Documentation]    Test binding forward speed with domain filter and multiple passrates.
87     FOR    ${num}    IN RANGE    16    20
88         ${passrate}    Evaluate    100.0/(2**(${num} - 16))
89         ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
90         ${exported_bindings}    Convert To String    ${exported_bindings}
91         Run Keyword And Ignore Error    Setup Domain Filter    ${num}    ${DOMAIN_1}
92         ${export_speed}    Forwarding Export    ${exported_bindings}    ${TEST_SAMPLES}    ${DOMAIN_1}
93         Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
94         Should Be True    ${export_speed} > ${MINIMAL_SPEED}
95     END
96
97 Binding Combined Filter Export Test
98     [Documentation]    Test binding export speed with domain filter, Outbound filter and multiple passrates.
99     Add Bindings Range    112    84213760    ${EXPORT_AMOUNT}
100     FOR    ${num}    IN RANGE    16    20
101         ${passrate}    Evaluate    100.0/(2**(${num} - 16))
102         ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
103         ${exported_bindings}    Convert To String    ${exported_bindings}
104         Run Keyword And Ignore Error    Setup Domain Filter    ${num}    ${DOMAIN_1}
105         Setup Filter    ${num}    outbound
106         ${export_speed}    Simple Export    ${exported_bindings}    ${TEST_SAMPLES}    ${DOMAIN_1}
107         Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
108         Should Be True    ${export_speed} > ${MINIMAL_SPEED}
109     END
110
111 Binding Combined Filter Forwarding Export Test
112     [Documentation]    Test binding forward speed with domain filter, Inbound-discarding filter and multiple passrates.
113     FOR    ${num}    IN RANGE    16    20
114         ${passrate}    Evaluate    100.0/(2**(${num} - 16))
115         ${exported_bindings}    Evaluate    math.ceil( ${EXPORT_AMOUNT}*${passrate}/100 )    modules=math
116         ${exported_bindings}    Convert To String    ${exported_bindings}
117         Run Keyword And Ignore Error    Setup Domain Filter    ${num}    ${DOMAIN_1}
118         Setup Filter    ${num}    inbound-discarding
119         ${export_speed}    Forwarding Export    ${exported_bindings}    ${TEST_SAMPLES}    ${DOMAIN_1}
120         Log    Outbound Export speed ${export_speed} with passrate ${passrate}%.
121         Should Be True    ${export_speed} > ${MINIMAL_SPEED}
122     END
123
124 *** Keywords ***
125 Setup Binding Export Topology
126     [Arguments]    ${version}=version4    ${PASSWORD}=${EMPTY}    ${destination_nodes}=3    ${destination_domain}=global
127     [Documentation]    Adds connections to local and remote nodes and wait until they are connected
128     Setup Simple Binding Export Topology    ${version}    ${PASSWORD}    ${destination_nodes}    1    ${destination_domain}
129     FOR    ${num}    IN RANGE    0    ${destination_nodes}
130         ${DESTINATION_NODE}    Get Ip From Number And Ip    ${num}    ${DESTINATION_IP}
131         ExportLibrary.Add Connection    ${version}    listener    127.0.0.1    64999    ${PASSWORD}
132         ...    ${DESTINATION_NODE}
133         Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker
134         ...    ${DESTINATION_NODE}    64999    domain=${destination_domain}
135     END
136
137 Setup Simple Binding Export Topology
138     [Arguments]    ${version}=version4    ${PASSWORD}=${EMPTY}    ${destination_nodes}=3    ${source_nodes}=1    ${destination_domain}=global
139     [Documentation]    Adds connections to local and remote nodes and wait until they are connected
140     FOR    ${num}    IN RANGE    0    ${source_nodes}
141         ${SOURCE_NODE}    Get Ip From Number And Ip    ${num}    ${SOURCE_IP}
142         ExportLibrary.Add Node    ${SOURCE_NODE}    ${version}    64999    ${PASSWORD}
143         ExportLibrary.Add Connection    ${version}    speaker    127.0.0.1    64999    ${PASSWORD}
144         ...    ${SOURCE_NODE}
145     END
146     FOR    ${num}    IN RANGE    0    ${destination_nodes}
147         ${DESTINATION_NODE}    Get Ip From Number And Ip    ${num}    ${DESTINATION_IP}
148         ExportLibrary.Add Destination Node    ${DESTINATION_NODE}    ${version}    64999    ${PASSWORD}
149         Add Connection    ${version}    speaker    ${DESTINATION_NODE}    64999    password=${PASSWORD}
150         ...    domain=${destination_domain}
151     END
152     ExportLibrary.Start Nodes
153     FOR    ${num}    IN RANGE    0    ${source_nodes}
154         ${SOURCE_NODE}    Get Ip From Number And Ip    ${num}    ${SOURCE_IP}
155         Add Connection    ${version}    listener    ${SOURCE_NODE}    64999    password=${PASSWORD}
156         Wait Until Keyword Succeeds    60    2    Verify Connection    ${version}    listener
157         ...    ${SOURCE_NODE}    64999
158     END
159
160 Simple Export
161     [Arguments]    ${check_amount}    ${samples}=10    ${destination_domain}=global
162     [Documentation]    Starts SXP nodes and checks if bindings are already exported, this is repeated N times
163     @{ITEMS}    Create List
164     FOR    ${num}    IN RANGE    0    ${samples}
165         Setup Simple Binding Export Topology    destination_domain=${destination_domain}
166         ExportLibrary.Set Export Amount    ${check_amount}
167         ExportLibrary.Initiate Simple Export    127.0.0.1
168         ${ELEMENT}    Wait Until Keyword Succeeds    120    1    Check Bindings Exported
169         Append To List    ${ITEMS}    ${ELEMENT}
170         Test Clean
171     END
172     Log    ${ITEMS}
173     ${export_speed}    Get Average Of Items    ${ITEMS}
174     [Return]    ${export_speed}
175
176 Forwarding Export
177     [Arguments]    ${check_amount}    ${samples}=10    ${destination_domain}=global
178     [Documentation]    Starts SXP nodes and checks if bindings are already forwarded, this is repeated N times
179     @{ITEMS}    Create List
180     FOR    ${num}    IN RANGE    0    ${samples}
181         Setup Binding Export Topology    destination_domain=${destination_domain}
182         ExportLibrary.Set Export Amount    ${check_amount}
183         ExportLibrary.Initiate Export    132.5.0.0/16    112
184         ${ELEMENT}    Wait Until Keyword Succeeds    360    1    Check Bindings Exported
185         Append To List    ${ITEMS}    ${ELEMENT}
186         Test Clean
187     END
188     Log    ${ITEMS}
189     ${export_speed}    Get Average Of Items    ${ITEMS}
190     [Return]    ${export_speed}
191
192 Check Bindings Exported
193     [Documentation]    Checking if bindings were exported and return export speed
194     ${all_exported}    ExportLibrary.All Exported
195     Should Be True    ${all_exported}
196     ${bindings_exported}    ExportLibrary.Get Bindings Exchange Count
197     Log    ${bindings_exported}
198     ${export_time}    ExportLibrary.Get Export Time
199     Log    ${export_time}
200     ${export_speed}    Evaluate    ${bindings_exported}/${export_time}
201     Log    ${export_speed}
202     [Return]    ${export_speed}
203
204 Setup Filter
205     [Arguments]    ${bits}    ${type}
206     [Documentation]    Creates peer-group and its filter with specific matching.
207     Add PeerGroup    GROUP    ${EMPTY}
208     ${entry}    Get Filter Entry    10    permit    pl=132.5.0.0/${bits}
209     Add Filter    GROUP    ${type}    ${entry}
210
211 Setup Domain Filter
212     [Arguments]    ${bits}    ${domain}
213     [Documentation]    Creates domain and its filter with specific matching.
214     Add Domain    ${domain}
215     ${domains}    Add Domains    ${domain}
216     ${entry}    Get Filter Entry    10    permit    pl=132.5.0.0/${bits}
217     Add Domain Filter    ${DOMAIN_0}    ${domains}    ${entry}
218
219 Test Clean
220     ExportLibrary.Clean Library
221     Clean Connections
222     Clean Connections    domain=${DOMAIN_1}
223     Clean Peer Groups
224
225 Clean Custom SXP Environment
226     [Documentation]    Cleans test resources
227     Test Clean
228     Clean SXP Environment