Merge lp://staging/~rvb/maas/bug-1337190 into lp://staging/~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 2503
Proposed branch: lp://staging/~rvb/maas/bug-1337190
Merge into: lp://staging/~maas-committers/maas/trunk
Diff against target: 19 lines (+2/-6)
1 file modified
src/maasserver/tests/test_api_nodegroup.py (+2/-6)
To merge this branch: bzr merge lp://staging/~rvb/maas/bug-1337190
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+225444@code.staging.launchpad.net

Commit message

Fix test_updates_mac_cluster_interface: use different interfaces for all the MAC addresses to avoid generating clashing IP addresses.

Description of the change

The problem was that MAC addresses could be linked to the same interface because the interface was chosen at random in:
        mac_addresses = {
            factory.make_mac_address(): random.choice(interfaces)
            for i in range(4)
            }

As a consequence, the call to `get_random_ip_from_interface_range` could return the *same* IP twice in:
        leases = {
            get_random_ip_from_interface_range(interface): (
                mac_address.mac_address)
            for mac_address, interface in mac_addresses.items()
        }
The result was a failure of the whole test because the leases would be missing an entry.

My solution restricts a bit what the test actually tests but I don't think it's a problem in practice because what update_mac_cluster_interfaces() does do not depend on whether the IP addresses in the leases dictionary are on the same interface or not.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.