test_spawn_raw_glance in XenAPIVMTestCase complains about missing pygrub

Bug #723621 reported by Vish Ishaya
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Salvatore Orlando

Bug Description

When running the tests I get the following output:
test_spawn_raw_glance sh: pygrub: not found
oddly, it doesn't seem to make the test fail.

The os.popen command should probably be stubbed out or something to squelch this error.

Thierry Carrez (ttx)
Changed in nova:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

We should stub out is_vdi_pv in virt/xenapi/vm_utils.py:

        def is_vdi_pv(dev):
            LOG.debug(_("Running pygrub against %s"), dev)
            output = os.popen('pygrub -qn /dev/%s' % dev)
            for line in output.readlines():
                #try to find kernel string
                m = re.search('(?<=kernel:)/.*(?:>)', line)
                if m and m.group(0).find('xen') != -1:
                    LOG.debug(_("Found Xen kernel %s") % m.group(0))
                    return True
            LOG.debug(_("No Xen kernel found. Booting HVM."))
            return False
        return with_vdi_attached_here(session, vdi_ref, True, is_vdi_pv)

The test does not fail because we do not check pygrub's exit code, we just parse its output (which is "pygrub: not found"!). If we are unable to find the string for a PV kernel in the output we automatically assume HVM.

I will stub out this function.

Changed in nova:
assignee: nobody → Salvatore Orlando (salvatore-orlando)
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote : RE: [Bug 723621] Re: test_spawn_raw_glance in XenAPIVMTestCase complains about missing pygrub

Nice LP formatting :P

URLs are:

- http://bazaar.launchpad.net/~hudson-openstack/nova/trunk/annotate/head:/nova/tests/xenapi/stubs.py#L110
- http://bazaar.launchpad.net/~hudson-openstack/nova/trunk/view/head:/nova/tests/test_xenapi.py#L54

> -----Original Message-----
> From: <email address hidden> [mailto:<email address hidden>] On Behalf Of
> Armando Migliaccio
> Sent: 23 February 2011 12:22
> To: Armando Migliaccio
> Subject: [Bug 723621] Re: test_spawn_raw_glance in XenAPIVMTestCase complains
> about missing pygrub
>
> For an example on how to stub out 'is_vdi_pv' see:
>
> http://bazaar.launchpad.net/~hudson-
> openstack/nova/trunk/annotate/head:/nova/tests/xenapi/stubs.py#L110
>
> and
>
> http://bazaar.launchpad.net/~hudson-
> openstack/nova/trunk/view/head:/nova/tests/test_xenapi.py#L54
>
> Hope this help!
>
> --
> You received this bug notification because you are subscribed to
> OpenStack Compute (nova).
> https://bugs.launchpad.net/bugs/723621
>
> Title:
> test_spawn_raw_glance in XenAPIVMTestCase complains about missing
> pygrub
>
> Status in OpenStack Compute (Nova):
> Confirmed
>
> Bug description:
> When running the tests I get the following output:
> test_spawn_raw_glance sh: pygrub: not
> found
> oddly, it doesn't seem to make the test fail.
>
> The os.popen command should probably be stubbed out or something to
> squelch this error.

Thierry Carrez (ttx)
Changed in nova:
status: Confirmed → Triaged
Revision history for this message
Rick Harris (rconradharris) wrote :

Just an FYI: this is stubbed out as part of xs-unified-images, so when that hits trunk, this issue should go away.

Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

Hi Rick, I quickly checked out the diff for xs-unified-images branch. I couldn't the find the point in which _is_vdi_pv is stubbed out.
Can you help me?

Anyway, we can either mark this bug as invalid or propose for merge the attached branch.

Revision history for this message
Rick Harris (rconradharris) wrote :

Hi Salvatore:

I ended up stubbing out `lookup_image` entirely (rather than the inner `_is_vdi_pv` function). Here's the code in tests/xenapi/stubs.py:

def stubout_lookup_image(stubs):
    @classmethod
    def fake_lookup_image(cls, session, instance_id, vdi_ref):
        # NOTE(sirp): pretending each image is paravirtualized for now
        is_pv = True
        return is_pv

    stubs.Set(vm_utils.VMHelper, 'lookup_image', fake_lookup_image)

Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

Hi Rick,

Sorry I missed that bit of code.
If we stub out only _is_vdi_pv, this would improve a little bit the coverage of the unit tests. So it might be worth proposing the attached branch for merge.
What's your opinion?

Revision history for this message
Rick Harris (rconradharris) wrote :

Salvatore,

No worries, it was buried inside a big-honking-patch :)

> If we stub out only _is_vdi_pv, this would improve a little bit the coverage of the unit tests

Yeah I think you're right, we should probably lean towards the solution w/ more code coverage. I'd vote to propose your branch, and I'll fix xs-unified-images onces your stuff hits trunk.

Changed in nova:
status: Triaged → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → 2011.2
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.