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
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ Once you save your changes to `.vscode/c_cpp_properties.json`, you should see th

### Building and Testing

#### Prerequisites

- Docker and Docker Compose
- For **macOS users**: Bash 4.0+ is required due to the use of associative arrays. macOS ships with Bash 3.2 by default. You can upgrade with:
```shell
# Install a newer bash version
brew install bash

# Update your shell or ensure the scripts use the new bash
export PATH="/opt/homebrew/bin:$PATH" # or /usr/local/bin for Intel Macs
```

#### Available Commands

The `./scripts` file contains multiple commands to make things easy:

| Command | Description |
Expand Down Expand Up @@ -234,28 +248,40 @@ The tests use a customized NGINX image, distinct from the main image, as well as

After making changes and finding that some tests fail, it can be difficult to understand why. By default, logs are written to Docker's internal log mechanism, but they won't be persisted after the test run completes and the containers are removed.

If you'd like to persist logs across test runs, you can configure the log driver to use `journald` (on Linux/Unix systems for example). You can do this by setting the environment variable `LOG_DRIVER` before running the tests:
If you'd like to persist logs across test runs, you can configure the log driver. By default, logs use the `json-file` driver for cross-platform compatibility. On Linux systems, you may prefer to use `journald` for better integration with systemd. You can do this by setting the environment variable `LOG_DRIVER` before running the tests:

```shell
# need to rebuild the test runner with the proper log driver
# For Linux systems with systemd (optional)
export LOG_DRIVER=journald

# For other systems or if you prefer file-based logs (default)
export LOG_DRIVER=json-file

# rebuild the test images
./scripts rebuild_test

# run the tests
./scripts test

# check the logs -- adjust the container name as needed
# For journald (Linux systems):
journalctl -eu docker CONTAINER_NAME=nginx-auth-jwt-test-nginx

# For json-file driver (all systems):
docker logs nginx-auth-jwt-test-nginx
```

Now you'll be able to see logs from previous test runs. The best way to make use of this is to open two terminals, one where you run the tests, and one where you follow the logs:
Now you'll be able to see logs from previous test runs. The best way to make use of this is to open two terminals, one where you run the tests, and one where you follow the logs:

```shell
# terminal 1
./scripts test

# terminal 2
# terminal 2 - choose based on your LOG_DRIVER setting:

# For journald:
journalctl -fu docker CONTAINER_NAME=jwt-nginx-test

# For json-file (default):
docker logs -f nginx-auth-jwt-test-nginx
```
2 changes: 1 addition & 1 deletion openssl.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN <<`
WORKDIR ${SRC_DIR}
RUN <<`
set -ex
curl --silent -LO https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz
curl --silent --location -O https://github.com/openssl/openssl/releases/download/openssl-${SSL_VERSION}/openssl-${SSL_VERSION}.tar.gz
tar -xf openssl-${SSL_VERSION}.tar.gz --strip-components=1
`
RUN ./config --prefix=${OUT_DIR} --openssldir=${OUT_DIR} shared zlib
Expand Down
4 changes: 3 additions & 1 deletion scripts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -eu
#!/usr/bin/env bash

set -eu

MAGENTA='\u001b[35m'
BLUE='\033[0;34m'
Expand Down
2 changes: 1 addition & 1 deletion test/docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
BASE_IMAGE: ${FULL_IMAGE_NAME}:${NGINX_VERSION:?required}
platform: linux/amd64
logging:
driver: ${LOG_DRIVER:-journald}
driver: ${LOG_DRIVER:-json-file}

runner:
container_name: ${TEST_CONTAINER_NAME_PREFIX:?required}-runner
Expand Down
4 changes: 3 additions & 1 deletion test/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -eu
#!/usr/bin/env bash

set -eu

# set a test # here to execute only that test and output additional info
DEBUG=
Expand Down