Upgrade RF syntax for v3.2 compatibility
[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     END
142     SxpLib.Add Connection    ${version}    both    127.0.0.5    64999    127.0.0.3    ${password}
143     SxpLib.Add Connection    ${version}    both    127.0.0.3    64999    127.0.0.5    ${password}
144     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    both    127.0.0.5
145     ...    64999    127.0.0.3
146     SxpLib.Add Bindings    50    10.10.10.50/32    127.0.0.5
147     SxpLib.Add Bindings    50    10.10.50.0/24    127.0.0.5
148     SxpLib.Add Bindings    50    10.50.0.0/16    127.0.0.5
149     SxpLib.Add Bindings    50    50.0.0.0/8    127.0.0.5
150     SxpLib.Add Bindings    10    10.10.10.10/32    127.0.0.1
151     SxpLib.Add Bindings    10    10.10.10.0/24    127.0.0.1
152     SxpLib.Add Bindings    10    10.10.0.0/16    127.0.0.1
153     SxpLib.Add Bindings    10    10.0.0.0/8    127.0.0.1
154
155 Setup Nodes Legacy Par One
156     [Arguments]    ${version}=version3    ${password}=none
157     FOR    ${node}    IN RANGE    1    6
158         SxpLib.Add Bindings    ${node}0    10.10.10.${node}0/32    127.0.0.${node}
159         SxpLib.Add Bindings    ${node}0    10.10.${node}0.0/24    127.0.0.${node}
160         SxpLib.Add Bindings    ${node}0    10.${node}0.0.0/16    127.0.0.${node}
161         SxpLib.Add Bindings    ${node}0    ${node}0.0.0.0/8    127.0.0.${node}
162     END
163     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.2    ${password}
164     SxpLib.Add Connection    ${version}    speaker    127.0.0.2    64999    127.0.0.1    ${password}
165     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker    127.0.0.2
166     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.4    ${password}
167     SxpLib.Add Connection    ${version}    speaker    127.0.0.4    64999    127.0.0.1    ${password}
168     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker    127.0.0.4
169     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.3    ${password}
170     SxpLib.Add Connection    ${version}    listener    127.0.0.3    64999    127.0.0.1    ${password}
171     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    listener    127.0.0.3
172     SxpLib.Add Connection    ${version}    listener    127.0.0.5    64999    127.0.0.3    ${password}
173     SxpLib.Add Connection    ${version}    speaker    127.0.0.3    64999    127.0.0.5    ${password}
174     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    listener    127.0.0.5
175     ...    64999    127.0.0.3
176
177 Setup Nodes Legacy Par Two
178     [Arguments]    ${version}=version3    ${password}=none
179     FOR    ${node}    IN RANGE    1    6
180         SxpLib.Add Bindings    ${node}0    10.10.10.${node}0/32    127.0.0.${node}
181         SxpLib.Add Bindings    ${node}0    10.10.${node}0.0/24    127.0.0.${node}
182         SxpLib.Add Bindings    ${node}0    10.${node}0.0.0/16    127.0.0.${node}
183         SxpLib.Add Bindings    ${node}0    ${node}0.0.0.0/8    127.0.0.${node}
184     END
185     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.2    ${password}
186     SxpLib.Add Connection    ${version}    listener    127.0.0.2    64999    127.0.0.1    ${password}
187     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    listener    127.0.0.2
188     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.4    ${password}
189     SxpLib.Add Connection    ${version}    listener    127.0.0.4    64999    127.0.0.1    ${password}
190     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    listener    127.0.0.4
191     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.3    ${password}
192     SxpLib.Add Connection    ${version}    speaker    127.0.0.3    64999    127.0.0.1    ${password}
193     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker    127.0.0.3
194     SxpLib.Add Connection    ${version}    speaker    127.0.0.5    64999    127.0.0.3    ${password}
195     SxpLib.Add Connection    ${version}    listener    127.0.0.3    64999    127.0.0.5    ${password}
196     BuiltIn.Wait Until Keyword Succeeds    15    1    Verify Connection    ${version}    speaker    127.0.0.5
197     ...    64999    127.0.0.3
198
199 Check One Group 4-2
200     [Documentation]    Check if only bindings matching filter from node 4 and 2 are propagated to SXP-DB of other nodes
201     ...    Database should contains only Bindings regarding to these matches:
202     ...    permit ACL 10.10.10.0 0.0.0.255
203     ...    permit ACL 10.0.0.0 0.254.0.0
204     ...    Info regarding filtering https://wiki.opendaylight.org/view/SXP:Beryllium:Developer_Guide
205     ${resp} =    SxpLib.Get Bindings    127.0.0.5
206     SxpLib.Should Contain Binding    ${resp}    10    10.10.10.10/32
207     SxpLib.Should Contain Binding    ${resp}    10    10.10.10.0/24
208     SxpLib.Should Contain Binding    ${resp}    10    10.10.0.0/16
209     SxpLib.Should Contain Binding    ${resp}    10    10.0.0.0/8
210     SxpLib.Should Contain Binding    ${resp}    20    10.10.10.20/32
211     SxpLib.Should Not Contain Binding    ${resp}    20    10.10.20.0/24
212     SxpLib.Should Contain Binding    ${resp}    20    10.20.0.0/16
213     SxpLib.Should Not Contain Binding    ${resp}    20    20.0.0.0/8
214     SxpLib.Should Contain Binding    ${resp}    30    10.10.10.30/32
215     SxpLib.Should Contain Binding    ${resp}    30    10.10.30.0/24
216     SxpLib.Should Contain Binding    ${resp}    30    10.30.0.0/16
217     SxpLib.Should Contain Binding    ${resp}    30    30.0.0.0/8
218     SxpLib.Should Contain Binding    ${resp}    40    10.10.10.40/32
219     SxpLib.Should Not Contain Binding    ${resp}    40    10.10.40.0/24
220     SxpLib.Should Contain Binding    ${resp}    40    10.40.0.0/16
221     SxpLib.Should Not Contain Binding    ${resp}    40    40.0.0.0/8
222
223 Check One Group 5-3
224     [Documentation]    Check if only bindings matching filter from node 5 and 3 are propagated to SXP-DB of other nodes
225     ...    Database should contains only Bindings regarding to these matches:
226     ...    permit SGT 30 ACL 10.10.10.0 0.0.0.255
227     ...    permit SGT 50 ACL 10.0.0.0 0.254.0.0
228     ...    Info regarding filtering https://wiki.opendaylight.org/view/SXP:Beryllium:Developer_Guide
229     ${resp} =    SxpLib.Get Bindings    127.0.0.4
230     SxpLib.Should Contain Binding    ${resp}    10    10.10.10.10/32
231     SxpLib.Should Contain Binding    ${resp}    10    10.10.10.0/24
232     SxpLib.Should Contain Binding    ${resp}    10    10.10.0.0/16
233     SxpLib.Should Contain Binding    ${resp}    10    10.0.0.0/8
234     SxpLib.Should Contain Binding    ${resp}    30    10.10.10.30/32
235     SxpLib.Should Not Contain Binding    ${resp}    30    10.10.30.0/24
236     SxpLib.Should Not Contain Binding    ${resp}    30    10.30.0.0/16
237     SxpLib.Should Not Contain Binding    ${resp}    30    30.0.0.0/8
238     SxpLib.Should Not Contain Binding    ${resp}    50    10.10.10.50/32
239     SxpLib.Should Not Contain Binding    ${resp}    50    10.10.50.0/24
240     SxpLib.Should Contain Binding    ${resp}    50    10.50.0.0/16
241     SxpLib.Should Not Contain Binding    ${resp}    50    50.0.0.0/8
242
243 Clean Nodes
244     SxpLib.Clean Bindings    127.0.0.1
245     SxpLib.Clean Bindings    127.0.0.2
246     SxpLib.Clean Bindings    127.0.0.3
247     SxpLib.Clean Bindings    127.0.0.4
248     SxpLib.Clean Bindings    127.0.0.5
249     SxpLib.Clean Peer Groups    127.0.0.1
250     SxpLib.Clean Connections    127.0.0.1
251     SxpLib.Clean Connections    127.0.0.2
252     SxpLib.Clean Connections    127.0.0.3
253     SxpLib.Clean Connections    127.0.0.4
254     SxpLib.Clean Connections    127.0.0.5