Update Robot Framework format - step 3
[integration/test.git] / csit / suites / bgpcep / bgpclustering / 050_bmp_ha_karaf_restart.robot
1 *** Settings ***
2 Documentation       BMP functional HA testing with BMP mock.
3 ...
4 ...                 Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
5 ...
6 ...                 This program and the accompanying materials are made available under the
7 ...                 terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...                 and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...                 This suite uses BMP mock. It is configured to have 3 peers (all 3 nodes of odl).
11 ...                 BMP implemented with singleton accepts only one incomming conection. BMP mock
12 ...                 logs will show that one peer will be connected and two will fail.
13 ...                 After killing karaf which owned connection new owner should be elected and
14 ...                 this new owner should accept incomming BMP connection.
15 ...                 TODO: Add similar keywords from all bgpclustering-ha tests into same libraries
16
17 Library             SSHLibrary    timeout=10s
18 Library             Collections
19 Library             OperatingSystem
20 Resource            ../../../libraries/BGPcliKeywords.robot
21 Resource            ../../../libraries/BgpOperations.robot
22 Resource            ../../../libraries/ClusterManagement.robot
23 Resource            ../../../libraries/NexusKeywords.robot
24 Resource            ../../../libraries/SetupUtils.robot
25 Resource            ../../../variables/Variables.robot
26
27 Suite Setup         Setup_Everything
28 Suite Teardown      Teardown_Everything
29 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
30 Test Teardown       SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
31
32
33 *** Variables ***
34 ${HOLDTIME}             180
35 ${BMP_LOG_FILE}         bmpmock.restart.log
36 ${CONFIG_SESSION}       session
37
38
39 *** Test Cases ***
40 Get_Example_Bm_Owner
41     [Documentation]    Find an odl node which is able to accept incomming connection.
42     ${bm_owner}    ${bm_candidates}=    Wait_Until_Keyword_Succeeds
43     ...    5x
44     ...    2s
45     ...    ClusterManagement.Get_Owner_And_Successors_For_Device
46     ...    bmp-monitors
47     ...    Bgpcep
48     ...    1
49     BuiltIn.Set Suite variable    ${bm_owner}
50     BuiltIn.Log    ${bm_owner}
51     BuiltIn.Log    ${ODL_SYSTEM_${bm_owner}_IP}
52     BuiltIn.Set Suite variable    ${bm_candidates}
53     ${session}=    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${bm_owner}
54     BuiltIn.Set_Suite_Variable    ${living_session}    ${session}
55     BuiltIn.Log    ${living_session}
56     BuiltIn.Set_Suite_Variable    ${living_node}    ${bm_owner}
57
58 Verify_Data_Reported_1
59     [Documentation]    Verifies if example-bmp-monitor reported expected data
60     BgpOperations.Bmp_Monitor_Postcondition    ${living_session}
61
62 Kill_Current_Owner_Member
63     [Documentation]    Killing cluster node which is connected with bmp mock.
64     ClusterManagement.Kill_Single_Member    ${bm_owner}
65     BuiltIn.Set Suite variable    ${old_bm_owner}    ${bm_owner}
66     BuiltIn.Set Suite variable    ${old_bm_candidates}    ${bm_candidates}
67     ${idx}=    Collections.Get From List    ${old_bm_candidates}    0
68     ${session}=    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${idx}
69     BuiltIn.Set_Suite_Variable    ${living_session}    ${session}
70     BuiltIn.Set_Suite_Variable    ${living_node}    ${idx}
71
72 Verify_New_Bm_Owner
73     [Documentation]    Verifies if new owner of bmp-monitor is elected.
74     BuiltIn.Wait_Until_Keyword_Succeeds
75     ...    10x
76     ...    5s
77     ...    Verify_New_Bm_Owner_Elected
78     ...    ${old_bm_owner}
79     ...    ${living_node}
80
81 Verify_Data_Reported_2
82     [Documentation]    Verifies if example-bmp-monitor reported expected data
83     BgpOperations.Bmp_Monitor_Postcondition    ${living_session}
84
85 Start_Old_Owner_Member
86     [Documentation]    Start killed node
87     ClusterManagement.Start_Single_Member    ${old_bm_owner}
88
89 Verify_New_Candidate
90     [Documentation]    Verifies started node become candidate for bmp-monitor
91     BuiltIn.Wait_Until_Keyword_Succeeds
92     ...    10x
93     ...    5s
94     ...    Verify_New_Bm_Candidate_Present
95     ...    ${old_bm_owner}
96     ...    ${living_node}
97
98 Verify_Data_Reported_3
99     [Documentation]    Verifies if example-bmp-monitor reported expected data
100     BgpOperations.Bmp_Monitor_Postcondition    ${living_session}
101
102 Stop_Bmp_Mock
103     [Documentation]    Send ctrl+c to bmp-mock to stop it
104     BGPcliKeywords.Stop_Console_Tool_And_Wait_Until_Prompt
105
106
107 *** Keywords ***
108 Setup_Everything
109     [Documentation]    Initial setup
110     SetupUtils.Setup_Utils_For_Setup_And_Teardown
111     ClusterManagement.ClusterManagement_Setup
112     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
113     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
114     ${name}=    NexusKeywords.Deploy_Test_Tool    bgpcep    bgp-bmp-mock
115     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
116     BgpOperations.Bmp_Monitor_Precondition    ${CONFIG_SESSION}
117     Start_Bmp_Mock
118
119 Teardown_Everything
120     [Documentation]    Suite cleanup
121     BGPcliKeywords.Store_File_To_Workspace    ${BMP_LOG_FILE}    ${BMP_LOG_FILE}
122     RequestsLibrary.Delete_All_Sessions
123     SSHLibrary.Close_All_Connections
124
125 Start_Bmp_Mock
126     [Documentation]    Starts bmp mock
127     ${command}=    BuiltIn.Set_Variable
128     ...    -jar ${filename} --local_address ${TOOLS_SYSTEM_IP} --remote_address ${ODL_SYSTEM_1_IP}:12345,${ODL_SYSTEM_2_IP}:12345,${ODL_SYSTEM_3_IP}:12345 --routers_count 1 --peers_count 1 --log_level INFO 2>&1 | tee ${BMP_LOG_FILE}
129     BGPcliKeywords.Start_Java_Tool_And_Verify_Connection    ${command}    successfully established.
130
131 Verify_New_Bm_Owner_Elected
132     [Documentation]    Verifies new owner was elected
133     [Arguments]    ${old_owner}    ${node_to_ask}
134     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device
135     ...    bmp-monitors
136     ...    Bgpcep
137     ...    ${node_to_ask}
138     BuiltIn.Log    ${owner}
139     BuiltIn.Should_Not_Be_Equal    ${old_owner}    ${owner}
140
141 Verify_New_Bm_Candidate_Present
142     [Documentation]    Verifies candidate's presence.
143     [Arguments]    ${candidate}    ${node_to_ask}
144     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device
145     ...    bmp-monitors
146     ...    Bgpcep
147     ...    ${node_to_ask}
148     BuiltIn.Log    ${owner}
149     BuiltIn.Should_Contain    ${candidates}    ${candidate}