b5dad252c89f47d940805cf2cabf2c72e732a112
[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       SxpLib.Setup SXP Environment
4 Suite Teardown    SxpLib.Clean SXP Environment
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 Clean Bindings
73     SxpLib.Clean Bindings    scope=all
74     SxpLib.Clean Bindings    domain=guest    scope=all
75
76 Verify Bindings Content
77     [Arguments]    ${should_contains_sgt}    ${should_not_contains_sgt}    ${prefix}    ${domain}=global
78     ${bindings} =    SxpLib.Get Bindings    domain=${domain}    scope=all
79     SxpLib.Should Contain Binding    ${bindings}    ${should_contains_sgt}    ${prefix}
80     SxpLib.Should Not Contain Binding    ${bindings}    ${should_not_contains_sgt}    ${prefix}
81
82 Verify Local Bindings Content
83     [Arguments]    ${local_sgt}    ${local_prefix}    ${network_sgt}    ${network_prefix}
84     ${bindings} =    SxpLib.Get Bindings    scope=local
85     SxpLib.Should Contain Binding    ${bindings}    ${local_sgt}    ${local_prefix}
86     SxpLib.Should Not Contain Binding    ${bindings}    ${network_sgt}    ${network_prefix}
87
88 Verify All Bindings Content
89     [Arguments]    ${local_sgt}    ${local_prefix}    ${network_sgt}    ${network_prefix}
90     ${bindings} =    SxpLib.Get Bindings
91     SxpLib.Should Contain Binding    ${bindings}    ${local_sgt}    ${local_prefix}
92     SxpLib.Should Contain Binding    ${bindings}    ${network_sgt}    ${network_prefix}