Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
build/
build-rum/
!build-rum/_deps/injectbrowsersdk-src/
httpd/
test/integration-test/.venv/
test/integration-test/.pytest_cache/
test/integration-test/__pycache__/
67 changes: 67 additions & 0 deletions test/integration-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Dockerfile for running httpd-datadog integration tests
FROM alpine:3.21

RUN apk add --no-cache \
autoconf \
build-base \
cmake \
curl \
expat-dev \
git \
libtool \
libunwind-dev \
linux-headers \
pcre2-dev \
python3

# uv (Python package manager)
COPY --from=ghcr.io/astral-sh/uv:0.9.28 /uv /usr/local/bin/uv

# Rust toolchain (required to build the RUM module)
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -yq --default-toolchain 1.73.0 \
&& ln -s ~/.cargo/bin/cargo /usr/bin/cargo
RUN cargo install --locked cbindgen --version 0.26.0 \
&& ln -s ~/.cargo/bin/cbindgen /usr/local/bin/cbindgen

# Apache httpd 2.4
COPY scripts/setup-httpd.py /tmp/setup-httpd.py
RUN python3 /tmp/setup-httpd.py -o /httpd 2.4.66 \
&& cd /httpd \
&& ./configure \
--with-included-apr \
--prefix=/httpd/httpd-build \
--enable-mpms-shared="all" \
&& make -j$(nproc) \
&& make install

# Copy project source
WORKDIR /workspace
COPY . .

# inject-browser-sdk is a private GitHub repository and cannot be cloned during
# docker build. Copy the pre-fetched source from the local cmake build directory
# and tell cmake to use it directly, bypassing the git clone.
# Hence the following have been run locally at least once:
# cmake --build build-rum
COPY build-rum/_deps/injectbrowsersdk-src /inject-browser-sdk-src

# Build without RUM support
RUN cmake -B build -DHTTPD_SRC_DIR=/httpd . \
&& cmake --build build -j$(nproc)

# Build with RUM support
RUN cmake -B build-rum \
-DHTTPD_SRC_DIR=/httpd \
-DHTTPD_DATADOG_ENABLE_RUM=ON \
-DFETCHCONTENT_SOURCE_DIR_INJECTBROWSERSDK=/inject-browser-sdk-src \
. \
&& cmake --build build-rum -j$(nproc)

# Python test dependencies
WORKDIR /workspace/test/integration-test
RUN uv sync

# Run all integration tests by default.
# The test suite auto-selects the correct module variant (RUM / non-RUM) per test.
CMD ["uv", "run", "pytest", "--bin-path=/httpd/httpd-build/bin/apachectl", "-v"]
95 changes: 56 additions & 39 deletions test/integration-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,76 @@

Integration tests for Apache httpd Datadog module using pytest.

## Quick Start
## All Tests

### Setup
All the commands below must be run from the root the repository, not from the `test/integration-test` directory:

```bash
# Install uv (Python package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh
```sh
cd httpd-datadog
```

### Pre-requisites

```sh
git submodule update --init --recursive
cmake --build build-rum # populates build-rum/_deps/injectbrowsersdk-src/
```

### Build the Docker Image

```sh
docker build -f test/integration-test/Dockerfile -t httpd-datadog-tests .
```

### Run All Tests

```sh
docker run --rm httpd-datadog-tests
```

### Run Tests by Markers

The tests have the following optional markers:

- `@pytest.mark.smoke` - Basic functionality tests
- `@pytest.mark.ci` - CI-suitable tests
- `@pytest.mark.requires_rum` - RUM tests (auto-build module with RUM)

# Install test dependencies
cd test/integration-test && uv sync
So, to run only smoke tests:

# Run smoke tests (auto-builds module variants as needed)
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v -m smoke
```sh
docker run --rm httpd-datadog-tests uv run pytest --bin-path=/httpd/httpd-build/bin/apachectl -v -m smoke
```

# Run CI tests
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v -m ci
Similarly, to run only CI tests:

# Run RUM tests only (auto-builds with RUM support)
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v -m requires_rum
```sh
docker run --rm httpd-datadog-tests uv run pytest --bin-path=/httpd/httpd-build/bin/apachectl -v -m ci
```

# Run all tests (auto-builds module variants as needed)
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v
### Run a Specific Test

# Run with pre-built module (skip auto-build)
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v \
--module-path=/path/to/mod_datadog.so
To run a specific test file:

# Run specific test file
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v \
scenarios/test_rum.py
```sh
docker run --rm httpd-datadog-tests uv run pytest --bin-path=/httpd/httpd-build/bin/apachectl -v scenarios/test_smoke.py
```

**Auto-Build Behavior:**
- The test suite automatically builds two module variants on demand:
- **Without RUM**: `build/mod_datadog/mod_datadog.so` (for regular tests).
- **With RUM**: `build-rum/mod_datadog/mod_datadog.so` (for `@pytest.mark.requires_rum` tests).
- Each variant is only built if tests requiring it are collected.
- Tests automatically use the correct variant based on markers.
- Build failures cause tests to fail (not skip).
- Use `--module-path` to override and skip auto-build.
To run a specific test function:

## Command-Line Options
```sh
docker run --rm httpd-datadog-tests uv run pytest --bin-path=/httpd/httpd-build/bin/apachectl -v scenarios/test_smoke.py::test_version_symbol
```

### Command-Line Options

Required options:
- `--bin-path` - Path to apachectl binary (e.g., `/usr/sbin/apachectl`)

Optional:
- `--module-path` - Path to mod_datadog.so (skips auto-build if provided)
Optional options:
- `--module-path` - Path to `mod_datadog.so` (skips auto-build if provided)
- `--log-dir` - Directory for test logs (defaults to temp directory)

## Test Markers

- `@pytest.mark.smoke` - Basic functionality tests
- `@pytest.mark.ci` - CI-suitable tests
- `@pytest.mark.requires_rum` - RUM tests (auto-build module with RUM)

## RUM Tests

Expand All @@ -80,7 +95,7 @@ DatadogRum On
- Child `<Location>` overrides parent.
- Auto-builds module with `-DHTTPD_DATADOG_ENABLE_RUM=ON` when RUM tests are detected.

## Docker Testing
### Docker Testing

```sh
docker run --rm -v "$PWD:/workspace" -w /workspace \
Expand All @@ -95,16 +110,18 @@ docker run --rm -v "$PWD:/workspace" -w /workspace \
"
```

## Troubleshooting
### Troubleshooting

**RUM build fails:** Check CMake output for missing dependencies (inject-browser-sdk is fetched automatically via CMake FetchContent)

**Tests hang:** Port 8136 in use

```sh
lsof -i :8136
```

**Module issues:**

```sh
ldd /path/to/mod_datadog.so
apachectl -f /path/to/config.conf -t
Expand Down
Loading