Skip to content

Commit

Permalink
Add new docker images to v2 pipeline for integration testing (#756)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Aphral Griffin <[email protected]>
  • Loading branch information
oliveromahony and aphralG authored Aug 19, 2024
1 parent 8e40275 commit 9a05ed0
Show file tree
Hide file tree
Showing 24 changed files with 253 additions and 276 deletions.
126 changes: 92 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ jobs:
with:
version: "${{ env.GOLANGCI_LINT_VERSION }}"
args: -c ./scripts/.golangci.yml
skip-pkg-cache: true
skip-cache: true
- name: Lint SDK Code
uses: golangci/golangci-lint-action@82d40c283aeb1f2b6595839195e95c2d6a49081b # v5.0.0
with:
version: "${{ env.GOLANGCI_LINT_VERSION }}"
working-directory: sdk
args: -c ../scripts/.golangci.yml
skip-pkg-cache: true
skip-cache: true

unit-test:
name: Unit Tests
Expand Down Expand Up @@ -111,43 +111,95 @@ jobs:
retention-days: 1

integration-tests:
name: Integration Tests
name: Integration Tests
needs: build-unsigned-snapshot
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
container:
- image: "rockylinux"
version: "8"
- image: "rockylinux"
version: "9"
- image: "almalinux"
version: "8"
- image: "almalinux"
version: "9"
- image: "amazonlinux"
version: "2"
- image: "amazonlinux"
version: "2023"
- image: "oraclelinux"
version: "8"
- image: "oraclelinux"
version: "9"
- image: "ubuntu"
version: "24.04"
- image: "alpine"
version: "3.17"
- image: "alpine"
version: "3.18"
- image: "alpine"
version: "3.19"
- image: "alpine"
version: "3.20"
- image: "debian"
version: "bullseye-slim"
- image: "debian"
version: "bookworm-slim"
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: Run Integration Tests
run: |
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
OS_RELEASE="${{ matrix.container.image }}" OS_VERSION="${{ matrix.container.version }}" \
make 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: integration-test-logs-${{ matrix.container.image }}-${{ matrix.container.version }}
path: /tmp/integration-test-logs/
retention-days: 3

official-image-integration-tests:
name: Integration Tests - Official Images
needs: build-unsigned-snapshot
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
container:
- image: "rockylinux"
version: "8"
- image: "rockylinux"
version: "9"
- image: "almalinux"
version: "8"
- image: "almalinux"
version: "9"
- image: "amazonlinux"
version: "2"
- image: "amazonlinux"
version: "2023"
- image: "oraclelinux"
version: "8"
- image: "oraclelinux"
version: "9"
- image: "ubuntu"
version: "24.04"
- image: "alpine"
version: "3.17"
- image: "bookworm"
version: "stable"
release: "debian"
- image: "bookworm"
version: "mainline"
release: "debian"
- image: "alpine"
version: "3.18"
version: "stable"
release: "alpine"
- image: "alpine"
version: "3.19"
- image: "alpine"
version: "3.20"
- image: "debian"
version: "bullseye-slim"
- image: "debian"
version: "bookworm-slim"
version: "mainline"
release: "alpine"
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
Expand All @@ -160,11 +212,17 @@ jobs:
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 }}
OS_RELEASE="${{ matrix.container.image }}" OS_VERSION="${{ matrix.container.version }}" \
make integration-test
CONTAINER_NGINX_IMAGE_REGISTRY="${{ secrets.REGISTRY_URL }}" TAG="${{ matrix.container.version }}-${{ matrix.container.image }}" OS_RELEASE="${{ matrix.container.release }}"\
make official-image-integration-test
- name: Container Output Logs
if: failure()
run: |
Expand All @@ -176,7 +234,7 @@ jobs:
if: success() || failure()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: integration-test-logs-${{ matrix.container.image }}-${{ matrix.container.version }}
name: integration-test-logs-${{ matrix.container.image }}-${{ matrix.container.version }}-new
path: /tmp/integration-test-logs/
retention-days: 3

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-branch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Release Branch
env:
NFPM_VERSION: 'v2.35.3'

on:
workflow_dispatch:
Expand Down Expand Up @@ -123,7 +125,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y gpgv1 monkeysphere
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.35.3
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
- name: Tag release
run: |
git config --global user.name 'github-actions'
Expand Down
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +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"

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 @@ -212,16 +213,27 @@ performance-test: ## Run performance tests

