autotest / virt-test

Linux Virtualization Tests
Other
97 stars 139 forks source link

Fix two indetectable iscsi bug #2233

Closed PandaWei closed 9 years ago

PandaWei commented 9 years ago

First : utils_test/libvirt.py: fix call export_target() twice

If the parameter 'is_login' is true,
export_target() will be call two times.
Error message as following,

* Command:
  targetcli /backstores/fileio/ create device.disk-pool
  /mnt/extra_disk/osc /virt-test/tmp/disk-pool
  Exit status: 1
  Duration: 0.110117912292

  stderr:
  expected a character buffer object

so move the first export_target() to else-block.

Second: virttest/iscsi.py: fix login failure

If both iSCSI server and iSCSI client are on localhost,
It's necessary to set up InitiatorName for localhost.
Otherwize, login will fail.
PandaWei commented 9 years ago

./run -t libvirt --no-downloads -k --keep-image-between-tests --tests "type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool" SETUP: PASS (0.00 s) DATA DIR: /var/lib/virt_test DEBUG LOG: /mnt/extra_disk/osc/virt-test/logs/run-2015-07-02-11.24.38/debug.log TESTS: 9 (1/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_none.pool_format_none: PASS (20.52 s) (2/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_none.pool_format_gpt: PASS (456.31 s) (3/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_linux.pool_format_none: PASS (23.13 s) (4/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_fat16.pool_format_none: PASS (20.92 s) (5/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_fat32.pool_format_none: PASS (20.99 s) (6/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_linux-swap.pool_format_none: PASS (22.14 s) (7/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_linux-lvm.pool_format_none: PASS (23.17 s) (8/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_linux-raid.pool_format_none: PASS (19.78 s) (9/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_extended.pool_format_none: PASS (20.83 s) TOTAL TIME: 627.96 s (10:27) TESTS PASSED: 9 TESTS FAILED: 0 SUCCESS RATE: 100.00 %

PandaWei commented 9 years ago

@waynesun09 I found two bugs about iscsi. Please help me to review it Thanks in advance.

waynesun09 commented 9 years ago

@PandaWei the fix look good to me, you need fix unittest for this update.

PandaWei commented 9 years ago

[root@localhost virt-test]# inspekt github 2233 Fetching https://github.com/autotest/virt-test/pull/2233.patch -> /tmp/github-2233.patch Github ID #2233 check PASS

[root@localhost virt-test]# python virttest/iscsi_unittest.py

....

Ran 4 tests in 0.005s

OK

@waynesun09 It's OK for my local test. and i can't open CI URL and don't know why. what's wrong with it?

waynesun09 commented 9 years ago

@PandaWei

======================================================================
ERROR: test_iscsi_get_device_name (virttest.iscsi_unittest.iscsi_test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/autotest/virt-test/virttest/iscsi_unittest.py", line 183, in test_iscsi_get_device_name
    iscsi_emulated.login()
  File "/home/travis/build/autotest/virt-test/virttest/iscsi.py", line 218, in login
    self.set_initiatorName(id=self.id, name=self.target)
  File "/home/travis/build/autotest/virt-test/virttest/iscsi.py", line 251, in set_initiatorName
    fd = open("/etc/iscsi/initiatorname.iscsi", 'w')
IOError: [Errno 2] No such file or directory: '/etc/iscsi/initiatorname.iscsi'
-------------------- >> begin captured logging << --------------------
root: DEBUG: Need to export target in host
root: DEBUG: Try to update iscsi initiatorname
--------------------- >> end captured logging << ---------------------

still fail in travis, seems travis-ci.org gfwed...

PandaWei commented 9 years ago

@waynesun09 Thanks for your reply. I have no idea to fix it. do you have any suggestion?

PandaWei commented 9 years ago

@waynesun09 I have updated the patch.

virttest/iscsi.py: fix login failure

1) If both iSCSI server and iSCSI client are on localhost,
   It's necessary to set up InitiatorName for localhost.
   Otherwize, login will fail.
2) Declare a global variable for iSCSI config file.
3) Update the unitest cases.
PandaWei commented 9 years ago

./run -t libvirt --no-downloads -k --keep-image-between-tests --tests "virsh.vol_create.positive_test.disk_pool" SETUP: PASS (0.00 s) DATA DIR: /var/lib/virt_test DEBUG LOG: /mnt/extra_disk/osc/virt-test/logs/run-2015-07-07-09.55.24/debug.log TESTS: 9 (1/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_none.pool_format_none: PASS (25.26 s) (2/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_none.pool_format_gpt: PASS (424.25 s) (3/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_linux.pool_format_none: PASS (26.20 s) (4/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_fat16.pool_format_none: PASS (25.15 s) (5/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_fat32.pool_format_none: PASS (23.81 s) (6/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_linux-swap.pool_format_none: PASS (26.73 s) (7/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_linux-lvm.pool_format_none: PASS (26.98 s) (8/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_linux-raid.pool_format_none: PASS (24.37 s) (9/9) type_specific.io-github-autotest-libvirt.virsh.vol_create.positive_test.disk_pool.vol_format_extended.pool_format_none: PASS (24.21 s) TOTAL TIME: 627.08 s (10:27) TESTS PASSED: 9 TESTS FAILED: 0 SUCCESS RATE: 100.00 %

waynesun09 commented 9 years ago

ACK and merging this now. Thanks @PandaWei