BenchmarkDotNet
BenchmarkDotNet copied to clipboard
Running in Kubernetes
I want to run my benchmarkdotnetnet app in Kubernetes (as I want to test in real prod env). I've used K8s Job resource for this. My Job mainifest file is as below
apiVersion: batch/v1
kind: Job
metadata:
name: redis-benchmarks
spec:
#completions: 4 # require 4 Pods to complete for a succesful job
#parallelism: 2 # allow up to 2 Pods to run in parallel
activeDeadlineSeconds: 240 # how long can the job be active before it's terminated?
template:
metadata:
name: redis-benchmarks
spec:
restartPolicy: Never # OnFailure or Never
containers:
- name: redis-benchmarks
image: goldytech/redisbenchmarks:1.0
imagePullPolicy: IfNotPresent
command: ["dotnet"]
args: ["PerformanceTests.dll", "----filter PerformanceTests.RedisBenchmark.RunTest"]
env:
- name: REDIS_CONNECTION
value: 10.97.225.36:6379,allowAdmin=true,abortConnect=False,syncTimeout=15000
Now when the Pod starts I get this error ERROR(S): Option '--filter PerformanceTests.RedisBenchmark.RunTest' is unknown.
I can run the tests directly with dotnet PerformanceTests.dll --filter PerformanceTests.RedisBenchmark.RunTest
My docker file is as
FROM mcr.microsoft.com/dotnet/sdk:6.0
WORKDIR /src
COPY ["PerformanceTests/PerformanceTests.csproj", "PerformanceTests/"]
RUN dotnet restore "PerformanceTests/PerformanceTests.csproj"
COPY . .
RUN dotnet build "PerformanceTests/PerformanceTests.csproj" -c Release -o /src/bin
RUN dotnet publish "PerformanceTests/PerformanceTests.csproj" -c Release -o /src/bin/publish
WORKDIR /src/bin/publish
ENTRYPOINT ["dotnet", "PerformanceTests.dll"]
I can run the test directly on docker too with this command
docker run --privileged -it goldytech/redisbenchmarks:1.0 --filter PerformanceTests.RedisBenchmark.RunTest
Also i wanted to know how can I log Summary
object from the var summary = BenchmarkRunner.Run<RedisBenchmark>();