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