Skip to content
Merged
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
22 changes: 17 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Fork, Clone, Branch and Create your PR

When cloning the repo, you have to initialize the submodules:

```sh
git submodule update --init --recursive
```
Expand All @@ -21,24 +22,35 @@ git submodule update --init --recursive
| `python` | 3.0+ | |
| `cmake` | 3.12+ | |

Once you got a valid `python` installation, install all the dependencies with
Once you got a valid Python installation, install all the dependencies with:

````shell
```sh
pip install -r requirements.txt
````
```

## Compiling

### Setup `httpd`

In order to build the module you have to configure `httpd` with the [scripts/setup-httpd.py](./scripts/setup-httpd.py) script:
In order to build the module you have to configure `httpd` with the [scripts/setup-httpd.py](./scripts/setup-httpd.py) script. Check what is the latest available version on [Apache website](https://httpd.apache.org), then:

```sh
python scripts/setup-httpd.py -o httpd $HTTPD_VERSION
export HTTPD_VERSION=2.4.66
python scripts/setup-httpd.py $HTTPD_VERSION
cd httpd
./configure --with-included-apr --prefix=$(pwd)/httpd-build --enable-mpms-shared="all"
```

### Install Rust

The RUM variant requires Rust to build:

```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

Relaunch your terminal (or do `source ~/.cargo/env`).

### Build the Module

CMake is our build system. If you are not familiar with CMake, read [the tutorial.](https://cmake.org/cmake/help/latest/guide/tutorial/index.html)
Expand Down
2 changes: 1 addition & 1 deletion cmake/deps/fmt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ if(NOT fmt_POPULATED)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_subdirectory(${fmt_SOURCE_DIR} EXCLUDE_FROM_ALL)
add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

3 changes: 3 additions & 0 deletions scripts/setup-httpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def main():
args = parser.parse_args()

args.output = os.path.abspath(args.output)
if os.path.exists(args.output):
print(f"Output directory '{args.output}' already exists. Please remove it before running this script.")
return 1

if not subprocess.run("git -v", shell=True, stdout=subprocess.DEVNULL):
print("git command must be available")
Expand Down
37 changes: 16 additions & 21 deletions test/integration-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ Integration tests for Apache httpd Datadog module using pytest.

## Quick Start

### Prerequisites

For local testing, install Apache development packages:
```bash
# Ubuntu/Debian
sudo apt-get install apache2 apache2-dev libapr1-dev libaprutil1-dev

# macOS
brew install httpd
```

### Setup

```bash
Expand All @@ -24,19 +13,25 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
# Install test dependencies
cd test/integration-test && uv sync

# Run all tests (auto-builds module variants as needed)
uv run pytest --bin-path=/usr/sbin/apachectl -v
# Run smoke tests (auto-builds module variants as needed)
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

# Run RUM tests only (auto-builds with RUM support)
uv run pytest --bin-path=/usr/sbin/apachectl -m requires_rum -v
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v -m requires_rum

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

# Run with pre-built module (skip auto-build)
uv run pytest --bin-path=/usr/sbin/apachectl \
--module-path=/path/to/mod_datadog.so -v
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v \
--module-path=/path/to/mod_datadog.so

# Run specific test file
uv run pytest --bin-path=/usr/sbin/apachectl \
scenarios/test_rum.py -v
uv run pytest --bin-path=../../httpd/httpd-build/bin/apachectl -v \
scenarios/test_rum.py
```

**Auto-Build Behavior:**
Expand Down Expand Up @@ -87,7 +82,7 @@ DatadogRum On

## Docker Testing

```bash
```sh
docker run --rm -v "$PWD:/workspace" -w /workspace \
datadog/docker-library:httpd-datadog-ci-2.4-cdb3cb2 \
sh -c "
Expand All @@ -105,12 +100,12 @@ docker run --rm -v "$PWD:/workspace" -w /workspace \
**RUM build fails:** Check CMake output for missing dependencies (inject-browser-sdk is fetched automatically via CMake FetchContent)

**Tests hang:** Port 8136 in use
```bash
```sh
lsof -i :8136
```

**Module issues:**
```bash
```sh
ldd /path/to/mod_datadog.so
apachectl -f /path/to/config.conf -t
```
3 changes: 2 additions & 1 deletion test/integration-test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,13 @@ def pytest_sessionstart(session: pytest.Session) -> None:

log_dir = session.config.getoption("--log-dir")
if log_dir:
log_dir = os.path.abspath(log_dir)
if os.path.exists(log_dir):
# TODO: Warn old logs will be removed and manage error
shutil.rmtree(log_dir)
os.mkdir(log_dir)
else:
log_dir = tempfile.mkdtemp(prefix="log-httpd-tests-", dir=".")
log_dir = tempfile.mkdtemp(prefix="log-httpd-tests-")

session.config.log_dir = log_dir

Expand Down
16 changes: 7 additions & 9 deletions test/integration-test/pytest_plugins/integration_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def _build_module(
# Configure
print(f" Configuring CMake...")
cmake_args = ["cmake", "-B", str(build_dir)]
httpd_src_dir = project_root / "httpd"
if httpd_src_dir.exists():
cmake_args.append(f"-DHTTPD_SRC_DIR={httpd_src_dir}")
if enable_rum:
cmake_args.append("-DHTTPD_DATADOG_ENABLE_RUM=ON")
cmake_args.append(".")
Expand Down Expand Up @@ -97,7 +100,7 @@ def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item

# Find project root
test_dir = Path(__file__).parent.parent
project_root = test_dir.parent.parent
project_root = test_dir.parent.parent.resolve()

if not (project_root / "CMakeLists.txt").exists():
pytest.exit("Cannot find project root CMakeLists.txt", returncode=1)
Expand Down Expand Up @@ -131,14 +134,9 @@ def pytest_sessionstart(session: pytest.Session) -> None:
session.config.module_path = explicit_path
return

# Otherwise, use the auto-built modules
# Default to non-RUM module if both were built
if session.config._module_paths.get("no_rum"):
session.config.module_path = str(session.config._module_paths["no_rum"])
elif session.config._module_paths.get("rum"):
session.config.module_path = str(session.config._module_paths["rum"])
else:
pytest.exit("No module path available", returncode=1)
# Module paths are populated later in pytest_collection_modifyitems (after collection).
# Set a placeholder here; pytest_runtest_setup will assign the correct variant per test.
session.config.module_path = None


def pytest_runtest_setup(item: pytest.Item) -> None:
Expand Down
Loading