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