Fake server id uses int type in unit test

Bug #1642113 reported by int32bit
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
Undecided
int32bit

Bug Description

Server id should be always str type not int, but currently in our unit test, we still use int rather than str:

https://github.com/openstack/python-novaclient/blob/master/novaclient/tests/unit/v2/fakes.py#L389

It may harmless in current test cases, but **there's a potential danger** in future. For example, we may compare server id in our code, but in our test will be 1234 == "1234" that certainly return false but it's not our expected result and yields a false positive. it trouble me a lot to run unit test in this commit:

https://review.openstack.org/gitweb?p=openstack/python-novaclient.git;a=blob;f=novaclient/utils.py;h=6a54e106abc135a4dc1333a3a069e7998ecbbf5c;hb=0d0cd3b70ff91fd4fee07d763c1c2bf2d0e2bc0b#l335

I re-check many times and completely certain work well but fail to unit test.

Honestly I almost couldn't find any advantage to use int type. So I think the id should be change to str in fake servers to fit real server uuid type.

int32bit (int32bit)
Changed in python-novaclient:
assignee: nobody → int32bit (int32bit)
int32bit (int32bit)
description: updated
int32bit (int32bit)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/398050

Changed in python-novaclient:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/398050
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=5c1efa52737900fda853379ca897377b8c21bde5
Submitter: Jenkins
Branch: master

commit 5c1efa52737900fda853379ca897377b8c21bde5
Author: int32bit <email address hidden>
Date: Wed Nov 16 10:40:43 2016 +0800

    Change fake server id as str to fit real server id type

    Server id should be always str type not int, but currently in our unit test,
    we still use int type. It may harmless in current test cases, but **there's a
    potential danger** in future. For example, we may compare server id in our
    code, in our test will be 1234 == "1234" which certainly return false but it's
    not our expected result and yields a false positive. it trouble me a lot to run
    unit test to solve 'bp show-server-all-tenants'. I re-check many times and
    completely certain work well but fail to unit test. Honestly I almost couldn't
    find any advantage to use int type. So I think the id should be change to str
    in fake servers to fit real server uuid type.

    Change-Id: I6b27d9c1629656dcc9b18497187c79ca96f6cd67
    Closes-Bug: #1642113

Changed in python-novaclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-novaclient 7.0.0

This issue was fixed in the openstack/python-novaclient 7.0.0 release.

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.