Skip to content

Conversation

@giancarloromeo
Copy link
Contributor

@giancarloromeo giancarloromeo commented Nov 19, 2025

What do these changes do?

This PR fixes a flaky test in test_search_directories by improving test reliability and adding utility functions for file ID level detection. The changes introduce helper functions to determine file nesting levels and modify the deletion logic to skip parent directory updates for root-level files.

Key Changes:

  • Added utility functions (get_file_id_level, is_nested_level_file_id) to detect file nesting depth
  • Modified delete_file to conditionally update parent directories based on file nesting level
  • Enhanced test coverage with additional subdirectory test case and comprehensive parameterized tests

Related issue/s

How to test

cd services/storage
pytest -vv --pdb tests/unit/test_simcore_s3_dsm.py::test_search_directories

Dev-ops

  • No changes

@giancarloromeo giancarloromeo added this to the Imparable milestone Nov 19, 2025
@giancarloromeo giancarloromeo self-assigned this Nov 19, 2025
@giancarloromeo giancarloromeo added the a:storage issue related to storage service label Nov 19, 2025
@giancarloromeo giancarloromeo changed the title 🐛 Flaky test_search_directories 🐛 Fix flaky test_search_directories Nov 19, 2025
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.24%. Comparing base (342a041) to head (e34422c).
⚠️ Report is 1 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (342a041) and HEAD (e34422c). Click for more details.

HEAD has 31 uploads less than BASE
Flag BASE (342a041) HEAD (e34422c)
unittests 32 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #8621       +/-   ##
===========================================
- Coverage   87.51%   67.24%   -20.27%     
===========================================
  Files        2010      836     -1174     
  Lines       78979    38032    -40947     
  Branches     1377      154     -1223     
===========================================
- Hits        69118    25576    -43542     
- Misses       9459    12407     +2948     
+ Partials      402       49      -353     
Flag Coverage Δ
integrationtests 63.89% <ø> (-0.05%) ⬇️
unittests 86.62% <100.00%> (+0.29%) ⬆️
Components Coverage Δ
pkg_aws_library ∅ <ø> (∅)
pkg_celery_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library ∅ <ø> (∅)
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 75.29% <ø> (-9.16%) ⬇️
agent ∅ <ø> (∅)
api_server ∅ <ø> (∅)
autoscaling ∅ <ø> (∅)
catalog ∅ <ø> (∅)
clusters_keeper ∅ <ø> (∅)
dask_sidecar ∅ <ø> (∅)
datcore_adapter ∅ <ø> (∅)
director ∅ <ø> (∅)
director_v2 78.62% <ø> (-12.61%) ⬇️
dynamic_scheduler ∅ <ø> (∅)
dynamic_sidecar 82.05% <ø> (-8.77%) ⬇️
efs_guardian ∅ <ø> (∅)
invitations ∅ <ø> (∅)
payments ∅ <ø> (∅)
resource_usage_tracker ∅ <ø> (∅)
storage 86.62% <100.00%> (-0.09%) ⬇️
webclient ∅ <ø> (∅)
webserver 58.86% <ø> (-27.85%) ⬇️

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 342a041...e34422c. 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.

@giancarloromeo giancarloromeo marked this pull request as ready for review November 19, 2025 10:56
@mergify
Copy link
Contributor

mergify bot commented Nov 19, 2025

🧪 CI Insights

Here's what we observed from your CI run for e34422c.

✅ Passed Jobs With Interesting Signals

Pipeline Job Signal Health on master Retries 🔍 CI Insights 📄 Logs
CI unit-tests Base branch is broken, but the job passed. Looks like this might be a real fix 💪 Broken 0 View View

…:giancarloromeo/osparc-simcore into is8619/fix-flaky-test-search-directories
Copy link
Collaborator

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

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

thanks

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.

Not sure I get what was "fixed" here.
create_directory_with_files is used in many other tests.
What I see is that in case we run that test and interrupt it, the cleanup_files_closure might not be called --> which will leak files.

I find not very helpful to have 2 fixtures that do more or less the same, in the same package and nobody knows when to use one or the other. What was the issue?

@giancarloromeo giancarloromeo added the 🤖-do-not-merge (optional) blocks Mergify from merging the PR label Nov 19, 2025
Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

nothing happened here!

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

i guess you noticed :-)

@giancarloromeo
Copy link
Contributor Author

nothing happened here!

A real bug in storage popped up, that's why :) Putting it back to Draft.

@giancarloromeo giancarloromeo marked this pull request as draft November 20, 2025 10:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a flaky test in test_search_directories by improving test reliability and adding utility functions for file ID level detection. The changes introduce helper functions to determine file nesting levels and modify the deletion logic to skip parent directory updates for root-level files.

Key Changes:

  • Added utility functions (get_file_id_level, is_nested_level_file_id) to detect file nesting depth
  • Modified delete_file to conditionally update parent directories based on file nesting level
  • Enhanced test coverage with additional subdirectory test case and comprehensive parameterized tests

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
services/storage/src/simcore_service_storage/utils/simcore_s3_dsm_utils.py Introduces utility functions for calculating file ID levels and detecting nested files, plus updates to use S3_OBJECT_DELIMITER constant
services/storage/src/simcore_service_storage/simcore_s3_dsm.py Modifies delete_file logic to skip parent directory updates for root-level files using the new is_nested_level_file_id check
services/storage/tests/unit/test_simcore_s3_dsm.py Adds nested subdirectory test case to verify search functionality for deeper directory structures
services/storage/tests/unit/test_simcore_s3_dsm_utils.py Adds comprehensive parameterized tests for the new utility functions covering edge cases and various path formats

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giancarloromeo giancarloromeo changed the title 🐛 Fix flaky test_search_directories 🐛 Concurrent deletion of files at root level causes deadlock Nov 20, 2025
@giancarloromeo giancarloromeo marked this pull request as ready for review November 20, 2025 14:54
@sonarqubecloud
Copy link

@giancarloromeo giancarloromeo removed the 🤖-do-not-merge (optional) blocks Mergify from merging the PR label Nov 20, 2025
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.

thanks!

@giancarloromeo giancarloromeo enabled auto-merge (squash) November 20, 2025 16:38
@giancarloromeo
Copy link
Contributor Author

@mergify queue

@mergify
Copy link
Contributor

mergify bot commented Nov 20, 2025

queue

🟠 Waiting for conditions to match

  • -closed [📌 queue requirement]
  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue default]
      • label=🤖-automerge
      • #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
      • 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
      • any of: [🛡 GitHub branch protection]
        • check-success = SonarCloud Code Analysis
        • check-neutral = SonarCloud Code Analysis
        • check-skipped = SonarCloud Code Analysis
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of: [📌 queue -> configuration change requirements]
    • -mergify-configuration-changed
    • check-success = Configuration changed

@giancarloromeo giancarloromeo merged commit 0f6f080 into ITISFoundation:master Nov 20, 2025
90 of 94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a:storage issue related to storage service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flaky tests/unit/test_simcore_s3_dsm.py::test_search_directories

6 participants