Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ef3438a
Add install test to CI
Dean-Coakley Dec 2, 2022
ff71fab
Fix apk package build
Dean-Coakley Dec 8, 2022
7c5f102
Merge branch 'main' into run-install-test
Dean-Coakley Jan 25, 2023
c44503c
Remove install stage from release workflow
Dean-Coakley Jan 26, 2023
bc75a8a
Set pkg path in CI
Dean-Coakley Jan 26, 2023
fba8e9c
Remove makefile vars. Var substitution
Dean-Coakley Jan 26, 2023
b7bae1e
Use env vars for agent pkg
Dean-Coakley Jan 26, 2023
ad5c140
Remove shell cmd
Dean-Coakley Jan 26, 2023
92c6fb8
Use regex instead
Dean-Coakley Jan 26, 2023
8242951
Fix var substitution
Dean-Coakley Jan 26, 2023
36da699
Use GitHub Actions exports
Dean-Coakley Jan 26, 2023
7174c26
Debug
Dean-Coakley Jan 26, 2023
396f848
Lint api integration test
Dean-Coakley Jan 30, 2023
113e6ee
Convert install/uninstall to integration test
Dean-Coakley Jan 30, 2023
afb44d0
Merge branch 'main' into run-install-test
Dean-Coakley Jan 30, 2023
4da18c0
Add base image override
Dean-Coakley Jan 30, 2023
2b0949a
Make deps
Dean-Coakley Jan 30, 2023
5686b7e
Remove trailing entrypoint script. Fix yum install cmd
Dean-Coakley Jan 31, 2023
6f34be4
Revert erroneous removal of benchmark test
Dean-Coakley Jan 31, 2023
bb3607a
Remove hardcode of file extension
Dean-Coakley Jan 31, 2023
9ee9279
Remove global var
Dean-Coakley Jan 31, 2023
23993e6
Use multi-stage builds
Dean-Coakley Jan 31, 2023
b32d9a2
Wait for agent container to be ready. Lint
Dean-Coakley Jan 31, 2023
8d76357
Move to log WaitStrategy
Dean-Coakley Jan 31, 2023
e0c4f2d
Fix http WaitStrategy with binding port
Dean-Coakley Feb 1, 2023
e326b27
Only bind containerPort. Remove hostPort bind
Dean-Coakley Feb 1, 2023
72fe67c
Remove trailing dockerfile. Update lint CI workflow OS
Dean-Coakley Feb 1, 2023
dbf8610
Lint Makefile. Simplify integration-test Dockerfile
Dean-Coakley Feb 2, 2023
3e89b35
PR feedback
Dean-Coakley Feb 3, 2023
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
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
jobs:
lint:
name: Lint
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
Expand Down Expand Up @@ -74,10 +74,9 @@ jobs:
go-version-file: 'go.mod'
- name: Run Integration Tests
run: |
sudo apt-get update
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
make integration-test

performance-test:
name: Performance Tests
if: "!github.event.pull_request.head.repo.fork"
Expand Down Expand Up @@ -171,7 +170,6 @@ jobs:
go-version-file: 'go.mod'
- name: Setup build environment
run: |
sudo apt-get update
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ LDFLAGS = "-w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=$
DEBUG_LDFLAGS = "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"

CERTS_DIR := ./build/certs
PACKAGE_PREFIX := nginx-agent
PACKAGES_REPO := "pkgs.nginx.com"
PACKAGE_PREFIX := nginx-agent
PACKAGES_REPO := "pkgs.nginx.com"
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
OSARCH := $(shell uname -m)
TEST_BUILD_DIR := build/test
PACKAGE_NAME := ${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}
TEST_BUILD_DIR := build/test
PACKAGE_NAME := "${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}"
# override this value if you want to change the architecture. GOOS options here: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63
LOCAL_ARCH := amd64

Expand Down Expand Up @@ -180,7 +180,8 @@ performance-test: ## Run performance tests
$(CONTAINER_CLITOOL) run -v ${PWD}:/home/nginx/$(CONTAINER_VOLUME_FLAGS) --rm nginx-agent-benchmark:1.0.0

