Tidied updated tests.
[integration/test.git] / csit / suites / sfc / Clustering_Datastore / 020_simple_clustering.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Service Functions, Operates functions from Restconf APIs.
3 Suite Setup       Init Variables
4 Suite Teardown    Delete All Sessions
5 Library           RequestsLibrary
6 Library           SSHLibrary
7 Library           Collections
8 Library           OperatingSystem
9 Variables         ../../../variables/Variables.py
10 Resource          ../../../libraries/Utils.robot
11
12 *** Test Cases ***
13 Add Service Functions To First Node
14     [Documentation]    Add service functions from JSON file
15     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
16     ${jsonbody}    Read JSON From File    ${SFC_FUNCTIONS_FILE}
17     Add Elements To URI From File    ${SFC_API}    ${SFC_FUNCTIONS_FILE}    ${HEADERS_YANG_JSON}
18     ${resp}    RequestsLibrary.Get    session    ${SFC_API}
19     Should Be Equal As Strings    ${resp.status_code}    200
20     ${result}    To JSON    ${resp.content}
21     Lists Should be Equal    ${result}    ${jsonbody}
22
23 Read Service Functions From Second Node
24     Create Session    session    http://${ODL_SYSTEM_2_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
25     ${jsonbody}    Read JSON From File    ${SFC_FUNCTIONS_FILE}
26     ${resp}    RequestsLibrary.Get    session    ${SFC_API}
27     Should Be Equal As Strings    ${resp.status_code}    200
28     ${result}    To JSON    ${resp.content}
29     Lists Should be Equal    ${result}    ${jsonbody}
30
31 Read Service Functions From Third Node
32     Create Session    session    http://${ODL_SYSTEM_3_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
33     ${jsonbody}    Read JSON From File    ${SFC_FUNCTIONS_FILE}
34     ${resp}    RequestsLibrary.Get    session    ${SFC_API}
35     Should Be Equal As Strings    ${resp.status_code}    200
36     ${result}    To JSON    ${resp.content}
37     Lists Should be Equal    ${result}    ${jsonbody}
38
39 *** Keywords ***
40 Read JSON From File
41     [Arguments]    ${filepath}
42     ${body}    OperatingSystem.Get File    ${filepath}
43     ${jsonbody}    To Json    ${body}
44     [Return]    ${jsonbody}
45
46 Init Variables
47     [Documentation]    Initialize ODL version specific variables
48     log    ${ODL_VERSION}
49     Run Keyword If    '${ODL_VERSION}' == 'stable-lithium'    Init Variables Lithium
50     ...    ELSE    Init Variables Master
51
52 Init Variables Master
53     [Documentation]    Sets variables specific to latest(master) version
54     Set Suite Variable    ${SFC_API}    /restconf/config/service-function:service-functions
55     Set Suite Variable    ${SFC_FUNCTIONS_FILE} ${CURDIR}/../../../variables/sfc/master/service-functions.json
56
57 Init Variables Lithium
58     [Documentation]    Sets variables specific to Lithium version
59     Set Suite Variable    ${SFC_API}    /restconf/config/service-function:service-functions
60     Set Suite Variable    ${SFC_FUNCTIONS_FILE} ${CURDIR}/../../../variables/sfc/lithium/service-functions.json