Skip to content

Commit 8d7dfdc

Browse files
committed
update integration tests
1 parent 4312e1c commit 8d7dfdc

File tree

3 files changed

+25
-56
lines changed

3 files changed

+25
-56
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,21 @@ jobs:
6464
OSARCH=amd64
6565
GO_VERSION=${{ env.GO_VERSION }}
6666
67-
- name: Run Load Test with CPU profiling
67+
- name: Run CPU Profiling Tests
6868
run: |
69-
make run-load-test-with-cpu-profiling
70-
make generate-pgo-profile
69+
cp profile.pgo old_profile.pgo || echo "No previous pgo profile found"
70+
make generate-pgo-profile || echo "No changes to profile"
71+
ls -l profile.pgo
72+
diff old_profile.pgo profile.pgo || echo "No differences found"
7173
72-
- name: Archive Load Test CPU profile
73-
id: artifact-upload-step
74-
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
75-
with:
76-
name: cpu-profile
77-
path: build/test/load/profile.pgo
78-
if-no-files-found: error
79-
80-
- name: Push PGO profile
74+
- name: Upload CPU Profile
8175
run: |
8276
git config --global user.name 'github-actions'
8377
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
8478
git commit -m "CI Autogenerated" -- ${{ steps.artifact-upload-step.outputs.artifact-id }} || echo "No changes to commit"
8579
git log -1
8680
81+
8782
proxy-sanity-check:
8883
name: Proxy Sanity Check
8984
runs-on: ubuntu-22.04

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,14 @@ local-rpm-package: ## Create local rpm package
283283

284284
generate-pgo-profile: build-mock-management-plane-grpc run-load-test-with-cpu-profiling ## Generate PGO profile
285285
@echo "Generating PGO profile"
286-
cp default.pgo old.pprof
287286
TEST_ENV="Container" CONTAINER_OS_TYPE=$(CONTAINER_OS_TYPE) BUILD_TARGET="install-agent-local" \
288287
PACKAGES_REPO=$(OSS_PACKAGES_REPO) PACKAGE_NAME=$(PACKAGE_NAME) BASE_IMAGE=$(BASE_IMAGE) \
289288
OS_VERSION=$(OS_VERSION) OS_RELEASE=$(OS_RELEASE) DOCKERFILE_PATH=$(DOCKERFILE_PATH) \
290289
IMAGE_PATH=$(IMAGE_PATH) TAG=${IMAGE_TAG} CONTAINER_NGINX_IMAGE_REGISTRY=${CONTAINER_NGINX_IMAGE_REGISTRY} \
291290
scripts/performance/profiling.sh
292291

293292
@(GOTOOL) pprof -proto -output=default.pgo merged.pprof build/test/load-cpu-profiling/load/metrics_load_cpu.pprof
294-
293+
rm $(find . -type f -name "*.test" | xargs)
295294

296295
# run under sudo locally
297296
load-test-image: ## Build performance load testing image

scripts/performance/profiling.sh

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
11
#!/usr/bin/env bash
22

