From 726d7b26be85e08e8b258d00b17cbba3cc5bbf57 Mon Sep 17 00:00:00 2001 From: m00g3n Date: Wed, 22 Nov 2023 14:20:29 +0100 Subject: [PATCH 1/6] add module benchmark --- hack/benchmark/benchmark.sh | 14 ++++++++++++++ hack/benchmark/secret.template.json | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 hack/benchmark/benchmark.sh create mode 100644 hack/benchmark/secret.template.json diff --git a/hack/benchmark/benchmark.sh b/hack/benchmark/benchmark.sh new file mode 100755 index 00000000..b1cba926 --- /dev/null +++ b/hack/benchmark/benchmark.sh @@ -0,0 +1,14 @@ +#!/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 ; 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' +} + +generate_data $1 $2 | tee /tmp/input.json | create_secrets diff --git a/hack/benchmark/secret.template.json b/hack/benchmark/secret.template.json new file mode 100644 index 00000000..30fc60b8 --- /dev/null +++ b/hack/benchmark/secret.template.json @@ -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" +} From 73ba184a24f36fd905f934e6d4bb5eb6809307f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drzewiecki?= Date: Fri, 24 Nov 2023 15:53:56 +0100 Subject: [PATCH 2/6] input file name is based on date and time --- hack/benchmark/benchmark.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hack/benchmark/benchmark.sh b/hack/benchmark/benchmark.sh index b1cba926..ea84cbd6 100755 --- a/hack/benchmark/benchmark.sh +++ b/hack/benchmark/benchmark.sh @@ -11,4 +11,7 @@ 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' } -generate_data $1 $2 | tee /tmp/input.json | create_secrets +datetime_postfix=$(date -u +%Y-%m-%dT%H:%M:%S) +input_filename="/tmp/input_"$datetime_postfix".json" +echo $input_filename +generate_data $1 $2 | tee $input_filename | create_secrets From 5c0d0d0f4d6d1d5e05c01b778513f83648a2378f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drzewiecki?= Date: Mon, 27 Nov 2023 08:04:03 +0100 Subject: [PATCH 3/6] docs on how to use benchmark.sh --- hack/benchmark/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 hack/benchmark/README.md diff --git a/hack/benchmark/README.md b/hack/benchmark/README.md new file mode 100644 index 00000000..f89436a7 --- /dev/null +++ b/hack/benchmark/README.md @@ -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)` + +Example usage `./hack/benchmark/benchmark.sh 10 ./hack/benchmark/secret.template.json` + +Script generates `/tmp/input_{currentdateandtime}.json` input file containing list of runtimeIDs of 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" +] +``` From 622146f764d471d8256daac45676d56f07075a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drzewiecki?= Date: Mon, 27 Nov 2023 08:28:53 +0100 Subject: [PATCH 4/6] makes runtimeIds lowercase and removes not needed filename print --- hack/benchmark/benchmark.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hack/benchmark/benchmark.sh b/hack/benchmark/benchmark.sh index ea84cbd6..18be1a10 100755 --- a/hack/benchmark/benchmark.sh +++ b/hack/benchmark/benchmark.sh @@ -4,7 +4,7 @@ _count=$1 _secret_template_path=$2 function generate_data { - jq -nR --arg _count $_count '[range(0;($_count|tonumber)) | input]' < <(while true; do uuidgen ; done) + jq -nR --arg _count $_count '[range(0;($_count|tonumber)) | input]' < <(while true; do uuidgen | awk '{print tolower($0)}' ; done) } function create_secrets { @@ -13,5 +13,4 @@ function create_secrets { datetime_postfix=$(date -u +%Y-%m-%dT%H:%M:%S) input_filename="/tmp/input_"$datetime_postfix".json" -echo $input_filename generate_data $1 $2 | tee $input_filename | create_secrets From 6c0465be06a75100d534c9b096121d19f93d5244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drzewiecki?= Date: Mon, 27 Nov 2023 08:38:32 +0100 Subject: [PATCH 5/6] reorders doc and improves the example --- hack/benchmark/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hack/benchmark/README.md b/hack/benchmark/README.md index f89436a7..2b5acd2f 100644 --- a/hack/benchmark/README.md +++ b/hack/benchmark/README.md @@ -5,8 +5,6 @@ The 'benchmark.sh' script creates secrets that can be used for benchmarking infr In order to use it, call `./hack/benchmark/benchmark.sh {number_of_secrets_to_generate) {path_to_secret_template)` -Example usage `./hack/benchmark/benchmark.sh 10 ./hack/benchmark/secret.template.json` - Script generates `/tmp/input_{currentdateandtime}.json` input file containing list of runtimeIDs of generated secrets: ``` json [ @@ -22,3 +20,5 @@ Script generates `/tmp/input_{currentdateandtime}.json` input file containing li "F107C364-5144-4F58-ACD0-2111CADF128B" ] ``` + +Example usage that will generate 10 secrets and apply them using kubectl `./hack/benchmark/benchmark.sh 10 ./hack/benchmark/secret.template.json | kubectl apply -f -` From f21e89d62b96488db2b7ab7b7a92f0c45b399ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=27Disper=27=20Drzewiecki?= Date: Mon, 27 Nov 2023 10:20:17 +0100 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Grzegorz Karaluch --- hack/benchmark/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hack/benchmark/README.md b/hack/benchmark/README.md index 2b5acd2f..ba586f61 100644 --- a/hack/benchmark/README.md +++ b/hack/benchmark/README.md @@ -1,11 +1,11 @@ # Benchmark -The 'benchmark.sh' script creates secrets that can be used for benchmarking infrastructure manager. +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)` -Script generates `/tmp/input_{currentdateandtime}.json` input file containing list of runtimeIDs of generated secrets: +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", @@ -21,4 +21,4 @@ Script generates `/tmp/input_{currentdateandtime}.json` input file containing li ] ``` -Example usage that will generate 10 secrets and apply them using kubectl `./hack/benchmark/benchmark.sh 10 ./hack/benchmark/secret.template.json | kubectl apply -f -` +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 -`