4 # Copyright 2017 RIFT.IO Inc
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 @file test_mro_pingpong.py
20 @author Paul Laidler (Paul.Laidler@riftio.com)
22 @brief Multi-RO test that instantiates two ping pong instances on seperate ROs
36 from contextlib
import contextmanager
39 import rift
.auto
.session
40 import rift
.auto
.descriptor
42 gi
.require_version('RwVnfrYang', '1.0')
43 from gi
.repository
import (
52 gi
.require_version('RwKeyspec', '1.0')
53 from gi
.repository
.RwKeyspec
import quoted_key
55 logging
.basicConfig(level
=logging
.DEBUG
)
56 logger
= logging
.getLogger(__name__
)
58 @pytest.mark
.setup('pingpong')
59 @pytest.mark
.depends('launchpad')
60 @pytest.mark
.incremental
61 class TestSetupPingpong(object):
62 def test_onboard(self
, mgmt_session
, descriptors
):
63 for descriptor
in descriptors
:
64 rift
.auto
.descriptor
.onboard(mgmt_session
, descriptor
)
66 def test_instantiate(self
, mgmt_session
, ro_account_info
):
67 catalog
= mgmt_session
.proxy(RwProjectNsdYang
).get_config("/rw-project:project[rw-project:name='default']/nsd-catalog")
70 for resource_orchestrator
, account_info
in ro_account_info
.items():
71 for datacenter
in account_info
['datacenters']:
72 nsr
= rift
.auto
.descriptor
.create_nsr(
74 "pingpong_{}".format(instance_id
),
76 resource_orchestrator
=resource_orchestrator
78 mgmt_session
.proxy(RwNsrYang
).create_config("/rw-project:project[rw-project:name='default']/ns-instance-config/nsr", nsr
)
82 @pytest.mark
.depends('pingpong')
83 @pytest.mark
.incremental
85 def test_service_started(self
, mgmt_session
):
86 nsr_opdata
= mgmt_session
.proxy(RwNsrYang
).get("/rw-project:project[rw-project:name='default']/ns-instance-opdata")
91 "/rw-project:project[rw-project:name='default']/ns-instance-opdata/nsr[ns-instance-config-ref={ns_instance_config_ref}]/operational-status"
93 ns_instance_config_ref
=quoted_key(nsr
.ns_instance_config_ref
)
95 mgmt_session
.proxy(RwNsrYang
).wait_for(xpath
, "running", fail_on
=['failed'], timeout
=300)
97 def test_service_configured(self
, mgmt_session
):
98 nsr_opdata
= mgmt_session
.proxy(RwNsrYang
).get("/rw-project:project[rw-project:name='default']/ns-instance-opdata")
103 "/rw-project:project[rw-project:name='default']/ns-instance-opdata/nsr[ns-instance-config-ref={}]/config-status"
105 quoted_key(nsr
.ns_instance_config_ref
)
107 mgmt_session
.proxy(RwNsrYang
).wait_for(xpath
, "configured", fail_on
=['failed'], timeout
=300)
109 @pytest.mark
.depends('pingpong')
110 @pytest.mark
.teardown('pingpong')
111 @pytest.mark
.incremental
112 class TestTeardownPingpong(object):
113 def test_teardown(self
, mgmt_session
):
114 ns_instance_config
= mgmt_session
.proxy(RwNsrYang
).get_config("/rw-project:project[rw-project:name='default']/ns-instance-config")
115 for nsr
in ns_instance_config
.nsr
:
116 mgmt_session
.proxy(RwNsrYang
).delete_config("/rw-project:project[rw-project:name='default']/ns-instance-config/nsr[id={}]".format(quoted_key(nsr
.id)))
119 vnfr_catalog
= mgmt_session
.proxy(RwVnfrYang
).get("/rw-project:project[rw-project:name='default']/vnfr-catalog")
120 assert vnfr_catalog
is None or len(vnfr_catalog
.vnfr
) == 0