Skip to content

Commit 543564f

Browse files
Introduce Dockerfile for running integration tests
1 parent 32588fe commit 543564f

File tree

3 files changed

+131
-39
lines changed

3 files changed

+131
-39
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.git/
2+
build/
3+
build-rum/
4+
!build-rum/_deps/injectbrowsersdk-src/
5+
httpd/
6+
test/integration-test/.venv/
7+
test/integration-test/.pytest_cache/
8+
test/integration-test/__pycache__/

test/integration-test/Dockerfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Dockerfile for running httpd-datadog integration tests
2+
FROM alpine:3.21
3+
4+
RUN apk add --no-cache \
5+
autoconf \
6+
build-base \
7+
cmake \
8+
curl \
9+
expat-dev \
10+
git \
11+
libtool \
12+
libunwind-dev \
13+
linux-headers \
14+
pcre2-dev \
15+
python3
16+
17+
# uv (Python package manager)
18+
COPY --from=ghcr.io/astral-sh/uv:0.9.28 /uv /usr/local/bin/uv
19+
20+
# Rust toolchain (required to build the RUM module)
21+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
22+
| sh -s -- -yq --default-toolchain 1.73.0 \
23+
&& ln -s ~/.cargo/bin/cargo /usr/bin/cargo
24+
RUN cargo install --locked cbindgen --version 0.26.0 \
25+
&& ln -s ~/.cargo/bin/cbindgen /usr/local/bin/cbindgen
26+
27+
# Apache httpd 2.4
28+
COPY scripts/setup-httpd.py /tmp/setup-httpd.py
29+
RUN python3 /tmp/setup-httpd.py -o /httpd 2.4.66 \
30+
&& cd /httpd \
31+
&& ./configure \
32+
--with-included-apr \
33+
--prefix=/httpd/httpd-build \
34+
--enable-mpms-shared="all" \
35+
&& make -j$(nproc) \
36+
&& make install
37+
38+
# Copy project source
39+
WORKDIR /workspace
40+
COPY . .
41+
42+
# inject-browser-sdk is a private GitHub repository and cannot be cloned during
43+
# docker build. Copy the pre-fetched source from the local cmake build directory
44+
# and tell cmake to use it directly, bypassing the git clone.
45+
# Hence the following have been run locally at least once:
46+
# cmake --build build-rum
47+
COPY build-rum/_deps/injectbrowsersdk-src /inject-browser-sdk-src
48+
49+
# Build without RUM support
50+
RUN cmake -B build -DHTTPD_SRC_DIR=/httpd . \
51+
&& cmake --build build -j$(nproc)
52+
53+
# Build with RUM support
54+
RUN cmake -B build-rum \
55+
-DHTTPD_SRC_DIR=/httpd \
56+
-DHTTPD_DATADOG_ENABLE_RUM=ON \
57+
-DFETCHCONTENT_SOURCE_DIR_INJECTBROWSERSDK=/inject-browser-sdk-src \
58+
. \
59+
&& cmake --build build-rum -j$(nproc)
60+
61+
# Python test dependencies
62+
WORKDIR /workspace/test/integration-test
63+
RUN uv sync
64+
65+
# Run all integration tests by default.
66+
# The test suite auto-selects the correct module variant (RUM / non-RUM) per test.
67+
CMD ["uv", "run", "pytest", "--bin-path=/httpd/httpd-build/bin/apachectl", "-v"]

test/integration-test/README.md

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,76 @@
22

33
Integration tests for Apache httpd Datadog module using pytest.
44

5-
## Quick Start
5+
## All Tests
66

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

9-
```bash
10-
# Install uv (Python package manager)
11-
curl -LsSf https://astral.sh/uv/install.sh | sh
9+
```sh
10+
cd httpd-datadog
11+
```
12+
13+
### Pre-requisites
14+
15+
```sh
16+
git submodule update --init --recursive
17+
cmake --build build-rum # populates build-rum/_deps/injectbrowsersdk-src/
18+
```
19+
20+
### Build the Docker Image
21+
22+
```sh
23+
docker build -f test/integration-test/Dockerfile -t httpd-datadog-tests .
24+
```
25+
26+
### Run All Tests
27+
28+
```sh
29+
docker run --rm httpd-datadog-tests
30+
```
31+
32+
### Run Tests by Markers
33+
34+
The tests have the following optional markers:
35+
36+
- `@pytest.mark.smoke` - Basic functionality tests
37+
- `@pytest.mark.ci` - CI-suitable tests
38+
- `@pytest.mark.requires_rum` - RUM tests (auto-build module with RUM)
1239

13-
# Install test dependencies
14-
cd test/integration-test && uv sync
40+
So, to run only smoke tests:
1541

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

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

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

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

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

32-
# Run specific test file
33-
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v \
34-
scenarios/test_rum.py
56+
```sh
57+
docker run --rm httpd-datadog-tests uv run pytest --bin-path=/httpd/httpd-build/bin/apachectl -v scenarios/test_smoke.py
3558
```
3659

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

46-
## Command-Line Options
62+
```sh
63+
docker run --rm httpd-datadog-tests uv run pytest --bin-path=/httpd/httpd-build/bin/apachectl -v scenarios/test_smoke.py::test_version_symbol
64+
```
65+
66+
### Command-Line Options
4767

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

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

55-
## Test Markers
56-
57-
- `@pytest.mark.smoke` - Basic functionality tests
58-
- `@pytest.mark.ci` - CI-suitable tests
59-
- `@pytest.mark.requires_rum` - RUM tests (auto-build module with RUM)
6075

6176
## RUM Tests
6277

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

83-
## Docker Testing
98+
### Docker Testing
8499

85100
```sh
86101
docker run --rm -v "$PWD:/workspace" -w /workspace \
@@ -95,16 +110,18 @@ docker run --rm -v "$PWD:/workspace" -w /workspace \
95110
"
96111
```
97112

98-
## Troubleshooting
113+
### Troubleshooting
99114

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

102117
**Tests hang:** Port 8136 in use
118+
103119
```sh
104120
lsof -i :8136
105121
```
106122

107123
**Module issues:**
124+
108125
```sh
109126
ldd /path/to/mod_datadog.so
110127
apachectl -f /path/to/config.conf -t

0 commit comments

Comments
 (0)