Skip to content
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

Killing the Discovery Service started by the Test Environment #346

Merged
merged 26 commits into from
Aug 14, 2023

Conversation

MounikaBattu17
Copy link
Contributor

@MounikaBattu17 MounikaBattu17 commented Aug 8, 2023

What does this Pull Request accomplish?

Acceptance tests (test_measurement_service.py, test_streaming_data_measurement.py, test_yield_vs_return.py) starts the discovery service for running their tests but doesn't terminate/kill it. This causes a Resource Warning while running all tests.
Approach is to start the Discovery service independently and scope it to whole test session.

  1. Created a Context Manager DiscoveryServiceProcess in tests/utilities/discovery_service_process.py.
    • __init__ is responsible for starting the discovery service and store the instance in self._proc.
    • __exit__ is responsible for killing the active Discovery service instance.
  2. Added a pytest fixture discovery_service_process that is responsible for
    • skipping tests for non-windows and measurement link registration file not found.
    • yielding the proc and scoped it to session for windows platform.
  3. Called the discovery_service_process fixture in measurement_service fixture in each acceptance test files.

Why should this Pull Request be merged?

  1. Starts and Closes Discovery Service instances.
  2. Fixes Resource Warning while running tests.

What testing has been done?

  1. Ran poetry run pytest, Observed there is no Resource Warning.
  2. Observed Discovery Service is started once and closed at the end of the test session.
  3. Verified acceptance tests are skipped if platform is non windows or measurement link registration file not available.

@github-actions
Copy link

github-actions bot commented Aug 8, 2023

Test Results

     12 files  ±0       12 suites  ±0   1m 58s ⏱️ - 16m 28s
   180 tests ±0     155 ✔️  -   25    25 💤 +  25  0 ±0 
2 148 runs  ±0  1 848 ✔️  - 300  300 💤 +300  0 ±0 

Results for commit 63dc634. ± Comparison against base commit 4c2672a.

♻️ This comment has been updated with latest results.

@dixonjoel
Copy link
Collaborator

Please update the PR description to match the implementation since you're not using the IsInTestState global now.

Copy link
Collaborator

@bkeryan bkeryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MounikaBattu17 Did #344 not fix the ResourceWarning?

@MounikaBattu17
Copy link
Contributor Author

MounikaBattu17 commented Aug 11, 2023

@MounikaBattu17 Did #344 not fix the ResourceWarning?

Yes, It fixed the resource warning. The ResourceWarning doesn't come if I run a measurement.

@bkeryan
Copy link
Collaborator

bkeryan commented Aug 11, 2023

This causes a Resource Warning while running all tests.

If the resource warning was already fixed, why does the description of this PR talk about the resource warning?

@vigkre vigkre self-requested a review August 14, 2023 08:44
@MounikaBattu17
Copy link
Contributor Author

MounikaBattu17 commented Aug 14, 2023

This causes a Resource Warning while running all tests.

If the resource warning was already fixed, why does the description of this PR talk about the resource warning?

The resource warning which I'm referring is from the tests. Earlier/ without this PR changes, there was a resource warning after the test run.

======================================================== warnings summary ========================================================= 
tests/unit/test_discovery_client.py::test___get_discovery_service_address___start_service_jit___returns_expected_value
  C:\Users\battu.mounika\AppData\Local\Programs\Python\Python38\lib\subprocess.py:946: ResourceWarning: subprocess 21300 is still running
    _warn("subprocess %s is still running" % self.pid,
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================== 179 passed, 1 warning in 148.70s (0:02:28) ============================================

Copy link
Collaborator

@dixonjoel dixonjoel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests pass locally for me and don't get skipped when I have the DS installed.

@MounikaBattu17 MounikaBattu17 requested a review from bkeryan August 14, 2023 14:36
@MounikaBattu17
Copy link
Contributor Author

This PR has got necessary approval. Hence merging.

@MounikaBattu17 MounikaBattu17 merged commit f009fcb into main Aug 14, 2023
@dixonjoel dixonjoel deleted the users/mounika/tests-fix-resoure-warning branch August 16, 2023 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants