Skip to content

Commit 566daaf

Browse files
committed
External interface code changes
Changes: 1. rest_client.robot: - rename openbmc session to redfish. - Add new keyword to perform POST request. 2. test_lock_management.robot: - Import redfish utils resource. - Add suite setup and teardown. - Replace session login with "Redfish Login" keyword. - Split read and write locks for Reboot template. - Cosmetic chnages to the codes alignment and dictionary. - Add test setup "No Operation." - Fix Reboot session for get lock list. - Remove "Run Keyword" directive for keywords calls. - Add Delete redfish session in strategic location. - Re-structure keyword for keyword "Create New Session". - Set test variable constant. - Replace logout with "Delete All Redfish Sessions" Tested: Ran couple of times to confirm the changes Test Lock Management feature of Management... | PASS | 10 critical tests, 10 passed, 0 failed 10 tests total, 10 passed, 0 failed Change-Id: I530c8a6753e7d1c105d7cb3b2fd586b2c3bb68fa Signed-off-by: George Keishing <[email protected]>
1 parent 4ad9f43 commit 566daaf

File tree

2 files changed

+106
-75
lines changed

2 files changed

+106
-75
lines changed

lib/rest_client.robot

+26-2
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ Redfish Login
386386
# set kwargs as follows:
387387
# ${kwargs}= Create Dictionary allow_redirect=${True}.
388388

389-
Create Session openbmc ${AUTH_URI} timeout=${timeout}
389+
Create Session redfish ${AUTH_URI} timeout=${timeout}
390390
${headers}= Create Dictionary Content-Type=application/json
391391
${data}= Set Variable If '${kwargs}' == '${EMPTY}'
392392
... {"UserName":"${rest_username}", "Password":"${rest_password}"}
393393
... {"UserName":"${rest_username}", "Password":"${rest_password}", ${kwargs}}
394394

395-
${resp}= Post Request openbmc /redfish/v1/SessionService/Sessions
395+
${resp}= Post Request redfish /redfish/v1/SessionService/Sessions
396396
... data=${data} headers=${headers}
397397
Should Be Equal As Strings ${resp.status_code} ${HTTP_CREATED}
398398

@@ -401,3 +401,27 @@ Redfish Login
401401
Set Global Variable ${XAUTH_TOKEN} ${resp.headers["X-Auth-Token"]}
402402

