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

SQS-347 | integration, synthetic monitoring tests for active orders #504

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

deividaspetraitis
Copy link
Collaborator

@deividaspetraitis deividaspetraitis commented Sep 9, 2024

Implements integration, synthetic monitoring tests for the for active orders query. Additionally adds test file for locust.

Summary by CodeRabbit

  • New Features

    • Introduced a new class for handling active orderbook orders, enhancing integration testing capabilities.
    • Added functionality to fetch active orders through a dedicated service method and endpoint.
  • Tests

    • Expanded test coverage for active orderbook orders, including latency performance metrics and response validation.
    • Introduced new test cases for the /passthrough/active-orders endpoint to ensure comprehensive testing.
  • Chores

    • Minor formatting adjustments for improved readability in the test suite.

query

Implements integration, synthetic monitoring tests for the for active orders
query. Additionally adds test file for locust.
Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Walkthrough

This pull request introduces enhancements across multiple files, including the addition of the PassthroughOrderbookActiveOrders class in locust/passthrough_orderbook_active_orders.py for load testing active orders. It also expands the test suite in tests/test_passthrough.py with new methods for validating active orderbook orders, and introduces a new test in tests/test_synthetic_geo.py to further ensure coverage of the /passthrough/active-orders endpoint.

Changes

Files Change Summary
locust/locustfile.py, locust/passthrough_orderbook_active_orders.py Added import statement for PassthroughOrderbookActiveOrders class and defined the class with a task for HTTP GET requests to the active orders endpoint.
tests/test_passthrough.py, tests/test_synthetic_geo.py Added a test method for validating active orderbook orders, including latency checks and response validation, and introduced a new test case for the /passthrough/active-orders endpoint.

Poem

🐇 In the meadow, changes bloom,
New classes and tests, making room.
Orderbooks dance, with data in tow,
Fetching and validating, watch them glow!
With every hop, our code takes flight,
A rabbit’s cheer for progress bright! 🌼

Tip

Announcements
  • The review status is no longer posted as a separate comment when there are no actionable or nitpick comments. In such cases, the review status is included in the walkthrough comment.
  • We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs: Walkthrough comment now includes a list of potentially related PRs to help you recall past context. Please share any feedback in the discussion post on our Discord.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs in the walkthrough comment. You can also provide custom labeling instructions in the UI or configuration file.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9b9da98 and b4aa1a8.

Files selected for processing (4)
  • locust/locustfile.py (1 hunks)
  • locust/passthrough_orderbook_active_orders.py (1 hunks)
  • tests/test_passthrough.py (3 hunks)
  • tests/test_synthetic_geo.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • locust/passthrough_orderbook_active_orders.py
Files skipped from review as they are similar to previous changes (1)
  • tests/test_synthetic_geo.py
Additional context used
Ruff
locust/locustfile.py

8-8: passthrough_orderbook_active_orders.PassthroughOrderbookActiveOrders imported but unused

Remove unused import: passthrough_orderbook_active_orders.PassthroughOrderbookActiveOrders

(F401)

tests/test_passthrough.py

2-2: conftest imported but unused

Remove unused import: conftest

(F401)


3-3: pytest imported but unused

Remove unused import: pytest

(F401)


5-5: from sqs_service import * used; unable to detect undefined names

(F403)


8-8: from e2e_math import * used; unable to detect undefined names

(F403)


9-9: from decimal import * used; unable to detect undefined names

(F403)


51-51: Yoda condition detected

Rewrite as elapsed_time_ms < EXPECTED_LATENCY_UPPER_BOUND_MS

(SIM300)

Additional comments not posted (4)
tests/test_passthrough.py (4)

1-1: Also applies to: 2-2, 3-3, 5-5, 6-6, 8-8, 9-9


33-34: LGTM!

The code changes are approved.


37-56: LGTM!

The code changes are approved.

Tools
Ruff

51-51: Yoda condition detected

Rewrite as elapsed_time_ms < EXPECTED_LATENCY_UPPER_BOUND_MS

(SIM300)


55-55: LGTM!

The code changes are approved.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@deividaspetraitis deividaspetraitis added the A:backport/v26.x backport patches to v26.x branch label Sep 9, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

Outside diff range, codebase verification and nitpick comments (1)
locust/locustfile.py (1)

9-9: Remove unused import PassthroughOrderbookActiveOrders.

