SXP: Improve parameter ${node_range}
[integration/test.git] / csit / suites / sxp / filtering / 030_Inbound_Filtering_Discarding.robot
1 *** Settings ***
2 Documentation     Test suite to verify inbound-discarding filtering functionality
3 Suite Setup       Setup SXP Environment    5
4 Suite Teardown    Clean SXP Environment    5
5 Test Teardown     Clean Nodes
6 Library           RequestsLibrary
7 Library           SSHLibrary
8 Library           ../../../libraries/Sxp.py
9 Library           ../../../libraries/Common.py
10 Resource          ../../../libraries/SxpLib.robot
11
12 *** Variables ***
13
14 *** Test Cases ***
15 Access List Filtering
16     [Documentation]    Test ACL filter behaviour during filter update
17     [Tags]    SXP    Filtering
18     Setup Nodes
19     ${peers} =    Sxp.Add Peers    127.0.0.2    127.0.0.4
20     SxpLib.Add PeerGroup    GROUP    ${peers}
21     ${entry1} =    Sxp.Get Filter Entry    10    permit    acl=10.10.10.0,0.0.0.255
22     ${entry2} =    Sxp.Get Filter Entry    20    permit    acl=10.0.0.0,0.254.0.0
23     ${entries} =    Combine Strings    ${entry1}    ${entry2}
24     SxpLib.Add Filter    GROUP    inbound-discarding    ${entries}
25     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 4-2
26     SxpLib.Delete Filter    GROUP    inbound-discarding
27     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 4-2
28
29 Access List Sgt Filtering
30     [Documentation]    Test ACL and SGT filter behaviour during filter update
31     [Tags]    SXP    Filtering
32     ${peers} =    Sxp.Add Peers    127.0.0.3    127.0.0.5
33     SxpLib.Add PeerGroup    GROUP    ${peers}
34     ${entry1} =    Sxp.Get Filter Entry    10    permit    sgt=30    acl=10.10.10.0,0.0.0.255
35     ${entry2} =    Sxp.Get Filter Entry    20    permit    sgt=50    acl=10.0.0.0,0.254.0.0
36     ${entries} =    Combine Strings    ${entry1}    ${entry2}
37     SxpLib.Add Filter    GROUP    inbound-discarding    ${entries}
38     Setup Nodes
39     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 5-3
40     SxpLib.Delete Filter    GROUP    inbound-discarding
41     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 5-3
42
43 Prefix List Filtering
44     [Documentation]    Test Prefix List filter behaviour during filter update
45     [Tags]    SXP    Filtering
46     Setup Nodes
47     ${peers} =    Sxp.Add Peers    127.0.0.2    127.0.0.4
48     SxpLib.Add PeerGroup    GROUP    ${peers}
49     ${entry1} =    Sxp.Get Filter Entry    10    permit    pl=10.10.10.0/24
50     ${entry2} =    Sxp.Get Filter Entry    20    permit    epl=10.0.0.0/8,le,16
51     ${entries} =    Combine Strings    ${entry1}    ${entry2}
52     SxpLib.Add Filter    GROUP    inbound-discarding    ${entries}
53     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 4-2
54     SxpLib.Delete Filter    GROUP    inbound-discarding
55     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 4-2
56
57 Prefix List Sgt Filtering
58     [Documentation]    Test Prefix List and SGT filter behaviour during filter update
59     [Tags]    SXP    Filtering
60     ${peers} =    Sxp.Add Peers    127.0.0.3    127.0.0.5
61     SxpLib.Add PeerGroup    GROUP    ${peers}
62     ${entry1} =    Sxp.Get Filter Entry    10    permit    sgt=30    pl=10.10.10.0/24
63     ${entry2} =    Sxp.Get Filter Entry    20    permit    pl=10.50.0.0/16
64     ${entries} =    Combine Strings    ${entry1}    ${entry2}
65     SxpLib.Add Filter    GROUP    inbound-discarding    ${entries}
66     Setup Nodes
67     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 5-3
68     SxpLib.Delete Filter    GROUP    inbound-discarding
69     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 5-3
70
71 Access List Filtering Legacy
72     [Documentation]    Test ACL filter behaviour during filter update
73     [Tags]    SXP    Filtering
74     Setup Nodes Legacy Par Two
75     ${peers} =    Sxp.Add Peers    127.0.0.2    127.0.0.4
76     SxpLib.Add PeerGroup    GROUP    ${peers}
77     ${entry1} =    Sxp.Get Filter Entry    10    permit    acl=10.10.10.0,0.0.0.255
78     ${entry2} =    Sxp.Get Filter Entry    20    permit    acl=10.0.0.0,0.254.0.0
79     ${entries} =    Combine Strings    ${entry1}    ${entry2}
80     SxpLib.Add Filter    GROUP    inbound-discarding    ${entries}
81     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 4-2
82     SxpLib.Delete Filter    GROUP    inbound-discarding
83     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 4-2
84
85 Access List Sgt Filtering Legacy
86     [Documentation]    Test ACL and SGT filter behaviour during filter update
87     [Tags]    SXP    Filtering
88     ${peers} =    Sxp.Add Peers    127.0.0.3    127.0.0.5
89     SxpLib.Add PeerGroup    GROUP    ${peers}
90     ${entry1} =    Sxp.Get Filter Entry    10    permit    sgt=30    acl=10.10.10.0,0.0.0.255
91     ${entry2} =    Sxp.Get Filter Entry    20    permit    sgt=50    acl=10.0.0.0,0.254.0.0
92     ${entries} =    Combine Strings    ${entry1}    ${entry2}
93     SxpLib.Add Filter    GROUP    inbound-discarding    ${entries}
94     Setup Nodes Legacy Par One
95     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 5-3
96     SxpLib.Delete Filter    GROUP    inbound-discarding
97     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 5-3
98
99 Prefix List Filtering Legacy
100     [Documentation]    Test Prefix List filter behaviour during filter update
101     [Tags]    SXP    Filtering
102     Setup Nodes Legacy Par Two
103     ${peers} =    Sxp.Add Peers    127.0.0.2    127.0.0.4
104     SxpLib.Add PeerGroup    GROUP    ${peers}
105     ${entry1} =    Sxp.Get Filter Entry    10    permit    pl=10.10.10.0/24
106     ${entry2} =    Sxp.Get Filter Entry    20    permit    epl=10.0.0.0/8,le,16
107     ${entries} =    Combine Strings    ${entry1}    ${entry2}
108     SxpLib.Add Filter    GROUP    inbound-discarding    ${entries}
109     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 4-2
110     SxpLib.Delete Filter    GROUP    inbound-discarding
111     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 4-2
112
113 Prefix List Sgt Filtering Legacy
114     [Documentation]    Test Prefix List and SGT filter behaviour during filter update
115     [Tags]    SXP    Filtering
116     ${peers} =    Sxp.Add Peers    127.0.0.3    127.0.0.5
117     SxpLib.Add PeerGroup    GROUP    ${peers}
118     ${entry1} =    Sxp.Get Filter Entry    10    permit    sgt=30    pl=10.10.10.0/24
119     ${entry2} =    Sxp.Get Filter Entry    20    permit    pl=10.50.0.0/16
120     ${entries} =    Combine Strings    ${entry1}    ${entry2}
121     SxpLib.Add Filter    GROUP    inbound-discarding    ${entries}
122     Setup Nodes Legacy Par One
123     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 5-3
124     SxpLib.Delete Filter    GROUP    inbound-discarding
125     BuiltIn.Wait Until Keyword Succeeds    4    2    Check One Group 5-3
126
127 *** Keywords ***
128 Setup Nodes
129     [Arguments]    ${version}=version4    ${password}=none
130     : FOR    ${node}    IN RANGE    2    5
131     \    SxpLib.Add Connection    ${version}    both    127.0.0.1    64999    127.0.0.${node}
132     \    ...    ${password}
133     \    SxpLib.Add Connection    ${version}    both    127.0.0.${node}    64999    127.0.0.1
134     \    ...    ${password}
135     \    BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    both
136     \    ...    127.0.0.${node}
137     \    SxpLib.Add Bindings    ${node}0    10.10.10.${node}0/32    127.0.0.${node}
138     \    SxpLib.Add Bindings    ${node}0    10.10.${node}0.0/24    127.0.0.${node}
139     \    SxpLib.Add Bindings    ${node}0    10.${node}0.0.0/16    127.0.0.${node}
140     \    SxpLib.Add Bindings    ${node}0    ${node}0.0.0.0/8    127.0.0.${node}
141     SxpLib.Add Connection    ${version}    both    127.0.0.5    64999    127.0.0.3    ${password}
142     SxpLib.Add Connection    ${version}    both    127.0.0.3    64999    127.0.0.5    ${password}
143     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    both    127.0.0.5
144     ...    64999    127.0.0.3
145     SxpLib.Add Bindings    50    10.10.10.50/32    127.0.0.5
146     SxpLib.Add Bindings    50    10.10.50.0/24    127.0.0.5
147     SxpLib.Add Bindings    50    10.50.0.0/16    127.0.0.5
148     SxpLib.Add Bindings    50    50.0.0.0/8    127.0.0.5
149     SxpLib.Add Bindings    10    10.10.10.10/32    127.0.0.1
150     SxpLib.Add Bindings    10    10.10.10.0/24    127.0.0.1
151     SxpLib.Add Bindings    10    10.10.0.0/16    127.0.0.1
152     SxpLib.Add Bindings    10    10.0.0.0/8    127.0.0.1
153
154 Setup Nodes Legacy Par One
155     [Arguments]    ${version}=version3    ${password}=none
156     : FOR    ${node}    IN RANGE    1    6
157     \    SxpLib.Add Bindings    ${node}0    10.10.10.${node}0/32    127.0.0.${node}
158     \    SxpLib.Add Bindings    ${node}0    10.10.${node}0.0/24    127.0.0.${node}
159     \    SxpLib.Add Bindings    ${node}0    10.${node}0.0.0/16    127.0.0.${node}
160     \    SxpLib.Add Bindings    ${node}0    ${node}0.0.0.0/8    127.0.0.${node}
161     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.2    ${password}
162     SxpLib.Add Connection    ${version}    speaker    127.0.0.2    64999    127.0.0.1    ${password}
163     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker    127.0.0.2
164     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.4    ${password}
165     SxpLib.Add Connection    ${version}    speaker    127.0.0.4    64999    127.0.0.1    ${password}
166     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker    127.0.0.4
167     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.3    ${password}
168     SxpLib.Add Connection    ${version}    listener    127.0.0.3    64999    127.0.0.1    ${password}
169     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    listener    127.0.0.3
170     SxpLib.Add Connection    ${version}    listener    127.0.0.5    64999    127.0.0.3    ${password}
171     SxpLib.Add Connection    ${version}    speaker    127.0.0.3    64999    127.0.0.5    ${password}
172     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    listener    127.0.0.5
173     ...    64999    127.0.0.3
174
175 Setup Nodes Legacy Par Two
176     [Arguments]    ${version}=version3    ${password}=none
177     : FOR    ${node}    IN RANGE    1    6
178     \    SxpLib.Add Bindings    ${node}0    10.10.10.${node}0/32    127.0.0.${node}
179     \    SxpLib.Add Bindings    ${node}0    10.10.${node}0.0/24    127.0.0.${node}
180     \    SxpLib.Add Bindings    ${node}0    10.${node}0.0.0/16    127.0.0.${node}
181     \    SxpLib.Add Bindings    ${node}0    ${node}0.0.0.0/8    127.0.0.${node}
182     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.2    ${password}
183     SxpLib.Add Connection    ${version}    listener    127.0.0.2    64999    127.0.0.1    ${password}
184     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    listener    127.0.0.2
185     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.4    ${password}
186     SxpLib.Add Connection    ${version}    listener    127.0.0.4    64999    127.0.0.1    ${password}
187     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    listener    127.0.0.4
188     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.3    ${password}
189     SxpLib.Add Connection    ${version}    speaker    127.0.0.3    64999    127.0.0.1    ${password}
190     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker    127.0.0.3
191     SxpLib.Add Connection    ${version}    speaker    127.0.0.5    64999    127.0.0.3    ${password}
192     SxpLib.Add Connection    ${version}    listener    127.0.0.3    64999    127.0.0.5    ${password}
193     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker    127.0.0.5
194     ...    64999    127.0.0.3
195
196 Check One Group 4-2
197     [Documentation]    Check if only bindings matching filter from node 4 and 2 are propagated to SXP-DB of other nodes
198     ...    Database should contains only Bindings regarding to these matches:
199     ...    permit ACL 10.10.10.0 0.0.0.255
200     ...    permit ACL 10.0.0.0 0.254.0.0
201     ...    Info regarding filtering https://wiki.opendaylight.org/view/SXP:Beryllium:Developer_Guide
202     ${resp} =    SxpLib.Get Bindings    127.0.0.5
203     SxpLib.Should Contain Binding    ${resp}    10    10.10.10.10/32
204     SxpLib.Should Contain Binding    ${resp}    10    10.10.10.0/24
205     SxpLib.Should Contain Binding    ${resp}    10    10.10.0.0/16
206     SxpLib.Should Contain Binding    ${resp}    10    10.0.0.0/8
207     SxpLib.Should Contain Binding    ${resp}    20    10.10.10.20/32
208     SxpLib.Should Not Contain Binding    ${resp}    20    10.10.20.0/24
209     SxpLib.Should Contain Binding    ${resp}    20    10.20.0.0/16
210     SxpLib.Should Not Contain Binding    ${resp}    20    20.0.0.0/8
211     SxpLib.Should Contain Binding    ${resp}    30    10.10.10.30/32
212     SxpLib.Should Contain Binding    ${resp}    30    10.10.30.0/24
213     SxpLib.Should Contain Binding    ${resp}    30    10.30.0.0/16
214     SxpLib.Should Contain Binding    ${resp}    30    30.0.0.0/8
215     SxpLib.Should Contain Binding    ${resp}    40    10.10.10.40/32
216     SxpLib.Should Not Contain Binding    ${resp}    40    10.10.40.0/24
217     SxpLib.Should Contain Binding    ${resp}    40    10.40.0.0/16
218     SxpLib.Should Not Contain Binding    ${resp}    40    40.0.0.0/8
219
220 Check One Group 5-3
221     [Documentation]    Check if only bindings matching filter from node 5 and 3 are propagated to SXP-DB of other nodes
222     ...    Database should contains only Bindings regarding to these matches:
223     ...    permit SGT 30 ACL 10.10.10.0 0.0.0.255
224     ...    permit SGT 50 ACL 10.0.0.0 0.254.0.0
225     ...    Info regarding filtering https://wiki.opendaylight.org/view/SXP:Beryllium:Developer_Guide
226     ${resp} =    SxpLib.Get Bindings    127.0.0.4
227     SxpLib.Should Contain Binding    ${resp}    10    10.10.10.10/32
228     SxpLib.Should Contain Binding    ${resp}    10    10.10.10.0/24
229     SxpLib.Should Contain Binding    ${resp}    10    10.10.0.0/16
230     SxpLib.Should Contain Binding    ${resp}    10    10.0.0.0/8
231     SxpLib.Should Contain Binding    ${resp}    30    10.10.10.30/32
232     SxpLib.Should Not Contain Binding    ${resp}    30    10.10.30.0/24
233     SxpLib.Should Not Contain Binding    ${resp}    30    10.30.0.0/16
234     SxpLib.Should Not Contain Binding    ${resp}    30    30.0.0.0/8
235     SxpLib.Should Not Contain Binding    ${resp}    50    10.10.10.50/32
236     SxpLib.Should Not Contain Binding    ${resp}    50    10.10.50.0/24
237     SxpLib.Should Contain Binding    ${resp}    50    10.50.0.0/16
238     SxpLib.Should Not Contain Binding    ${resp}    50    50.0.0.0/8
239
240 Clean Nodes
241     SxpLib.Clean Bindings    127.0.0.1
242     SxpLib.Clean Bindings    127.0.0.2
243     SxpLib.Clean Bindings    127.0.0.3
244     SxpLib.Clean Bindings    127.0.0.4
245     SxpLib.Clean Bindings    127.0.0.5
246     SxpLib.Clean Peer Groups    127.0.0.1
247     SxpLib.Clean Connections    127.0.0.1
248     SxpLib.Clean Connections    127.0.0.2
249     SxpLib.Clean Connections    127.0.0.3
250     SxpLib.Clean Connections    127.0.0.4
251     SxpLib.Clean Connections    127.0.0.5