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