integration-test:
PACKAGES_REPO=${OSS_PACKAGES_REPO} INSTALL_FROM_REPO=${INSTALL_FROM_REPO} PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} \
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} DOCKER_COMPOSE_FILE="docker-compose-${CONTAINER_OS_TYPE}.yml" \
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} DOCKER_COMPOSE_FILE="docker-compose.yml" \
${GOTEST} -v ./test/integration/install
PACKAGES_REPO=${OSS_PACKAGES_REPO} INSTALL_FROM_REPO=${INSTALL_FROM_REPO} PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} \
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} DOCKER_COMPOSE_FILE="docker-compose-${CONTAINER_OS_TYPE}.yml" \
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} DOCKER_COMPOSE_FILE="docker-compose.yml" \
${GOTEST} -v ./test/integration/api
PACKAGES_REPO=${OSS_PACKAGES_REPO} INSTALL_FROM_REPO=${INSTALL_FROM_REPO} PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} \
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} DOCKER_COMPOSE_FILE="docker-compose-${CONTAINER_OS_TYPE}.yml" \
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} DOCKER_COMPOSE_FILE="docker-compose.yml" \
${GOTEST} -v ./test/integration/features
PACKAGES_REPO=${OSS_PACKAGES_REPO} INSTALL_FROM_REPO=${INSTALL_FROM_REPO} PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} \
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} DOCKER_COMPOSE_FILE="docker-compose-${CONTAINER_OS_TYPE}.yml" \
OS_VERSION=${OS_VERSION} OS_RELEASE=${OS_RELEASE} CONTAINER_OS_TYPE=${CONTAINER_OS_TYPE} DOCKER_COMPOSE_FILE="docker-compose.yml" \
${GOTEST} -v ./test/integration/grpc

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" \
${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" \
${GOTEST} -v ./test/integration/grpc

test-bench: ## Run benchmark tests
Expand Down Expand Up @@ -279,7 +291,6 @@ image: ## Build agent container image for NGINX Plus, need nginx-repo.crt and ng
--build-arg PACKAGES_REPO=${PLUS_PACKAGES_REPO} \
--build-arg OS_RELEASE=${OS_RELEASE} \
--build-arg OS_VERSION=${OS_VERSION} \
--build-arg CONTAINER_REGISTRY=${CONTAINER_REGISTRY}

oss-image: ## Build agent container image for NGINX OSS
@echo Building image with $(CONTAINER_CLITOOL); \
Expand Down
4 changes: 3 additions & 1 deletion Makefile.containers
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ CONTAINER_REGISTRY = registry.access.redhat.com
BASE_IMAGE = $(CONTAINER_REGISTRY)/ubi$(OS_VERSION)/ubi:latest
endif

CONTAINER_VARS = CONTAINER_CLITOOL CONTAINER_COMPOSE CONTAINER_BUILDENV CONTAINER_OS_TYPE CONTAINER_REGISTRY
CONTAINER_NGINX_IMAGE_REGISTRY ?= registry.nginx.com

CONTAINER_VARS = CONTAINER_CLITOOL CONTAINER_COMPOSE CONTAINER_BUILDENV CONTAINER_OS_TYPE CONTAINER_REGISTRY CONTAINER_NGINX_IMAGE_REGISTRY
19 changes: 19 additions & 0 deletions test/docker/oss/apk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG CONTAINER_NGINX_IMAGE_REGISTRY
ARG TAG
ARG IMAGE_PATH
FROM ${CONTAINER_NGINX_IMAGE_REGISTRY}${IMAGE_PATH}:${TAG} AS install
LABEL maintainer="NGINX Docker Maintainers <[email protected]>"

ARG OS_RELEASE
ARG OS_VERSION
ARG PACKAGE_NAME
ARG CONTAINER_OS_TYPE

WORKDIR /agent
COPY ./build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE} /agent/build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE}
COPY ./ /agent

RUN apk add --allow-untrusted /agent/build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE}

RUN unlink /var/log/nginx/access.log
RUN unlink /var/log/nginx/error.log
23 changes: 23 additions & 0 deletions test/docker/oss/deb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG CONTAINER_NGINX_IMAGE_REGISTRY
ARG TAG
ARG IMAGE_PATH
FROM ${CONTAINER_NGINX_IMAGE_REGISTRY}${IMAGE_PATH}:${TAG} AS install
LABEL maintainer="NGINX Docker Maintainers <[email protected]>"

ARG OS_RELEASE
ARG OS_VERSION
ARG DEBIAN_FRONTEND=noninteractive
ARG PACKAGE_NAME
ARG CONTAINER_OS_TYPE

WORKDIR /agent
COPY ./build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE} /agent/build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE}
COPY ./ /agent

RUN apt-get update \
&& apt install --no-install-recommends --no-install-suggests -y /agent/build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE} \
&& rm /agent/build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE}

RUN unlink /var/log/nginx/access.log
RUN unlink /var/log/nginx/error.log

52 changes: 0 additions & 52 deletions test/integration/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions test/integration/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"time"

"github.com/nginx/agent/sdk/v2/proto"
"github.com/nginx/agent/test/integration/utils"
tutils "github.com/nginx/agent/v2/test/utils"

"github.com/go-resty/resty/v2"
"github.com/nginx/agent/test/integration/utils"
tutils "github.com/nginx/agent/v2/test/utils"
"github.com/stretchr/testify/assert"
)

Expand Down
24 changes: 0 additions & 24 deletions test/integration/api/docker-compose-apk.yml

This file was deleted.

Loading

0 comments on commit 9a05ed0

Please sign in to comment.