Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA-142595: Fix, unit tests and refactoring #216

Closed

Conversation

fquesnel
Copy link

This pull request includes:
-The fix from @wangyanbn (#203)
-The testing framework from @matelakat (#208)
-The unit tests for the fix, which are built on top of the testing framework
-Some additional refactoring, to prevent side effects when applying the fix

Thanks,
Flavien

return os.path.basename(devs[0])
else:
return INVALID_DEVICE_NAME

def _extract_dev(device_dir, procname, host, target):
"""Returns device name and creates dictionary entry for it"""
dev = _extract_dev_name(device_dir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename _get_block_device_name to something like _get_block_device_name_kernel_3x to communicate that it's the kernel 3.x specific way?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done.
Thanks.

@matelakat
Copy link
Contributor

@fquesnel - could you please review my changes and suggest any changes? also, could you please squash your commits to one, looking at the diff, it looks sensible as one change. Other than that, it looks good to me.

Mate Lakat and others added 2 commits August 28, 2014 12:16
Add a testing framework to enable us to check what happens if a given (SCSI)
device does not have a block subdirectory.

Signed-off-by: Mate Lakat <[email protected]>
Some device (e.g. a scsi security manager device.) has no subdir
"block/" , this will cause _extract_dev_name "IndexError: list index
out of range" error.
The following is the traceback info:
run this cmd: xe sr-probe type=lvmohba
There was an SR backend failure.
status: non-zero exit
stdout:
stderr: Traceback (most recent call last):
File "/opt/xensource/sm/LVMoHBASR", line 239, in ?
SRCommand.run(LVHDoHBASR, DRIVER_INFO)
File "/opt/xensource/sm/SRCommand.py", line 343, in run
sr = driver(cmd, cmd.sr_uuid)
File "/opt/xensource/sm/SR.py", line 139, in init
self.load(sr_uuid)
File "/opt/xensource/sm/LVMoHBASR", line 98, in load
print >>sys.stderr,self.hbasr.print_devs()
File "/opt/xensource/sm/HBASR.py", line 242, in print_devs
self._init_hbadict()
File "/opt/xensource/sm/HBASR.py", line 63, in _init_hbadict
dict = devscan.adapters(filterstr=self.type)
File "/opt/xensource/sm/devscan.py", line 75, in adapters
(dev, entry) = _extract_dev(dir, proc, id, lun)
File "/opt/xensource/sm/devscan.py", line 235, in _extract_dev
dev = _extract_dev_name(device_dir)
File "/opt/xensource/sm/devscan.py", line 226, in _extract_dev_name
dev = glob.glob(os.path.join(device_dir, 'block/*'))[0]
IndexError: list index out of range

Signed-off-by: Wang Yanbin [email protected]
@fquesnel fquesnel force-pushed the test-xs64bit-CA-142595 branch 2 times, most recently from 5efb3aa to 8701f04 Compare August 28, 2014 13:27
@fquesnel
Copy link
Author

@matelakat - I reviewed your changes and it looks good to me.
I squashed your changes to one commit.
I also squashed my changes to two commits, to separate the unit tests related to the fix from the refactoring. Besides, each item of my first comment now matches a commit.

Thanks,
Flavien

@matelakat
Copy link
Contributor

Could you please also add the [UnitTest] string to each of the changes that deal with Unit Tests? Like this: d10e3b0

Flavien Quesnel added 3 commits September 3, 2014 12:24
Add unit tests relating to the fix proposed by Wang Yanbin.

Signed-off-by: Flavien Quesnel <[email protected]>
Refactor code from devscan.py

Signed-off-by: Flavien Quesnel <[email protected]>
Add unit tests, following the refactoring of devscan.py

Signed-off-by: Flavien Quesnel <[email protected]>
@fquesnel fquesnel force-pushed the test-xs64bit-CA-142595 branch from 8701f04 to 84ad9da Compare September 3, 2014 11:26
@fquesnel
Copy link
Author

fquesnel commented Sep 3, 2014

OK, done.
Thanks.

@matelakat
Copy link
Contributor

Merged via 41aeac9

@matelakat matelakat closed this Sep 3, 2014
@fquesnel
Copy link
Author

fquesnel commented Sep 3, 2014

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants