@@ -635,30 +635,32 @@ def test_02_root_volume_attach_detach(self):
635635 type = 'ROOT' ,
636636 listall = True
637637 )
638- self .assertNotEqual (
639- root_volume_response ,
640- None ,
641- "Check if root volume exists in ListVolumes"
642- )
638+
643639 self .assertEqual (
644- isinstance (root_volume_response , list ) ,
645- True ,
646- "Check list volumes response for valid list"
640+ validateList (root_volume_response )[ 0 ] ,
641+ PASS ,
642+ "Invalid response returned for root volume list"
647643 )
644+
648645 # Grab the root volume for later use
649646 root_volume = root_volume_response [0 ]
650647
651648 # Stop VM
652649 self .debug ("Stopping the VM: %s" % self .virtual_machine .id )
653650 self .virtual_machine .stop (self .apiclient )
654651
655- # Ensure VM is stopped before detaching the root volume
656- time .sleep (self .services ["sleep" ])
657-
658652 vm_response = VirtualMachine .list (
659653 self .apiclient ,
660654 id = self .virtual_machine .id ,
661655 )
656+
657+ # Ensure that vm_response is a valid list
658+ self .assertEqual (
659+ validateList (vm_response )[0 ],
660+ PASS ,
661+ "Invalid response returned for vm_response list"
662+ )
663+
662664 vm = vm_response [0 ]
663665 self .assertEqual (
664666 vm .state ,
@@ -679,6 +681,7 @@ def test_02_root_volume_attach_detach(self):
679681 type = 'ROOT' ,
680682 listall = True
681683 )
684+
682685 self .assertEqual (
683686 no_root_volume_response ,
684687 None ,
@@ -699,43 +702,36 @@ def test_02_root_volume_attach_detach(self):
699702 type = 'ROOT' ,
700703 listall = True
701704 )
702- self .assertNotEqual (
703- new_root_volume_response ,
704- None ,
705- "Check if root volume exists in ListVolumes"
706- )
705+
706+ # Ensure that new_root_volume_response is a valid list
707707 self .assertEqual (
708- isinstance (new_root_volume_response , list ) ,
709- True ,
710- "Check list volumes response for valid list"
708+ validateList (new_root_volume_response )[ 0 ] ,
709+ PASS ,
710+ "Invalid response returned for new_root_volume_response list"
711711 )
712712
713713 # Start VM
714714 self .virtual_machine .start (self .apiclient )
715- # Sleep to ensure that VM is in ready state
716- time .sleep (self .services ["sleep" ])
717715
718716 vm_response = VirtualMachine .list (
719717 self .apiclient ,
720718 id = self .virtual_machine .id ,
721719 )
720+
722721 # Verify VM response to check whether VM deployment was successful
723722 self .assertEqual (
724- isinstance (vm_response , list ),
725- True ,
726- "Check list VM response for valid list"
727- )
728- self .assertNotEqual (
729- len (vm_response ),
730- 0 ,
731- "Check VMs available in List VMs response"
723+ validateList (vm_response )[0 ],
724+ PASS ,
725+ "Invalid response returned for vm_response list during VM start up"
732726 )
727+
733728 vm = vm_response [0 ]
734729 self .assertEqual (
735730 vm .state ,
736731 'Running' ,
737- "Check the state of VM"
732+ "Ensure the state of VM is running "
738733 )
734+
739735 except Exception as e :
740736 self .fail ("Exception occurred: %s" % e )
741737
0 commit comments