Skip to content

Commit

Permalink
add new plus docker images to v2 pipeline (#779)
Browse files Browse the repository at this point in the history
add new plus docker images to v2 pipeline
---------

Co-authored-by: Oliver O'Mahony <[email protected]>
  • Loading branch information
aphralG and oliveromahony authored Aug 22, 2024
1 parent 16b861d commit 6b08bf5
Show file tree
Hide file tree
Showing 17 changed files with 270 additions and 25 deletions.
83 changes: 80 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ jobs:
path: /tmp/integration-test-logs/
retention-days: 3

official-image-integration-tests:
name: Integration Tests - Official Images
official-oss-image-integration-tests:
name: Integration Tests - Official OSS Images
needs: build-unsigned-snapshot
runs-on: ubuntu-24.04
strategy:
Expand Down Expand Up @@ -234,9 +234,86 @@ jobs:
if: success() || failure()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: integration-test-logs-${{ matrix.container.image }}-${{ matrix.container.version }}-new
name: official-oss-integration-test-logs-${{ matrix.container.image }}-${{ matrix.container.version }}
path: /tmp/integration-test-logs/
retention-days: 3

official-plus-image-integration-tests:
name: Integration Tests - Official Plus Images
needs: build-unsigned-snapshot
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
container:
- image: "alpine"
version: "3.18"
plus: "r30"
release: "alpine"
path: "/nginx-plus/agent"
- image: "alpine"
version: "3.20"
plus: "r32"
release: "alpine"
path: "/nginx-plus/agent"
- image: "alpine"
version: "3.19"
plus: "r31"
release: "alpine"
path: "/nginx-plus/agent"
- image: "debian"
version: "bookworm"
plus: "r32"
release: "debian"
path: "/nginx-plus/agent"
- image: "debian"
version: "bookworm"
plus: "r31"
release: "debian"
path: "/nginx-plus/agent"
- image: "debian"
version: "bookworm"
plus: "r30"
release: "debian"
path: "/nginx-plus/agent"
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
- name: Download Packages
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: nginx-agent-unsigned-snapshots
path: build
- name: Login to Docker Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Run Integration Tests
run: |
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
CONTAINER_NGINX_IMAGE_REGISTRY="${{ secrets.REGISTRY_URL }}" TAG="${{ matrix.container.plus }}-${{ matrix.container.image }}-${{ matrix.container.version }}" \
OS_RELEASE="${{ matrix.container.release }}" IMAGE_PATH="${{ matrix.container.path }}" \
make official-image-integration-test
- name: Container Output Logs
if: failure()
run: |
docker ps -a
dockerid=$(docker ps -a --format "{{.ID}}")
docker logs "$dockerid"
- name: Archive integration test logs
if: success() || failure()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: official-plus-integration-test-logs-${{ matrix.container.image }}-${{ matrix.container.version }}-${{ matrix.container.plus }}
path: /tmp/integration-test-logs/
retention-days: 3

performance-test:
name: Performance Tests
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ OS_RELEASE ?= ubuntu
OS_VERSION ?= 24.04
BASE_IMAGE = "${CONTAINER_REGISTRY}/${OS_RELEASE}:${OS_VERSION}"
IMAGE_TAG = "agent_${OS_RELEASE}_${OS_VERSION}"
AGENT_IMAGE_PATH = "/nginx/agent"
IMAGE_PATH ?= "/nginx/agent"

VERSION_WITH_V := v${VERSION}
LDFLAGS = "-w -X main.version=${VERSION_WITH_V} -X main.commit=${COMMIT} -X main.date=${DATE}"
Expand Down Expand Up @@ -227,14 +227,14 @@ integration-test:

official-image-integration-test:
PACKAGE_NAME=${PACKAGE_NAME} CONTAINER_NGINX_IMAGE_REGISTRY=${CONTAINER_NGINX_IMAGE_REGISTRY} ARCH=${OSARCH} OS_VERSION=${OS_VERSION} \
OS_RELEASE=${OS_RELEASE} TAG=${TAG} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} IMAGE_PATH=${AGENT_IMAGE_PATH} DOCKER_COMPOSE_FILE="docker-compose-official-image.yml" \
${GOTEST} -v ./test/integration/api
PACKAGE_NAME=${PACKAGE_NAME} CONTAINER_NGINX_IMAGE_REGISTRY=${CONTAINER_NGINX_IMAGE_REGISTRY} ARCH=${OSARCH} OS_VERSION=${OS_VERSION} \
OS_RELEASE=${OS_RELEASE} TAG=${TAG} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} IMAGE_PATH=${AGENT_IMAGE_PATH} DOCKER_COMPOSE_FILE="docker-compose-official-image.yml" \
OS_RELEASE=${OS_RELEASE} TAG=${TAG} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} IMAGE_PATH=${IMAGE_PATH} DOCKER_COMPOSE_FILE="docker-compose-official-image.yml" \
${GOTEST} -v ./test/integration/features
PACKAGE_NAME=${PACKAGE_NAME} CONTAINER_NGINX_IMAGE_REGISTRY=${CONTAINER_NGINX_IMAGE_REGISTRY} ARCH=${OSARCH} OS_VERSION=${OS_VERSION} \
OS_RELEASE=${OS_RELEASE} TAG=${TAG} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} IMAGE_PATH=${AGENT_IMAGE_PATH} DOCKER_COMPOSE_FILE="docker-compose-official-image.yml" \
OS_RELEASE=${OS_RELEASE} TAG=${TAG} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} IMAGE_PATH=${IMAGE_PATH} DOCKER_COMPOSE_FILE="docker-compose-official-image.yml" \
${GOTEST} -v ./test/integration/grpc
PACKAGE_NAME=${PACKAGE_NAME} CONTAINER_NGINX_IMAGE_REGISTRY=${CONTAINER_NGINX_IMAGE_REGISTRY} ARCH=${OSARCH} OS_VERSION=${OS_VERSION} \
OS_RELEASE=${OS_RELEASE} TAG=${TAG} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} IMAGE_PATH=${IMAGE_PATH} DOCKER_COMPOSE_FILE="docker-compose-official-image.yml" \
${GOTEST} -v ./test/integration/api

