diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0690133d..f2796d9f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -43,3 +43,4 @@ jobs: - name: "Run Tests" run: | make test-integration + make test-memory-benchmark diff --git a/Makefile b/Makefile index 49a6506b..34db3d3c 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,11 @@ test-integration: ## Run integration tests @echo "# running integration tests" VPP_REPO=$(VPP_REPO) ./test/run_integration.sh +.PHONY: test-memory-benchmark +test-memory-benchmark: ## Run memory benchmark tests + @echo "# running memory benchmark tests" + VPP_REPO=$(VPP_REPO) ./test/run_memory_benchmark.sh + .PHONY: lint ## Run code linter lint: @golangci-lint run diff --git a/test/memory/memory_api_test.go b/test/memory/memory_api_test.go index 3dafb152..9db9ea38 100644 --- a/test/memory/memory_api_test.go +++ b/test/memory/memory_api_test.go @@ -155,7 +155,8 @@ func BenchmarkAPIMemory(b *testing.B) { } } if !pass { - b.Fatal("one or more memory thresholds was exceeded") + b.Errorf("one or more memory thresholds was exceeded") + b.FailNow() } } diff --git a/test/run_memory_benchmark.sh b/test/run_memory_benchmark.sh new file mode 100755 index 00000000..ec66de1e --- /dev/null +++ b/test/run_memory_benchmark.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# // Copyright (c) 2025 Cisco and/or its affiliates. +# // +# // Licensed under the Apache License, Version 2.0 (the "License"); +# // you may not use this file except in compliance with the License. +# // You may obtain a copy of the License at: +# // +# // http://www.apache.org/licenses/LICENSE-2.0 +# // +# // Unless required by applicable law or agreed to in writing, software +# // distributed under the License is distributed on an "AS IS" BASIS, +# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# // See the License for the specific language governing permissions and +# // limitations under the License. + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )" +VPP_REPO=${VPP_REPO:-release} +IMGTAG="govpp-integration" + +# Build Docker image +docker build -t "$IMGTAG" -f "$SCRIPT_DIR/build/Dockerfile.integration" --build-arg VPP_REPO="$VPP_REPO" "$SCRIPT_DIR/build" + +# Get VPP version +VPP_VERSION=$(docker run --rm -i "$IMGTAG" dpkg-query -f '${Version}' -W vpp) + +# Display test information +echo "==========================================================================" +echo " GOVPP MEMORY BENCHMARK TEST - $(date) " +echo "==========================================================================" +echo "- VPP_REPO: $VPP_REPO" +echo "- VPP version: $VPP_VERSION" +echo "--------------------------------------------------------------------------" + +# Run benchmark tests +if docker run -i --privileged -v "$(cd "$SCRIPT_DIR/.." && pwd)":/src -w /src/test/memory "$IMGTAG" go test -bench=.; then + echo -e "\e[32mPASSED\e[0m (took: ${SECONDS}s)" + exit 0 +else + echo -e "\e[31mFAILED!\e[0m (exit code: $?)" + exit $? +fi