From 9f85f0f6756a6aad4c22f8893e47372eb76c57be Mon Sep 17 00:00:00 2001 From: Are Almaas Date: Tue, 14 Jan 2025 15:53:48 +0100 Subject: [PATCH 1/8] test: exclude threhold tests from all tests --- .github/workflows/ci-cd-yt01.yml | 6 +++--- tests/k6/tests/enduser/all-tests.js | 2 -- .../{ => performance}/enduserSearchWithThresholds.js | 2 +- tests/k6/tests/serviceowner/all-tests.js | 4 ---- .../{ => performance}/createDialogWithThresholds.js | 2 +- .../{ => performance}/serviceOwnerSearchWithThresholds.js | 2 +- 6 files changed, 6 insertions(+), 12 deletions(-) rename tests/k6/tests/enduser/{ => performance}/enduserSearchWithThresholds.js (94%) rename tests/k6/tests/serviceowner/{ => performance}/createDialogWithThresholds.js (81%) rename tests/k6/tests/serviceowner/{ => performance}/serviceOwnerSearchWithThresholds.js (93%) diff --git a/.github/workflows/ci-cd-yt01.yml b/.github/workflows/ci-cd-yt01.yml index d7830ff9c..e842607fb 100644 --- a/.github/workflows/ci-cd-yt01.yml +++ b/.github/workflows/ci-cd-yt01.yml @@ -138,9 +138,9 @@ jobs: max-parallel: 1 matrix: files: - - tests/k6/tests/serviceowner/serviceOwnerSearchWithThresholds.js - - tests/k6/tests/serviceowner/createDialogWithThresholds.js - - tests/k6/tests/enduser/enduserSearchWithThresholds.js + - tests/k6/tests/serviceowner/performance/serviceOwnerSearchWithThresholds.js + - tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js + - tests/k6/tests/enduser/performance/enduserSearchWithThresholds.js fail-fast: false with: environment: yt01 diff --git a/tests/k6/tests/enduser/all-tests.js b/tests/k6/tests/enduser/all-tests.js index 4f547ec72..308bd1f4e 100644 --- a/tests/k6/tests/enduser/all-tests.js +++ b/tests/k6/tests/enduser/all-tests.js @@ -2,13 +2,11 @@ import { default as dialogDetails } from './dialogDetails.js'; import { default as dialogSearch } from './dialogSearch.js'; import { default as dialogSystemLabelLog } from './dialogSystemLabelLog.js'; -import { default as enduserSearchWithThresholds } from './enduserSearchWithThresholds.js'; import { default as parties } from './parties.js'; export default function() { dialogDetails(); dialogSearch(); dialogSystemLabelLog(); - enduserSearchWithThresholds(); parties(); } diff --git a/tests/k6/tests/enduser/enduserSearchWithThresholds.js b/tests/k6/tests/enduser/performance/enduserSearchWithThresholds.js similarity index 94% rename from tests/k6/tests/enduser/enduserSearchWithThresholds.js rename to tests/k6/tests/enduser/performance/enduserSearchWithThresholds.js index 8855cb07a..21164ab23 100644 --- a/tests/k6/tests/enduser/enduserSearchWithThresholds.js +++ b/tests/k6/tests/enduser/performance/enduserSearchWithThresholds.js @@ -1,4 +1,4 @@ -import { default as run } from "./performance/enduser-search.js"; +import { default as run } from "./enduser-search.js"; export let options = { summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'p(99.5)', 'p(99.9)', 'count'], diff --git a/tests/k6/tests/serviceowner/all-tests.js b/tests/k6/tests/serviceowner/all-tests.js index cef589b38..0f052a4f4 100644 --- a/tests/k6/tests/serviceowner/all-tests.js +++ b/tests/k6/tests/serviceowner/all-tests.js @@ -2,7 +2,6 @@ import { default as authentication } from './authentication.js'; import { default as authorization } from './authorization.js'; import { default as concurrency } from './concurrency.js'; -import { default as createDialogWithThresholds } from './createDialogWithThresholds.js'; import { default as dialogCreateActivity } from './dialogCreateActivity.js'; import { default as dialogCreateExternalResource } from './dialogCreateExternalResource.js'; import { default as dialogCreateInvalidActionCount } from './dialogCreateInvalidActionCount.js'; @@ -12,13 +11,11 @@ import { default as dialogCreateUpdatePatchDeleteCorrespondenceResource } from ' import { default as dialogDetails } from './dialogDetails.js'; import { default as dialogSearch } from './dialogSearch.js'; import { default as dialogUpdateActivity } from './dialogUpdateActivity.js'; -import { default as serviceOwnerSearchWithThresholds } from './serviceOwnerSearchWithThresholds.js'; export default function() { authentication(); authorization(); concurrency(); - createDialogWithThresholds(); dialogCreateActivity(); dialogCreateExternalResource(); dialogCreateInvalidActionCount(); @@ -28,5 +25,4 @@ export default function() { dialogDetails(); dialogSearch(); dialogUpdateActivity(); - serviceOwnerSearchWithThresholds(); } diff --git a/tests/k6/tests/serviceowner/createDialogWithThresholds.js b/tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js similarity index 81% rename from tests/k6/tests/serviceowner/createDialogWithThresholds.js rename to tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js index 56b473244..cb3d6f9ae 100644 --- a/tests/k6/tests/serviceowner/createDialogWithThresholds.js +++ b/tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js @@ -1,4 +1,4 @@ -import { default as run } from "./performance/create-dialog.js"; +import { default as run } from "./create-dialog.js"; export let options = { summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'p(99.5)', 'p(99.9)', 'count'], diff --git a/tests/k6/tests/serviceowner/serviceOwnerSearchWithThresholds.js b/tests/k6/tests/serviceowner/performance/serviceOwnerSearchWithThresholds.js similarity index 93% rename from tests/k6/tests/serviceowner/serviceOwnerSearchWithThresholds.js rename to tests/k6/tests/serviceowner/performance/serviceOwnerSearchWithThresholds.js index ed0fac469..84b71107e 100644 --- a/tests/k6/tests/serviceowner/serviceOwnerSearchWithThresholds.js +++ b/tests/k6/tests/serviceowner/performance/serviceOwnerSearchWithThresholds.js @@ -1,4 +1,4 @@ -import { default as run } from "./performance/serviceowner-search.js"; +import { default as run } from "./serviceowner-search.js"; export let options = { summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'p(99.5)', 'p(99.9)', 'count'], From 50b52cbf169ae068f36a8d72fb40682fd287d6ce Mon Sep 17 00:00:00 2001 From: Are Almaas Date: Tue, 14 Jan 2025 15:59:15 +0100 Subject: [PATCH 2/8] test: exclude threhold tests from all tests --- tests/k6/tests/performancetest_data/endusers-localdev.csv | 2 -- tests/k6/tests/performancetest_data/serviceowners-localdev.csv | 3 --- 2 files changed, 5 deletions(-) delete mode 100644 tests/k6/tests/performancetest_data/endusers-localdev.csv delete mode 100644 tests/k6/tests/performancetest_data/serviceowners-localdev.csv diff --git a/tests/k6/tests/performancetest_data/endusers-localdev.csv b/tests/k6/tests/performancetest_data/endusers-localdev.csv deleted file mode 100644 index caf69fb96..000000000 --- a/tests/k6/tests/performancetest_data/endusers-localdev.csv +++ /dev/null @@ -1,2 +0,0 @@ -ssn,resource,scopes -08895699684,super-simple-service,digdir:dialogporten \ No newline at end of file diff --git a/tests/k6/tests/performancetest_data/serviceowners-localdev.csv b/tests/k6/tests/performancetest_data/serviceowners-localdev.csv deleted file mode 100644 index 94c5ee022..000000000 --- a/tests/k6/tests/performancetest_data/serviceowners-localdev.csv +++ /dev/null @@ -1,3 +0,0 @@ -org,orgno,scopes,resource -digdir,991825827,digdir:dialogporten.serviceprovider digdir:dialogporten.serviceprovider.search,super-simple-service -nav,889640782,digdir:dialogporten.serviceprovider digdir:dialogporten.serviceprovider.search digdir:dialogporten.serviceprovider.legacyhtml altinn:system/notifications.condition.check digdir:dialogporten.correspondence From 31e5f27bb47c47d3ea57db40691e343233d7948d Mon Sep 17 00:00:00 2001 From: Amund Myrbostad Date: Tue, 14 Jan 2025 16:27:19 +0100 Subject: [PATCH 3/8] removed performance from auto gen of all tests --- tests/k6/scripts/generate_all_tests.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/k6/scripts/generate_all_tests.sh b/tests/k6/scripts/generate_all_tests.sh index d4112995e..1b4af7533 100755 --- a/tests/k6/scripts/generate_all_tests.sh +++ b/tests/k6/scripts/generate_all_tests.sh @@ -15,14 +15,16 @@ FUNCTION_BODY="" # Get all *.js files in the directory except for "all-tests.js" for JS_FILE in "$DIRECTORY_PATH"/*.js; do - BASE_NAME=$(basename "$JS_FILE" .js) - - if [[ "$BASE_NAME" != "all-tests" ]]; then - # Append to import strings - IMPORT_STATEMENTS="${IMPORT_STATEMENTS}import { default as ${BASE_NAME} } from './${BASE_NAME}.js';"$'\n' - - # Append to function body - FUNCTION_BODY="${FUNCTION_BODY} ${BASE_NAME}();"$'\n' + if [[ $DIRECTORY_PATH != *"performance"* ]]; then + BASE_NAME=$(basename "$JS_FILE" .js) + + if [[ "$BASE_NAME" != "all-tests" ]]; then + # Append to import strings + IMPORT_STATEMENTS="${IMPORT_STATEMENTS}import { default as ${BASE_NAME} } from './${BASE_NAME}.js';"$'\n' + + # Append to function body + FUNCTION_BODY="${FUNCTION_BODY} ${BASE_NAME}();"$'\n' + fi fi done @@ -33,6 +35,6 @@ export default function() { ${FUNCTION_BODY}}" # Output the script content to "all-tests.js" -echo "$SCRIPT_CONTENT" > "${DIRECTORY_PATH}/all-tests.js" +echo "$SCRIPT_CONTENT" >"${DIRECTORY_PATH}/all-tests.js" echo "all-tests.js has been generated successfully." From 391ae4d9df091c078763eff4f64d3513f1009539 Mon Sep 17 00:00:00 2001 From: Amund Myrbostad Date: Tue, 14 Jan 2025 16:35:27 +0100 Subject: [PATCH 4/8] Improved wildcard --- tests/k6/scripts/generate_all_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/k6/scripts/generate_all_tests.sh b/tests/k6/scripts/generate_all_tests.sh index 1b4af7533..8721fb010 100755 --- a/tests/k6/scripts/generate_all_tests.sh +++ b/tests/k6/scripts/generate_all_tests.sh @@ -15,7 +15,7 @@ FUNCTION_BODY="" # Get all *.js files in the directory except for "all-tests.js" for JS_FILE in "$DIRECTORY_PATH"/*.js; do - if [[ $DIRECTORY_PATH != *"performance"* ]]; then + if [[ $DIRECTORY_PATH != *"/performance/"* ]]; then BASE_NAME=$(basename "$JS_FILE" .js) if [[ "$BASE_NAME" != "all-tests" ]]; then From 7b8dac94a786ebf9c77705d92fd0702ed952bd58 Mon Sep 17 00:00:00 2001 From: Amund Myrbostad Date: Tue, 14 Jan 2025 16:44:56 +0100 Subject: [PATCH 5/8] Updated powershell script --- tests/k6/scripts/generate_all_tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/k6/scripts/generate_all_tests.ps1 b/tests/k6/scripts/generate_all_tests.ps1 index ee1af14d4..6bfea6ede 100644 --- a/tests/k6/scripts/generate_all_tests.ps1 +++ b/tests/k6/scripts/generate_all_tests.ps1 @@ -10,7 +10,7 @@ if (-not (Test-Path $DirectoryPath -PathType Container)) { } # Get all *.js files in the directory except for "all-tests.js" -$jsFiles = Get-ChildItem -Path $DirectoryPath -Filter "*.js" | Where-Object { $_.Name -ne "all-tests.js" } +$jsFiles = Get-ChildItem -Path $DirectoryPath -Filter "*.js" | Where-Object { $_.Name -ne "all-tests.js" } | Where-Object { $_.Directory.FullName.Contains("/performance/") } # Create the import strings $importStatements = $jsFiles | ForEach-Object { From 799d0cfd30215a2c83b8910fede625a47f57e3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Tue, 14 Jan 2025 19:54:39 +0100 Subject: [PATCH 6/8] Remove indentations --- tests/k6/scripts/generate_all_tests.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/k6/scripts/generate_all_tests.sh b/tests/k6/scripts/generate_all_tests.sh index 8721fb010..774df0d3c 100755 --- a/tests/k6/scripts/generate_all_tests.sh +++ b/tests/k6/scripts/generate_all_tests.sh @@ -13,19 +13,20 @@ fi IMPORT_STATEMENTS="" FUNCTION_BODY="" -# Get all *.js files in the directory except for "all-tests.js" for JS_FILE in "$DIRECTORY_PATH"/*.js; do - if [[ $DIRECTORY_PATH != *"/performance/"* ]]; then - BASE_NAME=$(basename "$JS_FILE" .js) + # Skip files in the "performance" directory or the "all-tests.js" file + if [[ $DIRECTORY_PATH == *"/performance/"* ]] || + [[ $(basename "$JS_FILE" .js) == "all-tests" ]]; then + continue + fi - if [[ "$BASE_NAME" != "all-tests" ]]; then - # Append to import strings - IMPORT_STATEMENTS="${IMPORT_STATEMENTS}import { default as ${BASE_NAME} } from './${BASE_NAME}.js';"$'\n' + BASE_NAME=$(basename "$JS_FILE" .js) - # Append to function body - FUNCTION_BODY="${FUNCTION_BODY} ${BASE_NAME}();"$'\n' - fi - fi + # Append to import strings + IMPORT_STATEMENTS="${IMPORT_STATEMENTS}import { default as ${BASE_NAME} } from './${BASE_NAME}.js';"$'\n' + + # Append to function body + FUNCTION_BODY="${FUNCTION_BODY} ${BASE_NAME}();"$'\n' done # Combine all the content From 8d5239df52cfc6c93133f9bba4faf7ff35c50e96 Mon Sep 17 00:00:00 2001 From: Amund Myrbostad Date: Tue, 14 Jan 2025 20:16:33 +0100 Subject: [PATCH 7/8] Flipped condtion --- tests/k6/scripts/generate_all_tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/k6/scripts/generate_all_tests.ps1 b/tests/k6/scripts/generate_all_tests.ps1 index 6bfea6ede..365eb1190 100644 --- a/tests/k6/scripts/generate_all_tests.ps1 +++ b/tests/k6/scripts/generate_all_tests.ps1 @@ -10,7 +10,7 @@ if (-not (Test-Path $DirectoryPath -PathType Container)) { } # Get all *.js files in the directory except for "all-tests.js" -$jsFiles = Get-ChildItem -Path $DirectoryPath -Filter "*.js" | Where-Object { $_.Name -ne "all-tests.js" } | Where-Object { $_.Directory.FullName.Contains("/performance/") } +$jsFiles = Get-ChildItem -Path $DirectoryPath -Filter "*.js" | Where-Object { $_.Name -ne "all-tests.js" } | Where-Object { -not $_.Directory.FullName.Contains("/performance/") } # Create the import strings $importStatements = $jsFiles | ForEach-Object { From 77934e7975acc4fe0d7adcf93c20272a19461bfb Mon Sep 17 00:00:00 2001 From: Amund Myrbostad Date: Tue, 14 Jan 2025 20:38:16 +0100 Subject: [PATCH 8/8] now correct and more robust check --- tests/k6/scripts/generate_all_tests.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/k6/scripts/generate_all_tests.ps1 b/tests/k6/scripts/generate_all_tests.ps1 index 365eb1190..7bd2a43c8 100644 --- a/tests/k6/scripts/generate_all_tests.ps1 +++ b/tests/k6/scripts/generate_all_tests.ps1 @@ -10,7 +10,9 @@ if (-not (Test-Path $DirectoryPath -PathType Container)) { } # Get all *.js files in the directory except for "all-tests.js" -$jsFiles = Get-ChildItem -Path $DirectoryPath -Filter "*.js" | Where-Object { $_.Name -ne "all-tests.js" } | Where-Object { -not $_.Directory.FullName.Contains("/performance/") } +$jsFiles = Get-ChildItem -Path $DirectoryPath -Filter "*.js" | + Where-Object { $_.Name -ne "all-tests.js" } | + Where-Object { $_.Directory.FullName -notlike "$(Join-Path -ChildPath "$(Join-Path 'performance' '*')" -Path *)" } # OS agnostic "*/performance/*" # Create the import strings $importStatements = $jsFiles | ForEach-Object {