Upgrade RF syntax for v3.2 compatibility
[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 Resource          Utils.robot
6 Variables         ../variables/Variables.py
7
8 *** Variables ***
9 ${ADD_BULK_CONFIG_NODES_API}    /restconf/operations/sal-bulk-flow:flow-test
10 ${GET_BULK_CONFIG_NODES_API}    /restconf/operations/sal-bulk-flow:read-flow-test
11 ${ADD_TABLE_NODEs_API}    /restconf/operations/sal-bulk-flow:table-test
12 ${jolokia_write_op_status}    /jolokia/read/org.opendaylight.openflowplugin.applications.bulk.o.matic:type=FlowCounter/WriteOpStatus
13 ${jolokia_read_op_status}    /jolokia/read/org.opendaylight.openflowplugin.applications.bulk.o.matic:type=FlowCounter/ReadOpStatus
14 ${jolokia_flow_count_status}    /jolokia/read/org.opendaylight.openflowplugin.applications.bulk.o.matic:type=FlowCounter/FlowCount
15
16 *** Keywords ***
17 Operation Status Check
18     [Arguments]    ${op_status_uri}    ${controller_index}
19     [Documentation]    Checks to see if read or write operation is successfull in controller node.
20     ${data}=    ClusterManagement.Get From Member    ${op_status_uri}    ${controller_index}
21     ${json}=    To Json    ${data}
22     ${value}=    Get From Dictionary    ${json}    value
23     ${value}=    Convert to String    ${value}
24     ${two}=    Convert to String    2
25     Should Start With    ${value}    ${two}
26
27 Wait Until Write Finishes
28     [Arguments]    ${controller_index}    ${timeout}
29     [Documentation]    Wait Until Write operation status is OK in member ${controller_index}.
30     Wait Until Keyword Succeeds    ${timeout}    1s    BulkomaticKeywords.Operation Status Check    ${jolokia_write_op_status}    ${controller_index}
31
32 Wait Until Read Finishes
33     [Arguments]    ${controller_index}    ${timeout}
34     [Documentation]    Wait Until Read operation status is OK in member ${controller_index}.
35     Wait Until Keyword Succeeds    ${timeout}    1s    BulkomaticKeywords.Operation Status Check    ${jolokia_read_op_status}    ${controller_index}
36
37 Add Bulk Flow
38     [Arguments]    ${json_body_add}    ${controller_index}
39     [Documentation]    Add Bulk Flow in member ${controller_index} according to \${json_body_add}.
40     ${resp}    ClusterManagement.Post As Json To Member    ${ADD_BULK_CONFIG_NODES_API}    ${json_body_add}    ${controller_index}
41
42 Add Table Flow
43     [Arguments]    ${json_body_add}    ${controller_index}
44     [Documentation]    Add Table in member ${controller_index} according to \${json_body_add}.
45     ${resp}    ClusterManagement.Post As Json To Member    ${ADD_TABLE_NODEs_API}    ${json_body_add}    ${controller_index}
46
47 Delete Bulk Flow
48     [Arguments]    ${json_body_del}    ${controller_index}
49     [Documentation]    Delete Bulk Flow in member ${controller_index} according to \${json_body_del}.
50     ${resp}    ClusterManagement.Post As Json To Member    ${ADD_BULK_CONFIG_NODES_API}    ${json_body_del}    ${controller_index}
51
52 Get Bulk Flow
53     [Arguments]    ${json_body_get}    ${controller_index}
54     [Documentation]    Get Bulk Flow in member ${controller_index} according to \${json_body_get}.
55     ${resp}    ClusterManagement.Post As Json To Member    ${GET_BULK_CONFIG_NODES_API}    ${json_body_get}    ${controller_index}
56
57 Get Bulk Flow Count
58     [Arguments]    ${controller_index}
59     [Documentation]    Get Flow count in member ${controller_index}. New Flow Count is available after Get Bulk Flow operation.
60     ${data}=    ClusterManagement.Get From Member    ${jolokia_flow_count_status}    ${controller_index}
61     [Return]    ${data}
62
63 Verify Flow Count
64     [Arguments]    ${flow_count}    ${controller_index}
65     [Documentation]    Verify Flow Count in member ${controller_index} matches ${flow_count}.
66     ${data}=    Get Bulk Flow Count    ${controller_index}
67     ${json}=    To Json    ${data}
68     ${value}=    Get From Dictionary    ${json}    value
69     Should Be Equal As Strings    ${value}    ${flow_count}
70
71 Add Bulk Flow In Node
72     [Arguments]    ${json_body_add}    ${controller_index}    ${timeout}
73     [Documentation]    Add Bulk Flow in member ${controller_index} and wait until operation is completed.
74     Add Bulk Flow    ${json_body_add}    ${controller_index}
75     Wait Until Write Finishes    ${controller_index}    ${timeout}
76
77 Add Table In Node
78     [Arguments]    ${json_body_add}    ${controller_index}    ${timeout}
79     [Documentation]    Add Table Flow in member ${controller_index} and wait until operation is completed.
80     Add Table Flow    ${json_body_add}    ${controller_index}
81     Wait Until Write Finishes    ${controller_index}    ${timeout}
82
83 Delete Bulk Flow In Node
84     [Arguments]    ${json_body_del}    ${controller_index}    ${timeout}
85     [Documentation]    Delete Bulk Flow in member ${controller_index} and wait until operation is completed.
86     Delete Bulk Flow    ${json_body_del}    ${controller_index}
87     Wait Until Write Finishes    ${controller_index}    ${timeout}
88
89 Get Bulk Flow And Verify Count In Cluster
90     [Arguments]    ${json_body_get}    ${timeout}    ${flow_count}    ${controller_index_list}=${EMPTY}
91     [Documentation]    Get Bulk Flow and Verify Flow Count in ${controller_index_list} matches ${flow_count}.
92     ${index_list} =    ClusterManagement.List Indices Or All    given_list=${controller_index_list}
93     FOR    ${index}    IN    @{index_list}
94         Get Bulk Flow    ${json_body_get}    ${index}
95     END
96     FOR    ${index}    IN    @{index_list}
97         Wait Until Read Finishes    ${index}    ${timeout}
98     END
99     FOR    ${index}    IN    @{index_list}
100         Verify Flow Count    ${flow_count}    ${index}
101     END
102
103 Set DPN And Flow Count In Json Add
104     [Arguments]    ${json_config}    ${dpn_count}    ${flows_count}
105     [Documentation]    Set new DPN count and flows count per DPN in the Bulkomatic Add json file.
106     ${body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${json_config}
107     ${get_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "1"
108     ${put_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "${dpn_count}"
109     ${str}    Replace String Using Regexp    ${body}    ${get_string}    ${put_string}
110     ${get_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "1000"
111     ${put_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "${flows_count}"
112     ${json_body_add}    Replace String Using Regexp    ${str}    ${get_string}    ${put_string}
113     ${get_string}=    Set Variable    "sal-bulk-flow:batch-size" : "1"
114     ${put_string}=    Set Variable    "sal-bulk-flow:batch-size" : "${flows_count}"
115     ${json_body_add}    Replace String Using Regexp    ${json_body_add}    ${get_string}    ${put_string}
116     Log    ${json_body_add}
117     [Return]    ${json_body_add}
118
119 Set DPN And Flow Count In Json Get
120     [Arguments]    ${json_config}    ${dpn_count}    ${flows_count}
121     [Documentation]    Set new DPN count and flows count per DPN in the Bulkomatic Get json file.
122     ${body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${json_config}
123     ${get_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "1"
124     ${put_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "${dpn_count}"
125     ${str}    Replace String Using Regexp    ${body}    ${get_string}    ${put_string}
126     ${get_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "1000"
127     ${put_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "${flows_count}"
128     ${json_body_get}    Replace String Using Regexp    ${str}    ${get_string}    ${put_string}
129     Log    ${json_body_get}
130     [Return]    ${json_body_get}
131
132 Set DPN And Flow Count In Json Del
133     [Arguments]    ${json_config}    ${dpn_count}    ${flows_count}
134     [Documentation]    Set new DPN count and flows count per DPN in the Bulkomatic Del json file.
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_del}    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_del}    Replace String Using Regexp    ${json_body_del}    ${get_string}    ${put_string}
145     Log    ${json_body_del}
146     [Return]    ${json_body_del}