Feature 11001: Robot framework linting for E2E tests
[osm/tests.git] / robot-systest / lib / nst_lib.resource
1 *** Comments ***
2 #   Copyright 2020 Atos
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15
16
17 *** Settings ***
18 Documentation   Library providing keywords for CRUD operations over Network Slice Templates with OSM client.
19 Library   OperatingSystem
20
21
22 *** Variables ***
23 ${SUCCESS_RETURN_CODE}   0
24 ${NST_DELETE_MAX_WAIT_TIME}   1min
25 ${NST_DELETE_POL_TIME}   15sec
26
27
28 *** Keywords ***
29 Get NST List
30     [Documentation]   Get the list of Network Slice Templates (NST) and log it.
31     ${rc}   ${stdout}=   Run And Return Rc And Output   osm netslice-template-list
32     Log   ${stdout}
33     Log   ${rc}
34     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
35
36 Create NST
37     [Documentation]   Upload a Network Slice Template (NST) to OSM and return the id.
38     [Arguments]   ${nst}
39     ${rc}   ${stdout}=   Run And Return Rc And Output   osm netslice-template-create ${nst}
40     Log   ${stdout}
41     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
42     RETURN   ${stdout}
43
44 Delete NST
45     [Documentation]   Delete a Network Slice Template (NST) from OSM.
46     [Arguments]   ${nst_id}
47     ${rc}   ${stdout}=   Run And Return Rc And Output   osm netslice-template-delete ${nst_id}
48     Log   ${stdout}
49     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
50     Wait Until Keyword Succeeds   ${NST_DELETE_MAX_WAIT_TIME}   ${NST_DELETE_POL_TIME}   Check For NST   ${nst_id}
51
52 Check For NST
53     [Documentation]   Check that a Network Slice Template (NST) exists in OSM.
54     [Arguments]   ${nst_id}
55     ${rc}   ${stdout}=   Run And Return Rc And Output   osm netslice-template-list | awk '{print $2}' | grep ${nst_id}
56     Log   ${rc},${stdout}
57     Should Not Be Equal As Strings   ${stdout}   ${nst_id}