403403
[Return] ${content}
404+
405+
406+
Redfish Post Request
407+
[Documentation] Do REST POST request and return the result.
408+
[Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
409+
410+
# Description of argument(s):
411+
# uri The URI to establish connection with
412+
# (e.g. '/xyz/openbmc_project/software/').
413+
# timeout Timeout in seconds to establish connection with URI.
414+
# quiet If enabled, turns off logging to console.
415+
# kwargs Any additional arguments to be passed directly to the
416+
# Post Request call. For example, the caller might
417+
# set kwargs as follows:
418+
# ${kwargs}= Create Dictionary allow_redirect=${True}.
419+
420+
${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
421+
${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN}
422+
Set To Dictionary ${kwargs} headers ${headers}
423+
Run Keyword If '${quiet}' == '${0}' Log Request method=Post base_uri=${base_uri} args=&{kwargs}
424+
${resp}= Post Request redfish ${base_uri} &{kwargs} timeout=${timeout}
425+
Run Keyword If '${quiet}' == '${0}' Log Response ${resp}
426+
427+
[Return] ${resp}

openpower/ext_interfaces/test_lock_management.robot

+80-73
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
Documentation Test Lock Management feature of Management Console on BMC.
44
55
Resource ../../lib/resource.robot
6-
Resource ../../lib/bmc_redfish_resource.robot
76
Resource ../../lib/openbmc_ffdc.robot
7+
Resource ../../lib/bmc_redfish_utils.robot
88

9+
Suite Setup Delete All Redfish Sessions
910
Test Setup Test Setup Execution
1011
Test Teardown Test Teardown Execution
12+
Suite Teardown Delete All Redfish Sessions
1113

1214
*** Variables ***
1315

@@ -192,11 +194,10 @@ Verify GetLockList Returns An Empty Record For An Invalid Session Id
192194
[Documentation] Verify GetLockList returns an empty record for an invalid session id.
193195
[Tags] Verify_GetLockList_Returns_An_Empty_Record_For_An_Invalid_Session_Id
194196
195-
${session_location}= Redfish.Get Session Location
196-
${session_id}= Evaluate os.path.basename($session_location) modules=os
197+
${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${hmc_id}"}}
197198

198-
${records}= Run Keyword Get Locks List ${session_id}
199-
${records}= Run Keyword Get Locks List ZZzZZz9zzZ
199+
${records}= Get Locks List ${resp['Id']}
200+
${records}= Get Locks List ZZzZZz9zzZ
200201
${length}= Get Length ${records}
201202
Should Be Equal ${length} ${0}
202203

@@ -214,30 +215,34 @@ Verify Lock Conflicts
214215
Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ['NA'] ${False}
215216

216217

217-
Verify Persistency Of Locks After BMC Reboot
218+
Verify Persistency Of Read Locks After BMC Reboot
218219
[Documentation] Verify persistency of locks after BMC reboot.
219-
[Tags] Verify_Persistency_Of_Locks_After_BMC_Reboot
220+
[Tags] Verify_Persistency_Of_Read_Locks_After_BMC_Reboot
220221
[Template] Locks Persistency Check After BMC Reboot
221222

222223
# lock_type seg_flags resource_id
223224
Read ${TWO_SEG_FLAG_2} ${234}
225+
226+
227+
Verify Persistency Of Write Locks After BMC Reboot
228+
[Documentation] Verify persistency of locks after BMC reboot.
229+
[Tags] Verify_Persistency_Of_Write_Locks_After_BMC_Reboot
230+
[Template] Locks Persistency Check After BMC Reboot
231+
232+
# lock_type seg_flags resource_id
224233
Write ${TWO_SEG_FLAG_2} ${234}
225234

226235

227236
Verify Valid Lock Transactions Release
228237
[Documentation] Verify valid lock transactions release.
229238
[Tags] Verify_Valid_Lock_Transactions_Release
230239
231-
${transaction_id1}= Acquire Lock On A Given Resource
232-
... Read ${TWO_SEG_FLAG_2} ${234}
240+
${transaction_id1}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234}
233241
${locks_before}= Get Locks List ${SESSION_ID}
234242

235-
${transaction_id2}= Acquire Lock On A Given Resource
236-
... Read ${TWO_SEG_FLAG_3} ${234}
237-
${transaction_id3}= Acquire Lock On A Given Resource
238-
... Read ${TWO_SEG_FLAG_2} ${234}
239-
${transaction_id4}= Acquire Lock On A Given Resource
240-
... Read ${TWO_SEG_FLAG_3} ${234}
243+
${transaction_id2}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_3} ${234}
244+
${transaction_id3}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234}
245+
${transaction_id4}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_3} ${234}
241246

242247
${transaction_ids}= Create List ${transaction_id2} ${transaction_id3} ${transaction_id4}
243248
Release Locks ${transaction_ids}
@@ -249,8 +254,7 @@ Verify Invalid Lock Transactions Release
249254
[Documentation] Verify invalid lock transactions release.
250255
[Tags] Verify_Invalid_Lock_Transactions_Release
251256
252-
${transaction_id1}= Acquire Lock On A Given Resource
253-
... Read ${TWO_SEG_FLAG_2} ${234}
257+
${transaction_id1}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234}
254258
${locks_before}= Get Locks List ${SESSION_ID}
255259

256260
${transaction_id2}= Evaluate ${transaction_id1} + 1
@@ -268,18 +272,15 @@ Verify Locks Release By Session
268272
[Tags] Verify_Locks_Release_By_Session
269273
270274
${locks_before}= Get Locks List ${SESSION_ID}
271-
${transaction_id1}= Acquire Lock On A Given Resource
272-
... Write ${TWO_SEG_FLAG_2} ${234}
275+
${transaction_id1}= Acquire Lock On A Given Resource Write ${TWO_SEG_FLAG_2} ${234}
273276

