4 # Copyright 2016 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_launchpad.py
20 @author Paul Laidler (Paul.Laidler@riftio.com)
22 @brief System test of basic launchpad functionality
28 gi
.require_version('RwsdnalYang', '1.0')
30 from gi
.repository
import RwsdnalYang
31 from gi
.repository
import RwSdnYang
32 from gi
.repository
import RwRoAccountYang
34 gi
.require_version('RwKeyspec', '1.0')
35 from gi
.repository
.RwKeyspec
import quoted_key
37 @pytest.mark
.setup('sdn')
38 @pytest.mark
.feature('sdn')
39 @pytest.mark
.incremental
41 def test_create_odl_sdn_account(self
, mgmt_session
, sdn_account_name
, sdn_account_type
):
42 '''Configure sdn account
45 SDN name and accout type.
47 proxy
= mgmt_session
.proxy(RwsdnalYang
)
48 sdn_account
= RwsdnalYang
.YangData_RwProject_Project_SdnAccounts_SdnAccountList(
49 name
=sdn_account_name
,
50 account_type
=sdn_account_type
)
51 xpath
= "/rw-project:project[rw-project:name='default']/sdn-accounts/sdn-account-list[name=%s]" % quoted_key(sdn_account_name
)
52 proxy
.replace_config(xpath
, sdn_account
)
53 sdn_account
= proxy
.get(xpath
)
55 def test_create_openstack_sdn_account(self
, mgmt_session
, openstack_sdn_account_name
, cloud_account
):
56 '''Configure sdn account
59 SDN name and account type.
61 proxy
= mgmt_session
.proxy(RwSdnYang
)
62 sdn_account
= RwSdnYang
.YangData_RwProject_Project_Sdn_Account
.from_dict({
63 'name': openstack_sdn_account_name
,
64 'account_type': 'openstack',
66 'admin': cloud_account
.openstack
.admin
,
67 'key': cloud_account
.openstack
.key
,
68 'secret': cloud_account
.openstack
.secret
,
69 'auth_url': cloud_account
.openstack
.auth_url
,
70 'tenant': cloud_account
.openstack
.tenant
,
71 'project_domain': cloud_account
.openstack
.project_domain
,
72 'user_domain': cloud_account
.openstack
.user_domain
,
73 'region': cloud_account
.openstack
.region
,
76 xpath
= "/rw-project:project[rw-project:name='default']/sdn/account[name={}]".format(quoted_key(openstack_sdn_account_name
))
77 proxy
.replace_config(xpath
, sdn_account
)
78 sdn_account
= proxy
.get(xpath
)
80 @pytest.mark
.depends('sdn')
81 @pytest.mark
.feature('sdn')
82 @pytest.mark
.incremental
84 def test_show_odl_sdn_account(self
, mgmt_session
, sdn_account_name
, sdn_account_type
):
85 '''Showing sdn account configuration
88 sdn_account.account_type is what was configured
90 proxy
= mgmt_session
.proxy(RwsdnalYang
)
91 xpath
= "/rw-project:project[rw-project:name='default']/sdn-accounts/sdn-account-list[name=%s]" % quoted_key(sdn_account_name
)
92 sdn_account
= proxy
.get_config(xpath
)
93 assert sdn_account
.account_type
== sdn_account_type
95 def test_openstack_sdn_account_connection_status(self
, mgmt_session
, openstack_sdn_account_name
):
96 '''Verify connection status on openstack sdn account
99 openstack sdn account is successfully connected
101 proxy
= mgmt_session
.proxy(RwSdnYang
)
103 '/rw-project:project[rw-project:name="default"]/sdn/account[name={}]/connection-status/status'.format(quoted_key(openstack_sdn_account_name
)),
108 @pytest.mark
.teardown('sdn')
109 @pytest.mark
.feature('sdn')
110 @pytest.mark
.incremental
111 class TestSdnTeardown
:
112 def test_delete_odl_sdn_account(self
, mgmt_session
, sdn_account_name
):
113 '''Unconfigure sdn account'''
114 proxy
= mgmt_session
.proxy(RwsdnalYang
)
115 xpath
= "/rw-project:project[rw-project:name='default']/sdn-accounts/sdn-account-list[name=%s]" % quoted_key(sdn_account_name
)
116 proxy
.delete_config(xpath
)
118 def test_delete_openstack_sdn_account(self
, mgmt_session
, openstack_sdn_account_name
):
119 '''Unconfigure sdn account'''
120 proxy
= mgmt_session
.proxy(RwSdnYang
)
121 xpath
= '/rw-project:project[rw-project:name="default"]/sdn/account[name={}]'.format(quoted_key(openstack_sdn_account_name
))
122 proxy
.delete_config(xpath
)
125 @pytest.mark
.setup('launchpad')
126 @pytest.mark
.depends('sdn')
127 @pytest.mark
.usefixtures('cloud_account')
128 @pytest.mark
.incremental
129 class TestLaunchpadSetup
:
130 def test_create_cloud_accounts(self
, mgmt_session
, cloud_module
, cloud_xpath
, cloud_accounts
, l2_port_chaining
, openstack_sdn_account_name
):
131 '''Configure cloud accounts
134 Cloud name and cloud type details
136 proxy
= mgmt_session
.proxy(cloud_module
)
137 for cloud_account
in cloud_accounts
:
139 cloud_account
.sdn_account
= openstack_sdn_account_name
140 xpath
= '{}[name={}]'.format(cloud_xpath
, quoted_key(cloud_account
.name
))
141 proxy
.replace_config(xpath
, cloud_account
)
142 response
= proxy
.get(xpath
)
143 assert response
.name
== cloud_account
.name
144 assert response
.account_type
== cloud_account
.account_type
146 def test_account_connection_status(self
, mgmt_session
, cloud_module
, cloud_xpath
, cloud_accounts
):
147 '''Verify connection status on each cloud account
150 Cloud account is successfully connected
152 proxy
= mgmt_session
.proxy(cloud_module
)
153 for cloud_account
in cloud_accounts
:
155 '{}[name={}]/connection-status/status'.format(cloud_xpath
, quoted_key(cloud_account
.name
)),
160 @pytest.mark
.feature('openmano')
161 def test_create_ro_accounts(self
, mgmt_session
, ro_accounts
):
162 for name
, ro_account
in ro_accounts
.items():
163 mgmt_session
.proxy(RwRoAccountYang
).create_config('/rw-project:project[rw-project:name="default"]/ro-account/account', ro_account
)
165 @pytest.mark
.feature('openmano')
166 def test_ro_account_connection_status(self
, mgmt_session
, ro_accounts
):
167 for name
, ro_account
in ro_accounts
.items():
168 mgmt_session
.proxy(RwRoAccountYang
).wait_for((
169 '/rw-project:project[rw-project:name="default"]'
170 '/ro-account-state/account[name={account_name}]/connection-status/status'
171 ).format(account_name
=quoted_key(ro_account
.name
)),
176 @pytest.mark
.teardown('launchpad')
177 @pytest.mark
.usefixtures('cloud_account')
178 @pytest.mark
.incremental
179 class TestLaunchpadTeardown
:
180 def test_delete_cloud_accounts(self
, mgmt_session
, cloud_module
, cloud_xpath
, cloud_accounts
):
181 '''Unconfigure cloud_account'''
182 proxy
= mgmt_session
.proxy(cloud_module
)
183 for cloud_account
in cloud_accounts
:
184 xpath
= "{}[name={}]".format(cloud_xpath
, quoted_key(cloud_account
.name
))
185 proxy
.delete_config(xpath
)
187 @pytest.mark
.feature('openmano')
188 def test_delete_ro_accounts(self
, mgmt_session
, ro_accounts
):
189 for name
, ro_account
in ro_accounts
.items():
190 xpath
= "/rw-project:project[rw-project:name='default']/ro-account/account[name={}]"
191 mgmt_session
.proxy(RwRoAccountYang
).delete_config(xpath
.format(quoted_key(name
)))