3-
# This script runs Go tests with CPU profiling enabled for all test packages in the test/integration directory.
4-
# It saves the CPU profiles in the profiles directory with the format <package-name>_<test_type>.pprof
5-
# Usage: ./scripts/performance/profiling.sh
6-
#
7-
# Variables:
8-
# - TEST_ENV: The test environment (default: "local")
9-
# - CONTAINER_OS_TYPE: The container OS type (default: "linux")
10-
# - BUILD_TARGET: The build target (default: "agent")
11-
# - PACKAGES_REPO: The packages repository (default: "packages.nginx.org")
12-
# - PACKAGE_NAME: The package name (default: "nginx-agent
13-
# - BASE_IMAGE: The base image (default: "ubuntu")
14-
# - OS_VERSION: The OS version (default: "20.04")
15-
# - OS_RELEASE: The OS release (default: "focal")
16-
# - DOCKERFILE_PATH: The Dockerfile path (default: "Dockerfile")
17-
# - IMAGE_PATH: The image path (default: "nginxinc/nginx-agent")
18-
# - TAG: The image tag (default: "latest")
19-
# - CONTAINER_NGINX_IMAGE_REGISTRY: The container registry (default: "docker.io")
20-
# Example:
21-
# TEST_ENV=ci CONTAINER_OS_TYPE=linux BUILD_TARGET=agent PACKAGES_REPO=nginxinc PACKAGE_NAME=nginx-agent BASE_IMAGE=ubuntu OS_VERSION=20.04 OS_RELEASE=focal DOCKERFILE_PATH=Dockerfile IMAGE_PATH=nginxinc/nginx-agent TAG=latest CONTAINER_NGINX_IMAGE_REGISTRY=docker.io ./scripts/performance/profiling.sh
22-
23-
## Print all variables in the environment
24-
#echo "TEST_ENV=$TEST_ENV"
25-
#echo "CONTAINER_OS_TYPE=$CONTAINER_OS_TYPE"
26-
#echo "BUILD_TARGET=$BUILD_TARGET"
27-
#echo "PACKAGES_REPO=$PACKAGES_REPO"
28-
#echo "PACKAGE_NAME=$PACKAGE_NAME"
29-
#echo "BASE_IMAGE=$BASE_IMAGE"
30-
#echo "OS_VERSION=$OS_VERSION"
31-
#echo "OS_RELEASE=$OS_RELEASE"
32-
#echo "DOCKERFILE_PATH=$DOCKERFILE_PATH"
33-
#echo "IMAGE_PATH=$IMAGE_PATH"
34-
#echo "TAG=$TAG"
35-
#echo "CONTAINER_NGINX_IMAGE_REGISTRY=$CONTAINER_NGINX_IMAGE_REGISTRY"
3+
# This script runs Go tests with CPU profiling enabled for all test packages found under the directories:
4+
# - internal/watcher
5+
# - test/integration
6+
# It saves the CPU profiles in the $PROFILES_DIR directory with the format <package-name>_<test_type>.pprof
7+
# e.g. <package-name>_watcher_cpu.pprof or <package-name>_integration_cpu.pprof
8+
9+
# The variables below can be set to customize the environment for the integration tests:
10+
# Example using variables defined in our Makefile:
11+
# TEST_ENV=ci CONTAINER_OS_TYPE=linux BUILD_TARGET=agent PACKAGES_REPO=nginxinc \
12+
# PACKAGE_NAME=nginx-agent BASE_IMAGE=ubuntu OS_VERSION=20.04 OS_RELEASE=focal \
13+
# DOCKERFILE_PATH=Dockerfile IMAGE_PATH=nginxinc/nginx-agent TAG=latest CONTAINER_NGINX_IMAGE_REGISTRY=docker.io \
14+
# ./scripts/performance/profiling.sh
3615

3716
set -e
3817
set -o pipefail
@@ -48,7 +27,7 @@ echo "$packages"
4827
for pkg in $packages; do
4928
echo "Running tests in package: ${pkg}"
5029
go test \
51-
-count 10 -timeout 1m \
30+
-count 10 -timeout 3m \
5231
-cpuprofile "${PROFILES_DIR}/$(basename $pkg)_watcher_cpu.pprof" \
5332
"./${pkg}" || { echo "Tests failed in package: ${pkg}, but continuing..."; continue; }
5433
echo "Profile saved to: ${PROFILES_DIR}/$(basename $pkg)_watcher_cpu.pprof"
@@ -62,18 +41,14 @@ echo "$packages"
6241
for pkg in $packages; do
6342
echo "Running tests in package: ${pkg}"
6443
go test -v \
65-
-count 3 -timeout 1m \
66-
-cpuprofile "profiles/$(basename $pkg)_integration_cpu.pprof" \
44+
-count 3 -timeout 3m \
45+
-cpuprofile "${PROFILES_DIR}/$(basename $pkg)_integration_cpu.pprof" \
6746
"./${pkg}" || { echo "Tests failed in package: ${pkg}, but continuing..."; continue; }
68-
mv $(basename $pkg).test profiles/$(basename $pkg)_integration_cpu.test
69-
echo "Profile saved to: profiles/${profile_name}"
47+
echo "Profile saved to: ${PROFILES_DIR}/$(basename $pkg)_integration_cpu.pprof"
7048
done
7149

7250
## Merge all CPU profiles
7351
files=$(ls ${PROFILES_DIR}/*.pprof)
7452
echo "Merging CPU profiles: $files"
7553
go tool pprof -proto -output=${PROFILES_DIR}/merged.pgo $files
76-
echo "Merged CPU profile saved to: default.pgo"
77-
78-
## Cleanup
79-
rm *.pprof
54+
echo "Merged CPU profile saved to: ${PROFILES_DIR}/merged.pgo"

0 commit comments

Comments
 (0)