274277
# Release Lock by Session without mentioning transaction_ids.
275278
Release Locks release_type=Session
276279
${locks_after}= Get Locks List ${SESSION_ID}
277280
Should Be Equal ${locks_before} ${locks_after}
278281

279-
${transaction_id1}= Acquire Lock On A Given Resource
280-
... Read ${TWO_SEG_FLAG_2} ${234}
281-
${transaction_id2}= Acquire Lock On A Given Resource
282-
... Read ${TWO_SEG_FLAG_3} ${234}
282+
${transaction_id1}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234}
283+
${transaction_id2}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_3} ${234}
283284
${transaction_ids}= Create List ${transaction_id1} ${transaction_id2}
284285

285286
# Release Lock by Session by mentioning transaction_ids also in the request.
@@ -289,17 +290,18 @@ Verify Locks Release By Session
289290
Verify Locks Created By One Session Cannot Be Deleted By Another Session
290291
[Documentation] Verify locks created by one session cannot be deleted by another session.
291292
[Tags] Verify_Locks_Created_By_One_Session_Cannot_Be_Deleted_By_Another_Session
293+
[Setup] No Operation
292294

293-
${transaction_id1}= Acquire Lock On A Given Resource
294-
... Read ${TWO_SEG_FLAG_2} ${234}
295-
${locks_tran1}= Get Locks List ${SESSION_ID}
295+
${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"hmc-id"}}
296+
Set Test Variable ${SESSION_ID} ${resp['Id']}
297+
${transaction_id1}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234}
298+
${locks_tran1}= Get Locks List ${resp['Id']}
296299

297-
Redfish.Login
298-
${session_id} ${session_key}= Return Session Id And Session Key
300+
${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"hmc-id"}}
301+
Set Test Variable ${SESSION_ID} ${resp['Id']}
299302

300-
${transaction_id2}= Acquire Lock On A Given Resource
301-
... Read ${TWO_SEG_FLAG_3} ${234}
302-
${locks_before}= Get Locks List ${SESSION_ID}
303+
${transaction_id2}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_3} ${234}
304+
${locks_before}= Get Locks List ${resp['Id']}
303305

304306
${transaction_ids}= Create List ${transaction_id1} ${transaction_id2}
305307
Release Locks ${transaction_ids} exp_status_code=${HTTP_UNAUTHORIZED} conflict_record=${locks_tran1}
@@ -323,16 +325,16 @@ Locks Persistency Check After BMC Reboot
323325
# seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
324326
# resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
325327

326-
${transaction_id}= Run Keyword Acquire Lock On A Given Resource
327-
... ${lock_type} ${seg_flags} ${resource_id}
328+
${transaction_id}= Acquire Lock On A Given Resource ${lock_type} ${seg_flags} ${resource_id}
328329

329-
${locks_prev}= Run Keyword Get Locks List ${SESSION_ID}
330+
${locks_prev}= Get Locks List ${SESSION_ID}
330331

331-
Initialize OpenBMC
332-
OBMC Reboot (off)
332+
Redfish OBMC Reboot (off)
333+
Redfish Login
333334

334-
${locks_curr}= Run Keyword Get Locks List ${SESSION_ID}
335+
${locks_curr}= Get Locks List ${SESSION_ID}
335336
Should Be Equal ${locks_prev} ${locks_curr}
337+
336338
${transaction_ids}= Create List ${transaction_id}
337339
Release Locks ${transaction_ids}
338340

@@ -346,11 +348,14 @@ Return Data Dictionary For Single Request
346348
# seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
347349
# resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
348350

349-
${SEG_FLAGS_LOCK}= Create Dictionary LockType=${lock_type} SegmentFlags=@{seg_flags}
351+
${SEG_FLAGS_LOCK}= Create Dictionary
352+
... LockType=${lock_type}
353+
... SegmentFlags=@{seg_flags}
350354
... ResourceID=${resource_id}
355+
351356
${SEG_FLAGS_ENTRIES}= Create List ${SEG_FLAGS_LOCK}
352357
${LOCK_REQUEST}= Create Dictionary Request=${SEG_FLAGS_ENTRIES}
353-
Log To Console ${LOCK_REQUEST}
358+
Log To Console \n ${LOCK_REQUEST}
354359

