911154437e5fa4181b244efb65320a6b59b5399c
[osm/tests.git] / robot-systest / lib / packages_lib.robot
1 # Copyright 2020 Canonical Ltd.
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 *** Settings ***
16 Library   String
17 Library   OperatingSystem
18
19
20 *** Variables ***
21 ${success_return_code}   0
22
23
24 *** Keywords ***
25 Package Build
26     [Documentation]   Build the package NS, VNF given the package_folder
27
28     [Arguments]   ${pkg_folder}   ${skip_charm_build}=${EMPTY}
29
30     ${skip_charm}   Set Variable If   '${skip_charm_build}'!='${EMPTY}'   --skip-charm-build   \
31     ${rc}   ${stdout}=   Run and Return RC and Output   osm package-build ${pkg_folder} ${skip_charm}
32     Should Be Equal As Integers   ${rc}   ${success_return_code}
33     Should Contain   ${stdout}   Package created
34     ${package}=   Get Line   ${stdout}   -1
35
36     [Return]   ${package}
37
38 Package Validate
39     [Documentation]   Validate descriptors given a base directory
40
41     [Arguments]   ${pkg_folder}
42     ${rc}   ${stdout}=   Run and Return RC and Output   osm package-validate ${pkg_folder} | awk -F\| '$2 !~ /-/ && $4 ~ /OK|ERROR/ {print $4}'
43     Should Be Equal As Integers   ${rc}   ${success_return_code}
44     Should Contain   ${stdout}   'OK'
45     ${package}=   Get Line   ${stdout}   -1
46
47     [Return]   ${package}
48