-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathtest_computeresource_osp.py
More file actions
173 lines (135 loc) · 5.54 KB
/
Copy pathtest_computeresource_osp.py
File metadata and controls
173 lines (135 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
"""
:Requirement: Computeresource
:CaseAutomation: Automated
:CaseComponent: ComputeResources-OpenStack
:Team: Rocket
:CaseImportance: High
"""
from box import Box
from fauxfactory import gen_string
import pytest
from robottelo.config import settings
from robottelo.exceptions import CLIReturnCodeError
OSP_SETTINGS = Box(
username=settings.osp.username,
password=settings.osp.password,
tenant=settings.osp.tenant,
project_domain_id=settings.osp.project_domain_id,
)
class TestOSPComputeResourceTestCase:
"""OSPComputeResource CLI tests."""
def cr_cleanup(self, id_type, value, target_sat):
"""Finalizer for removing CR from Satellite.
This should remove ssh key pairs from OSP in case of test fail.
"""
target_sat.cli.ComputeResource.delete({id_type: value})
assert not target_sat.cli.ComputeResource.exists(search=(id_type, value))
@pytest.fixture
def osp_version(request):
versions = {'osp16': settings.osp.api_url.osp16, 'osp17': settings.osp.api_url.osp17}
return versions[getattr(request, 'param', 'osp16')]
@pytest.mark.upgrade
@pytest.mark.parametrize('osp_version', ['osp16', 'osp17'], indirect=True)
@pytest.mark.parametrize(
'id_type',
['id', 'name'],
)
def test_crud_and_duplicate_name(self, request, id_type, osp_version, target_sat):
"""Create, list, update and delete Openstack compute resource
:id: caf60bad-999d-483e-807f-95f52f35085d
:expectedresults: OSP Compute resource can be created updated and deleted
:CaseImportance: Critical
:parametrized: yes
:BZ: 1579714
"""
# create
name = gen_string('alpha')
compute_resource = target_sat.cli.ComputeResource.create(
{
'name': name,
'provider': 'Openstack',
'user': OSP_SETTINGS.username,
'password': OSP_SETTINGS.password,
'tenant': OSP_SETTINGS.tenant,
'project-domain-id': OSP_SETTINGS.project_domain_id,
'url': osp_version,
}
)
request.addfinalizer(
lambda: self.cr_cleanup(id_type, compute_resource[id_type], target_sat)
)
assert compute_resource['name'] == name
assert target_sat.cli.ComputeResource.exists(search=(id_type, compute_resource[id_type]))
# negative create with same name
with pytest.raises(CLIReturnCodeError):
target_sat.cli.ComputeResource.create(
{
'name': name,
'provider': 'Openstack',
'user': OSP_SETTINGS.username,
'password': OSP_SETTINGS.password,
'tenant': OSP_SETTINGS.tenant,
'project-domain-id': OSP_SETTINGS.project_domain_id,
'url': osp_version,
}
)
# update
new_name = gen_string('alpha')
target_sat.cli.ComputeResource.update(
{id_type: compute_resource[id_type], 'new-name': new_name}
)
if id_type == 'name':
compute_resource = target_sat.cli.ComputeResource.info({'name': new_name})
else:
compute_resource = target_sat.cli.ComputeResource.info({'id': compute_resource['id']})
assert new_name == compute_resource['name']
def test_negative_create_osp_with_url(self, target_sat):
"""Attempt to create Openstack compute resource with invalid URL
:id: a6be8233-2641-4c87-8563-f48d6efbb6ac
:expectedresults: Compute resource is not created
:CaseImportance: Critical
:BZ: 1579714
"""
name = gen_string('alpha')
with pytest.raises(CLIReturnCodeError):
target_sat.cli.ComputeResource.create(
{
'name': name,
'provider': 'Openstack',
'user': OSP_SETTINGS.username,
'password': OSP_SETTINGS.password,
'tenant': OSP_SETTINGS.tenant,
'project-domain-id': OSP_SETTINGS.project_domain_id,
'url': 'invalid_url',
}
)
@pytest.mark.stubbed
def test_positive_provision_osp_with_host_group(self):
"""Provision a host on Openstack compute resource with
the help of hostgroup.
:id: d85df090-875f-4f2b-b0f2-708efd5f50f3
:setup: Hostgroup and provisioning setup like domain, subnet etc.
:steps:
1. Create a osp compute resource.
2. Create a hostgroup, with appropriate values
3. Use compute-attributes parameter to specify key-value parameters
regarding the virtual machine.
4. Provision the host.
:expectedresults: The host should be provisioned with host group
:CaseAutomation: NotAutomated
"""
@pytest.mark.stubbed
@pytest.mark.upgrade
def test_positive_provision_osp_without_host_group(self):
"""Provision a host on Openstack compute resource without
the help of hostgroup.
:id: 644000fc-a131-4df1-89ad-897f0c741f06
:setup: Provisioning setup like domain, subnet etc.
:steps:
1. Create a osp compute resource.
2. Use compute-attributes parameter to specify key-value parameters
regarding the virtual machine.
3. Provision the host.
:expectedresults: The host should be provisioned successfully
:CaseAutomation: NotAutomated
"""