blob: a80ae708875e9976d894db02b323fcb79647a63c [file] [log] [blame]
Mike Marchetti08f04282017-05-04 16:43:09 -04001# Copyright 2017 Sandvine
2#
3# All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17import pytest
18import time
19
20
21@pytest.mark.vim
22@pytest.mark.openstack
kasar0e4186c2017-08-16 23:40:41 -070023@pytest.mark.vmware
Mike Marchetti08f04282017-05-04 16:43:09 -040024class TestClass(object):
25
26 def test_empty_vim(self,osm):
27 assert not osm.get_api().vim.list()
28
29 @pytest.fixture(scope='function')
30 def cleanup_test_add_vim_account(self,osm,request):
31 def teardown():
32 try:
Mike Marchettiae7f5f32017-11-17 10:31:43 -050033 for vim in osm.get_api().vim.list(False):
34 osm.get_api().vim.delete(vim['name'])
Mike Marchetti08f04282017-05-04 16:43:09 -040035 except:
36 pass
37 request.addfinalizer(teardown)
38
39 @pytest.mark.openstack
Mike Marchettiae7f5f32017-11-17 10:31:43 -050040 @pytest.mark.smoke
Mike Marchetti08f04282017-05-04 16:43:09 -040041 def test_add_vim_account(self,osm,openstack,cleanup_test_add_vim_account):
Mike Marchettiae7f5f32017-11-17 10:31:43 -050042 os_access = {}
43 vim_name = 'helloworld-os'
44 os_access['vim-url'] = 'https://169.254.169.245/'
45 os_access['vim-username'] = 'pytest2'
46 os_access['vim-password'] = 'fred'
47 os_access['vim-tenant-name'] = 'pytest3'
48 os_access['vim-type'] = 'openstack'
49 os_access['description'] = 'a test vim'
50 assert not osm.get_api().vim.create(vim_name,os_access)
Mike Marchetti08f04282017-05-04 16:43:09 -040051
Mike Marchettiae7f5f32017-11-17 10:31:43 -050052 resp=osm.get_api().vim.get(vim_name)
53 assert resp['name'] == vim_name
Mike Marchettidbada222018-08-14 12:13:48 -040054 assert resp['vim_type'] == 'openstack'
kasarf834e202017-08-24 05:21:43 -070055 assert resp['vim_url'] == os_access['vim-url']
Mike Marchettidbada222018-08-14 12:13:48 -040056 assert resp['vim_user'] == os_access['vim-username']
57 assert resp['vim_tenant_name'] == os_access['vim-tenant-name']
Mike Marchettiae7f5f32017-11-17 10:31:43 -050058 assert not osm.get_api().vim.delete(vim_name)
kasar0e4186c2017-08-16 23:40:41 -070059
60 @pytest.mark.vmware
Mike Marchetti344c7c42018-01-16 11:25:30 -050061 #@pytest.mark.smoke
kasar0e4186c2017-08-16 23:40:41 -070062 def test_add_vim_account_vmware(self,osm,vmware,cleanup_test_add_vim_account):
Mike Marchettiae7f5f32017-11-17 10:31:43 -050063 os_access = {}
64 vim_name = 'helloworld-vmware'
65 os_access['vim-url'] = 'https://169.254.169.245/'
66 os_access['vim-username'] = 'pytest2'
67 os_access['vim-password'] = 'fred'
68 os_access['vim-tenant-name'] = 'pytest3'
69 os_access['vim-type'] = 'vmware'
70 os_access['description'] = 'a test vim'
71 assert not osm.get_api().vim.create(vim_name,os_access)
kasar0e4186c2017-08-16 23:40:41 -070072
Mike Marchettiae7f5f32017-11-17 10:31:43 -050073 resp=osm.get_api().vim.get(vim_name)
74 assert resp['name'] == vim_name
Mike Marchettidbada222018-08-14 12:13:48 -040075 assert resp['vim_type'] == 'vmware'
kasarf834e202017-08-24 05:21:43 -070076 assert resp['vim_url'] == os_access['vim-url']
Mike Marchettidbada222018-08-14 12:13:48 -040077 assert resp['vim_user'] == os_access['vim-username']
78 assert resp['vim_tenant_name'] == os_access['vim-tenant-name']
Mike Marchettiae7f5f32017-11-17 10:31:43 -050079 assert not osm.get_api().vim.delete(vim_name)
80
Mike Marchetti344c7c42018-01-16 11:25:30 -050081 #@pytest.mark.smoke
Mike Marchettiae7f5f32017-11-17 10:31:43 -050082 def test_add_multiple_accounts(self,osm,cleanup_test_add_vim_account):
83 os_access = {}
84 vims = [ {'name': 'testvim1', 'vim-type': 'openstack'}, {'name': 'testvim2','vim-type': 'vmware'} ]
85 os_access['vim-url'] = 'https://169.254.169.245/'
86 os_access['vim-username'] = 'pytest2'
87 os_access['vim-password'] = 'fred'
88 os_access['vim-tenant-name'] = 'pytest3'
89 os_access['description'] = 'a test vim'
90
91 for vim in vims:
92 os_access['vim-type'] = vim['vim-type']
93 assert not osm.get_api().vim.create(vim['name'],os_access)
94 resp=osm.get_api().vim.get(vim['name'])
95 assert resp['name'] == vim['name']
Mike Marchettidbada222018-08-14 12:13:48 -040096 assert resp['vim_type'] == vim['vim-type']
Mike Marchettiae7f5f32017-11-17 10:31:43 -050097 assert resp['vim_url'] == os_access['vim-url']
Mike Marchettidbada222018-08-14 12:13:48 -040098 assert resp['vim_user'] == os_access['vim-username']
99 assert resp['vim_tenant_name'] == os_access['vim-tenant-name']
Mike Marchettiae7f5f32017-11-17 10:31:43 -0500100
101 for vim in osm.get_api().vim.list(False):
102 osm.get_api().vim.delete(vim['name'])