| Jeremy Mordkoff | 6f07e6f | 2016-09-07 18:56:51 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | """ |
| 3 | # |
| 4 | # Copyright 2016 RIFT.IO Inc |
| 5 | # |
| 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 |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 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. |
| 17 | # |
| 18 | |
| 19 | @file test_launchpad.py |
| 20 | @author Paul Laidler (Paul.Laidler@riftio.com) |
| 21 | @date 07/07/2016 |
| 22 | @brief System test of basic launchpad functionality |
| 23 | """ |
| 24 | |
| 25 | import pytest |
| 26 | |
| 27 | import gi |
| 28 | gi.require_version('RwsdnYang', '1.0') |
| 29 | |
| 30 | from gi.repository import RwsdnYang |
| 31 | |
| 32 | @pytest.mark.setup('sdn') |
| 33 | @pytest.mark.feature('sdn') |
| 34 | @pytest.mark.incremental |
| 35 | class TestSdnSetup: |
| 36 | def test_create_odl_sdn_account(self, mgmt_session, sdn_account_name, sdn_account_type): |
| 37 | '''Configure sdn account |
| 38 | |
| 39 | Asserts: |
| 40 | SDN name and accout type. |
| 41 | ''' |
| 42 | proxy = mgmt_session.proxy(RwsdnYang) |
| 43 | sdn_account = RwsdnYang.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) |
| 49 | |
| 50 | @pytest.mark.depends('sdn') |
| 51 | @pytest.mark.feature('sdn') |
| 52 | @pytest.mark.incremental |
| 53 | class TestSdn: |
| 54 | def test_show_odl_sdn_account(self, mgmt_session, sdn_account_name, sdn_account_type): |
| 55 | '''Showing sdn account configuration |
| 56 | |
| 57 | Asserts: |
| 58 | sdn_account.account_type is what was configured |
| 59 | ''' |
| 60 | proxy = mgmt_session.proxy(RwsdnYang) |
| 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 |
| 64 | |
| 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(RwsdnYang) |
| 72 | xpath = "/sdn-accounts/sdn-account-list[name='%s']" % sdn_account_name |
| 73 | proxy.delete_config(xpath) |
| 74 | |
| 75 | |
| 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 |
| 82 | |
| 83 | Asserts: |
| 84 | Cloud name and cloud type details |
| 85 | ''' |
| 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 |
| 93 | |
| 94 | @pytest.mark.depends('launchpad') |
| 95 | @pytest.mark.usefixtures('cloud_account') |
| 96 | @pytest.mark.incremental |
| 97 | class TestLaunchpad: |
| 98 | def test_account_connection_status(self, mgmt_session, cloud_module, cloud_xpath, cloud_accounts): |
| 99 | '''Verify connection status on each cloud account |
| 100 | |
| 101 | Asserts: |
| 102 | Cloud account is successfully connected |
| 103 | ''' |
| 104 | proxy = mgmt_session.proxy(cloud_module) |
| 105 | for cloud_account in cloud_accounts: |
| 106 | proxy.wait_for( |
| 107 | '{}[name="{}"]/connection-status/status'.format(cloud_xpath, cloud_account.name), |
| 108 | 'success', |
| 109 | timeout=30, |
| 110 | fail_on=['failure']) |
| 111 | |
| 112 | |
| 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) |