Skip to content

VED-1260 Mock PDS lambda rate limiting in ref env#1427

Open
amarauzoma wants to merge 36 commits intomasterfrom
VED-1235-Lambda-to-mock-PDS-in-Ref
Open

VED-1260 Mock PDS lambda rate limiting in ref env#1427
amarauzoma wants to merge 36 commits intomasterfrom
VED-1235-Lambda-to-mock-PDS-in-Ref

Conversation

@amarauzoma
Copy link
Copy Markdown
Contributor

@amarauzoma amarauzoma commented Apr 17, 2026

  • Replaced deployed ref mock PDS dependency with local test-only mock tooling.
  • Added local PDS stub + dedicated Locust profile for average/boundary/spike rate-limit validation.
  • Added simple make commands with preset rates (125 average, 130 boundary, spike profile).
  • Updated docs and removed obsolete mock deployment wiring from infra/workflows.
  • Outcome: same rate-limit validation intent, cleaner and faster test execution, no unnecessary ref endpoint dependency.

amarauzoma and others added 2 commits April 17, 2026 12:51
- Added a new Lambda function to simulate PDS responses for patient lookups.
- Implemented rate limiting with configurable average and spike thresholds.
- Updated existing MNS publisher to utilize the new PDS base URL environment variable.
- Enhanced tests to cover scenarios with the mock PDS service, including rate limit handling.
- Created performance testing scripts to validate MNS behavior under load with the mock PDS.
- Updated infrastructure to route PDS calls in the ref environment to the mock endpoint.
- Streamlined the initialization of MockPdsService by consolidating parameters.
- Replaced multiple response methods with a unified error handling approach.
- Enhanced readability by reducing redundant code in the patient lookup logic.
- Updated tests to utilize helper functions for event creation and decision mocking.
@amarauzoma amarauzoma changed the title feat: Introduce Mock PDS Lambda for MNS integration testing VED-1235 Lambda-to-mock-PDS-in-Ref Apr 17, 2026
- Deleted the performance testing plan document for MNS integration with mocked PDS.
- This document outlined objectives, delivery approaches, and existing architecture for implementing a mocked PDS service.
…mock-PDS-in-Ref

Made-with: Cursor

# Conflicts:
#	tests/perf_tests/Makefile
- Removed the global service retrieval function and directly initialized the MockPdsService with a Redis client and rate limiter.
- Updated the lambda_handler to use the initialized service directly, improving performance and readability.
- Adjusted unit tests to accommodate the new service initialization approach, ensuring proper mocking and error handling.
… tests

- Updated sonar-project.properties to include coverage report for mock_pds.
- Added new unit tests for Mock PDS service to improve test coverage and handle edge cases.
- Introduced a new test file for rate limiting functionality in the Mock PDS service.
- Updated the quality-checks workflow to run tests for the new mock_pds service.
- Introduced a new Mock PDS Lambda function to simulate PDS responses.
- Created an ECR repository for the Mock PDS service with appropriate policies.
- Updated deployment workflows to include mock_pds in build flags and image overrides.
- Enhanced infrastructure configuration to support the new Mock PDS service, including image URI handling and environment variable setup.
Thomas-Boyle
Thomas-Boyle previously approved these changes Apr 22, 2026
Comment thread lambdas/mock_pds/pyproject.toml Outdated
Comment thread infrastructure/instance/mock_pds.tf
Comment thread .github/workflows/deploy-backend.yml
Comment thread lambdas/mock_pds/src/mock_pds_service.py
Comment thread lambdas/mock_pds/src/mock_pds_service.py
Comment thread .github/workflows/quality-checks.yml Outdated
Comment thread lambdas/shared/src/common/api_clients/get_pds_details.py Outdated
Copy link
Copy Markdown
Contributor

@avshetty1980 avshetty1980 left a comment

Choose a reason for hiding this comment

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

Nice, just a few nits.
I like the average + spike rate limiting with Redis atomicity per window

Comment thread lambdas/mock_pds/Dockerfile Fixed
…ient lookup functionality

- Add pyproject.toml for dependency management using Poetry
- Create lambda_handler.py to handle incoming requests and integrate with MockPdsService
- Implement MockPdsService to manage patient lookup and rate limiting logic
- Introduce FixedWindowRateLimiter for controlling request rates using Redis
- Add unit tests for MockPdsService and rate limiter functionality
- Update performance test setup to target deployed mock PDS Lambda instead of local server
- Remove local mock server implementation and related references from performance tests
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
17.7% Coverage on New Code (required ≥ 80%)
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

RUN mkdir -p /home/appuser && \
echo 'appuser:x:1001:1001::/home/appuser:/sbin/nologin' >> /etc/passwd && \
echo 'appuser:x:1001:' >> /etc/group && \
chown -R 1001:1001 /home/appuser && pip install "poetry~=2.1.4"
RUN mkdir -p /home/appuser && \
echo 'appuser:x:1001:1001::/home/appuser:/sbin/nologin' >> /etc/passwd && \
echo 'appuser:x:1001:' >> /etc/group && \
chown -R 1001:1001 /home/appuser && pip install "poetry~=2.1.4"
COPY ./mock_pds/poetry.lock ./mock_pds/pyproject.toml ./

WORKDIR /var/task
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request infrastructure Pull requests that update terraform code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants