SXP: Add RPC redirecting tests
[integration/test.git] / csit / suites / sxp / clustering / 040_RPC_Redirecting.robot
1 *** Settings ***
2 Documentation     SXP holds active SXP nodes only on the cluster owner node. Active SXP node holds its master database and datastore access. This implies that all RPC operation logic must be executed only on cluster owner node. In case RPC is send to another cluster node it must be redirected to owner to be properly executed. This suite contains tests for SxpControllerService and SxpConfigControllerService RPCs.
3 Suite Setup       SxpClusterLib.Setup SXP Cluster Session
4 Suite Teardown    SxpClusterLib.Clean SXP Cluster Session
5 Library           ../../../libraries/Common.py
6 Resource          ../../../libraries/SxpBindingOriginsLib.robot
7 Resource          ../../../libraries/SxpClusterLib.robot
8 Resource          ../../../libraries/SxpLib.robot
9
10 *** Test Cases ***
11 Test Add/Delete Node
12     [Documentation]    Adding and then deleting SXP node is sucessfull only if all operations are done on cluster owner node. To verify that all RPCs are redirected to cluster owner send add-node RPC to the first cluster node and delete-node RPC to the second cluster node (requires datastore access).
13     [Tags]    SXP Clustering Redirecting
14     SxpLib.Add Node    ${INADDR_ANY}    session=ClusterManagement__session_1
15     BuiltIn.Wait Until Keyword Succeeds    1m    1x    SxpClusterLib.Check Cluster Node started    ${INADDR_ANY}    ip=${EMPTY}
16     SxpLib.Delete Node    ${INADDR_ANY}    session=ClusterManagement__session_2
17     BuiltIn.Wait Until Keyword Succeeds    1m    1x    SxpClusterLib.Check Cluster Node stopped    ${INADDR_ANY}    ip=${EMPTY}
18
19 Test Add/Delete Binding
20     [Documentation]    Adding and then deleting binding from a SXP node is sucessfull only if all operations are done on cluster owner node. To verify that all RPCs are redirected to cluster owner send add-node RPC to the first cluster node, add-bindings RPC to the second cluster node (requires master database) and delete-bindings RPC to the third cluster node (requires master database).
21     [Tags]    SXP Clustering Redirecting
22     Add Node And Check It Is Started
23     SxpLib.Add Bindings    1100    1.1.1.1/32    node=${INADDR_ANY}    session=ClusterManagement__session_2
24     SxpLib.Delete Bindings    1100    1.1.1.1/32    node=${INADDR_ANY}    session=ClusterManagement__session_3
25     [Teardown]    Delete Node And Check It Is Stopped
26
27 Test Add/Delete Domain
28     [Documentation]    Adding and then deleting domain from a SXP node is sucessfull only if all operations are done on cluster owner node. To verify that all RPCs are redirected to cluster owner send add-node RPC to the first cluster node, add-domain RPC to the second cluster node (requires datastore access and master database) and delete-domain RPC to the third cluster node (requires datastore access).
29     [Tags]    SXP Clustering Redirecting
30     Add Node And Check It Is Started
31     SxpLib.Add Domain    cluster    node=${INADDR_ANY}    session=ClusterManagement__session_2
32     SxpLib.Delete Domain    cluster    node=${INADDR_ANY}    session=ClusterManagement__session_3
33     [Teardown]    Delete Node And Check It Is Stopped
34
35 Test Add/Delete Connection
36     [Documentation]    Adding and then deleting connection from a SXP node is sucessfull only if all operations are done on cluster owner node. To verify that all RPCs are redirected to cluster owner send add-node RPC to the first cluster node, add-connection RPC to the second cluster node (requires datastore access) and delete-connection RPC to the third cluster node (requires datastore access).
37     [Tags]    SXP Clustering Redirecting
38     Add Node And Check It Is Started
39     SxpLib.Add Connection    version4    listener    ${INADDR_ANY}    64999    node=${INADDR_ANY}    session=ClusterManagement__session_1
40     SxpLib.Delete Connections    ${INADDR_ANY}    64999    node=${INADDR_ANY}    session=ClusterManagement__session_2
41     [Teardown]    Delete Node And Check It Is Stopped
42
43 Test Add/Delete Peer Group
44     [Documentation]    Adding and then deleting peer group from a SXP node is sucessfull only if all operations are done on cluster owner node. To verify that all RPCs are redirected to cluster owner send add-peer-group RPC to the first cluster node, get-peer-groups RPC to the second cluster node (requires datastore access) and delete-peer-group RPC to the third cluster node (requires datastore access).
45     [Tags]    SXP Clustering Redirecting
46     [Setup]    Add Node And Check It Is Started
47     SxpLib.Add PeerGroup    GROUP    peers=${EMPTY}    node=${INADDR_ANY}    session=ClusterManagement__session_1
48     ${resp} =    SxpLib.Get Peer Groups    ${INADDR_ANY}    session=ClusterManagement__session_2
49     @{groups} =    Sxp.Parse Peer Groups    ${resp}
50     : FOR    ${group}    IN    @{groups}
51     \    SxpLib.Delete Peer Group    ${group['name']}    node=${INADDR_ANY}    session=ClusterManagement__session_3
52     [Teardown]    Delete Node And Check It Is Stopped
53
54 Test Add/Delete Domain Filter
55     [Documentation]    Adding and then deleting domain filter from a SXP node is sucessfull only if all operations are done on cluster owner node. To verify that all RPCs are redirected to cluster owner send add-domain-filter RPC to the first cluster node and delete-domain-filter RPC to the second cluster node (requires datastore access).
56     [Tags]    SXP Clustering Redirecting
57     [Setup]    Add Node And Check It Is Started
58     ${domain_1_xml} =    Sxp.Add Domains    domain-1
59     ${domain_2_xml} =    Sxp.Add Domains    domain-2
60     ${domains} =    Common.Combine Strings    ${domain_1_xml}    ${domain_2_xml}
61     ${entry} =    Sxp.Get Filter Entry    10    permit    pl=20.0.0.0/8
62     ${entries} =    Common.Combine Strings    ${entry}
63     SxpLib.Add Domain Filter    global    ${domains}    ${entries}    node=${INADDR_ANY}    session=ClusterManagement__session_1
64     SxpLib.Delete Domain Filter    global    node=${INADDR_ANY}    session=ClusterManagement__session_2
65     [Teardown]    Delete Node And Check It Is Stopped
66
67 Test Add/Delete Filter
68     [Documentation]    Adding, updating and then deleting filter from a SXP node is sucessfull only if all operations are done on cluster owner node. To verify that all RPCs are redirected to cluster owner send add-filter RPC to the first cluster node, update-filter RPC to the second cluster node (requires datastore access) and delete-filter RPC to the third cluster node (requires datastore access).
69     [Tags]    SXP Clustering Redirecting
70     [Setup]    Add Node And Check It Is Started
71     ${entry1} =    Sxp.Get Filter Entry    10    deny    pl=10.10.20.0/24
72     ${entry2} =    Sxp.Get Filter Entry    20    permit    epl=10.10.0.0/16,le,24
73     ${entry3} =    Sxp.Get Filter Entry    30    permit    sgt=30    pl=10.10.10.0/24
74     ${entries} =    Common.Combine Strings    ${entry1}    ${entry2}    ${entry3}
75     SxpLib.Add PeerGroup    GROUP    peers=${EMPTY}    node=${INADDR_ANY}    session=${CONTROLLER_SESSION}
76     SxpLib.Add Filter    GROUP    outbound    ${entries}    node=${INADDR_ANY}    policy=manual-update    session=ClusterManagement__session_1
77     SxpLib.Update Filter    GROUP    outbound    ${entries}    node=${INADDR_ANY}    policy=manual-update    session=ClusterManagement__session_2
78     SxpLib.Delete Filter    GROUP    outbound    node=${INADDR_ANY}    session=ClusterManagement__session_3
79     [Teardown]    Delete Node And Check It Is Stopped
80
81 Test Add/Update/Delete Binding Origin
82     [Documentation]    Binding origin operations need to be executed on cluster owner because they rely on static map which is present solely on cluster owner. To test that binding origin RPCs are redirected to cluster owner first add binding origin to the first node then update it on the second node (requires up-to date binding origin map) and update it on the third node (requires up-to date binding origin map).
83     [Tags]    SXP Clustering Redirecting
84     SxpBindingOriginsLib.Add Binding Origin    CLUSTER    0    session=ClusterManagement__session_1
85     SxpBindingOriginsLib.Update Binding Origin    CLUSTER    3    session=ClusterManagement__session_2
86     SxpBindingOriginsLib.Delete Binding Origin    CLUSTER    session=ClusterManagement__session_3
87     [Teardown]    SxpBindingOriginsLib.Revert To Default Binding Origins Configuration    session=${CONTROLLER_SESSION}
88
89 *** Keywords ***
90 Add Node And Check It Is Started
91     [Documentation]    Send add-node RPC to the first cluster member and check if node has been started.
92     SxpLib.Add Node    ${INADDR_ANY}    session=ClusterManagement__session_1
93     BuiltIn.Wait Until Keyword Succeeds    1m    1x    SxpClusterLib.Check Cluster Node started    ${INADDR_ANY}    ip=${EMPTY}
94
95 Delete Node And Check It Is Stopped
96     [Documentation]    Send delete-node RPC to the first cluster member and check if node has been stopped.
97     SxpLib.Delete Node    ${INADDR_ANY}    session=ClusterManagement__session_1
98     BuiltIn.Wait Until Keyword Succeeds    1m    1x    SxpClusterLib.Check Cluster Node stopped    ${INADDR_ANY}    ip=${EMPTY}