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