Get rid of deprecation warnings
[integration/test.git] / csit / libraries / CarPeople.robot
1 *** Settings ***
2 Documentation       Resource housing Keywords common to tests which interact with car/people models.
3 ...
4 ...                 Copyright (c) 2016-2017 Cisco Systems, Inc. and others. 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 ...
11 ...                 This resource is tightly coupled with "crud" cluster suite,
12 ...                 as it is not straightforward to allow ${VAR_DIR} customization.
13
14 Resource            ${CURDIR}/TemplatedRequests.robot
15
16
17 *** Variables ***
18 ${VAR_DIR}      ${CURDIR}/../../../variables/carpeople/crud
19
20
21 *** Keywords ***
22 Add_Several_People
23     [Documentation]    Simple loop for issuing add-person RPCs to session, one by one.
24     ...    People need to be added via RPC, otherwise buy-car routed RPC will not find registered path.
25     ...    See javadocs in RpcProviderRegistry.java
26     [Arguments]    ${session}    ${iterations}    ${iter_start}=1
27     FOR    ${i}    IN RANGE    ${iter_start}    ${iter_start}+${iterations}
28         TemplatedRequests.Post_As_Json_Templated
29         ...    folder=${VAR_DIR}/add-person
30         ...    mapping={"i": "${i}"}
31         ...    session=${session}
32     END
33
34 Buy_Several_Cars
35     [Documentation]    Simple loop for issuing buy-car RPCs to session, one by one.
36     ...    This needs to be a separate Keyword mostly just because nested FOR loops are not allowed.
37     ...    Actual fact of buying one car is done by inner Keyword.
38     [Arguments]    ${session}    ${iterations}    ${iter_start}=1    ${registration_delay}=20s
39     FOR    ${iter}    IN RANGE    ${iter_start}    ${iter_start}+${iterations}
40         Buy_Single_Car    session=${session}    iteration=${iter}    registration_delay=${registration_delay}
41     END
42
43 Buy_Single_Car
44     [Documentation]    Each buy-car RPC is routed, which means there is a delay between
45     ...    the time add-car RPC is executed and the time member in question registers the route.
46     ...    To distinguish functional bugs from performance ones, this Keyword waits up to 20 seconds
47     ...    while retrying buy-car requests.
48     [Arguments]    ${session}    ${iteration}=1    ${registration_delay}=20s
49     BuiltIn.Wait_Until_Keyword_Succeeds
50     ...    ${registration_delay}
51     ...    1s
52     ...    TemplatedRequests.Post_As_Json_Templated
53     ...    folder=${VAR_DIR}/buy-car
54     ...    mapping={"i": "${iteration}"}
55     ...    session=${session}
56
57 Set_Variables_For_Shard
58     [Documentation]    Get leader and followers for given shard name and
59     ...    set several suite variables related to member indices and sessions.
60     ...    ClusterManagement Resource is assumed to be initialized.
61     ...    TODO: car-people shard name causes dash in variable names. Should we convert to underscores?
62     [Arguments]    ${shard_name}    ${shard_type}=config
63     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard
64     ...    shard_name=${shard_name}
65     ...    shard_type=${shard_type}
66     BuiltIn.Set_Suite_Variable    \${${shard_name}_leader_index}    ${leader}
67     BuiltIn.Set_Suite_Variable    \${${shard_name}_follower_indices}    ${follower_list}
68     ${first_follower_index} =    Collections.Get_From_List    ${follower_list}    0
69     BuiltIn.Set_Suite_Variable    \${${shard_name}_first_follower_index}    ${first_follower_index}
70     ${leader_session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${leader}
71     BuiltIn.Set_Suite_Variable    \${${shard_name}_leader_session}    ${leader_session}
72     ${sessions} =    BuiltIn.Create_List
73     FOR    ${follower_index}    IN    @{follower_list}
74         ${follower_session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${follower_index}
75         Collections.Append_To_List    ${sessions}    ${follower_session}
76     END
77     BuiltIn.Set_Suite_Variable    \${${shard_name}_follower_sessions}    ${sessions}
78     ${first_follower_session} =    Collections.Get_From_List    ${sessions}    0
79     BuiltIn.Set_Suite_Variable    \${${shard_name}_first_follower_session}    ${first_follower_session}
80
81 Set_Tmp_Variables_For_Shard_For_Nodes
82     [Documentation]    Get current leader and followers for given shard. Can be used for less nodes than full odl configuration.
83     ...    Variable names do not contain neither node nor shard names, so the variables are only suitable for temporary use, as indicated by Tmp in the keyword name.
84     ...    This keyword sets the following suite variables:
85     ...    ${new_leader_session} - http session for the leader node
86     ...    ${new_follower_sessions} - list of http sessions for the follower nodes
87     ...    ${new_first_follower_session} - http session for the first follower node
88     ...    ${new_leader_index} - index of the shard leader
89     ...    ${new_followers_list} - list of followers indexes
90     [Arguments]    ${member_index_list}    ${shard_name}=car    ${shard_type}=config
91     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard
92     ...    shard_name=${shard_name}
93     ...    shard_type=${shard_type}
94     ...    member_index_list=${member_index_list}
95     BuiltIn.Set_Suite_Variable    \${new_leader_index}    ${leader}
96     BuiltIn.Set_Suite_Variable    \${new_followers_list}    ${follower_list}
97     ${leader_session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${leader}
98     BuiltIn.Set_Suite_Variable    \${new_leader_session}    ${leader_session}
99     ${sessions} =    BuiltIn.Create_List
100     FOR    ${follower_index}    IN    @{follower_list}
101         ${follower_session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${follower_index}
102         Collections.Append_To_List    ${sessions}    ${follower_session}
103     END
104     BuiltIn.Set_Suite_Variable    \${new_follower_sessions}    ${sessions}
105     ${first_follower_session} =    Collections.Get_From_List    ${sessions}    0
106     BuiltIn.Set_Suite_Variable    \${new_first_follower_session}    ${first_follower_session}
107     RETURN    ${leader}    ${follower_list}