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

refactor: Simplify testing with ScopedTritonServer instead of pytest fixtures #68

Merged
merged 12 commits into from
Jun 3, 2024

Conversation

KrishnanPrash
Copy link
Contributor

@KrishnanPrash KrishnanPrash commented May 31, 2024

This PR has been raised to address Jira Ticket [DLIS-6803]

Replaces the existing (pytest.fixture and generator) approach with ScopedTritonServer, a context manager, that starts and kills the server.

Specific features being added/addressed in this PR:

  • Eliminates the need for pytest.fixture to kill the background server.
  • Eliminates the need for generators to kill the background server.
  • Reduces the number of server-related arguments passed to the testing functions
  • Context Manager (ScopedTritonServer) abstracts away process id logic from the test functions
  • ScopedTritonServer Functions:
  • __enter__(): Sends start up command and polls until server is ready
  • __exit__(): Kills the server

tests/utils.py Outdated Show resolved Hide resolved
tests/utils.py Outdated Show resolved Hide resolved
tests/test_e2e.py Outdated Show resolved Hide resolved
tests/utils.py Outdated
self.timeout = timeout

def __enter__(self):
run(["remove", "-m", "all"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you make the following tweaks for use of clear()?

  1. move the _clear() helper into utils.py and use it here?
  2. Add a if repo: clause to the _clear() helper, I just realized it's missing. Will look like this.
  3. Update the other calls to do utils.clear() instead of self._clear()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it make sense to move all the helper functions into utils.py? It will reduce the replication of helper functions between test_cli.py and test_e2e.py.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good if being replicated

Copy link
Collaborator

@rmccorm4 rmccorm4 left a comment

Choose a reason for hiding this comment

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

Nice changes! Left some minor comments. CC @krishung5 for comments too.

@rmccorm4 rmccorm4 requested a review from krishung5 May 31, 2024 21:01
tests/test_e2e.py Outdated Show resolved Hide resolved
tests/test_e2e.py Outdated Show resolved Hide resolved
tests/utils.py Outdated Show resolved Hide resolved
tests/utils.py Outdated Show resolved Hide resolved
tests/test_cli.py Outdated Show resolved Hide resolved
Copy link
Contributor

@krishung5 krishung5 left a comment

Choose a reason for hiding this comment

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

Just some minor comments. Great work!

tests/test_e2e.py Outdated Show resolved Hide resolved
@KrishnanPrash KrishnanPrash changed the title Mock Server ScopedTritonServer Server May 31, 2024
@rmccorm4 rmccorm4 changed the title ScopedTritonServer Server Use a ScopedTritonServer instead of pytest fixtures for simpler testing May 31, 2024
@rmccorm4 rmccorm4 changed the title Use a ScopedTritonServer instead of pytest fixtures for simpler testing test: Simplify testing with ScopedTritonServer instead of pytest fixtures May 31, 2024
@rmccorm4 rmccorm4 changed the title test: Simplify testing with ScopedTritonServer instead of pytest fixtures refactor: Simplify testing with ScopedTritonServer instead of pytest fixtures May 31, 2024
Copy link
Collaborator

@rmccorm4 rmccorm4 left a comment

Choose a reason for hiding this comment

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

Nice refactoring!

@KrishnanPrash KrishnanPrash merged commit 4e62d74 into main Jun 3, 2024
6 checks passed
@KrishnanPrash KrishnanPrash deleted the kprashanth-mock-server branch June 4, 2024 18:12
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.

3 participants