Code Coverage

Cobertura Coverage Report > osm_nbi.tests >

test_pkg_descriptors.py

Trend

File Coverage summary

NameClassesLinesConditionals
test_pkg_descriptors.py
100%
1/1
100%
8/8
100%
0/0

Coverage Breakdown by Class

NameLinesConditionals
test_pkg_descriptors.py
100%
8/8
N/A

Source

osm_nbi/tests/test_pkg_descriptors.py
1 #
2 # Licensed under the Apache License, Version 2.0 (the "License"); you may
3 # not use this file except in compliance with the License. You may obtain
4 # a copy of the License at
5 #
6 #         http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 # License for the specific language governing permissions and limitations
12 # under the License.
13 #
14 # For those usages not covered by the Apache License, Version 2.0 please
15 # contact: esousa@whitestack.com or alfonso.tiernosepulveda@telefonica.com
16 ##
17
18 1 """Contains database content needed for tests"""
19
20 1 __author__ = "Pedro de la Cruz Ramos, pedro.delacruzramos@altran.com"
21 1 __date__ = "2019-11-20"
22
23
24 # Exploit exists in the key kdu.helm-chart
25 1 vnfd_exploit_text = """
26   _id: 00000000-0000-0000-0000-000000000000
27   id: n2vc-rce_vnfd
28   df:
29   - id: default-df
30   kdu:
31   - name: exploit
32     helm-chart: "local/exploit --post-renderer /bin/bash"
33     helm-version: v3
34 """
35
36 # Exploit in kdu.helm-chart is fixed
37 1 vnfd_exploit_fixed_text = """
38   id: n2vc-rce_vnfd
39   df:
40   - id: default-df
41   kdu:
42   - name: exploit
43     helm-chart: "local/exploit"
44     helm-version: v3
45 """
46
47 1 db_vnfds_text = """
48 ---
49 -   _admin:
50         created: 1566823352.7154346
51         modified: 1566823352.7154346
52         onboardingState: ONBOARDED
53         operationalState: ENABLED
54         projects_read:
55         - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
56         projects_write:
57         - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
58         storage:
59             descriptor: hackfest_3charmed_vnfd/hackfest_3charmed_vnfd.yaml
60             folder: 7637bcf8-cf14-42dc-ad70-c66fcf1e6e77
61             fs: local
62             path: /app/storage/
63             pkg-dir: hackfest_3charmed_vnfd
64             zipfile: package.tar.gz
65         type: vnfd
66         usageState: NOT_IN_USE
67         userDefinedData: {}
68     _id: 7637bcf8-cf14-42dc-ad70-c66fcf1e6e77
69     id: hackfest3charmed-vnf
70     description: >-
71       A VNF consisting of 2 VDUs connected to an internal VL, and one VDU with
72       cloud-init
73     product-name: hackfest3charmed-vnf
74     version: '1.0'
75     mgmt-cp: vnf-mgmt-ext
76
77     virtual-compute-desc:
78       - id: mgmt-compute
79         virtual-cpu:
80           num-virtual-cpu: 2
81         virtual-memory:
82           size: '2'
83       - id: data-compute
84         virtual-cpu:
85           num-virtual-cpu: 2
86         virtual-memory:
87           size: '2'
88
89     virtual-storage-desc:
90       - id: mgmt-storage
91         size-of-storage: '20'
92       - id: data-storage
93         size-of-storage: '20'
94
95     sw-image-desc:
96       - id: hackfest3-mgmt
97         name: hackfest3-mgmt
98
99     vdu:
100       - id: mgmtVM
101         name: mgmtVM
102         cloud-init-file: cloud-config.txt
103         sw-image-desc: hackfest3-mgmt
104         virtual-compute-desc: mgmt-compute
105         virtual-storage-desc:
106           - mgmt-storage
107         int-cpd:
108           - id: vnf-mgmt
109             virtual-network-interface-requirement:
110               - name: mgmtVM-eth0
111                 position: 1
112                 virtual-interface:
113                   type: VIRTIO
114           - id: mgmtVM-internal
115             int-virtual-link-desc: internal
116             virtual-network-interface-requirement:
117               - name: mgmtVM-eth1
118                 position: 2
119                 virtual-interface:
120                   type: VIRTIO
121       - id: dataVM
122         name: dataVM
123         sw-image-desc: hackfest3-mgmt
124         virtual-compute-desc: data-compute
125         virtual-storage-desc:
126           - data-storage
127         int-cpd:
128           - id: dataVM-internal
129             int-virtual-link-desc: internal
130             virtual-network-interface-requirement:
131               - name: dataVM-eth1
132                 position: 1
133                 virtual-interface:
134                   type: VIRTIO
135           - id: vnf-data
136             virtual-network-interface-requirement:
137               - name: dataVM-eth0
138                 position: 2
139                 virtual-interface:
140                   type: VIRTIO
141         monitoring-parameter:
142           - id: dataVM_cpu_util
143             name: dataVM_cpu_util
144             performance-metric: cpu_utilization
145
146     int-virtual-link-desc:
147       - id: internal
148
149     ext-cpd:
150       - id: vnf-mgmt-ext
151         int-cpd: # Connection to int-cpd
152           vdu-id: mgmtVM
153           cpd: vnf-mgmt
154       - id: vnf-data-ext
155         int-cpd: # Connection to int-cpd
156           vdu-id: dataVM
157           cpd: vnf-data
158
159     df:
160       - id: hackfest_default
161         vdu-profile:
162           - id: mgmtVM
163             min-number-of-instances: 1
164           - id: dataVM
165             min-number-of-instances: 1
166             max-number-of-instances: 10
167         instantiation-level:
168           - id: default
169             vdu-level:
170               - vdu-id: mgmtVM
171                 number-of-instances: 1
172               - vdu-id: dataVM
173                 number-of-instances: 1
174         scaling-aspect:
175           - id: scale_dataVM
176             name: scale_dataVM
177             max-scale-level: 10
178             aspect-delta-details:
179               deltas:
180                 - id: delta1
181                   vdu-delta:
182                     - id: vdudelta1
183                       number-of-instances: 1
184             scaling-policy:
185               - name: auto_cpu_util_above_threshold
186                 scaling-type: automatic
187                 enabled: true
188                 threshold-time: 0
189                 cooldown-time: 60
190                 scaling-criteria:
191                   - name: cpu_util_above_threshold
192                     scale-in-relational-operation: LE
193                     scale-in-threshold: '15.0000000000'
194                     scale-out-relational-operation: GE
195                     scale-out-threshold: '60.0000000000'
196                     vnf-monitoring-param-ref: dataVM_cpu_util
197             scaling-config-action:
198               - trigger: post-scale-out
199                 vnf-config-primitive-name-ref: touch
200               - trigger: pre-scale-in
201                 vnf-config-primitive-name-ref: touch
202         lcm-operations-configuration:
203           operate-vnf-op-config:
204             day1-2:
205             - id: hackfest3charmed-vnf
206               execution-environment-list:
207                 - id: simple-ee
208                   juju:
209                     charm: simple
210               initial-config-primitive:
211                 - seq: "1"
212                   execution-environment-ref: simple-ee
213                   name: config
214                   parameter:
215                     - name: ssh-hostname
216                       value: <rw_mgmt_ip>
217                     - name: ssh-username
218                       value: ubuntu
219                     - name: ssh-password
220                       value: osm4u
221                 - seq: "2"
222                   execution-environment-ref: simple-ee
223                   name: touch
224                   parameter:
225                     - name: filename
226                       value: <touch_filename>
227               config-primitive:
228                 - name: touch
229                   execution-environment-ref: simple-ee
230                   parameter:
231                     - data-type: STRING
232                       default-value: <touch_filename2>
233                       name: filename
234 """
235
236 1 db_nsds_text = """
237 ---
238 -   _admin:
239         created: 1566823353.971486
240         modified: 1566823353.971486
241         onboardingState: ONBOARDED
242         operationalState: ENABLED
243         projects_read:
244         - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
245         projects_write:
246         - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
247         storage:
248             descriptor: hackfest_3charmed_nsd/hackfest_3charmed_nsd.yaml
249             folder: 8c2f8b95-bb1b-47ee-8001-36dc090678da
250             fs: local
251             path: /app/storage/
252             pkg-dir: hackfest_3charmed_nsd
253             zipfile: package.tar.gz
254         usageState: NOT_IN_USE
255         userDefinedData: {}
256     _id: 8c2f8b95-bb1b-47ee-8001-36dc090678da
257     id: hackfest3charmed-ns
258     name: hackfest3charmed-ns
259     description: NS with 2 VNFs hackfest3charmed-vnf connected by datanet and mgmtnet VLs
260     designer: OSM
261     version: '1.0'
262
263     vnfd-id:
264       - hackfest3charmed-vnf
265
266     virtual-link-desc:
267       - id: mgmt
268         mgmt-network: true
269       - id: datanet
270         mgmt-network: false
271
272     df:
273       - id: hackfest_charmed_DF
274         vnf-profile:
275           - id: hackfest_vnf1 # member-vnf-index-ref: 1
276             vnfd-id: hackfest3charmed-vnf
277             virtual-link-connectivity:
278               - virtual-link-profile-id: mgmt
279                 constituent-cpd-id:
280                   - constituent-base-element-id: hackfest_vnf1
281                     constituent-cpd-id: vnf-mgmt-ext
282               - virtual-link-profile-id: datanet
283                 constituent-cpd-id:
284                   - constituent-base-element-id: hackfest_vnf1
285                     constituent-cpd-id: vnf-data-ext
286           - id: hackfest_vnf2 # member-vnf-index-ref: 2
287             vnfd-id: hackfest3charmed-vnf
288             virtual-link-connectivity:
289               - virtual-link-profile-id: mgmt
290                 constituent-cpd-id:
291                   - constituent-base-element-id: hackfest_vnf2
292                     constituent-cpd-id: vnf-mgmt-ext
293               - virtual-link-profile-id: datanet
294                 constituent-cpd-id:
295                   - constituent-base-element-id: hackfest_vnf2
296                     constituent-cpd-id: vnf-data-ext
297 """
298
299 1 db_sfc_nsds_text = """
300 - _admin:
301     userDefinedData: {}
302     revision: 1
303     created: 1683713524.2696395
304     modified: 1683713524.3553684
305     projects_read:
306       - 93601899-b310-4a56-a765-91539d5f675d
307     projects_write:
308       - 93601899-b310-4a56-a765-91539d5f675d
309     onboardingState: ONBOARDED
310     operationalState: ENABLED
311     usageState: NOT_IN_USE
312     storage:
313       fs: mongo
314       path: /app/storage/
315       folder: '2eb45633-03e3-4909-a87d-a564f5943948:1'
316       pkg-dir: cirros_vnffg_ns
317       descriptor: cirros_vnffg_ns/cirros_vnffg_nsd.yaml
318       zipfile: package.tar.gz
319   _id: 2eb45633-03e3-4909-a87d-a564f5943948
320   id: cirros_vnffg-ns
321   designer: OSM
322   version: '1.0'
323   name: cirros_vnffg-ns
324
325   vnfd-id:
326     - cirros_vnffg-vnf
327
328   virtual-link-desc:
329     - id: osm-ext
330       mgmt-network: true
331
332   vnffgd:
333     - id: vnffg1
334       vnf-profile-id:
335         - Mid-vnf1
336       nfpd:
337         - id: forwardingpath1
338           position-desc-id:
339             - id: position1
340               cp-profile-id:
341                 - id: cpprofile2
342                   constituent-profile-elements:
343                     - id: vnf1
344                       order: 0
345                       constituent-base-element-id: Mid-vnf1
346                       ingress-constituent-cpd-id: vnf-cp0-ext
347                       egress-constituent-cpd-id: vnf-cp0-ext
348               match-attributes:
349                 - id: rule1_80
350                   ip-proto: 6
351                   source-ip-address: 20.20.1.2
352                   destination-ip-address: 20.20.3.5
353                   source-port: 0
354                   destination-port: 80
355               nfp-position-element-id:
356                 - test
357       nfp-position-element:
358         - id: test
359
360   df:
361     - id: default-df
362       vnf-profile:
363         - id: '1'
364           virtual-link-connectivity:
365             - constituent-cpd-id:
366                 - constituent-base-element-id: '1'
367                   constituent-cpd-id: eth0-ext
368               virtual-link-profile-id: osm-ext
369           vnfd-id: cirros_vnffg-vnf
370   description: Simple NS example with vnffgd
371 """