Skip to content

Commit 66722ca

Browse files
authored
Add upgrade tests (#1245)
1 parent c9fd4b2 commit 66722ca

File tree

10 files changed

+456
-18
lines changed

10 files changed

+456
-18
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,50 @@ jobs:
156156
if: always()
157157
run: bash ./scripts/dashboard/format_results.sh ${{job.status}} ${{github.job}}/${{matrix.container.image}}-${{matrix.container.version}} ${{github.workspace}}
158158

159+
upgrade-tests:
160+
name: Upgrade Tests
161+
needs: build-unsigned-snapshot
162+
runs-on: ubuntu-22.04
163+
strategy:
164+
matrix:
165+
container:
166+
- image: "ubuntu"
167+
version: "24.04"
168+
- image: "redhatenterprise"
169+
version: "9"
170+
- image: "alpine"
171+
version: "3.22"
172+
steps:
173+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
174+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
175+
with:
176+
go-version-file: 'go.mod'
177+
cache: false
178+
- name: Download Packages
179+
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
180+
with:
181+
name: nginx-agent-unsigned-snapshots
182+
path: build
183+
184+
- name: Create Results Directory
185+
run: mkdir -p ${{ github.workspace }}/test/dashboard/logs/${{ github.job }}/${{matrix.container.image}}-${{matrix.container.version}}
186+
187+
- name: Start Promtail
188+
uses: ./.github/actions/start-promtail
189+
with:
190+
loki_url: ${{ secrets.LOKI_DASHBOARD_URL }}
191+
192+
- name: Run Upgrade Tests
193+
run: |
194+
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
195+
OS_RELEASE="${{ matrix.container.image }}" OS_VERSION="${{ matrix.container.version }}" \
196+
make upgrade-test | tee ${{github.workspace}}/test/dashboard/logs/${{github.job}}/${{matrix.container.image}}-${{matrix.container.version}}/raw_logs.log
197+
exit "${PIPESTATUS[0]}"
198+
199+
- name: Format Results
200+
if: always()
201+
run: bash ./scripts/dashboard/format_results.sh ${{job.status}} ${{github.job}}/${{matrix.container.image}}-${{matrix.container.version}} ${{github.workspace}}
202+
159203
official-oss-image-integration-tests:
160204
name: Integration Tests - Official OSS Images
161205
needs: build-unsigned-snapshot

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ VERSION ?= $(shell git describe --match "v[0-9]*" --abbrev=0 --tags)
5252
ifeq ($(strip $(VERSION)),)
5353
VERSION := $(shell curl https://api.github.com/repos/nginx/agent/releases/latest -s | jq .name -r)
5454
endif
55+
5556
COMMIT = $(shell git rev-parse --short HEAD)
5657
DATE = $(shell date +%F_%H-%M-%S)
5758
LDFLAGS = "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
@@ -166,6 +167,12 @@ integration-test: $(SELECTED_PACKAGE) build-mock-management-plane-grpc
166167
OS_VERSION=$(OS_VERSION) OS_RELEASE=$(OS_RELEASE) \
167168
go test -v ./test/integration/installuninstall ./test/integration/managementplane ./test/integration/auxiliarycommandserver ./test/integration/nginxless
168169

170+
upgrade-test: $(SELECTED_PACKAGE) build-mock-management-plane-grpc
171+
TEST_ENV="Container" CONTAINER_OS_TYPE=$(CONTAINER_OS_TYPE) BUILD_TARGET="install-agent-repo" CONTAINER_NGINX_IMAGE_REGISTRY=${CONTAINER_NGINX_IMAGE_REGISTRY} \
172+
PACKAGES_REPO=$(OSS_PACKAGES_REPO) PACKAGE_NAME=$(PACKAGE_NAME) BASE_IMAGE=$(BASE_IMAGE) \
173+
DOCKERFILE_PATH=$(DOCKERFILE_PATH) IMAGE_PATH=$(IMAGE_PATH) TAG=${IMAGE_TAG} OS_VERSION=$(OS_VERSION) OS_RELEASE=$(OS_RELEASE) \
174+
go test -v ./test/integration/upgrade
175+
169176
official-image-integration-test: $(SELECTED_PACKAGE) build-mock-management-plane-grpc
170177
TEST_ENV="Container" CONTAINER_OS_TYPE=$(CONTAINER_OS_TYPE) CONTAINER_NGINX_IMAGE_REGISTRY=${CONTAINER_NGINX_IMAGE_REGISTRY} BUILD_TARGET="install" \
171178
PACKAGES_REPO=$(OSS_PACKAGES_REPO) TAG=${TAG} PACKAGE_NAME=$(PACKAGE_NAME) BASE_IMAGE=$(BASE_IMAGE) DOCKERFILE_PATH=$(OFFICIAL_IMAGE_DOCKERFILE_PATH) \

test/docker/nginx-oss/apk/Dockerfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ FROM ${BASE_IMAGE} as install-nginx
33
LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
44

55
ARG ENTRY_POINT
6-
ARG PACKAGES_REPO
76

87
WORKDIR /agent
98
COPY ./build /agent/build
@@ -33,12 +32,10 @@ RUN apk add --allow-untrusted /agent/build/${PACKAGE_NAME}.apk
3332

3433
FROM install-nginx as install-agent-repo
3534

35+
ARG PACKAGES_REPO
36+
3637
# Setup nginx agent repository
3738
RUN curl -o /etc/apk/keys/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub
39+
RUN printf "http://${PACKAGES_REPO}/nginx-agent/alpine/v`grep -o -E '^[0-9]+\.[0-9]+' /etc/alpine-release`/main" | tee -a /etc/apk/repositories
3840

39-
RUN printf "%s%s%s\n" \
40-
"http://${PACKAGES_REPO}/nginx-agent/alpine/v" \
41-
`grep -o -E '^[0-9]+\.[0-9]+' /etc/alpine-release` \
42-
"/main" | tee -a /etc/apk/repositories
43-
44-
RUN apk add nginx-agent@nginx-agent
41+
RUN apk add nginx-agent
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# /etc/nginx-agent/nginx-agent.conf
3+
#
4+
# Configuration file for NGINX Agent.
5+
#
6+
7+
log:
8+
# set log level (error, warn, info, debug; default "info")
9+
level: debug
10+
# set log path. if empty, don't log to file.
11+
path: /var/log/nginx-agent/
12+
13+
allowed_directories:
14+
- /etc/nginx
15+
- /usr/local/etc/nginx
16+
- /usr/share/nginx/modules
17+
- /var/run/nginx
18+
- /var/log/nginx
19+
20+
command:
21+
server:
22+
host: managementPlane
23+
port: 9092
24+
type: grpc
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# /etc/nginx-agent/nginx-agent.conf
3+
#
4+
# Configuration file for NGINX Agent.
5+
#
6+
7+
log:
8+
# set log level (error, warn, info, debug; default "info")
9+
level: debug
10+
# set log path. if empty, don't log to file.
11+
path: /var/log/nginx-agent/
12+
13+
allowed_directories:
14+
- /etc/nginx
15+
- /usr/local/etc/nginx
16+
- /usr/share/nginx/modules
17+
- /var/run/nginx
18+
- /var/log/nginx
19+
20+
command:
21+
server:
22+
host: managementPlane
23+
port: 9092
24+
type: grpc
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
worker_processes 1;
2+
error_log /var/log/nginx/error.log;
3+
events {
4+
worker_connections 1024;
5+
}
6+
7+
http {
8+
default_type application/octet-stream;
9+
10+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
11+
'$status $body_bytes_sent "$http_referer" '
12+
'"$http_user_agent" "$http_x_forwarded_for" '
13+
'"$bytes_sent" "$request_length" "$request_time" '
14+
'"$gzip_ratio" $server_protocol ';
15+
16+
access_log /var/log/nginx/access.log main;
17+
18+
sendfile on;
19+
keepalive_timeout 65;
20+
21+
server {
22+
listen 8080;
23+
server_name localhost;
24+
25+
location / {
26+
root /usr/share/nginx/html;
27+
index index.html index.htm;
28+
}
29+
30+
##
31+
# Enable Metrics
32+
##
33+
location /api {
34+
stub_status;
35+
allow 127.0.0.1;
36+
deny all;
37+
}
38+
39+
# redirect server error pages to the static page /50x.html
40+
#
41+
error_page 500 502 503 504 /50x.html;
42+
location = /50x.html {
43+
root /usr/share/nginx/html;
44+
}
45+
}
46+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
worker_processes 1;
2+
error_log /var/log/nginx/error.log;
3+
4+
events {
5+
worker_connections 1024;
6+
}
7+
8+
http {
9+
default_type application/octet-stream;
10+
11+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
12+
'$status $body_bytes_sent "$http_referer" '
13+
'"$http_user_agent" "$http_x_forwarded_for" '
14+
'"$bytes_sent" "$request_length" "$request_time" '
15+
'"$gzip_ratio" $server_protocol ';
16+
17+
access_log /var/log/nginx/access.log main;
18+
19+
sendfile on;
20+
keepalive_timeout 65;
21+
22+
server {
23+
listen 8080;
24+
server_name localhost;
25+
26+
location / {
27+
root /usr/share/nginx/html;
28+
index index.html index.htm;
29+
}
30+
31+
##
32+
# Enable Metrics
33+
##
34+
location /api/ {
35+
api write=on;
36+
allow 127.0.0.1;
37+
deny all;
38+
status_zone my_location_zone1;
39+
}
40+
41+
# redirect server error pages to the static page /50x.html
42+
#
43+
error_page 500 502 503 504 /50x.html;
44+
location = /50x.html {
45+
root /usr/share/nginx/html;
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)