diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e3c9d298..c49cf3b9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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: @@ -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: | @@ -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 diff --git a/.github/workflows/release-branch.yml b/.github/workflows/release-branch.yml index 9f6943d2d..78fcb34ba 100644 --- a/.github/workflows/release-branch.yml +++ b/.github/workflows/release-branch.yml @@ -1,4 +1,6 @@ name: Release Branch +env: + NFPM_VERSION: 'v2.35.3' on: workflow_dispatch: @@ -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' diff --git a/Makefile b/Makefile index 6247d5bc8..38fef30cb 100644 --- a/Makefile +++ b/Makefile @@ -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}" @@ -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 @@ -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); \ diff --git a/Makefile.containers b/Makefile.containers index c7047ad34..95e374ec6 100644 --- a/Makefile.containers +++ b/Makefile.containers @@ -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 diff --git a/test/docker/oss/apk/Dockerfile b/test/docker/oss/apk/Dockerfile new file mode 100644 index 000000000..dbca0f18c --- /dev/null +++ b/test/docker/oss/apk/Dockerfile @@ -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 " + +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 diff --git a/test/docker/oss/deb/Dockerfile b/test/docker/oss/deb/Dockerfile new file mode 100644 index 000000000..30d30d544 --- /dev/null +++ b/test/docker/oss/deb/Dockerfile @@ -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 " + +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 + diff --git a/test/integration/Dockerfile b/test/integration/Dockerfile deleted file mode 100644 index 7f236091a..000000000 --- a/test/integration/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -ARG DEVOPS_DOCKER_URL -ARG GO_LANG_CONTAINER - -FROM ${GO_LANG_CONTAINER} AS builder -ENV GOFLAGS="-mod=vendor" -ADD ./ /go_src -RUN cd /go_src/test/integration/ && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go test -v -timeout 5m -c -o integration-test - -FROM ${DEVOPS_DOCKER_URL}/dockerhub-remote/ubuntu:24.04 -ARG METRICS_MODULE_PKG -ARG NGINX_PLUS_VERSION -ADD ./ /go_src - -COPY ${METRICS_MODULE_PKG} /module.tar.gz - -RUN mkdir -p /etc/ssl/nginx \ - && mv /go_src/build/nginx-repo.crt /etc/ssl/nginx/nginx-repo.crt && mv /go_src/build/nginx-repo.key /etc/ssl/nginx/nginx-repo.key \ - && chmod +r /etc/ssl/nginx/*.* \ - && set -ex \ - && apt-get update \ - && apt-get install --no-install-recommends --no-install-suggests -y \ - curl \ - gnupg \ - ca-certificates \ - apt-transport-https \ - lsb-release \ - procps \ - && \ - NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \ - for server in \ - hkp://keyserver.ubuntu.com:80 \ - pgp.mit.edu; do \ - echo "Fetching GPG key $NGINX_GPGKEY from $server"; \ - gpg --keyserver "$server" \ - --recv-keys "$NGINX_GPGKEY" \ - && break; \ - done \ - && export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn \ - && curl -sS https://cs.nginx.com/static/keys/nginx_signing.key | apt-key add - \ - && curl -sS --output /etc/apt/apt.conf.d/90pkgs-nginx https://cs.nginx.com/static/files/90pkgs-nginx \ - && gpg --export "$NGINX_GPGKEY" > /etc/apt/trusted.gpg.d/nginx.gpg \ - && printf "deb https://pkgs.nginx.com/plus/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) nginx-plus\n" > /etc/apt/sources.list.d/nginx-plus.list \ - && mkdir -p /var/tmp/packages-repository/metrics \ - && tar xf /go_src/build/test/metrics-module.tar.gz -C /var/tmp/packages-repository/metrics/ \ - && apt-key add /var/tmp/packages-repository/metrics/nginx-signing.key \ - && echo "deb file:/var/tmp/packages-repository/metrics/ubuntu $(lsb_release -cs) controller" > /etc/apt/sources.list.d/nginx-metrics.list \ - && apt-get update \ - && apt-get install -y -q nginx-plus=${NGINX_PLUS_VERSION}~$(lsb_release -cs) nginx-plus-module-metrics - -COPY --from=builder /go_src/test/integration/integration-test /integration-test - -ENTRYPOINT ["/integration-test"] diff --git a/test/integration/api/api_test.go b/test/integration/api/api_test.go index 909074da1..c9e2516e0 100644 --- a/test/integration/api/api_test.go +++ b/test/integration/api/api_test.go @@ -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" ) diff --git a/test/integration/api/docker-compose-apk.yml b/test/integration/api/docker-compose-apk.yml deleted file mode 100644 index 07ae78d9c..000000000 --- a/test/integration/api/docker-compose-apk.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: '3.9' - -networks: - monitoring: - driver: bridge - -services: - agent: - build: - context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/apk/Dockerfile - target: install-agent-local - args: - PACKAGE_NAME: ${PACKAGE_NAME} - PACKAGES_REPO: ${PACKAGES_REPO} - BASE_IMAGE: ${BASE_IMAGE} - ENTRY_POINT: "./scripts/docker/entrypoint.sh" - ports: - - 9091:9091 - networks: - - monitoring - volumes: - - ./nginx.conf:/etc/nginx/nginx.conf - - ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf diff --git a/test/integration/api/docker-compose-deb.yml b/test/integration/api/docker-compose-deb.yml deleted file mode 100644 index 0f816641c..000000000 --- a/test/integration/api/docker-compose-deb.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: '3.9' - -networks: - monitoring: - driver: bridge - -services: - agent: - build: - context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/deb/Dockerfile - target: install-agent-local - args: - PACKAGE_NAME: ${PACKAGE_NAME} - PACKAGES_REPO: ${PACKAGES_REPO} - BASE_IMAGE: ${BASE_IMAGE} - ENTRY_POINT: "./scripts/docker/entrypoint.sh" - ports: - - 9091:9091 - networks: - - monitoring - volumes: - - ./nginx.conf:/etc/nginx/nginx.conf - - ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf diff --git a/test/integration/api/docker-compose-official-image.yml b/test/integration/api/docker-compose-official-image.yml new file mode 100644 index 000000000..79b6db1e6 --- /dev/null +++ b/test/integration/api/docker-compose-official-image.yml @@ -0,0 +1,25 @@ +version: '3.9' + +networks: + monitoring: + driver: bridge + +services: + agent: + build: + context: ../../../ + dockerfile: ./test/docker/oss/${CONTAINER_OS_TYPE}/Dockerfile + target: install + args: + PACKAGE_NAME: ${PACKAGE_NAME} + TAG: ${TAG} + CONTAINER_NGINX_IMAGE_REGISTRY: ${CONTAINER_NGINX_IMAGE_REGISTRY} + CONTAINER_OS_TYPE: ${CONTAINER_OS_TYPE} + IMAGE_PATH: ${IMAGE_PATH} + ports: + - 9091:9091 + networks: + - monitoring + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + - ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf diff --git a/test/integration/api/docker-compose-rpm.yml b/test/integration/api/docker-compose.yml similarity index 86% rename from test/integration/api/docker-compose-rpm.yml rename to test/integration/api/docker-compose.yml index 93340cecf..d80191011 100644 --- a/test/integration/api/docker-compose-rpm.yml +++ b/test/integration/api/docker-compose.yml @@ -4,11 +4,11 @@ networks: monitoring: driver: bridge -services: +services: agent: build: context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/rpm/Dockerfile + dockerfile: ./scripts/docker/nginx-oss/${CONTAINER_OS_TYPE}/Dockerfile target: install-agent-local args: PACKAGE_NAME: ${PACKAGE_NAME} diff --git a/test/integration/features/docker-compose-apk.yml b/test/integration/features/docker-compose-apk.yml deleted file mode 100644 index 3519675e8..000000000 --- a/test/integration/features/docker-compose-apk.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: '3.9' - -networks: - monitoring: - driver: bridge - -services: - agent: - build: - context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/apk/Dockerfile - target: install-agent-local - args: - PACKAGE_NAME: ${PACKAGE_NAME} - PACKAGES_REPO: ${PACKAGES_REPO} - BASE_IMAGE: ${BASE_IMAGE} - ENTRY_POINT: "./scripts/docker/entrypoint.sh" - ports: - - 9091:9091 - networks: - - monitoring - volumes: - - ./nginx.conf:/etc/nginx/nginx.conf - - ${CONF_FILE} diff --git a/test/integration/features/docker-compose-deb.yml b/test/integration/features/docker-compose-deb.yml deleted file mode 100644 index 561ba30b6..000000000 --- a/test/integration/features/docker-compose-deb.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: '3.9' - -networks: - monitoring: - driver: bridge - -services: - agent: - build: - context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/deb/Dockerfile - target: install-agent-local - args: - PACKAGE_NAME: ${PACKAGE_NAME} - PACKAGES_REPO: ${PACKAGES_REPO} - BASE_IMAGE: ${BASE_IMAGE} - ENTRY_POINT: "./scripts/docker/entrypoint.sh" - ports: - - 9091:9091 - networks: - - monitoring - volumes: - - ./nginx.conf:/etc/nginx/nginx.conf - - ${CONF_FILE} diff --git a/test/integration/features/docker-compose-official-image.yml b/test/integration/features/docker-compose-official-image.yml new file mode 100644 index 000000000..805f8a7af --- /dev/null +++ b/test/integration/features/docker-compose-official-image.yml @@ -0,0 +1,25 @@ +version: '3.9' + +networks: + monitoring: + driver: bridge + +services: + agent: + build: + context: ../../../ + dockerfile: ./test/docker/oss/${CONTAINER_OS_TYPE}/Dockerfile + target: install + args: + PACKAGE_NAME: ${PACKAGE_NAME} + TAG: ${TAG} + CONTAINER_NGINX_IMAGE_REGISTRY: ${CONTAINER_NGINX_IMAGE_REGISTRY} + CONTAINER_OS_TYPE: ${CONTAINER_OS_TYPE} + IMAGE_PATH: ${IMAGE_PATH} + ports: + - 9091:9091 + networks: + - monitoring + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + - ${CONF_FILE} diff --git a/test/integration/features/docker-compose-rpm.yml b/test/integration/features/docker-compose.yml similarity index 87% rename from test/integration/features/docker-compose-rpm.yml rename to test/integration/features/docker-compose.yml index 1f7f2e512..6d16e6aff 100644 --- a/test/integration/features/docker-compose-rpm.yml +++ b/test/integration/features/docker-compose.yml @@ -8,7 +8,7 @@ services: agent: build: context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/rpm/Dockerfile + dockerfile: ./scripts/docker/nginx-oss/${CONTAINER_OS_TYPE}/Dockerfile target: install-agent-local args: PACKAGE_NAME: ${PACKAGE_NAME} diff --git a/test/integration/grpc/docker-compose-apk.yml b/test/integration/grpc/docker-compose-apk.yml deleted file mode 100644 index 07c5aa1d5..000000000 --- a/test/integration/grpc/docker-compose-apk.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: '3.9' - -services: - agent: - build: - context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/apk/Dockerfile - target: install-agent-local - args: - PACKAGE_NAME: ${PACKAGE_NAME} - PACKAGES_REPO: ${PACKAGES_REPO} - BASE_IMAGE: ${BASE_IMAGE} - ENTRY_POINT: "./scripts/docker/entrypoint.sh" - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf diff --git a/test/integration/grpc/docker-compose-deb.yml b/test/integration/grpc/docker-compose-deb.yml deleted file mode 100644 index ae6f69864..000000000 --- a/test/integration/grpc/docker-compose-deb.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: '3.9' - -services: - agent: - build: - context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/deb/Dockerfile - target: install-agent-local - args: - PACKAGE_NAME: ${PACKAGE_NAME} - PACKAGES_REPO: ${PACKAGES_REPO} - BASE_IMAGE: ${BASE_IMAGE} - ENTRY_POINT: "./scripts/docker/entrypoint.sh" - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf diff --git a/test/integration/grpc/docker-compose-official-image.yml b/test/integration/grpc/docker-compose-official-image.yml new file mode 100644 index 000000000..ac65c5a5a --- /dev/null +++ b/test/integration/grpc/docker-compose-official-image.yml @@ -0,0 +1,18 @@ +version: '3.9' + +services: + agent: + build: + context: ../../../ + dockerfile: ./test/docker/oss/${CONTAINER_OS_TYPE}/Dockerfile + target: install + args: + PACKAGE_NAME: ${PACKAGE_NAME} + TAG: ${TAG} + CONTAINER_NGINX_IMAGE_REGISTRY: ${CONTAINER_NGINX_IMAGE_REGISTRY} + CONTAINER_OS_TYPE: ${CONTAINER_OS_TYPE} + IMAGE_PATH: ${IMAGE_PATH} + extra_hosts: + - "host.docker.internal:host-gateway" + volumes: + - ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf diff --git a/test/integration/grpc/docker-compose-rpm.yml b/test/integration/grpc/docker-compose.yml similarity index 86% rename from test/integration/grpc/docker-compose-rpm.yml rename to test/integration/grpc/docker-compose.yml index c682a9169..34c6cfe77 100644 --- a/test/integration/grpc/docker-compose-rpm.yml +++ b/test/integration/grpc/docker-compose.yml @@ -4,7 +4,7 @@ services: agent: build: context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/rpm/Dockerfile + dockerfile: ./scripts/docker/nginx-oss/${CONTAINER_OS_TYPE}/Dockerfile target: install-agent-local args: PACKAGE_NAME: ${PACKAGE_NAME} diff --git a/test/integration/install/docker-compose-deb.yml b/test/integration/install/docker-compose-deb.yml deleted file mode 100644 index 2f9d5efd8..000000000 --- a/test/integration/install/docker-compose-deb.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '3.9' - -services: - agent: - build: - context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/deb/Dockerfile - target: install-nginx - args: - PACKAGE_NAME: ${PACKAGE_NAME} - PACKAGES_REPO: ${PACKAGES_REPO} - INSTALL_FROM_REPO: ${INSTALL_FROM_REPO} - BASE_IMAGE: ${BASE_IMAGE} - ENTRY_POINT: "./scripts/docker/agentless-entrypoint.sh" - ports: - - 80 diff --git a/test/integration/install/docker-compose-rpm.yml b/test/integration/install/docker-compose-rpm.yml deleted file mode 100644 index c7346187c..000000000 --- a/test/integration/install/docker-compose-rpm.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3.9' - -services: - agent: - build: - context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/rpm/Dockerfile - target: install-nginx - args: - PACKAGE_NAME: ${PACKAGE_NAME} - PACKAGES_REPO: ${PACKAGES_REPO} - INSTALL_FROM_REPO: ${INSTALL_FROM_REPO} - BASE_IMAGE: ${BASE_IMAGE} - OS_RELEASE: ${OS_RELEASE} - OS_VERSION: ${OS_VERSION} - ENTRY_POINT: "./scripts/docker/agentless-entrypoint.sh" - ports: - - 80 diff --git a/test/integration/install/docker-compose-apk.yml b/test/integration/install/docker-compose.yml similarity index 76% rename from test/integration/install/docker-compose-apk.yml rename to test/integration/install/docker-compose.yml index cf1dc051a..4f79793ce 100644 --- a/test/integration/install/docker-compose-apk.yml +++ b/test/integration/install/docker-compose.yml @@ -4,13 +4,15 @@ services: agent: build: context: ../../../ - dockerfile: ./scripts/docker/nginx-oss/apk/Dockerfile + dockerfile: ./scripts/docker/nginx-oss/${CONTAINER_OS_TYPE}/Dockerfile target: install-nginx args: PACKAGE_NAME: ${PACKAGE_NAME} PACKAGES_REPO: ${PACKAGES_REPO} INSTALL_FROM_REPO: ${INSTALL_FROM_REPO} BASE_IMAGE: ${BASE_IMAGE} + OS_RELEASE: ${OS_RELEASE} + OS_VERSION: ${OS_VERSION} ENTRY_POINT: "./scripts/docker/agentless-entrypoint.sh" ports: - 80 diff --git a/test/integration/utils/test_container_utils.go b/test/integration/utils/test_container_utils.go index 9a2c649d9..04934c6a4 100644 --- a/test/integration/utils/test_container_utils.go +++ b/test/integration/utils/test_container_utils.go @@ -36,12 +36,16 @@ func SetupTestContainerWithAgent(t *testing.T, testName string, conf string, wai require.NoError(t, comp.WaitForService("agent", wait.ForLog(waitForLog)).WithEnv( map[string]string{ - "PACKAGE_NAME": os.Getenv("PACKAGE_NAME"), - "PACKAGES_REPO": os.Getenv("PACKAGES_REPO"), - "BASE_IMAGE": os.Getenv("BASE_IMAGE"), - "OS_RELEASE": os.Getenv("OS_RELEASE"), - "OS_VERSION": os.Getenv("OS_VERSION"), - "CONF_FILE": conf, + "PACKAGE_NAME": os.Getenv("PACKAGE_NAME"), + "PACKAGES_REPO": os.Getenv("PACKAGES_REPO"), + "BASE_IMAGE": os.Getenv("BASE_IMAGE"), + "OS_RELEASE": os.Getenv("OS_RELEASE"), + "OS_VERSION": os.Getenv("OS_VERSION"), + "CONTAINER_OS_TYPE": os.Getenv("CONTAINER_OS_TYPE"), + "CONTAINER_NGINX_IMAGE_REGISTRY": os.Getenv("CONTAINER_NGINX_IMAGE_REGISTRY"), + "TAG": os.Getenv("TAG"), + "IMAGE_PATH": os.Getenv("IMAGE_PATH"), + "CONF_FILE": conf, }, ).Up(ctxCancel, compose.Wait(true)), "compose.Up()") @@ -77,12 +81,16 @@ func SetupTestContainerWithoutAgent(t *testing.T) *testcontainers.DockerContaine err = comp. WithEnv(map[string]string{ - "PACKAGE_NAME": os.Getenv("PACKAGE_NAME"), - "PACKAGES_REPO": os.Getenv("PACKAGES_REPO"), - "INSTALL_FROM_REPO": os.Getenv("INSTALL_FROM_REPO"), - "BASE_IMAGE": os.Getenv("BASE_IMAGE"), - "OS_RELEASE": os.Getenv("OS_RELEASE"), - "OS_VERSION": os.Getenv("OS_VERSION"), + "PACKAGE_NAME": os.Getenv("PACKAGE_NAME"), + "PACKAGES_REPO": os.Getenv("PACKAGES_REPO"), + "INSTALL_FROM_REPO": os.Getenv("INSTALL_FROM_REPO"), + "BASE_IMAGE": os.Getenv("BASE_IMAGE"), + "OS_RELEASE": os.Getenv("OS_RELEASE"), + "OS_VERSION": os.Getenv("OS_VERSION"), + "CONTAINER_NGINX_IMAGE_REGISTRY": os.Getenv("CONTAINER_NGINX_IMAGE_REGISTRY"), + "TAG": os.Getenv("TAG"), + "CONTAINER_OS_TYPE": os.Getenv("CONTAINER_OS_TYPE"), + "IMAGE_PATH": os.Getenv("IMAGE_PATH"), }). WaitForService("agent", wait.NewLogStrategy("nginx_pid").WithOccurrence(1)). Up(ctx, compose.Wait(true))