test-bench: ## Run benchmark tests
cd test/performance && GOWORK=off CGO_ENABLED=0 ${GOTEST} -mod=vendor -count 5 -timeout 2m -bench=. -benchmem metrics_test.go
Expand Down
8 changes: 6 additions & 2 deletions test/integration/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -82,8 +83,11 @@ func TestAPI_Metrics(t *testing.T) {
assert.NotContains(t, resp.String(), "test_fail_metric")
// Validate that the agent can call the stub status API
assert.Contains(t, resp.String(), "nginx_http_request_count")
// Validate that the agent can read the NGINX access logs
assert.Contains(t, resp.String(), "nginx_http_status_2xx")

if os.Getenv("IMAGE_PATH") == "/nginx/agent" {
// Validate that the agent can read the NGINX access logs
assert.Contains(t, resp.String(), "nginx_http_status_2xx")
}

metrics := tutils.ProcessResponse(resp)

Expand Down
4 changes: 2 additions & 2 deletions test/integration/api/docker-compose-official-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ services:
networks:
- monitoring
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf
- ${NGINX_CONF_FILE}
- ${AGENT_CONF_FILE}
4 changes: 2 additions & 2 deletions test/integration/api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ services:
networks:
- monitoring
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf
- ${NGINX_CONF_FILE}
- ${AGENT_CONF_FILE}
File renamed without changes.
50 changes: 50 additions & 0 deletions test/integration/api/nginx-plus.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$bytes_sent" "$request_length" "$request_time" '
'"$gzip_ratio" $server_protocol ';

access_log /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 65;

server {
listen 8080;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

##
# Enable Metrics
##
location /api/ {
api write=on;
allow 127.0.0.1;
deny all;
status_zone my_location_zone1;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
4 changes: 2 additions & 2 deletions test/integration/features/docker-compose-official-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ services:
networks:
- monitoring
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ${CONF_FILE}
- ${NGINX_CONF_FILE}
- ${AGENT_CONF_FILE}
4 changes: 2 additions & 2 deletions test/integration/features/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ services:
networks:
- monitoring
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ${CONF_FILE}
- ${NGINX_CONF_FILE}
- ${AGENT_CONF_FILE}
File renamed without changes.
49 changes: 49 additions & 0 deletions test/integration/features/nginx-plus.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$bytes_sent" "$request_length" "$request_time" '
'"$gzip_ratio" $server_protocol ';

access_log /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 65;

server {
listen 8080;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

##
# Enable Metrics
##
location /api/ {
api write=on;
allow 127.0.0.1;
deny all;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
2 changes: 1 addition & 1 deletion test/integration/grpc/docker-compose-official-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf
- ${AGENT_CONF_FILE}
2 changes: 1 addition & 1 deletion test/integration/grpc/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf
- ${AGENT_CONF_FILE}
2 changes: 1 addition & 1 deletion test/integration/install/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ services:
ports:
- 80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf # default nginx apk conf does not listen on localhost
- ${NGINX_CONF_FILE} # default nginx apk conf does not listen on localhost
File renamed without changes.
49 changes: 49 additions & 0 deletions test/integration/install/nginx-plus.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$bytes_sent" "$request_length" "$request_time" '
'"$gzip_ratio" $server_protocol ';

access_log /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 65;

server {
listen 8080;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

##
# Enable Metrics
##
location /api/ {
api write=on;
allow 127.0.0.1;
deny all;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
Loading

0 comments on commit 6b08bf5

Please sign in to comment.