e6b27fb42612ae9d95f3314818ac680ae581082e
[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 ${jolokia_write_op_status}    /jolokia/read/org.opendaylight.openflowplugin.applications.bulk.o.matic:type=FlowCounter/WriteOpStatus
12 ${jolokia_read_op_status}    /jolokia/read/org.opendaylight.openflowplugin.applications.bulk.o.matic:type=FlowCounter/ReadOpStatus
13 ${jolokia_flow_count_status}    /jolokia/read/org.opendaylight.openflowplugin.applications.bulk.o.matic:type=FlowCounter/FlowCount
14
15 *** Keywords ***
16 Operation Status Check
17     [Arguments]    ${controller_index}    ${op_status_uri}
18     [Documentation]    Checks to see if read or write operation is successfull in controller node.
19     ${data}=    Utils.Get Data From URI    controller${controller_index}    ${op_status_uri}
20     Log    ${data}
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 ${controller_index}.
30     Wait Until Keyword Succeeds    ${timeout}    1s    BulkomaticKeywords.Operation Status Check    ${controller_index}    ${jolokia_write_op_status}
31
32 Wait Until Read Finishes
33     [Arguments]    ${controller_index}    ${timeout}
34     [Documentation]    Wait Until Read operation status is OK in ${controller_index}.
35     Wait Until Keyword Succeeds    ${timeout}    1s    BulkomaticKeywords.Operation Status Check    ${controller_index}    ${jolokia_read_op_status}
36
37 Add Bulk Flow
38     [Arguments]    ${controller_index}    ${add_bulk_json_file}
39     [Documentation]    Add Bulk Flow in ${controller_index} according to ${add_bulk_json_file}.
40     ${add_body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${add_bulk_json_file}
41     ${resp}    Utils.Post Elements To URI    ${ADD_BULK_CONFIG_NODES_API}    ${add_body}    headers=${HEADERS_YANG_JSON}    session=controller${controller_index}
42
43 Delete Bulk Flow
44     [Arguments]    ${controller_index}    ${del_bulk_json_file}
45     [Documentation]    Delete Bulk Flow in ${controller_index} according to ${del_bulk_json_file}.
46     ${del_body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${del_bulk_json_file}
47     ${resp}    Utils.Post Elements To URI    ${ADD_BULK_CONFIG_NODES_API}    ${del_body}    headers=${HEADERS_YANG_JSON}    session=controller${controller_index}
48
49 Get Bulk Flow
50     [Arguments]    ${controller_index}    ${get_bulk_json_file}
51     [Documentation]    Get Bulk Flow in ${controller_index} according to ${get_bulk_json_file}.
52     ${get_body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${get_bulk_json_file}
53     ${resp}    Utils.Post Elements To URI    ${GET_BULK_CONFIG_NODES_API}    ${get_body}    headers=${HEADERS_YANG_JSON}    session=controller${controller_index}
54
55 Get Bulk Flow Count
56     [Arguments]    ${controller_index}
57     [Documentation]    Get Flow count in ${controller_index}. New Flow Count is available after Get Bulk Flow operation.
58     ${data}=    Utils.Get Data From URI    controller${controller_index}    ${jolokia_flow_count_status}
59     Log    ${data}
60     [Return]    ${data}
61
62 Verify Flow Count
63     [Arguments]    ${controller_index}    ${flow_count}
64     [Documentation]    Verify Flow Count in ${controller_index} matches ${flow_count}.
65     ${data}=    Get Bulk Flow Count    ${controller_index}
66     Log    ${data}
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]    ${controller_index}    ${add_bulk_json_file}    ${timeout}
73     [Documentation]    Add Bulk Flow in ${controller_index} and wait until operation is completed.
74     Add Bulk Flow    ${controller_index}    ${add_bulk_json_file}
75     Wait Until Write Finishes    ${controller_index}    ${timeout}
76
77 Delete Bulk Flow In Node
78     [Arguments]    ${controller_index}    ${delete_bulk_json_file}    ${timeout}
79     [Documentation]    Delete Bulk Flow in ${controller_index} and wait until operation is completed.
80     Delete Bulk Flow    ${controller_index}    ${delete_bulk_json_file}
81     Wait Until Write Finishes    ${controller_index}    ${timeout}
82
83 Get Bulk Flow And Verify Count In Cluster
84     [Arguments]    ${controller_index_list}    ${get_bulk_json_file}    ${timeout}    ${flow_count}
85     [Documentation]    Get Bulk Flow and Verify Flow Count in ${controller_index_list} matches ${flow_count}.
86     : FOR    ${index}    IN    @{controller_index_list}
87     \    Get Bulk Flow    ${index}    ${get_bulk_json_file}
88     : FOR    ${index}    IN    @{controller_index_list}
89     \    Wait Until Read Finishes    ${index}    ${timeout}
90     : FOR    ${index}    IN    @{controller_index_list}
91     \    Verify Flow Count    ${index}    ${flow_count}