integration-test: local-deb-package
PACKAGE=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} go test ./test/integration/api
PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} go test ./test/integration/install
PACKAGE_NAME=${PACKAGE_NAME} BASE_IMAGE=${BASE_IMAGE} go test ./test/integration/api

test-bench: ## Run benchmark tests
cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 5 -timeout 2m -bench=. -benchmem metrics_test.go
Expand All @@ -193,10 +194,6 @@ benchmark-image: ## Build benchmark test container image for NGINX Plus, need ng
--secret id=nginx-key,src=build/nginx-repo.key \
-f test/docker/Dockerfile .

# Install tests
test-install: ## Run agent install test
GOWORK=off CGO_ENABLED=0 go test -v ./test/install

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Cert Generation #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand Down
30 changes: 30 additions & 0 deletions scripts/docker/nginx-oss/agentless-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -e
set -x
set -euxo pipefail

handle_term()
{
echo "received TERM signal"
echo "stopping nginx ..."
kill -TERM "${nginx_pid}" 2>/dev/null
}

trap 'handle_term' TERM

# Launch nginx
echo "starting nginx ..."
/usr/sbin/nginx -g "daemon off;" &

nginx_pid=$!

wait_term()
{
trap - TERM
kill -QUIT "${nginx_pid}" 2>/dev/null
echo "waiting for nginx to stop..."
wait ${nginx_pid}
}

wait_term
29 changes: 13 additions & 16 deletions scripts/docker/nginx-oss/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE} as install
FROM ${BASE_IMAGE} as install-nginx
LABEL maintainer="NGINX Agent Maintainers <agent@nginx.com>"

ARG PACKAGE
ARG AGENT_CONF
ARG NGINX_CONF
ARG ENTRY_POINT

WORKDIR /agent
COPY ./ /agent
COPY $ENTRY_POINT /agent/entrypoint.sh
COPY $AGENT_CONF /agent/nginx-agent.conf
COPY $NGINX_CONF /agent/nginx.conf

RUN set -x \
&& addgroup --system --gid 101 nginx \
Expand All @@ -26,19 +22,20 @@ RUN set -x \
make \
curl \
vim \
golang \
nginx \
&& apt-get update \
&& apt install -y -f /agent/build/$PACKAGE.deb

# run the nginx and agent
FROM install as runtime

COPY --from=install /agent/entrypoint.sh /agent/entrypoint.sh
COPY --from=install /agent/nginx-agent.conf /etc/nginx-agent/nginx-agent.conf

nginx
RUN chmod +x /agent/entrypoint.sh
STOPSIGNAL SIGTERM

EXPOSE 80 443

ENTRYPOINT ["/agent/entrypoint.sh"]


FROM install-nginx as install-agent

ARG PACKAGE_NAME
ARG AGENT_CONF

COPY $AGENT_CONF /agent/nginx-agent.conf
COPY --from=install-nginx /agent/nginx-agent.conf /etc/nginx-agent/nginx-agent.conf
RUN apt install -y -f /agent/build/$PACKAGE_NAME.deb
1 change: 0 additions & 1 deletion sdk/proto/events/event.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions test/install/README.md

This file was deleted.

148 changes: 0 additions & 148 deletions test/install/agent_install_test.go

This file was deleted.

19 changes: 8 additions & 11 deletions test/integration/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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:20.04
FROM ${DEVOPS_DOCKER_URL}/dockerhub-remote/ubuntu:22.04
ARG METRICS_MODULE_PKG
ARG NGINX_PLUS_VERSION
ADD ./ /go_src
Expand All @@ -18,14 +18,13 @@ RUN mkdir -p /etc/ssl/nginx \
&& chmod +r /etc/ssl/nginx/*.* \
&& set -ex \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install --no-install-recommends --no-install-suggests -y \
curl \
gnupg \
ca-certificates \
apt-transport-https \
lsb-release \
procps \
curl \
gnupg \
ca-certificates \
apt-transport-https \
lsb-release \
procps \
&& \
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
for server in \
Expand All @@ -41,14 +40,12 @@ RUN mkdir -p /etc/ssl/nginx \
&& 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 \
&& apt-get update \
&& 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 \
&& apt-get -y clean all
&& 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

Expand Down
Loading