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

test(cosmic-swingset): Add test coverage for Prometheus output #10954

Merged
merged 15 commits into from
Feb 9, 2025

Conversation

gibson042
Copy link
Member

Extends #10941
Fixes #10911

Description

Extracts a testable launchChain unit in packages/cosmic-swingset/src/chain-main.js, and uses that for an ava snapshot test of localhost:${OTEL_EXPORTER_PROMETHEUS_PORT}/metrics. Includes incidental fixes and utility additions along the way (and therefore best reviewed by commit).

Security Considerations

None known.

Scaling Considerations

n/a

Documentation Considerations

n/a

Testing Considerations

Just the usual --update-snapshots when things change.

Upgrade Considerations

n/a

@gibson042 gibson042 requested a review from mhofman February 6, 2025 03:58
@gibson042 gibson042 requested a review from a team as a code owner February 6, 2025 03:58
@gibson042 gibson042 force-pushed the gibson-10911-prometheus-snapshot branch from af8cdb2 to 799daa7 Compare February 6, 2025 04:31
Copy link

cloudflare-workers-and-pages bot commented Feb 6, 2025

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: a820af8
Status: ✅  Deploy successful!
Preview URL: https://87e763ce.agoric-sdk.pages.dev
Branch Preview URL: https://gibson-10911-prometheus-snap.agoric-sdk.pages.dev

View logs

@gibson042 gibson042 changed the base branch from master to gibson-10937-update-opentelemetry February 6, 2025 04:34
@gibson042 gibson042 force-pushed the gibson-10911-prometheus-snapshot branch from 799daa7 to 452567e Compare February 6, 2025 04:35
Base automatically changed from gibson-10937-update-opentelemetry to master February 6, 2025 16:49
Copy link

github-actions bot commented Feb 6, 2025

Base branch is changed to master. Please re-run the integration tests by adding 'force:integration' label.

Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

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

This looks like the beginning of some awesome test framework for cosmic-swingset. Pretty amazing!

I am however concerned the hangover / savedChainSends logic got hurt in the refactor. (it was really hard to track where things moved, I kinda wish that refactor commit could have been split in multiple commits to facilitate diffing)

packages/cosmic-swingset/src/chain-main.js Outdated Show resolved Hide resolved
packages/cosmic-swingset/src/chain-main.js Show resolved Hide resolved
packages/internal/src/js-utils.js Outdated Show resolved Hide resolved
packages/internal/src/js-utils.js Outdated Show resolved Hide resolved
import '@endo/eventual-send/shim.js';

try {
lockdown({ __hardenTaming__: 'unsafe' });
Copy link
Member

Choose a reason for hiding this comment

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

Sad, we can't even test if the intrinsics are frozen with unsafe harden.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm pretty sure this matches behavior of the import '@endo/init/unsafe-fast.js's it is replacing:

https://github.com/endojs/endo/blob/master/packages/init/unsafe-fast.js

We might be able to change it; I just needed to avoid double-lockdown errors.

Copy link
Member

Choose a reason for hiding this comment

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

The part that you're missing is that '@endo/init/pre.js' is mapped to init/src/pre-node.js on node through the package.json exports, which imports both './node-async_hooks-patch.js' and '../pre.js'.

Copy link
Member

Choose a reason for hiding this comment

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

Should the file's name capture this is doing an unsafe lockdown ?

Copy link
Member

Choose a reason for hiding this comment

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

Also the original @endo/init also tames async_hooks which this doesn't do. See endojs/endo#2711

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fine with this as-is, but will accept suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer renaming this file to maybe-unsafe-lockdown.js to avoid hiding the unsafe harden taming.

@gibson042 gibson042 force-pushed the gibson-10911-prometheus-snapshot branch from e32baf0 to 96713e6 Compare February 7, 2025 19:27
@gibson042 gibson042 requested a review from mhofman February 7, 2025 19:52
Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

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

Thanks so much for rebasing and splitting that refactor commit. It's so much easier to follow now.

Besides the minor feedback on the maybe lockdown file, this looks great! Feel free to merge once ready.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer renaming this file to maybe-unsafe-lockdown.js to avoid hiding the unsafe harden taming.

Comment on lines +247 to +251
const { name: dbDir, removeCallback: cleanupDB } = tmp.dirSync({
prefix: debugName || 'testdb',
unsafeCleanup: true,
});
const launchChain = makeLaunchChain(fakeAgcc, dbDir, {
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure that stateDBDir is unused if slogSender and swingStore are provided.

@gibson042 gibson042 added the automerge:rebase Automatically rebase updates, then merge label Feb 8, 2025
@gibson042 gibson042 force-pushed the gibson-10911-prometheus-snapshot branch from 2a77aac to a820af8 Compare February 8, 2025 23:36
Copy link
Contributor

mergify bot commented Feb 9, 2025

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

Copy link
Contributor

mergify bot commented Feb 9, 2025

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@mergify mergify bot merged commit 85bac81 into master Feb 9, 2025
83 checks passed
@mergify mergify bot deleted the gibson-10911-prometheus-snapshot branch February 9, 2025 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add snapshot test of prometheus metrics
2 participants