slow unit tests

Bug #1478644 reported by Clinton Knight
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Shared File Systems Service (Manila)
Fix Released
Low
Clinton Knight

Bug Description

As of liberty.2, the Manila unit tests are taking ~60 seconds to run on my system. A dozen or so of the tests consistently take an integral number of seconds to run (i.e. 1, 2, 3 or 4 seconds), indicating the presence of a time.sleep() call in the code that hasn't been mocked. By mocking time.sleep() in just a few files, the time needed to run the unit tests falls by a third to ~40 seconds (!). No test failures were observed after making these changes.

Before the changes:

Slowest 10 tests took 19.13 secs:
manila.tests.share.drivers.hds.test_sop.SopShareDriverTestCase
    test_wait_for_job_completion_simple 1.01
manila.tests.share.drivers.quobyte.test_jsonrpc.QuobyteJsonRpcTestCase
    test_jsonrpc_call_http_exception_retry 3.01
manila.tests.share.drivers.test_generic.GenericShareDriverTestCase
    test_attach_volume_attached_retry_correct 2.01
    test_attach_volume_failed_attach_1_ManilaException 4.02
    test_attach_volume_failed_attach_2_Invalid 4.01
    test_wait_for_available_volume 1.01
    test_wait_for_available_volume_invalid_1__Mock_id__140081480654736__ 1.01
    test_wait_for_available_volume_invalid_2__Mock_id__140081480668304__ 1.01
manila.tests.share.drivers.test_service_instance.ServiceInstanceManagerTestCase
    test___create_service_instance_with_sg_success_1_nova 1.01
    test___create_service_instance_with_sg_success_2_neutron 1.02

Ran 2930 tests in 57.610s

After the changes:

Slowest 4 tests took 1.28 secs:
manila.tests.api.contrib.test_admin_actions.AdminActionsTest
    test_admin_force_delete_share 0.43
manila.tests.share.test_manager.ShareManagerTestCase
    test_create_share_from_snapshot_with_server 0.30
    test_create_share_with_share_network_server_exists 0.26
    test_delete_share_last_on_server_with_sec_services_2_False 0.31

Ran 2930 tests in 38.173s

Tags: tests unit
description: updated
Revision history for this message
jason bishop (jason-bishop) wrote : Re: [Bug 1478644] Re: slow unit tests
Download full text (4.4 KiB)

my bad for the sleep. I can fix real fast if you want.

On Mon, Jul 27, 2015 at 10:21 AM, Clinton Knight <email address hidden> wrote:

> ** Description changed:
>
> As of liberty.2, the Manila unit tests are taking ~60 seconds to run on
> my system. A dozen or so of the tests consistently take an integral
> number of seconds to run (i.e. 1, 2, 3 or 4 seconds), indicating the
> presence of a time.sleep() call in the code that hasn't been mocked. By
> mocking time.sleep() in just a few files, the time needed to run the
> unit tests falls by a third to ~40 seconds (!). No test failures were
> observed after making these changes.
> +
> +
> + Before the changes:
> +
> + Slowest 10 tests took 19.13 secs:
> + manila.tests.share.drivers.hds.test_sop.SopShareDriverTestCase
> + test_wait_for_job_completion_simple
> 1.01
> + manila.tests.share.drivers.quobyte.test_jsonrpc.QuobyteJsonRpcTestCase
> + test_jsonrpc_call_http_exception_retry
> 3.01
> + manila.tests.share.drivers.test_generic.GenericShareDriverTestCase
> + test_attach_volume_attached_retry_correct
> 2.01
> + test_attach_volume_failed_attach_1_ManilaException
> 4.02
> + test_attach_volume_failed_attach_2_Invalid
> 4.01
> + test_wait_for_available_volume
> 1.01
> +
> test_wait_for_available_volume_invalid_1__Mock_id__140081480654736__ 1.01
> +
> test_wait_for_available_volume_invalid_2__Mock_id__140081480668304__ 1.01
> +
> manila.tests.share.drivers.test_service_instance.ServiceInstanceManagerTestCase
> + test___create_service_instance_with_sg_success_1_nova
> 1.01
> + test___create_service_instance_with_sg_success_2_neutron
> 1.02
> +
> + Ran 2930 tests in 57.610s
> +
> +
> + After the changes:
> +
> + Slowest 4 tests took 1.28 secs:
> + manila.tests.api.contrib.test_admin_actions.AdminActionsTest
> + test_admin_force_delete_share
> 0.43
> + manila.tests.share.test_manager.ShareManagerTestCase
> + test_create_share_from_snapshot_with_server
> 0.30
> + test_create_share_with_share_network_server_exists
> 0.26
> + test_delete_share_last_on_server_with_sec_services_2_False
> 0.31
> +
> + Ran 2930 tests in 38.173s
>
> --
> You received this bug notification because you are subscribed to Manila.
> Matching subscriptions: jason bishop
> https://bugs.launchpad.net/bugs/1478644
>
> Title:
> slow unit tests
>
> Status in Manila:
> In Progress
>
> Bug description:
> As of liberty.2, the Manila unit tests are taking ~60 seconds to run
> on my system. A dozen or so of the tests consistently take an
> integral number of seconds to run (i.e. 1, 2, 3 or 4 seconds),
> indicating the presence of a time.sleep() call in the code that hasn't
> been mocked. By mocking time.sleep() in just a few files, the time
> needed to run the unit tests falls by a third to ~40 seconds (!). No
> test failures were observed after making these changes.
>
>
> Before the changes:
>
> Slowest 10 tests took 19.13 secs:
> manila.tests.share.drivers.hds.test_sop.SopShareDriverTestCase
> test_wait_for_job_completion_simple
> 1.01
> manila.tests.share.drivers.quobyte.test_jsonrpc.QuobyteJsonRpcTestCase
> tes...

Read more...

Revision history for this message
Clinton Knight (clintonk) wrote :

No worries, Jason, I have several to fix so I'll patch 'em all at once. Thanks for the offer, though!

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to manila (master)

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

Changed in manila:
milestone: liberty-3 → liberty-2
Changed in manila:
milestone: liberty-2 → liberty-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to manila (master)

Reviewed: https://review.openstack.org/206652
Committed: https://git.openstack.org/cgit/openstack/manila/commit/?id=0a39557c74d66218d06d63d40fd453a7382a775c
Submitter: Jenkins
Branch: master

commit 0a39557c74d66218d06d63d40fd453a7382a775c
Author: Clinton Knight <email address hidden>
Date: Mon Jul 27 13:06:57 2015 -0400

    Fix slow unit tests

    As of liberty.2, the Manila unit tests are taking ~60 seconds to run
    on my system. A dozen or so of the tests consistently take an integral
    number of seconds to run (i.e. 1, 2, 3 or 4 seconds), indicating the
    presence of a time.sleep() call in the code that hasn't been mocked.
    By mocking time.sleep() and time.time() in just a few files, the time
    needed to run the unit tests falls by a third to ~40 seconds (!).

    Change-Id: I66a6d864823b10a4193eadf65a1c5d3028f2afa7
    Closes-bug: 1478644

Changed in manila:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in manila:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in manila:
milestone: liberty-3 → 1.0.0
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.