Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / sfc / SFC_Basic / 050__sfc_service_schedule_types.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Function Schedule Algorithm Types, Operates types from Restconf APIs.
3 Suite Setup       Init Suite
4 Suite Teardown    Delete All Sessions
5 Test Setup        Remove All Elements If Exist    ${SERVICE_SCHED_TYPES_URI}
6 Library           SSHLibrary
7 Library           Collections
8 Library           OperatingSystem
9 Library           RequestsLibrary
10 Resource          ../../../variables/sfc/Variables.robot
11 Resource          ../../../libraries/Utils.robot
12 Resource          ../../../libraries/TemplatedRequests.robot
13
14 *** Test Cases ***
15 Add Service Function Schedule Algorithm Types
16     [Documentation]    Add Service Function Schedule Algorithm Types from JSON file
17     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
18     ${body}    OperatingSystem.Get File    ${SERVICE_SCHED_TYPES_FILE}
19     ${jsonbody}    To Json    ${body}
20     ${types}    Get From Dictionary    ${jsonbody}    service-function-scheduler-types
21     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_SCHED_TYPES_URI}
22     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
23     ${result}    To JSON    ${resp.content}
24     ${type}    Get From Dictionary    ${result}    service-function-scheduler-types
25     Lists Should be Equal    ${type}    ${types}
26
27 Delete All Service Function Schedule Algorithm Types
28     [Documentation]    Delete Service Function Schedule Algorithm Types
29     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
30     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_SCHED_TYPES_URI}
31     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
32     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
33     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_SCHED_TYPES_URI}
34     Should Be Equal As Strings    ${resp.status_code}    404
35
36 Get Ramdom Schedule Algorithm Type
37     [Documentation]    Get Ramdom Schedule Algorithm Type
38     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
39     ${elements}=    Create List    random    "enabled":false    service-function-scheduler-type:random
40     Check For Elements At URI    ${SERVICE_RANDOM_SCHED_TYPE_URI}    ${elements}
41     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_RANDOM_SCHED_TYPE_URI}
42
43 Get A Non-existing Service Function Schedule Algorithm Type
44     [Documentation]    Get A Non-existing Service Function Schedule Algorithm Type
45     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
46     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_SCHED_TYPE_URI_BASE}user-defined
47     Should Be Equal As Strings    ${resp.status_code}    404
48
49 Delete Ramdom Schedule Algorithm Type
50     [Documentation]    Delete Ramdom Schedule Algorithm Type
51     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
52     Remove All Elements At URI    ${SERVICE_RANDOM_SCHED_TYPE_URI}
53     ${elements}=    Create List    random    service-function-scheduler-type:random
54     Check For Elements Not At URI    ${SERVICE_SCHED_TYPES_URI}    ${elements}
55
56 Delete A Non-existing Service Function Schedule Algorithm Type
57     [Documentation]    Delete A Non existing Service Function Schedule Algorithm Type
58     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
59     ${body}    OperatingSystem.Get File    ${SERVICE_SCHED_TYPES_FILE}
60     ${jsonbody}    To Json    ${body}
61     ${types}    Get From Dictionary    ${jsonbody}    service-function-scheduler-types
62     ${resp}    RequestsLibrary.Delete Request    session    ${SERVICE_SCHED_TYPE_URI_BASE}user-defined
63     Should Be Equal As Strings    ${resp.status_code}    404
64     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_SCHED_TYPES_URI}
65     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
66     ${result}    To JSON    ${resp.content}
67     ${type}    Get From Dictionary    ${result}    service-function-scheduler-types
68     Lists Should be Equal    ${type}    ${types}
69
70 Put one Service Function Schedule Algorithm Type
71     [Documentation]    Put one Service Function Schedule Algorithm Type
72     Add Elements To URI From File    ${SERVICE_WSP_SCHED_TYPE_URI}    ${SERVICE_WSP_SCHED_TYPE_FILE}
73     ${elements}=    Create List    weighted-shortest-path    service-function-scheduler-type:weighted-shortest-path
74     Check For Elements At URI    ${SERVICE_WSP_SCHED_TYPE_URI}    ${elements}
75     Check For Elements At URI    ${SERVICE_SCHED_TYPES_URI}    ${elements}
76
77 *** Keywords ***
78 Init Suite
79     [Documentation]    Initialize session and ODL version specific variables
80     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
81     log    ${ODL_STREAM}
82     Set Suite Variable    ${VERSION_DIR}    master
83     Set Suite Variable    ${TEST_DIR}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}
84     Set Suite Variable    ${SERVICE_SCHED_TYPES_FILE}    ${TEST_DIR}/service-schedule-types.json
85     Set Suite Variable    ${SERVICE_WSP_SCHED_TYPE_URI}    ${SERVICE_SCHED_TYPE_URI_BASE}weighted-shortest-path
86     Set Suite Variable    ${SERVICE_WSP_SCHED_TYPE_FILE}    ${TEST_DIR}/service-wsp-schedule-type.json