hyperdx/smoke-tests/otel-collector/README.md
2025-05-23 01:41:35 +00:00

2 KiB

OpenTelemetry Collector Smoke Tests

This directory contains smoke tests for validating the OpenTelemetry Collector functionality in HyperDX.

Prerequisites

Before running the tests, ensure you have the following tools installed:

  • Bats - Bash Automated Testing System
  • Docker and Docker Compose
  • curl - Command line tool for transferring data
  • ClickHouse client - Command-line client for ClickHouse
    • Make sure to run clickhouse install to install the ClickHouse client after downloading ClickHouse

Running the Tests

To run all the tests:

cd smoke-tests/otel-collector
bats *.bats

To run a specific test file:

bats hdx-1453-auto-parse-json.bats

Test Structure

  • *.bats - Test files written in Bats
  • setup_suite.bash - Contains global setup_suite and teardown_suite functions that run once for the entire test suite
  • data/ - Test data used by the tests
  • test_helpers/ - Utility functions for the tests
  • docker-compose.yaml - Docker Compose configuration for the test environment

The test suite uses Bats' setup_suite and teardown_suite hooks to initialize the environment only once, regardless of how many test files are run. This optimizes test execution by:

  1. Validating the environment once
  2. Starting Docker containers once at the beginning of the test suite
  3. Cleaning up containers once at the end of the test suite

Debugging

If you need to debug the tests, you can set the SKIP_CLEANUP environment variable to prevent the Docker containers from being torn down after the tests complete:

SKIP_CLEANUP=1 bats *.bats

or

SKIP_CLEANUP=true bats *.bats

With SKIP_CLEANUP enabled, the test containers will remain running after the tests complete, allowing you to inspect logs, connect to the containers, and debug issues.

To manually clean up the containers after debugging:

docker compose down