Skip to content

Conversation

@pcrespov
Copy link
Member

@pcrespov pcrespov commented Jun 17, 2025

What do these changes do?

This PR aims to standardize the testing of ApplicationSettings across all services. Currently, there are inconsistencies in how environment variables are mocked in tests. These differences must be addressed before we can enforce the upcoming feature that allows replacing .env-devel with an external env file. Some groundwork was left as-is where already present, but a thorough review is still required.

Highlights

  • All services now include a test_core_settings.py module
    • Exception: web/server, where the file is named test_application_settings.py image
  • Each test suite includes at least one test verifying ApplicationSettings behavior for different app_environment values
    • ⚠️ The fixtures used to mock environment variables differ across services (see Follow Up)

Follow-Up Work Required

To complete the unification:

  • ✅ Standardize fixture names used for mocking environment variables
  • ✅ Harmonize mocking workflows, which currently vary:
    • Some use .env-devel filtered via docker-compose.yml’s environment section
    • Others rely on different or inconsistent methods
  • Unify usage of external_envfile_dict: will allow to run tests against configurations in deploys
    • Refactor so that it has to be explicitly enabled in the test that we want to use it, instead of as a generic fixture (which might have unexpected and bad consequences)

Related issue/s

How to test

⚠️ Warning: Use --external-envfile with care. Some tests might unintentionally affect real deployments (e.g. delete/write databases, ...)

This is how we validate an ApplicationSettings against an actual envfile ( NOTE: only for services that use --external-envfile )

  1. create a symbolic link to the repo root and name it .secrets
cd osparc-simcore
ln -s /path/to/osparc-config/deployments/mydeploy.com/repo.config .secrets
  1. Update .vscode/launch.json from the template
  2. Run pytest with --external-envfile option
    • UI: Open a test_core_settings.py and run Python: Test w/ repo.config
      image
    • Command line (e.g. for catalog)
cd services/catalog
# w/o external
pytest -vv -s tests/unit -k test_valid_application_settings

# w/ external envfile
pytest -vv --log-cli-level=INFO --external-envfile=../../.secrets tests/unit -k test_valid_application_settings```

image

Dev-ops

None

@codecov
Copy link

codecov bot commented Jun 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.05%. Comparing base (6903354) to head (ef422ad).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7919      +/-   ##
==========================================
+ Coverage   88.04%   88.05%   +0.01%     
==========================================
  Files        1846     1839       -7     
  Lines       71225    71035     -190     
  Branches     1220     1220              
==========================================
- Hits        62707    62553     -154     
+ Misses       8166     8130      -36     
  Partials      352      352              
Flag Coverage Δ
integrationtests 64.20% <ø> (-0.08%) ⬇️
unittests 86.65% <ø> (+0.02%) ⬆️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library 93.92% <ø> (ø)
pkg_dask_task_models_library 79.62% <ø> (ø)
pkg_models_library 93.27% <ø> (ø)
pkg_notifications_library 85.26% <ø> (ø)
pkg_postgres_database 88.18% <ø> (ø)
pkg_service_integration 69.92% <ø> (ø)
pkg_service_library 72.67% <ø> (ø)
pkg_settings_library 90.90% <ø> (ø)
pkg_simcore_sdk 85.05% <ø> (ø)
agent 96.29% <ø> (ø)
api_server 92.31% <ø> (ø)
autoscaling 96.03% <ø> (ø)
catalog 92.29% <ø> (ø)
clusters_keeper 99.13% <ø> (ø)
dask_sidecar 91.79% <ø> (ø)
datcore_adapter 97.94% <ø> (ø)
director 76.73% <ø> (ø)
director_v2 91.14% <ø> (-0.02%) ⬇️
dynamic_scheduler 96.69% <ø> (ø)
dynamic_sidecar 90.09% <ø> (ø)
efs_guardian 89.65% <ø> (ø)
invitations 93.00% <ø> (ø)
payments 92.57% <ø> (ø)
resource_usage_tracker 89.00% <ø> (ø)
storage 87.53% <ø> (+0.07%) ⬆️
webclient ∅ <ø> (∅)
webserver 87.66% <ø> (-0.05%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6903354...ef422ad. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pcrespov pcrespov self-assigned this Jun 17, 2025
@pcrespov pcrespov added this to the Engage milestone Jun 17, 2025
@pcrespov pcrespov added a:storage issue related to storage service a:director issue related with the director service a:webserver webserver's codebase. Assigning the area is particularly useful for bugs a:catalog catalog service a:director-v2 issue related with the director-v2 service a:apiserver api-server service a:autoscaling autoscaling service in simcore's stack a:agent agent service a:invitations invitations service a:resource-usage-tracker resource usage tracker service a:clusters-keeper a:payments area: payments service a:dynamic-scheduler a:datcore-adapter a:notifications labels Jun 17, 2025
@pcrespov pcrespov force-pushed the is7395/test-settings branch from 94d77b8 to b04258d Compare June 17, 2025 18:40
@pcrespov pcrespov added the t:maintenance Some planned maintenance work label Jun 17, 2025
@pcrespov pcrespov changed the title Is7395/test settings ♻️ Maintenance: Unify ApplicationSettings Testing Across Services and Prepare for External Env File Support Jun 17, 2025
@pcrespov pcrespov marked this pull request as ready for review June 17, 2025 18:45
@pcrespov pcrespov enabled auto-merge (squash) June 17, 2025 18:46
@pcrespov
Copy link
Member Author

@mergify queue

@pcrespov pcrespov added the 🤖-automerge marks PR as ready to be merged for Mergify label Jun 18, 2025
@mergify
Copy link
Contributor

mergify bot commented Jun 18, 2025

queue

🟠 Waiting for conditions to match

  • -closed [📌 queue requirement]
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of: [📌 queue -> configuration change requirements]
    • -mergify-configuration-changed
    • check-success = Configuration changed
  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default]
      • #approved-reviews-by >= 2 [🛡 GitHub branch protection]
      • #approved-reviews-by>=2
      • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
      • #changes-requested-reviews-by=0
      • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
      • #review-threads-unresolved=0
      • -conflict
      • -draft
      • base=master
      • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
      • label!=🤖-do-not-merge
      • label=🤖-automerge
      • any of: [🛡 GitHub branch protection]
        • check-skipped = deploy to dockerhub
        • check-neutral = deploy to dockerhub
        • check-success = deploy to dockerhub
      • any of: [🛡 GitHub branch protection]
        • check-success = system-tests
        • check-neutral = system-tests
        • check-skipped = system-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = unit-tests
        • check-neutral = unit-tests
        • check-skipped = unit-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = check OAS' are up to date
        • check-neutral = check OAS' are up to date
        • check-skipped = check OAS' are up to date
      • any of: [🛡 GitHub branch protection]
        • check-success = integration-tests
        • check-neutral = integration-tests
        • check-skipped = integration-tests
      • any of: [🛡 GitHub branch protection]
        • check-success = build-test-images (frontend) / build-test-images
        • check-neutral = build-test-images (frontend) / build-test-images
        • check-skipped = build-test-images (frontend) / build-test-images

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

This can be a very DANGEROUS feature and I would like to be sure that it is clear with every dev that this can affect the deployments depending on what test(s) are being run. Otherwise I like that it is made simpler. but ideally we should prevent tests that are not only read-only...

@sonarqubecloud
Copy link

@pcrespov pcrespov merged commit c1d1065 into ITISFoundation:master Jun 22, 2025
95 checks passed
@pcrespov pcrespov deleted the is7395/test-settings branch June 25, 2025 08:18
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Aug 5, 2025
88 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-automerge marks PR as ready to be merged for Mergify a:agent agent service a:apiserver api-server service a:autoscaling autoscaling service in simcore's stack a:catalog catalog service a:clusters-keeper a:datcore-adapter a:director issue related with the director service a:director-v2 issue related with the director-v2 service a:dynamic-scheduler a:invitations invitations service a:notifications a:payments area: payments service a:resource-usage-tracker resource usage tracker service a:storage issue related to storage service a:webserver webserver's codebase. Assigning the area is particularly useful for bugs t:maintenance Some planned maintenance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test settings against repo.config(s) @pcrespov

5 participants