Skip to content

Reduce sleep time for Unit Test of Consumer to 0 seconds #26131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

lbajsarowicz
Copy link
Contributor

@lbajsarowicz lbajsarowicz commented Dec 19, 2019

Description (*)

Running Unit Tests locally takes too much time. One of the reasons is visible below:

Having to wait 30 seconds for sleep instruction is just waste of time and resources.

To fix that - I inject to the Object constructor the value of 0, which causes sleep 0 seconds.

Before
image

<testsuite name="Magento\MessageQueue\Test\Unit\Model\ConsumerRunnerTest" file="/var/www/html/app/code/Magento/MessageQueue/Test/Unit/Model/ConsumerRunnerTest.php" tests="3" assertions="9" errors="0" failures="0" skipped="0" time="30.002373">
      <testcase name="testMagicMethod" class="Magento\MessageQueue\Test\Unit\Model\ConsumerRunnerTest" classname="Magento.MessageQueue.Test.Unit.Model.ConsumerRunnerTest" file="/var/www/html/app/code/Magento/MessageQueue/Test/Unit/Model/ConsumerRunnerTest.php" line="64" assertions="3" time="0.001108"/>
      <testcase name="testMagicMethodNoRelatedConsumer" class="Magento\MessageQueue\Test\Unit\Model\ConsumerRunnerTest" classname="Magento.MessageQueue.Test.Unit.Model.ConsumerRunnerTest" file="/var/www/html/app/code/Magento/MessageQueue/Test/Unit/Model/ConsumerRunnerTest.php" line="88" assertions="3" time="0.000909"/>
      <testcase name="testMagicMethodMaintenanceModeIsOn" class="Magento\MessageQueue\Test\Unit\Model\ConsumerRunnerTest" classname="Magento.MessageQueue.Test.Unit.Model.ConsumerRunnerTest" file="/var/www/html/app/code/Magento/MessageQueue/Test/Unit/Model/ConsumerRunnerTest.php" line="105" assertions="3" time="30.000356"/>
    </testsuite>

After
image

<testsuite name="Magento\MessageQueue\Test\Unit\Model\ConsumerRunnerTest" file="/var/www/html/app/code/Magento/MessageQueue/Test/Unit/Model/ConsumerRunnerTest.php" tests="3" assertions="9" errors="0" failures="0" skipped="0" time="0.002123">
      <testcase name="testMagicMethod" class="Magento\MessageQueue\Test\Unit\Model\ConsumerRunnerTest" classname="Magento.MessageQueue.Test.Unit.Model.ConsumerRunnerTest" file="/var/www/html/app/code/Magento/MessageQueue/Test/Unit/Model/ConsumerRunnerTest.php" line="73" assertions="3" time="0.001037"/>
      <testcase name="testMagicMethodNoRelatedConsumer" class="Magento\MessageQueue\Test\Unit\Model\ConsumerRunnerTest" classname="Magento.MessageQueue.Test.Unit.Model.ConsumerRunnerTest" file="/var/www/html/app/code/Magento/MessageQueue/Test/Unit/Model/ConsumerRunnerTest.php" line="95" assertions="3" time="0.000890"/>
      <testcase name="testMagicMethodMaintenanceModeIsOn" class="Magento\MessageQueue\Test\Unit\Model\ConsumerRunnerTest" classname="Magento.MessageQueue.Test.Unit.Model.ConsumerRunnerTest" file="/var/www/html/app/code/Magento/MessageQueue/Test/Unit/Model/ConsumerRunnerTest.php" line="115" assertions="3" time="0.000196"/>
    </testsuite>

Fixed Issues (if relevant)

N/A

Manual testing scenarios (*)

  1. Run unit tests

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Dec 19, 2019

Hi @lbajsarowicz. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@magento-engcom-team magento-engcom-team added Partner: Strix partners-contribution Pull Request is created by Magento Partner labels Dec 19, 2019
@dmytro-ch dmytro-ch self-assigned this Dec 19, 2019
@dmytro-ch
Copy link
Contributor

Nice catch, @lbajsarowicz !
Thank you.

@dmytro-ch dmytro-ch added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Award: category of expertise labels Dec 19, 2019
@engcom-Delta
Copy link
Contributor

✔️ QA passed

@m2-assistant
Copy link

m2-assistant bot commented Dec 29, 2019

Hi @lbajsarowicz, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants