Merge lp://staging/~tealeg/landscape-client/fix-lucid-detect-package-changes-traceback into lp://staging/~landscape/landscape-client/trunk

Proposed by Geoff Teale
Status: Merged
Approved by: Geoff Teale
Approved revision: 684
Merged at revision: 680
Proposed branch: lp://staging/~tealeg/landscape-client/fix-lucid-detect-package-changes-traceback
Merge into: lp://staging/~landscape/landscape-client/trunk
Diff against target: 77 lines (+30/-5)
3 files modified
landscape/lib/fs.py (+15/-3)
landscape/lib/tests/test_fs.py (+14/-0)
landscape/package/tests/test_reporter.py (+1/-2)
To merge this branch: bzr merge lp://staging/~tealeg/landscape-client/fix-lucid-detect-package-changes-traceback
Reviewer Review Type Date Requested Status
Free Ekanayaka (community) Approve
Alberto Donato Approve
Review via email: mp+165894@code.staging.launchpad.net

Commit message

This branch fixes an issues exposed by running tests on a fast machine. A test
relies on relies on a file being last being checked 1 second or more before an
assertion is made which is indirectly based on the modification time of that
 file, on a fast enough machine this test will always fail.

I have added an offset parameter landscape.lib.fs.touch_file allowing us to
offset the access and modification time of the file, and then used it to set
the modification time of the file a second further into the future thus
ensuring the test conditions are met for a wider window.

Description of the change

This branch fixes an issues exposed by running tests on a fast machine. A test relies on relies on a file being last being checked 1 second or more before an assertion is made which is indirectly based on the modification time of that file, on a fast enough machine this test will always fail.

I have added an offset parameter landscape.lib.fs.touch_file allowing us to offset the access and modification time of the file, and then used it to set the modification time of the file a second further into the future thus ensuring the test conditions are met for a wider window.

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

Looks good, +1!

review: Approve
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Good catch, +1

[1]

+def touch_file(path, offset=None)

Please document this new parameter (I'd also probably rename it to offset_time) and maybe mention that it's used for testing.

[2]

+ if offset is not None:
+ offset_time = long(time.time()) + offset
+ os.utime(path, (offset_time, offset_time))
+ else:
+ os.utime(path, None)

In these cases please prefer to set your parameters and then call the API you need in one site only, rather than having two call sites. For example:

    timestamps = None
    if offset is not None:
        timestamp = long(time.time()) + offset
        timestamps = (timestamp, timestamp)
    os.utime(path, timestamps)

review: Approve
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :
Download full text (183.7 KiB)

The attempt to merge lp:~tealeg/landscape-client/fix-lucid-detect-package-changes-traceback into lp:landscape-client failed. Below is the output from the failed tests.

python setup.py build_ext -i
running build_ext
landscape.broker.tests.test_amp
  RemoteBrokerTest
    test_call_if_accepted ... [OK]
    test_call_if_accepted_with_not_accepted ... [OK]
    test_call_on_events ... [OK]
    test_exit ... [OK]
    test_fire_event ... [OK]
    test_get_accepted_message_types ... [OK]
    test_get_server_uuid ... [OK]
    test_is_message_pending ... [OK]
    test_listen_events ... [OK]
    test_method_call_error ... [OK]
    test_ping ... [OK]
    test_register ... [OK]
    test_register_client ... [OK]
    test_register_client_accepted_message_type ... [OK]
    test_reload_configuration ... [OK]
    test_send_message ... [OK]
    test_send_message_with_urgent ... [OK]
    test_stop_clients ... [OK]
  RemoteClientTest
    test_exit ... [OK]
    test_fire_event ... [OK]
    test_message ... [OK]
    test_method_call_error ... [OK]
    test_ping ... [OK]
landscape.broker.tests.test_client
  BrokerClientTest
    test_add ... [OK]
    test_dispatch_message ... [OK]
    test_dispatch_message_with_exception ... [OK]
    test_dispatch_message_with_no_handler ... [OK]
    test_exchange ... [OK]
    test_exchange_logs_errors_and_continues ... [OK]
    test_exchange_on_plugin_without_exchange_method ... [OK]
    test_exit ... [OK]
    test_fire_event ... [OK]
    test_fire_event_with_acceptance_changed ... [OK]
    test_fire_event_with_arguments ... [OK]
    test_fire_event_with_mixed_results ... [OK]
    test_get_named_plugin ... ...

684. By Geoff Teale

Fix up test I missed! **oops**

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.

Subscribers

People subscribed via source and target branches

to all changes: