Reconcilliation in a 3 node cluster multi DPN environment
[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}    ${json_body_add}
39     [Documentation]    Add Bulk Flow in ${controller_index} according to ${json_body_add}.
40     ${resp}    Utils.Post Elements To URI    ${ADD_BULK_CONFIG_NODES_API}    ${json_body_add}    headers=${HEADERS_YANG_JSON}    session=controller${controller_index}
41
42 Delete Bulk Flow
43     [Arguments]    ${controller_index}    ${json_body_del}
44     [Documentation]    Delete Bulk Flow in ${controller_index} according to ${json_body_del}.
45     ${resp}    Utils.Post Elements To URI    ${ADD_BULK_CONFIG_NODES_API}    ${json_body_del}    headers=${HEADERS_YANG_JSON}    session=controller${controller_index}
46
47 Get Bulk Flow
48     [Arguments]    ${controller_index}    ${json_body_get}
49     [Documentation]    Get Bulk Flow in ${controller_index} according to ${json_body_get}.
50     ${resp}    Utils.Post Elements To URI    ${GET_BULK_CONFIG_NODES_API}    ${json_body_get}    headers=${HEADERS_YANG_JSON}    session=controller${controller_index}
51
52 Get Bulk Flow Count
53     [Arguments]    ${controller_index}
54     [Documentation]    Get Flow count in ${controller_index}. New Flow Count is available after Get Bulk Flow operation.
55     ${data}=    Utils.Get Data From URI    controller${controller_index}    ${jolokia_flow_count_status}
56     Log    ${data}
57     [Return]    ${data}
58
59 Verify Flow Count
60     [Arguments]    ${controller_index}    ${flow_count}
61     [Documentation]    Verify Flow Count in ${controller_index} matches ${flow_count}.
62     ${data}=    Get Bulk Flow Count    ${controller_index}
63     Log    ${data}
64     ${json}=    To Json    ${data}
65     ${value}=    Get From Dictionary    ${json}    value
66     Should Be Equal As Strings    ${value}    ${flow_count}
67
68 Add Bulk Flow In Node
69     [Arguments]    ${controller_index}    ${json_body_add}    ${timeout}
70     [Documentation]    Add Bulk Flow in ${controller_index} and wait until operation is completed.
71     Add Bulk Flow    ${controller_index}    ${json_body_add}
72     Wait Until Write Finishes    ${controller_index}    ${timeout}
73
74 Delete Bulk Flow In Node
75     [Arguments]    ${controller_index}    ${json_body_del}    ${timeout}
76     [Documentation]    Delete Bulk Flow in ${controller_index} and wait until operation is completed.
77     Delete Bulk Flow    ${controller_index}    ${json_body_del}
78     Wait Until Write Finishes    ${controller_index}    ${timeout}
79
80 Get Bulk Flow And Verify Count In Cluster
81     [Arguments]    ${controller_index_list}    ${json_body_get}    ${timeout}    ${flow_count}
82     [Documentation]    Get Bulk Flow and Verify Flow Count in ${controller_index_list} matches ${flow_count}.
83     : FOR    ${index}    IN    @{controller_index_list}
84     \    Get Bulk Flow    ${index}    ${json_body_get}
85     : FOR    ${index}    IN    @{controller_index_list}
86     \    Wait Until Read Finishes    ${index}    ${timeout}
87     : FOR    ${index}    IN    @{controller_index_list}
88     \    Verify Flow Count    ${index}    ${flow_count}
89
90 Set DPN And Flow Count In Json Add
91     [Arguments]    ${json_config}    ${dpn_count}    ${flows_count}
92     [Documentation]    Set new DPN count and flows count per DPN in the Bulkomatic Add json file.
93     ${body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${json_config}
94     ${get_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "1"
95     ${put_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "${dpn_count}"
96     ${str}    Replace String Using Regexp    ${body}    ${get_string}    ${put_string}
97     ${get_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "1000"
98     ${put_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "${flows_count}"
99     ${json_body_add}    Replace String Using Regexp    ${str}    ${get_string}    ${put_string}
100     Log    ${json_body_add}
101     [Return]    ${json_body_add}
102
103 Set DPN And Flow Count In Json Get
104     [Arguments]    ${json_config}    ${dpn_count}    ${flows_count}
105     [Documentation]    Set new DPN count and flows count per DPN in the Bulkomatic Get 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_get}    Replace String Using Regexp    ${str}    ${get_string}    ${put_string}
113     Log    ${json_body_get}
114     [Return]    ${json_body_get}
115
116 Set DPN And Flow Count In Json Del
117     [Arguments]    ${json_config}    ${dpn_count}    ${flows_count}
118     [Documentation]    Set new DPN count and flows count per DPN in the Bulkomatic Del json file.
119     ${body}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/${json_config}
120     ${get_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "1"
121     ${put_string}=    Set Variable    "sal-bulk-flow:dpn-count" : "${dpn_count}"
122     ${str}    Replace String Using Regexp    ${body}    ${get_string}    ${put_string}
123     ${get_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "1000"
124     ${put_string}=    Set Variable    "sal-bulk-flow:flows-per-dpn" : "${flows_count}"
125     ${json_body_del}    Replace String Using Regexp    ${str}    ${get_string}    ${put_string}
126     Log    ${json_body_del}
127     [Return]    ${json_body_del}