Skip to content

Conversation

@nik-localstack
Copy link
Contributor

@nik-localstack nik-localstack commented Sep 24, 2025

Motivation

We want to collect test metrics when the system running pytest is not the same running LocalStack

Changes

  • Introduces the ability to store test metrics directly within the LocalStack container's filesystem instead of only in the system running pytest. This provides more flexibility for metric collection in different deployment scenarios (like when running in k8s)
  • Adds ENV_INTERNAL_TEST_STORE_METRICS_IN_LOCALSTACK environment variable to enable local filesystem storage
  • Adds ENV_INTERNAL_TEST_STORE_METRICS_PATH environment variable to specify custom storage path (defaults to /tmp/localstack-metrics)

@nik-localstack nik-localstack self-assigned this Sep 24, 2025
@nik-localstack nik-localstack added semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes labels Sep 24, 2025
@github-actions
Copy link

github-actions bot commented Sep 24, 2025

S3 Image Test Results (AMD64 / ARM64)

    2 files  ±0    2 suites  ±0   8m 12s ⏱️ +17s
  532 tests ±0  480 ✅ ±0   52 💤 ±0  0 ❌ ±0 
1 064 runs  ±0  960 ✅ ±0  104 💤 ±0  0 ❌ ±0 

Results for commit ecdd453. ± Comparison against base commit a4e351d.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Sep 24, 2025

Test Results - Preflight, Unit

22 291 tests  ±0   20 548 ✅ ±0   15m 21s ⏱️ -56s
     1 suites ±0    1 743 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit ecdd453. ± Comparison against base commit a4e351d.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Sep 24, 2025

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 23s ⏱️ +2s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit ecdd453. ± Comparison against base commit a4e351d.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Sep 24, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 38m 49s ⏱️
5 169 tests 4 673 ✅ 496 💤 0 ❌
5 175 runs  4 673 ✅ 502 💤 0 ❌

Results for commit ecdd453.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Sep 24, 2025

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   2h 0m 30s ⏱️ +30s
4 795 tests ±0  4 459 ✅ ±0  336 💤 ±0  0 ❌ ±0 
4 797 runs  ±0  4 459 ✅ ±0  338 💤 ±0  0 ❌ ±0 

Results for commit ecdd453. ± Comparison against base commit a4e351d.

♻️ This comment has been updated with latest results.

@alexrashed alexrashed added the notes: skip Pull request does not have to be mentioned in the release notes label Sep 24, 2025
@nik-localstack nik-localstack added this to the 4.10 milestone Sep 26, 2025
@nik-localstack nik-localstack force-pushed the k8s/tests-api-coverage branch 3 times, most recently from 578366d to 1fda6e1 Compare October 2, 2025 12:54
@nik-localstack nik-localstack force-pushed the k8s/tests-api-coverage branch from 1fda6e1 to ecdd453 Compare October 6, 2025 09:11
@nik-localstack nik-localstack marked this pull request as ready for review October 6, 2025 14:51
@nik-localstack nik-localstack requested a review from thrau as a code owner October 6, 2025 14:51
@nik-localstack nik-localstack requested a review from a team October 6, 2025 14:51
Copy link
Contributor

@cloutierMat cloutierMat left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this! 🚀 Overall the changes look good and I like the use of constants here instead of hardcoded strings 👍

I am not sure about the file saving strategy, we now lose the de-duplicate and we are doing file operations on every request. I would like have a bit more insight over the impact of those changes before merging.

# refrain from adding duplicates
if metric not in MetricHandler.metric_data:
MetricHandler.metric_data.append(metric)
self.append_metric(metric)
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Since when storing the file locally, we don't append to MetricHandler.metric_data this won't prevent duplicate. Do you know if the risk of duplicate entry is high? The pr that introduces it doesn't give much more information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand the need of adding duplicates. In the localstack-docs script https://github.com/localstack/localstack-docs/blob/main/scripts/create_data_coverage.py that uses these files, duplication is not affecting the results.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure either, it is also only called from a single response handler, not too sure how there could even be a duplicate in the first place 🤷‍♂️

Comment on lines +236 to +238
with open(self.local_filename, "a") as fd:
writer = csv.writer(fd)
writer.writerow(metric)
Copy link
Contributor

Choose a reason for hiding this comment

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

question: My understanding is that every request going through our gateway will create an entry and open/close the csv file. Have you tested the cost implication of this? Do you have any full run example showing the additional cost is minimal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests may take ~3 minutes more than before so the impact is not that big.
We can reiterate and improve later if it starts becoming an issue, wdyt ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds reasonable enough 😄

Copy link
Contributor Author

@nik-localstack nik-localstack left a comment

Choose a reason for hiding this comment

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

Thanks for the review @cloutierMat
I agree with your concerns, and I tried to think of a better approach but given that this flow is a bit outdated (and most of the data that are created from these report files are not used anymore) I don't think it makes sense to invest more time now. Ideally we can re-iterate if this becomes an issue, or if/when we clean up this process a bit.

Comment on lines +236 to +238
with open(self.local_filename, "a") as fd:
writer = csv.writer(fd)
writer.writerow(metric)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests may take ~3 minutes more than before so the impact is not that big.
We can reiterate and improve later if it starts becoming an issue, wdyt ?

# refrain from adding duplicates
if metric not in MetricHandler.metric_data:
MetricHandler.metric_data.append(metric)
self.append_metric(metric)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand the need of adding duplicates. In the localstack-docs script https://github.com/localstack/localstack-docs/blob/main/scripts/create_data_coverage.py that uses these files, duplication is not affecting the results.

Copy link
Contributor

@cloutierMat cloutierMat left a comment

Choose a reason for hiding this comment

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

Thanks for answering my concerns @nik-localstack!

🚀 LGTM

# refrain from adding duplicates
if metric not in MetricHandler.metric_data:
MetricHandler.metric_data.append(metric)
self.append_metric(metric)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure either, it is also only called from a single response handler, not too sure how there could even be a duplicate in the first place 🤷‍♂️

Comment on lines +236 to +238
with open(self.local_filename, "a") as fd:
writer = csv.writer(fd)
writer.writerow(metric)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds reasonable enough 😄

@nik-localstack nik-localstack merged commit 343d436 into main Oct 13, 2025
48 checks passed
@nik-localstack nik-localstack deleted the k8s/tests-api-coverage branch October 13, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants