Step 1: Move vm scripts to the right place
[integration/test.git] / test / 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       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Library           SSHLibrary
6 Library           Collections
7 Library           OperatingSystem
8 Library           RequestsLibrary
9 Variables         ../../../variables/Variables.py
10 Resource          ../../../libraries/Utils.robot
11
12 *** Variables ***
13 ${SERVICE_SCHED_TYPES_URI}    /restconf/config/service-function-scheduler-type:service-function-scheduler-types/
14 ${SERVICE_SCHED_TYPES_FILE}    ../../../variables/sfc/service-schedule-types.json
15 ${SERVICE_WSP_SCHED_TYPE_URI}    /restconf/config/service-function-scheduler-type:service-function-scheduler-types/service-function-scheduler-type/service-function-scheduler-type:weighted-shortest-path
16 ${SERVICE_WSP_SCHED_TYPE_FILE}    ../../../variables/sfc/service-wsp-schedule-type.json
17
18 *** Test Cases ***
19 Add Service Function Schedule Algorithm Types
20     [Documentation]    Add Service Function Schedule Algorithm Types from JSON file
21     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
22     ${body}    OperatingSystem.Get File    ${SERVICE_SCHED_TYPES_FILE}
23     ${jsonbody}    To Json    ${body}
24     ${types}    Get From Dictionary    ${jsonbody}    service-function-scheduler-types
25     ${resp}    RequestsLibrary.Get    session    ${SERVICE_SCHED_TYPES_URI}
26     Should Be Equal As Strings    ${resp.status_code}    200
27     ${result}    To JSON    ${resp.content}
28     ${type}    Get From Dictionary    ${result}    service-function-scheduler-types
29     Lists Should be Equal    ${type}    ${types}
30
31 Delete All Service Function Schedule Algorithm Types
32     [Documentation]    Delete Service Function Schedule Algorithm Types
33     ${resp}    RequestsLibrary.Get    session    ${SERVICE_SCHED_TYPES_URI}
34     Should Be Equal As Strings    ${resp.status_code}    200
35     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
36     ${resp}    RequestsLibrary.Get    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     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
42     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
43     ${elements}=    Create List    random    "enabled":false    service-function-scheduler-type:random
44     Check For Elements At URI    ${SERVICE_SCHED_TYPES_URI}service-function-scheduler-type/service-function-scheduler-type:random    ${elements}
45     ${resp}    RequestsLibrary.Get    session    ${SERVICE_SCHED_TYPES_URI}service-function-scheduler-type/service-function-scheduler-type:random
46
47 Get A Non-existing Service Function Schedule Algorithm Type
48     [Documentation]    Get A Non-existing Service Function Schedule Algorithm Type
49     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
50     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
51     ${resp}    RequestsLibrary.Get    session    ${SERVICE_SCHED_TYPES_URI}service-function-scheduler-type/service-function-scheduler-type:user-defined
52     Should Be Equal As Strings    ${resp.status_code}    404
53
54 Delete Ramdom Schedule Algorithm Type
55     [Documentation]    Delete Ramdom Schedule Algorithm Type
56     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
57     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
58     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}service-function-scheduler-type/service-function-scheduler-type:random
59     ${elements}=    Create List    random    service-function-scheduler-type:random
60     Check For Elements Not At URI    ${SERVICE_SCHED_TYPES_URI}    ${elements}
61
62 Delete A Non-existing Service Function Schedule Algorithm Type
63     [Documentation]    Delete A Non existing Service Function Schedule Algorithm Type
64     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
65     Add Elements To URI From File    ${SERVICE_SCHED_TYPES_URI}    ${SERVICE_SCHED_TYPES_FILE}
66     ${body}    OperatingSystem.Get File    ${SERVICE_SCHED_TYPES_FILE}
67     ${jsonbody}    To Json    ${body}
68     ${types}    Get From Dictionary    ${jsonbody}    service-function-scheduler-types
69     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}service-function-scheduler-type/service-function-scheduler-type:user-defined
70     ${resp}    RequestsLibrary.Get    session    ${SERVICE_SCHED_TYPES_URI}
71     Should Be Equal As Strings    ${resp.status_code}    200
72     ${result}    To JSON    ${resp.content}
73     ${type}    Get From Dictionary    ${result}    service-function-scheduler-types
74     Lists Should be Equal    ${type}    ${types}
75
76 Put one Service Function Schedule Algorithm Type
77     [Documentation]    Put one Service Function Schedule Algorithm Type
78     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}
79     Add Elements To URI From File    ${SERVICE_WSP_SCHED_TYPE_URI}    ${SERVICE_WSP_SCHED_TYPE_FILE}
80     ${elements}=    Create List    weighted-shortest-path    service-function-scheduler-type:weighted-shortest-path
81     Check For Elements At URI    ${SERVICE_WSP_SCHED_TYPE_URI}    ${elements}
82     Check For Elements At URI    ${SERVICE_SCHED_TYPES_URI}    ${elements}
83
84 Clean Datastore After Tests
85     [Documentation]    Delete All Service Function Schedule Algorithm Types From Datastore After Tests
86     Remove All Elements At URI    ${SERVICE_SCHED_TYPES_URI}