Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add module benchmark #71

Merged
merged 7 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions hack/benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Benchmark
The 'benchmark.sh' script creates secrets that can be used for benchmarking Infrastructure Manager.

## Usage

In order to use it, call `./hack/benchmark/benchmark.sh {number_of_secrets_to_generate) {path_to_secret_template)`

The script generates the `/tmp/input_{currentdateandtime}.json` input file containing a list of runtimeIDs of the generated secrets:
``` json
[
"AB65AB53-7B0A-481C-A472-349B4947D50D",
"C212033F-A5F8-416F-BF9C-E735A37D4B0E",
"2FFAEDD5-EE90-40F4-955D-DA5493F98263",
"C4E7015A-A79A-457D-A5BC-782D8E614568",
"70607990-5581-445F-A4D1-2AC9C845DB19",
"B9900F40-3A28-4025-A653-353FC91CC603",
"BCE7D3F5-8221-48E5-B634-3FB8EC4F2BA8",
"32054BD1-5AEA-481A-A9A5-1D8CF7CDF4AD",
"AEF09754-E727-4C12-B147-806481D529E5",
"F107C364-5144-4F58-ACD0-2111CADF128B"
]
```

The example usage that generates 10 secrets and applies them using kubectl `./hack/benchmark/benchmark.sh 10 ./hack/benchmark/secret.template.json | kubectl apply -f -`
16 changes: 16 additions & 0 deletions hack/benchmark/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

_count=$1
_secret_template_path=$2

function generate_data {
jq -nR --arg _count $_count '[range(0;($_count|tonumber)) | input]' < <(while true; do uuidgen | awk '{print tolower($0)}' ; done)
}

function create_secrets {
cat /dev/stdin | jq -r --argjson t "$(<$_secret_template_path)" '.[] as $id | $t | .metadata.name=$id | .metadata.labels["kyma-project.io/runtime-id"]=$id'
}

datetime_postfix=$(date -u +%Y-%m-%dT%H:%M:%S)
input_filename="/tmp/input_"$datetime_postfix".json"
generate_data $1 $2 | tee $input_filename | create_secrets
16 changes: 16 additions & 0 deletions hack/benchmark/secret.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"apiVersion": "v1",
"data": {
"config": "dGhpcyBpcyBmb3IgdGVzdHMgb25seQ=="
},
"kind": "Secret",
"metadata": {
"labels": {
"kyma-project.io/runtime-id": "01a5af79-b073-48a1-906d-26c15933b12a",
"kyma-project.io/shoot-name": "benchmark-invalid"
},
"name": "kubeconfig-01a5af79-b073-48a1-906d-26c15933b12a",
"namespace": "kcp-system"
},
"type": "Opaque"
}
Loading