The import PassthroughOrderbookActiveOrders in locust/locustfile.py is not used anywhere in the file. It is recommended to remove this unused import to maintain clean and efficient code.

  • File: locust/locustfile.py
    • Line: from passthrough_orderbook_active_orders import PassthroughOrderbookActiveOrders
Analysis chain

Verify the usage of the new import.

It's important to ensure that the import PassthroughOrderbookActiveOrders is actually used in the file or planned for future use. If it's not used, it should be removed to avoid confusion and maintain clean code.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `PassthroughOrderbookActiveOrders` in `locustfile.py`.

# Test: Search for the usage of `PassthroughOrderbookActiveOrders`. Expect: At least one usage.
rg --type python 'PassthroughOrderbookActiveOrders' locust/locustfile.py

Length of output: 103


Script:

#!/bin/bash
# Description: Verify the usage of `PassthroughOrderbookActiveOrders` in `locustfile.py`.

# Test: Search for the usage of `PassthroughOrderbookActiveOrders`. Expect: At least one usage.
rg 'PassthroughOrderbookActiveOrders' locust/locustfile.py

Length of output: 139

Tools
Ruff

9-9: passthrough_orderbook_active_orders.PassthroughOrderbookActiveOrders imported but unused

Remove unused import: passthrough_orderbook_active_orders.PassthroughOrderbookActiveOrders

(F401)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ec649ca and 9b9da98.

Files selected for processing (6)
  • locust/locustfile.py (1 hunks)
  • locust/passthrough_orderbook_active_orders.py (1 hunks)
  • tests/active_orderbook_orders_response.py (1 hunks)
  • tests/sqs_service.py (2 hunks)
  • tests/test_passthrough.py (3 hunks)
  • tests/test_synthetic_geo.py (1 hunks)
Additional context used
Ruff
locust/locustfile.py

9-9: passthrough_orderbook_active_orders.PassthroughOrderbookActiveOrders imported but unused

Remove unused import: passthrough_orderbook_active_orders.PassthroughOrderbookActiveOrders

(F401)

tests/test_passthrough.py

2-2: conftest imported but unused

Remove unused import: conftest

(F401)


3-3: pytest imported but unused

Remove unused import: pytest

(F401)


5-5: from sqs_service import * used; unable to detect undefined names

(F403)


8-8: from e2e_math import * used; unable to detect undefined names

(F403)


9-9: from decimal import * used; unable to detect undefined names

(F403)


51-51: Yoda condition detected

Rewrite as elapsed_time_ms < EXPECTED_LATENCY_UPPER_BOUND_MS

(SIM300)


51-51: expected_latency_upper_bound_ms may be undefined, or defined from star imports

(F405)

tests/test_synthetic_geo.py

46-46: Redefinition of unused test_synth_passthrough_portfolio_assets from line 41

(F811)

Additional comments not posted (2)
locust/passthrough_orderbook_active_orders.py (1)

7-10: Basic functionality approved.

The implementation of the passthroughOrderbookActiveOrders task method aligns with the PR objectives to enhance testing for active orders. The method correctly uses the HttpUser client to make a GET request.

tests/test_passthrough.py (1)

33-56: New test method for active orders approved.

The new test method test_active_orderbook_orders and the helper function run_test_active_orderbook_orders are well-implemented and align with the PR objectives to enhance testing for active orders. The method correctly measures latency and validates the response, which is crucial for performance testing.

Tools
Ruff

51-51: Yoda condition detected

Rewrite as elapsed_time_ms < EXPECTED_LATENCY_UPPER_BOUND_MS

(SIM300)


51-51: expected_latency_upper_bound_ms may be undefined, or defined from star imports

(F405)

locust/passthrough_orderbook_active_orders.py Show resolved Hide resolved
locust/passthrough_orderbook_active_orders.py Outdated Show resolved Hide resolved
locust/locustfile.py Show resolved Hide resolved
tests/test_passthrough.py Show resolved Hide resolved
tests/test_passthrough.py Show resolved Hide resolved
tests/test_passthrough.py Show resolved Hide resolved
tests/test_synthetic_geo.py Outdated Show resolved Hide resolved
tests/active_orderbook_orders_response.py Show resolved Hide resolved
tests/sqs_service.py Show resolved Hide resolved
Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

LGTM overall but experienced this when running

