Skip to content

Integration test the tools and extractors #26

Open

Description

@0xB10C

We should test the tools using integration test. So far some progress has been made in #222 to lay the groundwork for this and test the metrics tool.

Next to the tools, it might be possible to test the extractors similary

Activity

  1. changed the title [-]Test tools[/-] [+]Test the tools[/+] on Jul 23, 2024
  2. 0xB10C commented on Jul 7, 2025

    @0xB10C
    CollaboratorAuthor

    This is still needed, however, we don't use nanomsg anymore. Instead, a NATS.io server is used. NATS allows us to record and replay messages with https://docs.nats.io/nats-concepts/jetstream which could be used to replay a recording during a test and feed it into a tool.

  3. 0xB10C commented on Jul 7, 2025

    @0xB10C
    CollaboratorAuthor

    edit 2025-08-18: this comment is outdated. Feel free to ignore.

    An alternative to a NATS JetStream based approach could be a testing-extractor that publishes a fixed set of messages into a NATS server and clients read from it. This might be easier to implement and makes it easier to add new test cases since we don't need to recreate a NATS JetStream file to read from. A workflow for this would be similar to:

    • Spin up a NATS server in GH Actions (using Docker or binary).
    • Wait until NATS is ready.
    • Run a tool / consumer.
    • Run the testing-extractor / publisher (it should send a few test messages).
    • Assert/test that the tool output is as expected

    A GH actions workflow to run a NATS server could look similar to:

    name: Integration Test
    
    on: [push, pull_request]
    
    jobs:
      test:
        runs-on: ubuntu-latest
        services:
          nats:
            image: nats:latest
            ports:
              - 4222:4222
            options: >-
              --health-cmd "nats-server -v"
              --health-interval 5s
              --health-timeout 10s
              --health-retries 5
    
        steps:
    ...
  4. 0xB10C commented on Jul 8, 2025

    @0xB10C
    CollaboratorAuthor

    I moved the ebpf extractor into extractors/, this allows us to have multiple extractors in this directory. For example, a testing-extractor.

    edit 2025-08-18: I don't think a separate testing-extractor is the way to go anymore. See #222 for the preferred approach.

  5. 0xB10C commented on Aug 18, 2025

    @0xB10C
    CollaboratorAuthor

    #222 implemented integration tests for the metrics tool by starting a testing-NATS server per test. This allows running multiple tests in parallel and makes sure there's no state left in NATS from a previous test. All other tools should be tested similarly. See https://github.com/0xB10C/peer-observer/blob/master/tools/metrics/tests/integration.rs

  6. changed the title [-]Test the tools[/-] [+]Test the tools and extractors[/+] on Sep 3, 2025
  7. changed the title [-]Test the tools and extractors[/-] [+]Integration test the tools and extractors[/+] on Sep 3, 2025
  8. 0xB10C commented on Oct 31, 2025

    @0xB10C
    CollaboratorAuthor

    The big thing missing here is the ebpf-extractor integration tests. These are probably a bit harder to do than the others because they also require root privileges to run. That's fine for the CI, but not ideal for local development.

  9. deadmanoz commented on Mar 13, 2026

    @deadmanoz
    Collaborator

    I want to experiment with adding some custom tracepoints into Bitcoin Core and have them flow through to peer-observer, so looked into the ebpf tests within peer-observer, to find none, and this issue!

    So it makes sense to get the ebpf tests sorted as the first order of business. The first step is thus a refactor of the ebpf-extractor to expose a testable run() function, matching the pattern of the rpc, log, and p2p extractors. This will give a slim main.rs and move mostly everything into a lib.rs.

    Next would be writing the actual integration tests. The plan is to follow the same pattern as the other extractors (temp NATS server, regtest bitcoind, etc). As you note @0xB10C these tests will require Linux with eBPF support and root privileges so maybe some gating behind feature flag is required.

    If you have any opinion or preferences on this, please let me know, otherwise I will use my best judgement and we'll find out at PR review time 😛

  10. 0xB10C commented on Mar 13, 2026

    @0xB10C
    CollaboratorAuthor

    (only saw this after my comment in #380, so reposting it here:

    from #380 (comment)

    I don't want to recommend devs to run them locally due to their privilege requirements (especially if they aren't touching the ebpf-extractor in their code changes). This means introducing another feature flag for it, and not being able to run with --all-features locally. We can and should run them in CI. Maybe we can also implement a "skip", if the user does not have the right priviledges...

    But def Concept ACK on adding tests for the ebpf-extractor in some way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions