Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / libraries / BulkomaticKeywords.robot
1 *** Settings ***
2 Documentation       Bulkomatic Keyword library contains keywords for performing bulkomatic operations
3 ...                 with a single bulkomatic API we can trigger bulk flows in config datastore which eventually populates switches and operational datastore
4 ...                 So far this library is only to be used by MD-SAL clustering and OpenFlowplugin clustering test as it is very specific for these tests
5
6 Resource            ClusterManagement.robot
7 Resource            Utils.robot
8 Variables           ../variables/Variables.py
9
10
11 *** Variables ***
12 ${ADD_BULK_CONFIG_NODES_API}    /rests/operations/sal-bulk-flow:flow-test
13 ${GET_BULK_CONFIG_NODES_API}    /rests/operations/sal-bulk-flow:read-flow-test
14 ${ADD_TABLE_NODEs_API}          /rests/operations/sal-bulk-flow:table-test
15 ${jolokia_write_op_status}
16 ...                             /jolokia/read/org.opendaylight.openflowplugin.applications.bulk.o.matic:type=FlowCounter/WriteOpStatus
17 ${jolokia_read_op_status}
18 ...                             /jolokia/read/org.opendaylight.openflowplugin.applications.bulk.o.matic:type=FlowCounter/ReadOpStatus
19 ${jolokia_flow_count_status}
20 ...                             /jolokia/read/org.opendaylight.openflowplugin.applications.bulk.o.matic:type=FlowCounter/FlowCount
21
22
23 *** Keywords ***
24 Operation Status Check
25     [Documentation]    Checks to see if read or write operation is successfull in controller node.
26     [Arguments]    ${op_status_uri}    ${controller_index}
27     ${data}=    ClusterManagement.Get From Member    ${op_status_uri}    ${controller_index}
28     ${json}=    Utils.Json Parse From String    ${data}
29     ${value}=    Get From Dictionary    ${json}    value
30     ${value}=    Convert to String    ${value}
31     ${two}=    Convert to String    2
32     Should Start With    ${value}    ${two}
33
34 Wait Until Write Finishes
35     [Documentation]    Wait Until Write operation status is OK in member ${controller_index}.
36     [Arguments]    ${controller_index}    ${timeout}
37     Wait Until Keyword Succeeds
38     ...    ${timeout}
39     ...    1s
40     ...    BulkomaticKeywords.Operation Status Check
41     ...    ${jolokia_write_op_status}
42     ...    ${controller_index}
43
44 Wait Until Read Finishes
45     [Documentation]    Wait Until Read operation status is OK in member ${controller_index}.
46     [Arguments]    ${controller_index}    ${timeout}
47     Wait Until Keyword Succeeds
48     ...    ${timeout}
49     ...    1s
50     ...    BulkomaticKeywords.Operation Status Check
51     ...    ${jolokia_read_op_status}
52     ...    ${controller_index}
53
54 Add Bulk Flow
55     [Documentation]    Add Bulk Flow in member ${controller_index} according to \${json_body_add}.
56     [Arguments]    ${json_body_add}    ${controller_index}
57     ${resp}=    ClusterManagement.Post As Json To Member
58     ...    ${ADD_BULK_CONFIG_NODES_API}
59     ...    ${json_body_add}
60     ...    ${controller_index}
61
62 Add Table Flow
63     [Documentation]    Add Table in member ${controller_index} according to \${json_body_add}.
64     [Arguments]    ${json_body_add}    ${controller_index}
65     ${resp}=    ClusterManagement.Post As Json To Member
66     ...    ${ADD_TABLE_NODEs_API}
67     ...    ${json_body_add}
68     ...    ${controller_index}
69
70 Delete Bulk Flow
71     [Documentation]    Delete Bulk Flow in member ${controller_index} according to \${json_body_del}.
72     [Arguments]    ${json_body_del}    ${controller_index}
73     ${resp}=    ClusterManagement.Post As Json To Member
74     ...    ${ADD_BULK_CONFIG_NODES_API}
75     ...    ${json_body_del}
76     ...    ${controller_index}
77
78 Get Bulk Flow
79     [Documentation]    Get Bulk Flow in member ${controller_index} according to \${json_body_get}.
80     [Arguments]    ${json_body_get}    ${controller_index}
81     ${resp}=    ClusterManagement.Post As Json To Member
82     ...    ${GET_BULK_CONFIG_NODES_API}
83     ...    ${json_body_get}
84     ...    ${controller_index}
85
86 Get Bulk Flow Count
87     [Documentation]    Get Flow count in member ${controller_index}. New Flow Count is available after Get Bulk Flow operation.
88     [Arguments]    ${controller_index}
89     ${data}=    ClusterManagement.Get From Member    ${jolokia_flow_count_status}    ${controller_index}
90     RETURN    ${data}
91
92 Verify Flow Count
93     [Documentation]    Verify Flow Count in member ${controller_index} matches ${flow_count}.
94     [Arguments]    ${flow_count}    ${controller_index}
95     ${data}=    Get Bulk Flow Count    ${controller_index}
96     ${json}=    Utils.Json Parse From String    ${data}
97     ${value}=    Get From Dictionary    ${json}    value
98     Should Be Equal As Strings    ${value}    ${flow_count}
99
100 Add Bulk Flow In Node
101     [Documentation]    Add Bulk Flow in member ${controller_index} and wait until operation is completed.
102     [Arguments]    ${json_body_add}    ${controller_index}    ${timeout}
103     Add Bulk Flow    ${json_body_add}    ${controller_index}
104     Wait Until Write Finishes    ${controller_index}    ${timeout}
105
106 Add Table In Node
107     [Documentation]    Add Table Flow in member ${controller_index} and wait until operation is completed.
108     [Arguments]    ${json_body_add}    ${controller_index}    ${timeout}
109     Add Table Flow    ${json_body_add}    ${controller_index}
110     Wait Until Write Finishes    ${controller_index}    ${timeout}
111
112 Delete Bulk Flow In Node
113     [Documentation]    Delete Bulk Flow in member ${controller_index} and wait until operation is completed.
114     [Arguments]    ${json_body_del}    ${controller_index}    ${timeout}
115     Delete Bulk Flow    ${json_body_del}    ${controller_index}
116     Wait Until Write Finishes    ${controller_index}    ${timeout}
117
118 Get Bulk Flow And Verify Count In Cluster
119     [Documentation]    Get Bulk Flow and Verify Flow Count in ${controller_index_list} matches ${flow_count}.
120     [Arguments]    ${json_body_get}    ${timeout}    ${flow_count}    ${controller_index_list}=${EMPTY}
121     ${index_list}=    ClusterManagement.List Indices Or All    given_list=${controller_index_list}
122     FOR    ${index}    IN    @{index_list}
123         Get Bulk Flow    ${json_body_get}    ${index}
124     END
125     FOR    ${index}    IN    @{index_list}
126         Wait Until Read Finishes    ${index}    ${timeout}
127     END
128     FOR    ${index}    IN    @{index_list}
129         Verify Flow Count    ${flow_count}    ${index}
130     END
131
132 Set DPN And Flow Count In Json Add
133     [Documentation]    Set new DPN count and flows count per DPN in the Bulkomatic Add json file.
134     [Arguments]    ${json_config}    ${dpn_count}    ${flows_count}
135     ${body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${json_config}
136     ${get_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "1"
137     ${put_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "${dpn_count}"
138     ${str}=    Replace String Using Regexp    ${body}    ${get_string}    ${put_string}
139     ${get_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "1000"
140     ${put_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "${flows_count}"
141     ${json_body_add}=    Replace String Using Regexp    ${str}    ${get_string}    ${put_string}
142     ${get_string}=    Set Variable    "sal-bulk-flow:batch-size" : "1"
143     ${put_string}=    Set Variable    "sal-bulk-flow:batch-size" : "${flows_count}"
144     ${json_body_add}=    Replace String Using Regexp    ${json_body_add}    ${get_string}    ${put_string}
145     Log    ${json_body_add}
146     RETURN    ${json_body_add}
147
148 Set DPN And Flow Count In Json Get
149     [Documentation]    Set new DPN count and flows count per DPN in the Bulkomatic Get json file.
150     [Arguments]    ${json_config}    ${dpn_count}    ${flows_count}
151     ${body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${json_config}
152     ${get_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "1"
153     ${put_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "${dpn_count}"
154     ${str}=    Replace String Using Regexp    ${body}    ${get_string}    ${put_string}
155     ${get_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "1000"
156     ${put_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "${flows_count}"
157     ${json_body_get}=    Replace String Using Regexp    ${str}    ${get_string}    ${put_string}
158     Log    ${json_body_get}
159     RETURN    ${json_body_get}
160
161 Set DPN And Flow Count In Json Del
162     [Documentation]    Set new DPN count and flows count per DPN in the Bulkomatic Del json file.
163     [Arguments]    ${json_config}    ${dpn_count}    ${flows_count}
164     ${body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${json_config}
165     ${get_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "1"
166     ${put_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "${dpn_count}"
167     ${str}=    Replace String Using Regexp    ${body}    ${get_string}    ${put_string}
168     ${get_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "1000"
169     ${put_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "${flows_count}"
170     ${json_body_del}=    Replace String Using Regexp    ${str}    ${get_string}    ${put_string}
171     ${get_string}=    Set Variable    "sal-bulk-flow:batch-size" : "1"
172     ${put_string}=    Set Variable    "sal-bulk-flow:batch-size" : "${flows_count}"
173     ${json_body_del}=    Replace String Using Regexp    ${json_body_del}    ${get_string}    ${put_string}
174     Log    ${json_body_del}
175     RETURN    ${json_body_del}