================================================================ short test summary info =================================================================
FAILED tests/test_passthrough.py::TestPassthrough::test_active_orderbook_orders[http://localhost:9092] - NameError: name 'expected_latency_upper_bound_ms' is not defined

Let's please fix pre-merge

tests/test_synthetic_geo.py Outdated Show resolved Hide resolved
locust/passthrough_orderbook_active_orders.py Outdated Show resolved Hide resolved
locust/passthrough_orderbook_active_orders.py Show resolved Hide resolved
tests/test_synthetic_geo.py Outdated Show resolved Hide resolved
tests/test_passthrough.py Show resolved Hide resolved
Copy link

sonarcloud bot commented Sep 10, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 50%)

See analysis details on SonarCloud

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
tests/test_passthrough.py (1)

51-51: Consider rewriting the assertion condition for better readability.

The assertion condition is using a Yoda condition, which is a style where the constant is placed on the left side of the comparison operator. While it is a valid condition, it can be rewritten in the conventional way for better readability.

Apply this diff to rewrite the assertion condition:

-assert EXPECTED_LATENCY_UPPER_BOUND_MS > elapsed_time_ms, f"Error: latency {elapsed_time_ms} exceeded {EXPECTED_LATENCY_UPPER_BOUND_MS} ms"
+assert elapsed_time_ms < EXPECTED_LATENCY_UPPER_BOUND_MS, f"Error: latency {elapsed_time_ms} exceeded {EXPECTED_LATENCY_UPPER_BOUND_MS} ms"
Tools
Ruff

51-51: Yoda condition detected

Rewrite as elapsed_time_ms < EXPECTED_LATENCY_UPPER_BOUND_MS

(SIM300)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9b9da98 and b4aa1a8.

Files selected for processing (4)
  • locust/locustfile.py (1 hunks)
  • locust/passthrough_orderbook_active_orders.py (1 hunks)
  • tests/test_passthrough.py (3 hunks)
  • tests/test_synthetic_geo.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • locust/passthrough_orderbook_active_orders.py
Files skipped from review as they are similar to previous changes (1)
  • tests/test_synthetic_geo.py
Additional context used
Ruff
locust/locustfile.py

8-8: passthrough_orderbook_active_orders.PassthroughOrderbookActiveOrders imported but unused

Remove unused import: passthrough_orderbook_active_orders.PassthroughOrderbookActiveOrders

(F401)

tests/test_passthrough.py

2-2: conftest imported but unused

Remove unused import: conftest

(F401)


3-3: pytest imported but unused

Remove unused import: pytest

(F401)


5-5: from sqs_service import * used; unable to detect undefined names

(F403)


8-8: from e2e_math import * used; unable to detect undefined names

(F403)


9-9: from decimal import * used; unable to detect undefined names

(F403)


51-51: Yoda condition detected

Rewrite as elapsed_time_ms < EXPECTED_LATENCY_UPPER_BOUND_MS

(SIM300)

Additional comments not posted (4)
tests/test_passthrough.py (4)

1-1: Also applies to: 2-2, 3-3, 5-5, 6-6, 8-8, 9-9


33-34: LGTM!

The code changes are approved.


37-56: LGTM!

The code changes are approved.

Tools
Ruff

51-51: Yoda condition detected

Rewrite as elapsed_time_ms < EXPECTED_LATENCY_UPPER_BOUND_MS

(SIM300)


55-55: LGTM!

The code changes are approved.

@deividaspetraitis
Copy link
Collaborator Author

All suggestions were addressed, merging. 🚀

@deividaspetraitis deividaspetraitis merged commit 9de1489 into v25.x Sep 10, 2024
9 of 10 checks passed
@deividaspetraitis deividaspetraitis deleted the SQS-347-new branch September 10, 2024 09:15
mergify bot pushed a commit that referenced this pull request Sep 10, 2024
…504)

* SQS-347 | integration, synthetic monitoring tests for active orders
query

Implements integration, synthetic monitoring tests for the for active orders
query. Additionally adds test file for locust.

(cherry picked from commit 9de1489)
deividaspetraitis added a commit that referenced this pull request Sep 10, 2024
…504) (#507)

* SQS-347 | integration, synthetic monitoring tests for active orders
query

Implements integration, synthetic monitoring tests for the for active orders
query. Additionally adds test file for locust.

(cherry picked from commit 9de1489)

Co-authored-by: Deividas Petraitis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v26.x backport patches to v26.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants