dotnet / dotnet/BenchmarkDotNet

Running in Kubernetes

Open
#1,928 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
11.5k
Forks
1.1k
Avg merge
4d 11h
Merged PRs (30d)
11

Description

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(); `

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.