Skip to content

Add first integration tests for metrics tool - #222

Merged
0xB10C merged 19 commits into
masterfrom
2025-08-first-steps-intregration-test
Aug 18, 2025
Merged

0xB10C merged 19 commits into
masterfrom
2025-08-first-steps-intregration-test

Conversation

@0xB10C

@0xB10C 0xB10C commented Aug 13, 2025

Copy link
Copy Markdown
Collaborator

The integration tests start a nats-server (needs to be provided with NATS_SERVER_BINARY) for each test on a random port and check that publishing an event into NATS results in the metrics being set to a certain value.

$ cargo test --features nats_integration_tests

As a drive-by, this resolves (partially) #192 for the metrics tool.

Part of #26

@0xB10C
0xB10C force-pushed the 2025-08-first-steps-intregration-test branch 2 times, most recently from 6a66532 to 1facbc3 Compare August 13, 2025 15:35
@0xB10C
0xB10C marked this pull request as ready for review August 13, 2025 15:46
Comment thread tools/metrics/tests/integration.rs Resolved
@0xB10C
0xB10C force-pushed the 2025-08-first-steps-intregration-test branch from 1facbc3 to ec0eacf Compare August 13, 2025 21:32
@0xB10C

0xB10C commented Aug 13, 2025

Copy link
Copy Markdown
Collaborator Author

This might not work as is: The metrics are registered as static and we share state between all test cases. There is no way of resetting it.

An alternative is a custom registry, but then we'd need to manually define an register the metrics. A macro can probably help out here..

@0xB10C

0xB10C commented Aug 14, 2025

Copy link
Copy Markdown
Collaborator Author

An alternative is a custom registry, but then we'd need to manually define an register the metrics. A macro can probably help out here..

done that

@0xB10C
0xB10C force-pushed the 2025-08-first-steps-intregration-test branch 2 times, most recently from 77ffcb4 to 315182a Compare August 15, 2025 12:16
@0xB10C

0xB10C commented Aug 16, 2025

Copy link
Copy Markdown
Collaborator Author

I'm a bit puzzled about the CI failure in the Ubuntu job. It seems to be only happening sometimes. The connectivity-check tool isn't touched much and especially not the metrics of the tool.

   Compiling connectivity-check v0.1.0 (/home/runner/work/peer-observer/peer-observer/tools/connectivity-check)
error: constant `SUBSYSTEM_RUNTIME` is never used
  --> tools/connectivity-check/src/metrics.rs:11:7
   |
11 | const SUBSYSTEM_RUNTIME: &str = "runtime";
   |       ^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> tools/connectivity-check/src/main.rs:1:38
   |
1  | #![cfg_attr(feature = "strict", deny(warnings))]
   |                                      ^^^^^^^^
   = note: `#[deny(dead_code)]` implied by `#[deny(warnings)]`

error: could not compile `connectivity-check` (bin "connectivity-check") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 101.

0xB10C added a commit that referenced this pull request Aug 16, 2025
Remove the metric from connectivity-check, because it's currently
unused, the docs are wrong, and probably not needed at all.

Also, the CI in #222 (comment)
seems to be having problems due to this. Possibly only found by a
newer rust version on Ubuntu.
0xB10C added a commit that referenced this pull request Aug 16, 2025
Remove the metric from connectivity-check, because it's currently
unused, the docs are wrong, and probably not needed at all.

Also, the CI in #222 (comment)
seems to be having problems due to this. Possibly only found by a
newer rust version on Ubuntu.
@0xB10C

0xB10C commented Aug 16, 2025

Copy link
Copy Markdown
Collaborator Author

removed this in #223

0xB10C added a commit that referenced this pull request Aug 16, 2025
Remove the metric from connectivity-check, because it's currently
unused, the docs are wrong, and probably not needed at all.

Also, the CI in #222 (comment)
seems to be having problems due to this. Possibly only found by a
newer rust version on Ubuntu.
0xB10C added 6 commits August 16, 2025 13:54
by splitting up main.rs into lib.rs and adding a run() fn
these shouldn't have been there in the first place
gets rid of all unwraps() and expects()
This allows us to run multiple metrics::run() in paralell.
Initializing multiple loggers at the same time is not possible.
This addresses #192 for the metrics tool and allows us to
use a select pattern for stopping the metrics tool early in
the integration tests.
@0xB10C
0xB10C force-pushed the 2025-08-first-steps-intregration-test branch from af2cf39 to 921c0d0 Compare August 16, 2025 11:57
Comment thread tools/metrics/src/lib.rs Resolved
0xB10C added 6 commits August 17, 2025 22:39
this is useful for integration test. Allows stopping the tool when
done. Currently not used via main.rs
Static metrics don't work in integration tests since multiple
tests change the same metrics. This causes undesirable state
between tests. Rather, have a Metrics struct with metrics that
each metrics tool instance creates for itself.
@0xB10C
0xB10C force-pushed the 2025-08-first-steps-intregration-test branch from 921c0d0 to b32adb7 Compare August 17, 2025 20:42
@0xB10C
0xB10C merged commit bb15a7b into master Aug 18, 2025
@0xB10C
0xB10C deleted the 2025-08-first-steps-intregration-test branch August 18, 2025 13:07
edge-smith3tb added a commit to edge-smith3tb/peer-observer that referenced this pull request Sep 30, 2025
Remove the metric from connectivity-check, because it's currently
unused, the docs are wrong, and probably not needed at all.

Also, the CI in peer-observer/peer-observer#222 (comment)
seems to be having problems due to this. Possibly only found by a
newer rust version on Ubuntu.
forge-dev480lo added a commit to forge-dev480lo/peer-observer that referenced this pull request Dec 13, 2025
Remove the metric from connectivity-check, because it's currently
unused, the docs are wrong, and probably not needed at all.

Also, the CI in peer-observer/peer-observer#222 (comment)
seems to be having problems due to this. Possibly only found by a
newer rust version on Ubuntu.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant