Best Python code snippet using autotest_python
iscsi_unittest.py
Source:iscsi_unittest.py
...20 lg_cmd += "%s" % iscsi_obj.target21 self.setup_stubs_portal_visible(iscsi_obj)22 os.path.isfile.expect_call(iscsi_obj.emulated_image).and_return(False)23 utils.system.expect_call(c_cmd)24 self.setup_stubs_export_target(iscsi_obj)25 utils.system.expect_call("service iscsid restart")26 self.setup_stubs_portal_visible(iscsi_obj, "127.0.0.1:3260,1 %s"27 % iscsi_obj.target)28 lg_msg = "successful"29 utils.system_output.expect_call(lg_cmd).and_return(lg_msg)30 def setup_stubs_get_device_name(self, iscsi_obj):31 s_msg = "tcp [15] 127.0.0.1:3260,1 %s" % iscsi_obj.target32 utils.system_output.expect_call("iscsiadm --mode session",33 ignore_status=True34 ).and_return(s_msg)35 detail = "Target: iqn.iscsitest\n Attached scsi disk "36 detail += "sdb State running"37 utils.system_output.expect_call("iscsiadm -m session -P 3"38 ).and_return(detail)39 def setup_stubs_cleanup(self, iscsi_obj, fname=""):40 s_msg = "tcp [15] 127.0.0.1:3260,1 %s" % iscsi_obj.target41 utils.system_output.expect_call("iscsiadm --mode session",42 ignore_status=True43 ).and_return(s_msg)44 out_cmd = "iscsiadm --mode node --logout -T %s" % iscsi_obj.target45 utils.system_output.expect_call(out_cmd).and_return("successful")46 os.path.isfile.expect_call(fname).and_return(False)47 s_cmd = "tgtadm --lld iscsi --mode target --op show"48 utils.system_output.expect_call(s_cmd49 ).and_return("Target 1: iqn.iscsitest")50 d_cmd = "tgtadm --lld iscsi --mode target --op delete"51 d_cmd += " --tid %s" % iscsi_obj.emulated_id52 utils.system.expect_call(d_cmd)53 def setup_stubs_logged_in(self, result=""):54 utils.system_output.expect_call("iscsiadm --mode session",55 ignore_status=True56 ).and_return(result)57 def setup_stubs_portal_visible(self, iscsi_obj, result=""):58 host_name = iscsi_obj.portal_ip59 v_cmd = "iscsiadm -m discovery -t sendtargets -p %s" % host_name60 utils.system_output.expect_call(v_cmd,61 ignore_status=True).and_return(result)62 def setup_stubs_export_target(self, iscsi_obj):63 s_cmd = "tgtadm --lld iscsi --mode target --op show"64 utils.system_output.expect_call(s_cmd).and_return("")65 utils.system_output.expect_call(s_cmd).and_return("")66 t_cmd = "tgtadm --mode target --op new --tid"67 t_cmd += " %s --lld iscsi " % iscsi_obj.emulated_id68 t_cmd += "--targetname %s" % iscsi_obj.target69 utils.system.expect_call(t_cmd)70 l_cmd = "tgtadm --lld iscsi --op bind --mode target"71 l_cmd += " --tid %s -I ALL" % iscsi_obj.emulated_id72 utils.system.expect_call(l_cmd)73 utils.system_output.expect_call(s_cmd).and_return("")74 t_cmd = "tgtadm --mode logicalunit --op new "75 t_cmd += "--tid %s --lld iscsi " % iscsi_obj.emulated_id76 t_cmd += "--lun %s " % 0...
iscsi_uinttest.py
Source:iscsi_uinttest.py
...20 lg_cmd += "%s" % iscsi_obj.target21 self.setup_stubs_portal_visible(iscsi_obj)22 os.path.isfile.expect_call(iscsi_obj.emulated_image).and_return(False)23 utils.system.expect_call(c_cmd)24 self.setup_stubs_export_target(iscsi_obj)25 utils.system.expect_call("service iscsid restart")26 self.setup_stubs_portal_visible(iscsi_obj, "127.0.0.1:3260,1 %s"27 % iscsi_obj.target)28 lg_msg = "successful"29 utils.system_output.expect_call(lg_cmd).and_return(lg_msg)30 def setup_stubs_get_device_name(self, iscsi_obj):31 s_msg = "127.0.0.1:3260,1 %s" % iscsi_obj.target32 utils.system_output.expect_call("iscsiadm --mode session"33 ).and_return(s_msg)34 detail = "Target: iqn.iscsitest\n Attached scsi disk sdb State"35 utils.system_output.expect_call("iscsiadm -m session -P 3"36 ).and_return(detail)37 def setup_stubs_cleanup(self, iscsi_obj, fname=""):38 s_msg = "127.0.0.1:3260,1 %s" % iscsi_obj.target39 utils.system_output.expect_call("iscsiadm --mode session"40 ).and_return(s_msg)41 utils.system_output.expect_call("iscsiadm --mode session"42 ).and_return(s_msg)43 out_cmd = "iscsiadm --mode node --logout -T %s" % iscsi_obj.target44 utils.system_output.expect_call(out_cmd).and_return("successful")45 os.path.isfile.expect_call(fname).and_return(False)46 s_cmd = "tgtadm --lld iscsi --mode target --op show"47 utils.system_output.expect_call(s_cmd48 ).and_return("Target 1: iqn.iscsitest")49 d_cmd = "tgtadm --lld iscsi --mode target --op delete"50 d_cmd += " --tid %s" % iscsi_obj.emulated_id51 utils.system.expect_call(d_cmd)52 def setup_stubs_logged_in(self, result=""):53 utils.system_output.expect_call("iscsiadm --mode session"54 ).and_return(result)55 def setup_stubs_portal_visible(self, iscsi_obj, result=""):56 host_name = iscsi_obj.portal_ip57 v_cmd = "iscsiadm -m discovery -t sendtargets -p %s" % host_name58 utils.system_output.expect_call(v_cmd).and_return(result)59 def setup_stubs_export_target(self, iscsi_obj):60 s_cmd = "tgtadm --lld iscsi --mode target --op show"61 utils.system_output.expect_call(s_cmd).and_return("")62 utils.system_output.expect_call(s_cmd).and_return("")63 t_cmd = "tgtadm --mode target --op new --tid"64 t_cmd += " %s --lld iscsi " % iscsi_obj.emulated_id65 t_cmd += "--targetname %s" % iscsi_obj.target66 utils.system.expect_call(t_cmd)67 l_cmd = "tgtadm --mode logicalunit --op new --tid"68 l_cmd += " %s --lld iscsi" % iscsi_obj.emulated_id69 l_cmd += " --lun 1 --backing-store "70 l_cmd += "%s" % iscsi_obj.emulated_image71 b_cmd = "tgtadm --lld iscsi --op bind --mode target --tid"72 b_cmd += " %s -I ALL" % iscsi_obj.emulated_id73 utils.system.expect_call(l_cmd)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!