Merge "Added vim-emu install option to installer."
[osm/devops.git] / systest / testcases / vim / test_vim.py
1 # 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
17 import pytest
18 import time
19
20
21 @pytest.mark.vim
22 @pytest.mark.openstack
23 @pytest.mark.vmware
24 class 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:
33 for vim in osm.get_api().vim.list(False):
34 osm.get_api().vim.delete(vim['name'])
35 except:
36 pass
37 request.addfinalizer(teardown)
38
39 @pytest.mark.openstack
40 @pytest.mark.smoke
41 def test_add_vim_account(self,osm,openstack,cleanup_test_add_vim_account):
42 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)
51
52 resp=osm.get_api().vim.get(vim_name)
53 assert resp['name'] == vim_name
54 assert resp['type'] == 'openstack'
55 assert resp['vim_url'] == os_access['vim-url']
56 assert resp['vim_url_admin'] == os_access['vim-url']
57 assert resp['vim_tenants'][0]['user'] == os_access['vim-username']
58 assert resp['vim_tenants'][0]['vim_tenant_name'] == os_access['vim-tenant-name']
59 assert not osm.get_api().vim.delete(vim_name)
60
61 @pytest.mark.vmware
62 #@pytest.mark.smoke
63 def test_add_vim_account_vmware(self,osm,vmware,cleanup_test_add_vim_account):
64 os_access = {}
65 vim_name = 'helloworld-vmware'
66 os_access['vim-url'] = 'https://169.254.169.245/'
67 os_access['vim-username'] = 'pytest2'
68 os_access['vim-password'] = 'fred'
69 os_access['vim-tenant-name'] = 'pytest3'
70 os_access['vim-type'] = 'vmware'
71 os_access['description'] = 'a test vim'
72 assert not osm.get_api().vim.create(vim_name,os_access)
73
74 resp=osm.get_api().vim.get(vim_name)
75 assert resp['name'] == vim_name
76 assert resp['type'] == 'vmware'
77 assert resp['vim_url'] == os_access['vim-url']
78 assert resp['vim_url_admin'] == os_access['vim-url']
79 assert resp['vim_tenants'][0]['user'] == os_access['vim-username']
80 assert resp['vim_tenants'][0]['vim_tenant_name'] == os_access['vim-tenant-name']
81
82 assert not osm.get_api().vim.delete(vim_name)
83
84 #@pytest.mark.smoke
85 def test_add_multiple_accounts(self,osm,cleanup_test_add_vim_account):
86 os_access = {}
87 vims = [ {'name': 'testvim1', 'vim-type': 'openstack'}, {'name': 'testvim2','vim-type': 'vmware'} ]
88 os_access['vim-url'] = 'https://169.254.169.245/'
89 os_access['vim-username'] = 'pytest2'
90 os_access['vim-password'] = 'fred'
91 os_access['vim-tenant-name'] = 'pytest3'
92 os_access['description'] = 'a test vim'
93
94 for vim in vims:
95 os_access['vim-type'] = vim['vim-type']
96 assert not osm.get_api().vim.create(vim['name'],os_access)
97 resp=osm.get_api().vim.get(vim['name'])
98 assert resp['name'] == vim['name']
99 assert resp['type'] == vim['vim-type']
100 assert resp['vim_url'] == os_access['vim-url']
101 assert resp['vim_url_admin'] == os_access['vim-url']
102 assert resp['vim_tenants'][0]['user'] == os_access['vim-username']
103 assert resp['vim_tenants'][0]['vim_tenant_name'] == os_access['vim-tenant-name']
104
105 for vim in osm.get_api().vim.list(False):
106 osm.get_api().vim.delete(vim['name'])