355360
[Return] ${LOCK_REQUEST}
356361

@@ -370,17 +375,17 @@ Acquire Lock On A Given Resource
370375
# err_msgs List of expected error messages.
371376

372377
${data}= Return Data Dictionary For Single Request ${lock_type} ${seg_flags} ${resource_id}
373-
${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock
374-
... body=${data} valid_status_codes=[${exp_status_code}]
378+
${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${data}
375379

376380
${transaction_id}= Run Keyword If ${exp_status_code} != ${HTTP_OK}
377-
... Set Variable ${0}
378-
... ELSE Load Lock Record And Build Transaction To Session Map ${resp.text}
381+
... Set Variable ${0}
382+
... ELSE
383+
... Load Lock Record And Build Transaction To Session Map ${resp.text}
379384

380385
Run Keyword If ${exp_status_code} == ${HTTP_CONFLICT} and ${err_msgs} == ['NA']
381-
... Load Response And Verify Conflict ${resp.text} ${SESSION_ID}
386+
... Load Response And Verify Conflict ${resp.text} ${SESSION_ID}
382387
... ELSE Run Keyword If ${exp_status_code} != ${HTTP_OK} and ${err_msgs} != ${EMPTY_LIST}
383-
... Load Response And Verify Error ${resp.text} err_msgs=${err_msgs}
388+
... Load Response And Verify Error ${resp.text} err_msgs=${err_msgs}
384389

385390
Append Transaction Id And Session Id To Locks Dictionary ${transaction_id}
386391

@@ -418,7 +423,7 @@ Load Response And Verify Error
418423
Append To List ${extended_errors} ${error[0]["Message"]}
419424
END
420425

421-
Log To Console EXTENDED = ${extended_errors}
426+
Log To Console \n ${extended_errors}
422427

423428
FOR ${exp_error} IN @{err_msgs}
424429
Run Keyword Expect List Of Errors In An Extended Errors ${exp_error} ${extended_errors}
@@ -459,9 +464,8 @@ Get Locks List
459464

460465
${sessions}= Evaluate json.dumps(${sessions}) json
461466
${data}= Set Variable {"SessionIDs": ${sessions}}
462-
${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
463-
... body=${data} valid_status_codes=[${exp_status_code}]
464-
467+
${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
468+
... data=${data}
465469
${locks}= Evaluate json.loads('''${resp.text}''') json
466470

467471
[Return] ${locks["Records"]}
@@ -482,9 +486,8 @@ Release Locks
482486
# When release_type=Session then TransactionIDs list will be ignored.
483487
${data}= Set Variable {"Type": "${release_type}", "TransactionIDs": ${transaction_ids}}
484488
${data}= Evaluate json.dumps(${data}) json
485-
${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock
486-
... body=${data} valid_status_codes=[${exp_status_code}]
487-
Should Be True ${resp.status} ${exp_status_code}
489+
${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
490+
Should Be True ${resp.status_code} ${exp_status_code}
488491
Return From Keyword If ${conflict_record} == ${EMPTY_LIST}
489492

490493
${conflict}= Evaluate json.loads('''${resp.text}''') json
@@ -522,7 +525,7 @@ Verify Lock Record
522525
# lock_records A dictionary containing key value pairs of a lock record.
523526

524527
${session}= Get From Dictionary ${LOCKS} ${lock_records["TransactionID"]}
525-
${locks}= Run Keyword Get Locks List ${session}
528+
${locks}= Get Locks List ${session}
526529

527530
${lock_record_found}= Set Variable ${False}
528531

@@ -552,7 +555,7 @@ Load Response And Verify Conflict
552555
# "SessionID": "B6geYEdo6T", "TransactionID": 104 } }
553556
# sessions Comma separated list of sessions
554557

555-
${curr_locks}= Run Keyword Get Locks List ${sessions}
558+
${curr_locks}= Get Locks List ${sessions}
556559
${conflict_resp}= Replace String ${conflict_resp} \" \\"
557560
${conflict_response}= Evaluate json.loads('''${conflict_resp}''') json
558561

@@ -576,13 +579,19 @@ Acquire And Release Lock
576579
# err_msgs List of expected error messages.
577580
# new_sess_req Create a new session before acquiring a lock if True.
578581

582+
# Delete the session.
583+
Run Keyword If ${new_sess_req} == ${True} Delete All Redfish Sessions
584+
579585
# Get REST session to BMC.
580586
Run Keyword If ${new_sess_req} == ${True} Create New Session
581587

582-
${inputs}= Create Dictionary LockType=${lock_type} ResourceID=${resource_id}
583-
... SegmentFlags=${seg_flags} HMCID=${hmc_id}
588+
${inputs}= Create Dictionary
589+
... LockType=${lock_type}
590+
... ResourceID=${resource_id}
591+
... SegmentFlags=${seg_flags}
592+
... HMCID=${hmc_id}
584593

585-
${transaction_id}= Run Keyword Acquire Lock On A Given Resource ${inputs["LockType"]}
594+
${transaction_id}= Acquire Lock On A Given Resource ${inputs["LockType"]}
586595
... ${inputs["SegmentFlags"]} ${inputs["ResourceID"]} ${exp_status_code} err_msgs=${err_msgs}
587596

588597
# Each lock request from a new session is saved so that for next lock request using same session
@@ -601,28 +610,19 @@ Acquire And Release Lock
601610
Release Locks ${transaction_ids}
602611
Verify Lock Record ${False} &{inputs}
603612

604-
# Delete the session.
605-
Redfish.Logout
606-
607613

608614
Create New Session
609615
[Documentation] Create new session.
610616
611-
# Delete current session.
612-
Redfish.Logout
613-
614-
# Get a redfish session to BMC.
615-
Redfish.Login
616-
${session_id} ${session_key}= Return Session Id And Session Key
617-
Set Test Variable ${SESSION_ID} ${session_id}
618-
Set Test Variable ${SESSION_KEY} ${session_key}
617+
${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${hmc_id}"}}
618+
Set Test Variable ${SESSION_ID} ${resp['Id']}
619619

620620

621621
Test Teardown Execution
622622
[Documentation] Test teardown execution.
623623
624624
FFDC On Test Case Fail
625-
Redfish.Logout
625+
Delete All Redfish Sessions
626626

627627

628628
Return Session Id And Session Key
@@ -638,10 +638,12 @@ Return Session Id And Session Key
638638
Test Setup Execution
639639
[Documentation] Test setup execution.
640640
641+
# This is a test constant value.
642+
Set Test Variable ${hmc_id} hmc-id
641643
Create New Session
642644

643-
Set Test Variable Dictionary Of Previous Lock Request ${EMPTY} ${EMPTY_LIST} ${EMPTY} ${EMPTY}
644-
... ${EMPTY} ${EMPTY}
645+
Set Test Variable Dictionary Of Previous Lock Request
646+
... ${EMPTY} ${EMPTY_LIST} ${EMPTY} ${EMPTY} ${EMPTY} ${EMPTY}
645647

646648

647649
Set Test Variable Dictionary Of Previous Lock Request
@@ -658,7 +660,12 @@ Set Test Variable Dictionary Of Previous Lock Request
658660
# session_id Session id of the transaction.
659661
# transaction_id Transaction_id of the lock request.
660662

661-
${prev_inputs}= Create Dictionary LockType=${lock_type} ResourceID=${resource_id}
662-
... SegmentFlags=${seg_flags} HMCID=${hmc_id} SessionID=${session_id} TransactionID=${transaction_id}
663+
${prev_inputs}= Create Dictionary
664+
... LockType=${lock_type}
665+
... ResourceID=${resource_id}
666+
... SegmentFlags=${seg_flags}
667+
... HMCID=${hmc_id}
668+
... SessionID=${session_id}
669+
... TransactionID=${transaction_id}
663670

664671
Set Test Variable ${PREV_INPUTS} ${prev_inputs}

0 commit comments

Comments
 (0)