-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_hitachi.py
More file actions
303 lines (270 loc) · 9.56 KB
/
Copy pathtest_hitachi.py
File metadata and controls
303 lines (270 loc) · 9.56 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import pytest
import keyring
'''@fixture
def hitachi():
from HitachiBlockAPI.Hitachi import RestAPI
return RestAPI()
'''
import json
from HitachiBlockAPI.Hitachi import RestAPI
#import the logger of the Hitachi.py Module
from HitachiBlockAPI.Hitachi import logger
#import the logging module to specify the logging level
import logging
#set logging level
logger.setLevel(logging.DEBUG)
#check if string is of json format
def is_json(myjson:str):
try:
json_object = json.loads(myjson)
except ValueError as e:
return False
return True
#PF REST API
#storage = RestAPI(fqdn_ip=keyring.get_password('HitachiBlockAPI', 'StorageIp'), username='hup', password=keyring.get_password('HitachiBlockAPI', 'hup'))
#serial_number = 0
# Ops Center CM REST API
storage = RestAPI(fqdn_ip=keyring.get_password('HitachiBlockAPI', 'OpsCenterIp'), port=keyring.get_password('HitachiBlockAPI', 'OpsCenterPort'), username='hup', password=keyring.get_password('HitachiBlockAPI', 'hup'))
serial_number = keyring.get_password('HitachiBlockAPI', 'StorageSerial')
portId='CL1-B'
ldevNumber=0
portId_hostGroupId='CL1-B,5'
replicationType='GAD'
@pytest.mark.storage_systems_get
def test_storage_systems_get():
result = storage.storage_systems_get()
#must be of type list
assert type(result) == dict
@pytest.mark.storage_device_id_set
def test_storage_device_id_set():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
@pytest.mark.storage_device_id_get
def test_storage_device_id_get():
result = storage.storage_device_id_get()
#must be of type list
assert type(result) == str
assert len(result) == 12
@pytest.mark.storage_details_get
def test_storage_details_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type str
assert type(result) == str
assert len(result) == 12
result = storage.storage_details_get()
#must be json compatible
assert type(result) == dict
@pytest.mark.storage_summaries_get
def test_storage_summaries_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type str
assert type(result) == str
assert len(result) == 12
result = storage.storage_summaries_get(timeout=90)
#must be json compatible
assert type(result) == dict
@pytest.mark.jobs_all
def test_jobs_all():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type str
assert type(result) == str
assert len(result) == 12
result = storage._jobs_get()
#must be of type list or None (empty job list)
if not result == None:
assert type(result) == list
def test_jobs_last_get():
result = storage._jobs_last_get()
#must be of type dict
assert type(result) == dict
#set variable for the next test
global jobId
jobId = str(result['jobId'])
def test_jobs_by_id_get():
result = storage._jobs_by_id_get(jobId=jobId)
#must be of type dict
assert type(result) == dict
@pytest.mark.session_all
def test_session_all():
def test_session_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type str
assert type(result) == str
assert len(result) == 12
result = storage._session_get()
assert type(result) == str
assert result == ''
def test_session_create():
result = storage._session_create()
assert type(result) == None
def test_session_get():
result = storage._session_get()
assert type(result) == list
def test_session_delete():
result = storage._session_delete()
assert type(result) == str
assert result == ''
@pytest.mark.resource_group
def test_resource_group_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type str
assert type(result) == str
assert len(result) == 12
result = storage.resource_group_get()
#must be of type dict
assert type(result) == dict
@pytest.mark.pools_get
def test_pools_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type str
assert type(result) == str
assert len(result) == 12
result = storage.pools_get()
#must be of type dict
assert type(result) == dict
@pytest.mark.pools_get_pool0
def test_pools_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.pools_get(poolId=0)
#must be of type dict
assert type(result) == dict
@pytest.mark.ports_get
def test_ports_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.ports_get(timeout=90)
#must be of type dict
assert type(result) == dict
@pytest.mark.ports_get_1port
def test_ports_get_1port():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.ports_get(portId=portId)
#must be of type dict
assert type(result) == dict
@pytest.mark.ldevs_get_1ldev
def test_ldevs_get_1ldev():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.ldevs_get(ldevNumber=ldevNumber)
#must be of type dict
assert type(result) == dict
@pytest.mark.ldevs_get
def test_ldevs_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.ldevs_get()
#must be of type dict
assert type(result) == dict
@pytest.mark.host_groups_one_port_get
def test_host_groups_one_port_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.host_groups_one_port_get(portId=portId)
#must be of type dict
assert type(result) == dict
@pytest.mark.host_groups_all_ports_get
def test_host_groups_all_ports_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.host_groups_all_ports_get()
#must be of type dict
assert type(result) == dict
@pytest.mark.luns_get_portId_hostGroupId
def test_luns_get_portId_hostGroupId():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.luns_get(portId_hostGroupId=portId_hostGroupId)
#must be of type dict
assert type(result) == dict
@pytest.mark.luns_one_port_get
def test_luns_one_port_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.luns_one_port_get(portId=portId)
#must be of type dict
assert type(result) == dict
@pytest.mark.luns_all_ports_get
def test_luns_all_ports_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.luns_all_ports_get()
#must be of type dict
assert type(result) == dict
@pytest.mark.wwns_get_portId_hostGroupId
def test_wwns_get_portId_hostGroupId():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.wwns_get(portId_hostGroupId=portId_hostGroupId)
#must be of type dict
assert type(result) == dict
@pytest.mark.wwns_one_port_get
def test_wwns_one_port_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.wwns_one_port_get(portId=portId)
#must be of type dict
assert type(result) == dict
@pytest.mark.wwns_all_ports_get
def test_wwns_all_ports_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.wwns_all_ports_get()
#must be of type dict
assert type(result) == dict
@pytest.mark.replication_get_gad
def test_replication_get_gad():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.replication_get(replicationType=replicationType)
#must be of type dict
assert type(result) == dict
@pytest.mark.replication_get
def test_replication_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.replication_get()
#must be of type dict
assert type(result) == dict
@pytest.mark.snapshots_get
def test_snapshots_get():
result = storage.storage_device_id_set(serial_number=serial_number)
#must be of type list
assert type(result) == str
assert len(result) == 12
result = storage.snapshots_get()
#must be of type dict
assert type(result) == dict