Skip to content

Commit 027d295

Browse files
committed
fix load test, benchmark json file
1 parent 15af15a commit 027d295

File tree

5 files changed

+68
-49
lines changed

5 files changed

+68
-49
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
- name: Run Load Test with CPU profiling
6868
run: |
6969
make run-load-test-with-cpu-profiling
70+
make generate-pgo-profile
7071
7172
- name: Archive Load Test CPU profile
7273
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
@@ -75,10 +76,6 @@ jobs:
7576
path: build/test/load/profile.pgo
7677
if-no-files-found: error
7778

78-
- name: Run Profiling script
79-
run: |
80-
make generate-pgo-profile
81-
8279
- name: Push PGO profile
8380
run: |
8481
git config --global user.name 'github-actions'

Makefile

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ PROJECT_FILE = main.go
4646
COLLECTOR_PATH ?= /etc/nginx-agent/opentelemetry-collector-agent.yaml
4747
MANIFEST_DIR ?= /var/lib/nginx-agent
4848
DIRS = $(BUILD_DIR) $(TEST_BUILD_DIR) $(BUILD_DIR)/$(DOCS_DIR) $(BUILD_DIR)/$(DOCS_DIR)/$(PROTO_DIR)
49+
TIME_NOW := $(shell date +%s)
4950
$(shell mkdir -p $(DIRS))
5051

5152
VERSION ?= $(shell git describe --match "v[0-9]*" --abbrev=0 --tags)
@@ -289,49 +290,78 @@ generate-pgo-profile: build-mock-management-plane-grpc ## Generate PGO profile
289290

290291
# run under sudo locally
291292
load-test-image: ## Build performance load testing image
292-
@echo "🚚 Building load test image"
293+
@echo "🚚 Building load test image"
293294
$(CONTAINER_BUILDENV) $(CONTAINER_CLITOOL) build \
294295
-t $(IMAGE_TAG)_load_test:1.0.0 . \
296+
--no-cache \
295297
-f ./test/docker/load/Dockerfile \
296298
--secret id=nginx-crt,src=$(CERTS_DIR)/nginx-repo.crt \
297299
--secret id=nginx-key,src=$(CERTS_DIR)/nginx-repo.key \
298300
--build-arg OSARCH=$(OSARCH) \
299301
--build-arg GO_VERSION=$(GO_VERSION)
300302

301303
run-load-test-image: ## Run performance load testing image
302-
@echo "🚚 Running load tests"
304+
@mkdir -p $(TEST_BUILD_DIR)/load
305+
@echo "🚚 Running load tests"
303306
$(CONTAINER_CLITOOL) rm -f agent-load-test || true
304307

305-
## Run the load test container
308+
# Run the load test container
306309
@$(CONTAINER_BUILDENV) $(CONTAINER_CLITOOL) run \
307310
--name agent-load-test \
308311
$(IMAGE_TAG)_load_test:1.0.0
309312

310-
# Copy the files generated by the load tests
313+
# Copy the files generated by the load tests
311314
@$(CONTAINER_CLITOOL) cp \
312-
agent-load-test:/agent/performance/load-tests \
315+
agent-load-test:/agent/performance/load \
313316
$(TEST_BUILD_DIR)/load
314-
@echo "Benchmarks saved to $(TEST_BUILD_DIR)/load"
317+
@echo "Results saved to $(TEST_BUILD_DIR)/load"
315318
@find $(TEST_BUILD_DIR)/load -type f -exec ls -lh {} \;
316319

317-
## Stop and remove the container
318-
$(CONTAINER_CLITOOL) stop agent-load-test && $(CONTAINER_CLITOOL) rm -f agent-load-test
320+
# Copy the benchmark json to the $(TEST_BUILD_DIR)/load directory for easier access
321+
@$(CONTAINER_CLITOOL) cp \
322+
agent-load-test:/agent/test/load \
323+
$(TEST_BUILD_DIR)/load
324+
@echo "Benchmark results saved to $(TEST_BUILD_DIR)/load/benchmarks.json"
325+
326+
# Copy the results to the $(TEST_BUILD_DIR)/load directory for easier access
327+
@$(CONTAINER_CLITOOL) cp \
328+
agent-load-test:/agent/test/load/results \
329+
$(TEST_BUILD_DIR)/load/
330+
@echo "Benchmark results saved to $(TEST_BUILD_DIR)/load/results"
331+
332+
# Stop and remove the container
333+
@$(CONTAINER_CLITOOL) stop agent-load-test && $(CONTAINER_CLITOOL) rm -f agent-load-test
319334

320335
run-load-test-with-cpu-profiling: ## Run performance load testing with cpu profiling
321-
@echo "🚚 Running load tests with cpu profiling"
336+
@echo "🚚 Running load tests with cpu profiling"
337+
@mkdir -p $(TEST_BUILD_DIR)
322338
@$(CONTAINER_CLITOOL) rm -f agent-load-test-with-cpu-profiling || true
339+
@echo "Current epoch time is $(TIME_NOW)"
323340

324-
## Run the load test container
341+
# Run the load test container
325342
@$(CONTAINER_BUILDENV) $(CONTAINER_CLITOOL) run \
326343
--name agent-load-test-with-cpu-profiling \
327344
--env PROFILE=true \
328345
$(IMAGE_TAG)_load_test:1.0.0
329346

