blob: 1d57598176deb6aa90217fd77bc1fda5e9102260 [file] [log] [blame]
Felipe Vicensf96bb452020-06-22 08:12:30 +02001# -*- coding: utf-8 -*-
2
3##
4# Copyright 2019 Tech Mahindra Limited
5#
6# All Rights Reserved.
7#
8# Licensed under the Apache License, Version 2.0 (the "License"); you may
9# not use this file except in compliance with the License. You may obtain
10# a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17# License for the specific language governing permissions and limitations
18# under the License.
19##
20
21## Change log:
22# 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 06-sep-2019
23##
24
25*** Settings ***
26Library String
27
28
29*** Variables ***
30${success_return_code} 0
garciadeblas499c8672021-03-25 11:51:08 +010031${failure_return_code} 0
Felipe Vicensf96bb452020-06-22 08:12:30 +020032${delete_max_wait_time} 1min
33${delete_pol_time} 15sec
34
35
36*** Keywords ***
37Get VNFDs List
garciadeblasf70f5362020-09-29 15:38:47 +000038 ${rc} ${stdout}= Run and Return RC and Output osm vnfpkg-list
Felipe Vicensf96bb452020-06-22 08:12:30 +020039 log ${stdout}
40 log ${rc}
41 Should Be Equal As Integers ${rc} ${success_return_code}
42
43
44Create VNFD
ramonsalguer89edc072020-07-17 18:08:52 +000045 [Documentation] Onboards ("creates") a NF Package into OSM.
46 ... - Parameters:
47 ... - vnfd_pkg: Name (and location) of the NF Package
48 ... - overrides (optional): String with options to override the EPA and/or interface properties of the Package.
49 ... This is very useful to allow to deploy e.g. non-EPA packages in EPA VIMs (or vice-versa).
50 ... Valid strings are the same as in the command. E.g.:
51 ... - `--override-epa`: adds EPA attributes to all VDUs.
52 ... - `--override-nonepa`: removes all EPA attributes from all VDUs.
53 ... - `--override-paravirt`: converts all interfaces to `PARAVIRT`. This one can be combined with
54 ... the others above (e.g. '--override-nonepa --override-paravirt').
55 ... - Relevant environment variables:
56 ... - OVERRIDES: If the environment variable "OVERRIDES" exists, it prevails over the value in the argument.
57 ... This is often more convenient to enforce the same behaviour for every test run in a given VIM.
Felipe Vicensf96bb452020-06-22 08:12:30 +020058
ramonsalguer89edc072020-07-17 18:08:52 +000059 [Arguments] ${vnfd_pkg} ${overrides}=${EMPTY}
60
61 # If env variable "OVERRIDES" exists, it prevails over the value in the argument
62 ${overrides}= Get Environment Variable OVERRIDES default=${overrides}
63
64 # Proceedes with the onboarding with the appropriate arguments
garciadeblasf70f5362020-09-29 15:38:47 +000065 ${rc} ${stdout}= Run and Return RC and Output osm vnfpkg-create ${overrides} ${vnfd_pkg}
Felipe Vicensf96bb452020-06-22 08:12:30 +020066 log ${stdout}
67 Should Be Equal As Integers ${rc} ${success_return_code}
68 ${lines}= Get Line Count ${stdout}
69 ${last}= Evaluate ${lines} - 1
70 ${id}= Get Line ${stdout} ${last}
71 [Return] ${id}
72
73
aguilarherna9dca3a82021-03-24 16:59:34 +010074Create VNFD Overriding Fields
75 [Documentation] Onboards ("creates") a NF Package into OSM.
76 ... - Parameters:
77 ... - vnfd_pkg: Name (and location) of the NF Package
78 ... - override_fields: String with options to override fields in descriptor, format: "key1.key2...=value[;key3...=value;...]"
79 ... - overrides (optional): String with options to override the EPA and/or interface properties of the Package.
80 ... This is very useful to allow to deploy e.g. non-EPA packages in EPA VIMs (or vice-versa).
81 ... Valid strings are the same as in the command. E.g.:
82 ... - `--override-epa`: adds EPA attributes to all VDUs.
83 ... - `--override-nonepa`: removes all EPA attributes from all VDUs.
84 ... - `--override-paravirt`: converts all interfaces to `PARAVIRT`. This one can be combined with
85 ... the others above (e.g. '--override-nonepa --override-paravirt').
garciadeblas499c8672021-03-25 11:51:08 +010086 ... - Relevant environment variables:
aguilarherna9dca3a82021-03-24 16:59:34 +010087 ... - OVERRIDES: If the environment variable "OVERRIDES" exists, it prevails over the value in the argument.
88 ... This is often more convenient to enforce the same behaviour for every test run in a given VIM.
89
90 [Arguments] ${vnfd_pkg} ${override_fields} ${overrides}=${EMPTY}
91
92 # If env variable "OVERRIDES" exists, it prevails over the value in the argument
93 ${overrides}= Get Environment Variable OVERRIDES default=${overrides}
94
95 # Proceedes with the onboarding with the appropriate arguments
96 ${rc} ${stdout}= Run and Return RC and Output osm vnfpkg-create ${overrides} ${vnfd_pkg} --override '${override_fields}'
97 log ${stdout}
98 Should Be Equal As Integers ${rc} ${success_return_code}
99 ${lines}= Get Line Count ${stdout}
100 ${last}= Evaluate ${lines} - 1
101 ${id}= Get Line ${stdout} ${last}
102 [Return] ${id}
103
104
Felipe Vicensf96bb452020-06-22 08:12:30 +0200105Delete VNFD
106 [Arguments] ${vnfd_id}
107
garciadeblasf70f5362020-09-29 15:38:47 +0000108 ${rc} ${stdout}= Run and Return RC and Output osm vnfpkg-delete ${vnfd_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200109 log ${stdout}
110 Should Be Equal As Integers ${rc} ${success_return_code}
111 WAIT UNTIL KEYWORD SUCCEEDS ${delete_max_wait_time} ${delete_pol_time} Check For VNFD ${vnfd_id}
112
113
garciadeblas499c8672021-03-25 11:51:08 +0100114Assert Failure Delete VNFD
115 [Documentation] Deletes a NF Package that cannot be deleted and asserts the failure
Felipe Vicensf96bb452020-06-22 08:12:30 +0200116 [Arguments] ${vnfd_id}
117
garciadeblas499c8672021-03-25 11:51:08 +0100118 ${rc} ${stdout}= Run and Return RC and Output osm vnfpkg-delete ${vnfd_id}
119 log ${stdout}
120 Should Be Equal As Integers ${rc} ${failure_return_code}
121 Should Contain ${stdout} 409 msg=Expected Conflict values=False
122 WAIT UNTIL KEYWORD SUCCEEDS ${delete_max_wait_time} ${delete_pol_time} Check For VNFD ${vnfd_id} True
123
124
125Check For VNFD
126 [Arguments] ${vnfd_id} ${exists}=False
127
garciadeblasf70f5362020-09-29 15:38:47 +0000128 ${rc} ${stdout}= Run and Return RC and Output osm vnfpkg-list | awk '{print $2}' | grep ${vnfd_id}
garciadeblas499c8672021-03-25 11:51:08 +0100129 Run Keyword If ${exists} Should Be Equal As Strings ${stdout} ${vnfd_id}
130 ... ELSE Should Not Be Equal As Strings ${stdout} ${vnfd_id}
131