From 05769a24599a0750a92d808057e19b95543b9aa8 Mon Sep 17 00:00:00 2001 From: Mirela Popoveniuc Date: Fri, 8 Jan 2021 15:31:12 +0000 Subject: [PATCH 1/3] Fix unit test test_profiler_runner that was failing sometimes. --- test/unit/test_profiler_runner.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/unit/test_profiler_runner.py b/test/unit/test_profiler_runner.py index f4ba436..9f8e2fd 100644 --- a/test/unit/test_profiler_runner.py +++ b/test/unit/test_profiler_runner.py @@ -3,6 +3,7 @@ from test.pytestutils import before from test.help_utils import wait_for from mock import MagicMock +from time import sleep from codeguru_profiler_agent.profiler_runner import ProfilerRunner from codeguru_profiler_agent.profiler_disabler import ProfilerDisabler @@ -87,6 +88,9 @@ def test_when_orchestrator_says_no_to_profiler(self): self.profiler_runner.start() # still it is safer to wait until the new config has been applied wait_for(lambda: AgentConfiguration.get().reporting_interval.total_seconds() == 151) + # sometimes it takes a few milliseconds for the scheduler to be updated with the AgentConfiguration, + # so let's sleep for 100 ms + sleep(0.1) assert self.profiler_runner.scheduler._get_next_delay_seconds() == 151 self.mock_collector.add.assert_not_called() From e0eb42b745651a28f45981a5b2709af4a8055f78 Mon Sep 17 00:00:00 2001 From: Mirela Popoveniuc Date: Fri, 8 Jan 2021 15:46:18 +0000 Subject: [PATCH 2/3] Include link to GitHub in README.md for tracking back from PyPI. --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1927ecd..f567230 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,17 @@ For more details, check the documentation: https://docs.aws.amazon.com/codeguru/ ## How to use it -This package is released to PyPI, so use it as any Python package from PyPI: https://pypi.org/project/codeguru-profiler-agent +This package is being released to PyPI as [codeguru-profiler-agent](https://pypi.org/project/codeguru-profiler-agent), so use it as any Python package from PyPI. For a demo application that uses this agent, check our [demo application](https://github.com/aws-samples/aws-codeguru-profiler-python-demo-application). -## Release to PyPI +## How to contribute + +Check the GitHub repository at [aws/amazon-codeguru-profiler-python-agent](https://github.com/aws/amazon-codeguru-profiler-python-agent). + +See [CONTRIBUTING](CONTRIBUTING.md) for details. + +## How to release to PyPI Use the `setup.py` script to create the archive. @@ -18,5 +24,5 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform ## License -This project is licensed under the Apache-2.0 License. +This project is licensed under the Apache-2.0 License. See [LICENSE](LICENSE) for details. From 64213b52a9743ef1afaedf7e4e1fddabdf1e2231 Mon Sep 17 00:00:00 2001 From: Mirela Popoveniuc Date: Fri, 8 Jan 2021 17:04:37 +0000 Subject: [PATCH 3/3] Addressed comments - used wait_for(..) instead of sleep(..). --- test/unit/test_profiler_runner.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/unit/test_profiler_runner.py b/test/unit/test_profiler_runner.py index 9f8e2fd..9ba9230 100644 --- a/test/unit/test_profiler_runner.py +++ b/test/unit/test_profiler_runner.py @@ -88,9 +88,7 @@ def test_when_orchestrator_says_no_to_profiler(self): self.profiler_runner.start() # still it is safer to wait until the new config has been applied wait_for(lambda: AgentConfiguration.get().reporting_interval.total_seconds() == 151) - # sometimes it takes a few milliseconds for the scheduler to be updated with the AgentConfiguration, - # so let's sleep for 100 ms - sleep(0.1) + wait_for(lambda: self.profiler_runner.scheduler._get_next_delay_seconds() == 151) assert self.profiler_runner.scheduler._get_next_delay_seconds() == 151 self.mock_collector.add.assert_not_called()