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
32 @pytest.mark
.setup('sdn')
33 @pytest.mark
.feature('sdn')
34 @pytest.mark
.incremental
36 def test_create_odl_sdn_account(self
, mgmt_session
, sdn_account_name
, sdn_account_type
):
37 '''Configure sdn account
40 SDN name and accout type.
42 proxy
= mgmt_session
.proxy(RwsdnalYang
)
43 sdn_account
= RwsdnalYang
.SDNAccount(
44 name
=sdn_account_name
,
45 account_type
=sdn_account_type
)
46 xpath
= "/sdn-accounts/sdn-account-list[name='%s']" % sdn_account_name
47 proxy
.create_config(xpath
, sdn_account
)
48 sdn_account
= proxy
.get(xpath
)
50 @pytest.mark
.depends('sdn')
51 @pytest.mark
.feature('sdn')
52 @pytest.mark
.incremental
54 def test_show_odl_sdn_account(self
, mgmt_session
, sdn_account_name
, sdn_account_type
):
55 '''Showing sdn account configuration
58 sdn_account.account_type is what was configured
60 proxy
= mgmt_session
.proxy(RwsdnalYang
)
61 xpath
= "/sdn-accounts/sdn-account-list[name='%s']" % sdn_account_name
62 sdn_account
= proxy
.get_config(xpath
)
63 assert sdn_account
.account_type
== sdn_account_type
65 @pytest.mark
.teardown('sdn')
66 @pytest.mark
.feature('sdn')
67 @pytest.mark
.incremental
68 class TestSdnTeardown
:
69 def test_delete_odl_sdn_account(self
, mgmt_session
, sdn_account_name
):
70 '''Unconfigure sdn account'''
71 proxy
= mgmt_session
.proxy(RwsdnalYang
)
72 xpath
= "/sdn-accounts/sdn-account-list[name='%s']" % sdn_account_name
73 proxy
.delete_config(xpath
)
76 @pytest.mark
.setup('launchpad')
77 @pytest.mark
.usefixtures('cloud_account')
78 @pytest.mark
.incremental
79 class TestLaunchpadSetup
:
80 def test_create_cloud_accounts(self
, mgmt_session
, cloud_module
, cloud_xpath
, cloud_accounts
):
81 '''Configure cloud accounts
84 Cloud name and cloud type details
86 proxy
= mgmt_session
.proxy(cloud_module
)
87 for cloud_account
in cloud_accounts
:
88 xpath
= '{}[name="{}"]'.format(cloud_xpath
, cloud_account
.name
)
89 proxy
.replace_config(xpath
, cloud_account
)
90 response
= proxy
.get(xpath
)
91 assert response
.name
== cloud_account
.name
92 assert response
.account_type
== cloud_account
.account_type
94 @pytest.mark
.depends('launchpad')
95 @pytest.mark
.usefixtures('cloud_account')
96 @pytest.mark
.incremental
98 def test_account_connection_status(self
, mgmt_session
, cloud_module
, cloud_xpath
, cloud_accounts
):
99 '''Verify connection status on each cloud account
102 Cloud account is successfully connected
104 proxy
= mgmt_session
.proxy(cloud_module
)
105 for cloud_account
in cloud_accounts
:
107 '{}[name="{}"]/connection-status/status'.format(cloud_xpath
, cloud_account
.name
),
113 @pytest.mark
.teardown('launchpad')
114 @pytest.mark
.usefixtures('cloud_account')
115 @pytest.mark
.incremental
116 class TestLaunchpadTeardown
:
117 def test_delete_cloud_accounts(self
, mgmt_session
, cloud_module
, cloud_xpath
, cloud_accounts
):
118 '''Unconfigure cloud_account'''
119 proxy
= mgmt_session
.proxy(cloud_module
)
120 for cloud_account
in cloud_accounts
:
121 xpath
= "{}[name='{}']".format(cloud_xpath
, cloud_account
.name
)
122 proxy
.delete_config(xpath
)