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