330-
# Copy the files generated by the load tests
347+
# Copy the files generated by the load tests
348+
DIR=profiles/$(TIME_NOW)
331349
@$(CONTAINER_CLITOOL) cp \
332-
agent-load-test-with-cpu-profiling:/agent/performance/load-tests \
333-
profiles
334-
@echo "Benchmarks and profile saved to profiles directory"
350+
agent-load-test-with-cpu-profiling:/agent/performance/load \
351+
$(DIR)
352+
@echo "Benchmarks and profile saved to $(DIR) directory"
353+
354+
# Copy the benchmark results to the root of build directory for easier access
355+
@$(CONTAINER_CLITOOL) cp \
356+
agent-load-test-with-cpu-profiling:/agent/test/load/benchmarks.json \
357+
$(TEST_BUILD_DIR)/load/benchmarks.json
358+
@echo "Benchmark results saved to $(TEST_BUILD_DIR)/load/benchmarks.json"
359+
360+
# Copy the results to the $(TEST_BUILD_DIR)/load directory for easier access
361+
@$(CONTAINER_CLITOOL) cp \
362+
agent-load-test:/agent/test/load/results \
363+
$(TEST_BUILD_DIR)/load
364+
@echo "Benchmark results saved to $(TEST_BUILD_DIR)/load/results"
335365

336-
# Stop and remove the container
366+
# Stop and remove the container
337367
@$(CONTAINER_CLITOOL) stop agent-load-test-with-cpu-profiling && $(CONTAINER_CLITOOL) rm -f agent-load-test-with-cpu-profiling

test/docker/load/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ARG OSARCH
5757

5858
# Install Go
5959
RUN wget -q https://go.dev/dl/go${GO_VERSION}.linux-${OSARCH}.tar.gz \
60-
&& tar -xvf go${GO_VERSION}.linux-${OSARCH}.tar.gz \
60+
&& tar -xf go${GO_VERSION}.linux-${OSARCH}.tar.gz \
6161
&& mv go /usr/local > /dev/null \
6262
&& rm go${GO_VERSION}.linux-${OSARCH}.tar.gz
6363

test/docker/load/entrypoint.sh

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,44 @@
11
#!/bin/bash
22

33
PROFILE=${PROFILE:-"false"}
4-
DESTINATION="/agent/performance"
5-
BENCHMARKS_DIR="${DESTINATION}/load-tests"
6-
mkdir -p ${BENCHMARKS_DIR}
4+
BENCHMARKS_DIR="/agent/performance/load"
75

86
load_test() {
97
echo "Running load tests..."
10-
echo "Results will be saved to ${BENCHMARKS_DIR}/benchmarks.json"
11-
go test -v -timeout 1m ./test/load/... \
12-
| tee ${BENCHMARKS_DIR}/benchmarks.json || { echo "Load tests failed, exiting..."; exit 1; }
13-
find ${BENCHMARKS_DIR}
8+
pushd test/load
9+
go test -v -timeout 1m ./...
10+
11+
cp benchmarks.json ${BENCHMARKS_DIR}
12+
cp -r results ${BENCHMARKS_DIR}/results
13+
popd
1414
}
1515

1616
load_test_with_profile() {
1717
echo "Running load tests with CPU Profiling enabled..."
18-
mkdir -p ${BENCHMARKS_DIR}
19-
go test -v -timeout 1m ./test/load/... \
20-
-cpuprofile ${BENCHMARKS_DIR}/metrics_cpu.pprof \
21-
| tee ${BENCHMARKS_DIR}/benchmarks.json || { echo "Load tests failed, exiting..."; exit 1; }
22-
cp ${BENCHMARKS_DIR}/metrics_load_cpu.pprof ${BENCHMARKS_DIR}/profile.pgo
23-
find ${BENCHMARKS_DIR}
24-
}
18+
pushd test/load
19+
go test -v -timeout 1m ./... \
20+
-cpuprofile ${BENCHMARKS_DIR}/metrics_load_cpu.pprof
21+
22+
cp benchmarks.json ${BENCHMARKS_DIR}/benchmarks.json
23+
cp -r results ${BENCHMARKS_DIR}/results
2524

26-
copy_agent_files() {
27-
echo "Copying agent files..."
28-
cp /agent/test/load/results/TestMetric10kDPS/OTLP-linux-build/nginx-agent/agent.log ${BENCHMARKS_DIR}/agent.log \
29-
|| echo "No agent.log file found"
30-
cp /agent/test/load/results/TestMetric10kDPS/OTLP-linux-build/nginx-agent/opentelemetry-collector-agent.log ${BENCHMARKS_DIR}/otel.log \
31-
|| echo "No opentelemetry-collector-agent.log file found"
25+
popd
3226
}
3327

3428
## Main script execution starts here
35-
36-
mkdir -p $DESTINATION
29+
mkdir -p ${BENCHMARKS_DIR}
3730

3831
echo "Running in $(pwd)"
3932
# Run load tests
4033
# $PROFILE - if true, run with CPU profiling enabled
4134
if [[ "$PROFILE" == "true" ]]; then
4235
echo "CPU Profiling is enabled."
43-
load_test_with_profile
36+
load_test_with_profile || { echo "Load tests with profiling failed"; exit 1; }
4437
else
45-
load_test
38+
load_test || { echo "Load tests failed"; exit 1; }
4639
fi
4740

48-
copy_agent_files
41+
echo "Listing contents of ${BENCHMARKS_DIR}:"
42+
ls -la ${BENCHMARKS_DIR}
43+
4944
echo "Done."

test/load/otel_collector_plugin_load_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ func TestMetric10kDPS(t *testing.T) {
4242
name: name + "-none",
4343
compression: "none",
4444
},
45-
{
46-
name: name + "-gzip",
47-
compression: "gzip",
48-
},
4945
}
5046

5147
for _, test := range tests {
@@ -98,6 +94,7 @@ func TestMetric10kDPS(t *testing.T) {
9894
tc.ValidateData()
9995
})
10096

97+
// Save intermediate results after each test case
10198
testbed.SaveResults(performanceResultsSummary)
10299
}
103100
}

0 commit comments

Comments
 (0)