3d716d726fa715c9b399e40f133ef95201a5789e
[integration/test.git] / csit / suites / bgpcep / bgpclustering / 080_pcep_ha_karaf_restart.robot
1 *** Settings ***
2 Documentation     PCEP functional HA testing with one pcep peer.
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 distbmution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...               This suite uses PCC mock. It is configured to have 3 peers (all 3 nodes of odl).
11 ...               PCEP implemented with singleton accepts only one incomming conection. PCC 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 PCC connection.
15 Suite Setup       Setup_Everything
16 Suite Teardown    Teardown_Everything
17 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
18 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
19 Library           SSHLibrary    timeout=10s
20 Library           Collections
21 Library           OperatingSystem
22 Resource          ../../../variables/Variables.robot
23 Resource          ../../../libraries/SetupUtils.robot
24 Resource          ../../../libraries/ClusterManagement.robot
25 Resource          ../../../libraries/RemoteBash.robot
26 Resource          ../../../libraries/TemplatedRequests.robot
27 Resource          ../../../libraries/NexusKeywords.robot
28
29 *** Variables ***
30 ${HOLDTIME}       180
31 ${DIR_WITH_TEMPLATES}    ${CURDIR}/../../../variables/bgpclustering/
32
33 *** Test Cases ***
34 Get_Example_Pcep_Owner
35     [Documentation]    Find an odl node which is able to accept incomming connection. To this node netconf connector should be configured.
36     ${pcep_owner}    ${pcep_candidates}=    Wait_Until_Keyword_Succeeds    5x    2s    ClusterManagement.Get_Owner_And_Successors_For_device    pcep-topology
37     ...    Bgpcep    1
38     BuiltIn.Set Suite variable    ${pcep_owner}
39     BuiltIn.Log    ${pcep_owner}
40     BuiltIn.Set Suite variable    ${pcep_candidates}
41     ${session}=    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${pcep_owner}
42     BuiltIn.Set_Suite_Variable    ${living_session}    ${session}
43     BuiltIn.Log    ${living_session}
44     BuiltIn.Set_Suite_Variable    ${living_node}    ${pcep_owner}
45
46 Verify_Data_Reported_1
47     [Documentation]    Verifies if pcep-topology reported expected data
48     ...    Expects pcep-topology not be empty/filled path-computation.
49     Verify_Data_Reported
50
51 Kill_Current_Owner_Member
52     [Documentation]    Killing cluster node which is connected with pcc-mock.
53     ClusterManagement.Kill_Single_Member    ${pcep_owner}
54     BuiltIn.Set Suite variable    ${old_pcep_owner}    ${pcep_owner}
55     BuiltIn.Set Suite variable    ${old_pcep_candidates}    ${pcep_candidates}
56     ${idx}=    Collections.Get From List    ${old_pcep_candidates}    0
57     ${session}=    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${idx}
58     BuiltIn.Set_Suite_Variable    ${living_session}    ${session}
59     BuiltIn.Set_Suite_Variable    ${living_node}    ${idx}
60
61 Verify_New_Pcep_Owner
62     [Documentation]    Verifies if new owner of pcep-topology is elected.
63     BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    Verify_New_Pcep_Owner_Elected    ${old_pcep_owner}    ${living_node}
64
65 Verify_Data_Reported_2
66     [Documentation]    Verifies if pcep-topology reports expected data
67     ...    Expects pcep-topology not be empty/filled path-computation.
68     Verify_Data_Reported
69
70 Start_Stopped_Member
71     [Documentation]    Starting stopped node
72     ClusterManagement.Start_Single_Member    ${old_pcep_owner}
73
74 Verify_New_Candidate
75     [Documentation]    Verifies started node become candidate for pcep_topology
76     BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    Verify_New_Pcep_Candidate_Present    ${old_pcep_owner}    ${living_node}
77
78 Verify_Data_Reported_3
79     [Documentation]    Verifies if pcep-topology reported expected data
80     ...    Expects pcep-topology not be empty/filled path-computation.
81     Verify_Data_Reported
82
83 Stop_Pcc_Mock
84     [Documentation]    Send ctrl+c to pcc-mock to stop it.
85     RemoteBash.Write_Bare_Ctrl_C
86     ${output}=    SSHLibrary.Read_Until_Prompt
87     BuiltIn.Log    ${output}
88
89 *** Keywords ***
90 Setup_Everything
91     [Documentation]    Initial setup
92     SetupUtils.Setup_Utils_For_Setup_And_Teardown
93     ClusterManagement.ClusterManagement_Setup
94     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
95     ${name}=    NexusKeywords.Deploy_Test_Tool    bgpcep    pcep-pcc-mock
96     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
97     #Setting Pcc Name and its code for mapping for templates
98     BuiltIn.Set_Suite_Variable    ${pcc_name}    pcc_${TOOLS_SYSTEM_IP}_tunnel_1
99     ${code}=    Evaluate    binascii.b2a_base64('${pcc_name}')[:-1]    modules=binascii
100     BuiltIn.Set_Suite_Variable    ${pcc_name_code}    ${code}
101     Start_Pcc_Mock
102
103 Teardown_Everything
104     [Documentation]    Suite cleanup
105     SSHLibrary.Get_File    pccmock.log
106     ${cnt}=    OperatingSystem.Get_File    pccmock.log
107     Log    ${cnt}
108     RequestsLibrary.Delete_All_Sessions
109     SSHLibrary.Close_All_Connections
110
111 Start_Pcc_Mock
112     [Documentation]    Starts pcc mock
113     ${command}=    NexusKeywords.Compose_Full_Java_Command    -jar ${filename} --reconnect 1 --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_1_IP}:4189,${ODL_SYSTEM_2_IP}:4189,${ODL_SYSTEM_3_IP}:4189 --log-level INFO 2>&1 | tee pccmock.log
114     BuiltIn.Log    ${command}
115     SSHLibrary.Set_Client_Configuration    timeout=30s
116     SSHLibrary.Write    ${command}
117     ${output}=    SSHLibrary.Read_Until    started
118     BuiltIn.Log    ${output}
119
120 Verify_Data_Reported
121     [Documentation]    Verifies if the tool reported expected data
122     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}    CODE=${pcc_name_code}    NAME=${pcc_name}    IP_ODL=${ODL_SYSTEM_${pcep_owner}_IP}
123     BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    TemplatedRequests.Get_As_Json_Templated    ${DIR_WITH_TEMPLATES}${/}pcep_on_state    ${mapping}    ${living_session}
124     ...    verify=True
125
126 Verify_New_Pcep_Owner_Elected
127     [Arguments]    ${old_owner}    ${node_to_ask}
128     [Documentation]    Verifies new owner was elected
129     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    pcep-topology    Bgpcep    ${node_to_ask}
130     BuiltIn.Should_Not_Be_Equal    ${old_owner}    ${owner}
131     BuiltIn.Set_Suite_Variable    ${pcep_owner}    ${owner}
132
133 Verify_New_Pcep_Candidate_Present
134     [Arguments]    ${candidate}    ${node_to_ask}
135     [Documentation]    Verifies candidate's presence.
136     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    pcep-topology    Bgpcep    ${node_to_ask}
137     Collections.Append_To_List    ${candidates}    ${owner}
138     BuiltIn.Should_Contain    ${candidates}    ${candidate}
139     BuiltIn.Set_Suite_Variable    ${pcep_owner}    ${owner}