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