Initial tests contributions
[osm/tests.git] / robot-systest / lib / nst_lib.robot
1 #   Copyright 2020 Atos
2 #
3 #   Licensed under the Apache License, Version 2.0 (the "License");
4 #   you may not use this file except in compliance with the License.
5 #   You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #   Unless required by applicable law or agreed to in writing, software
10 #   distributed under the License is distributed on an "AS IS" BASIS,
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #   See the License for the specific language governing permissions and
13 #   limitations under the License.
14
15 *** Variables ***
16 ${success_return_code}   0
17 ${ns_launch_max_wait_time}   5min
18 ${ns_launch_pol_time}   30sec
19 ${ns_delete_max_wait_time}   1min
20 ${ns_delete_pol_time}   15sec
21
22 *** Keywords ***
23 Get NST List
24     ${rc}   ${stdout}=   Run and Return RC and Output   osm netslice-template-list
25     log   ${stdout}
26     log   ${rc}
27     Should Be Equal As Integers   ${rc}   ${success_return_code}
28
29
30 Create NST
31     [Arguments]   ${nst}
32
33     ${rc}   ${stdout}=   Run and Return RC and Output   osm netslice-template-create ${nst}
34     log   ${stdout}
35     Should Be Equal As Integers   ${rc}   ${success_return_code}
36     [Return]  ${stdout}
37
38
39 Delete NST
40     [Arguments]   ${nst_id}
41
42     ${rc}   ${stdout}=   Run and Return RC and Output   osm netslice-template-delete ${nst_id}
43     log   ${stdout}
44     Should Be Equal As Integers   ${rc}   ${success_return_code}
45     WAIT UNTIL KEYWORD SUCCEEDS   ${delete_max_wait_time}   ${delete_pol_time}   Check For NST   ${nst_id}
46
47
48 Check For NST
49     [Arguments]   ${nst_id}
50
51     ${rc}   ${stdout}=   Run and Return RC and Output   osm netslice-template-list | awk '{print $2}' | grep ${nst_id}
52     Should Not Be Equal As Strings   ${stdout}   ${nst_id}
53