5b97776a717c44512d4d580c041677fe78f80630
[integration/test.git] / csit / suites / sxp / binding-origin / 020_Binding_Origins_Checks.robot
1 *** Settings ***
2 Documentation     Test suite to verify binding origins checks are performed in master database
3 Suite Setup       Create Session And Node
4 Suite Teardown    Delete Node And Close Session
5 Test Setup        Clean Bindings
6 Library           RequestsLibrary
7 Resource          ../../../libraries/SxpLib.robot
8
9 *** Test Cases ***
10 Test Add Lower Priority Binding
11     [Documentation]    Test that incoming binding with lower priority does not override already existing
12     ...    higher priority binding in master database for the same IP prefix
13     [Tags]    Binding Origins Checks    SXP
14     BuiltIn.Comment    Add binding
15     SxpLib.Add Bindings    10    1.1.1.1/32    origin=LOCAL
16     BuiltIn.Comment    Try to add binding with lower priority
17     BuiltIn.Run Keyword And Expect Error    RPC result is False    SxpLib.Add Bindings    20    1.1.1.1/32    origin=NETWORK
18     BuiltIn.Comment    Verify that new binding is not added and previous binding is preserved
19     Verify Bindings Content    10    20    1.1.1.1/32
20
21 Test Add Higher Priority Binding
22     [Documentation]    Test that incoming binding with higher priority overrides already existing
23     ...    lower priority binding in master database for the same IP prefix
24     [Tags]    Binding Origins Checks    SXP
25     BuiltIn.Comment    Add binding
26     SxpLib.Add Bindings    10    1.1.1.1/32    origin=NETWORK
27     BuiltIn.Comment    Add binding with higher priority
28     SxpLib.Add Bindings    20    1.1.1.1/32    origin=LOCAL
29     BuiltIn.Comment    Verify that new binding replaced previous binding
30     Verify Bindings Content    20    10    1.1.1.1/32
31
32 Test Add Unknown Priority Binding
33     [Documentation]    Test that incoming binding with unknown priority cannot be added to master database
34     [Tags]    Binding Origins Checks    SXP
35     BuiltIn.Comment    Try to add binding with unknown origin priority
36     BuiltIn.Run Keyword And Expect Error    400 != 200    SxpLib.Add Bindings    10    1.1.1.1/32    origin=CLUSTER
37     BuiltIn.Comment    Verify that binding is not in master database
38     SxpLib.Bindings Should Not Contain    10    1.1.1.1/32
39
40 Test Add Lower Priority Binding To Domain
41     [Documentation]    Test that incoming binding with lower priority does not override already existing
42     ...    higher priority binding in master database for the same IP prefix
43     BuiltIn.Comment    Create custom domain with binding
44     SxpLib.Add Domain    guest    10    1.1.1.1/32    origin=LOCAL
45     BuiltIn.Comment    Try add binding to custom domain with lower priority
46     BuiltIn.Run Keyword And Expect Error    RPC result is False    SxpLib.Add Bindings    20    1.1.1.1/32    domain=guest    origin=NETWORK
47     BuiltIn.Comment    Verify that new binding is not added and previous binding is preserved
48     Verify Bindings Content    10    20    1.1.1.1/32    guest
49
50 Test Add Higher Priority Binding To Domain
51     [Documentation]    Test that incoming binding with lower priority does not override already existing
52     ...    higher priority binding in master database for the same IP prefix
53     BuiltIn.Comment    Create custom domain with binding
54     SxpLib.Add Domain    guest    10    1.1.1.1/32    origin=NETWORK
55     BuiltIn.Comment    Add binding to custom domain with higher priority
56     SxpLib.Add Bindings    20    1.1.1.1/32    domain=guest    origin=LOCAL
57     BuiltIn.Comment    Verify that new binding replaced previous binding
58     Verify Bindings Content    20    10    1.1.1.1/32    guest
59
60 Test Get Bindings
61     [Documentation]    Test that when requesting for LOCAL bindings then only LOCAL bindings are returned
62     BuiltIn.Comment    Add LOCAL binding
63     SxpLib.Add Bindings    10    1.1.1.1/32    origin=LOCAL
64     BuiltIn.Comment    Add NETWORK binding
65     SxpLib.Add Bindings    20    2.2.2.2/32    origin=NETWORK
66     BuiltIn.Comment    Verify request for LOCAL bindings
67     Verify Local Bindings Content    10    1.1.1.1/32    20    2.2.2.2/32
68     BuiltIn.Comment    Verify request for ALL bindings
69     Verify All Bindings Content    10    1.1.1.1/32    20    2.2.2.2/32
70
71 *** Keywords ***
72 Create Session And Node
73     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
74     SxpLib.Setup SXP Environment
75
76 Delete Node And Close Session
77     SxpLib.Clean SXP Environment
78     RequestsLibrary.Delete All Sessions
79
80 Clean Bindings
81     SxpLib.Clean Bindings    scope=all
82     SxpLib.Clean Bindings    domain=guest    scope=all
83
84 Verify Bindings Content
85     [Arguments]    ${should_contains_sgt}    ${should_not_contains_sgt}    ${prefix}    ${domain}=global
86     ${bindings} =    SxpLib.Get Bindings    domain=${domain}    scope=all
87     SxpLib.Should Contain Binding    ${bindings}    ${should_contains_sgt}    ${prefix}
88     SxpLib.Should Not Contain Binding    ${bindings}    ${should_not_contains_sgt}    ${prefix}
89
90 Verify Local Bindings Content
91     [Arguments]    ${local_sgt}    ${local_prefix}    ${network_sgt}    ${network_prefix}
92     ${bindings} =    SxpLib.Get Bindings    scope=local
93     SxpLib.Should Contain Binding    ${bindings}    ${local_sgt}    ${local_prefix}
94     SxpLib.Should Not Contain Binding    ${bindings}    ${network_sgt}    ${network_prefix}
95
96 Verify All Bindings Content
97     [Arguments]    ${local_sgt}    ${local_prefix}    ${network_sgt}    ${network_prefix}
98     ${bindings} =    SxpLib.Get Bindings
99     SxpLib.Should Contain Binding    ${bindings}    ${local_sgt}    ${local_prefix}
100     SxpLib.Should Contain Binding    ${bindings}    ${network_sgt}    ${network_prefix}