From e34192ab3b848381edb1f794583a1bb01a3299b8 Mon Sep 17 00:00:00 2001 From: MK Software Date: Mon, 2 Sep 2024 11:23:09 +0200 Subject: [PATCH] wip --- README.md | 23 ++++++++++ .../data/keep-sending.sh | 44 ++++++++++--------- .../run-mocks-setup-data.sh | 2 +- scenario-examples-bootstrapper/utils/lib.sh | 12 ++++- 4 files changed, 58 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 546fe5b..380613c 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,27 @@ In the docker compose case (see the example above) to achieve it, you should: 1. create a shared configuration volume and mount it in `nu-example-scenarios-library` and `designer` services 2. include `/opt/nussknacker/conf/additional-configuration.conf` in the `CONFIG_FILE` ENV value +### Other configuration + +#### Using Scenario Examples Bootstrapper with scenario defined outside + +You don't have to put your scenario is the Library to be able to use it with the Scenario Examples Bootstapper. All you need to do is to mount +your example from e.g. `my-scenario` folder to `/scenario-examples/my-scenario` in the container. Your scenario will be read and bootstrapped. + +#### Disabling specific example scenarios + +You can disable a specific example by setting e.g. `LOAN_REQUEST_DISABLED: true` - this ENV disables `loan-request` scenario example. +So, all you need to do is to take name of your example (the example's folder name), change `-` to `_`, uppercase it and add `_DISABLED` - +it gives you the name of the ENV. Don't forget to set `true` as its value. + +#### Disabling all (embedded) example scenarios + +You can disable all examples embedded into library by setting `DISABLE_EMBEDDED_EXAMPLES: true`. + +#### Disabling data generation for all scenarios + +You can disable only data generation for all the examples from the library by setting `DISABLE_DATA_GENERATION: true` + ## What's underneath and how it works ### Scenario Examples Library @@ -261,7 +282,9 @@ See the `scenario-examples-library/offer-customer-proposal-based-on-activity-eve Check out the following resources to see how to create Wiremock mappings: https://github.com/wiremock/wiremock-faker-extension/blob/main/docs/reference.md + https://docs.wiremock.io/response-templating/basics/ + https://docs.wiremock.io/response-templating/dates-and-times/ ### Example data for scenario showcase diff --git a/scenario-examples-bootstrapper/data/keep-sending.sh b/scenario-examples-bootstrapper/data/keep-sending.sh index 13383c5..2293b4e 100755 --- a/scenario-examples-bootstrapper/data/keep-sending.sh +++ b/scenario-examples-bootstrapper/data/keep-sending.sh @@ -4,23 +4,27 @@ cd "$(dirname "$0")" source ../utils/lib.sh -magenta_echo "-------- DATA GENERATION ACTIVATION STAGE is starting... ------\n" - -shopt -s nullglob - -for FOLDER in /scenario-examples/*; do - if is_scenario_enabled "$FOLDER"; then - echo -e "Starting to send static and generated data for scenario from ${GREEN}$FOLDER${RESET} directory...\n\n" - - ./http/send-http-static-requests.sh "$FOLDER" - ./kafka/send-kafka-static-messages.sh "$FOLDER" - ./http/continuously-send-http-generated-requests.sh "$FOLDER" - ./kafka/continuously-send-kafka-generated-messages.sh "$FOLDER" - - echo -e "Static data sent and generators from ${GREEN}$FOLDER${RESET} directory are runnning!\n\n" - else - echo -e "Skipping sending static and generated data for scenario from ${GREEN}$FOLDER${RESET} directory.\n" - fi -done - -magenta_echo "-------- DATA GENERATION ACTIVATION STAGE is finished! --------\n\n" \ No newline at end of file +if is_data_generation_active; then + magenta_echo "-------- DATA GENERATION ACTIVATION STAGE is starting... ------\n" + + shopt -s nullglob + + for FOLDER in /scenario-examples/*; do + if is_scenario_enabled "$FOLDER"; then + echo -e "Starting to send static and generated data for scenario from ${GREEN}$FOLDER${RESET} directory...\n\n" + + ./http/send-http-static-requests.sh "$FOLDER" + ./kafka/send-kafka-static-messages.sh "$FOLDER" + ./http/continuously-send-http-generated-requests.sh "$FOLDER" + ./kafka/continuously-send-kafka-generated-messages.sh "$FOLDER" + + echo -e "Static data sent and generators from ${GREEN}$FOLDER${RESET} directory are runnning!\n\n" + else + echo -e "Skipping sending static and generated data for scenario from ${GREEN}$FOLDER${RESET} directory.\n" + fi + done + + magenta_echo "-------- DATA GENERATION ACTIVATION STAGE is finished! --------\n\n" +else + magenta_echo "-------- DATA GENERATION IS DISABLED! ------\n" +fi diff --git a/scenario-examples-bootstrapper/run-mocks-setup-data.sh b/scenario-examples-bootstrapper/run-mocks-setup-data.sh index 27e7a59..0917375 100755 --- a/scenario-examples-bootstrapper/run-mocks-setup-data.sh +++ b/scenario-examples-bootstrapper/run-mocks-setup-data.sh @@ -9,7 +9,7 @@ rm -rf /app/healthy if /app/mocks/db/is-postgres-ready.sh && /app/mocks/http-service/is-wiremock-ready.sh; then green_echo "------ Nu scenarios library is being prepared... ---------\n" - if is_embedded_examples_active; then + if are_embedded_examples_active; then mkdir -p /scenario-examples mv /tmp/scenario-examples/* /scenario-examples/ fi diff --git a/scenario-examples-bootstrapper/utils/lib.sh b/scenario-examples-bootstrapper/utils/lib.sh index 6065819..b067e61 100755 --- a/scenario-examples-bootstrapper/utils/lib.sh +++ b/scenario-examples-bootstrapper/utils/lib.sh @@ -98,8 +98,16 @@ function is_scenario_enabled() { return 0 } -function is_embedded_examples_active() { - if [[ "${DISABLE_EMBDEDED_EXAMPLES,,}" == "true" ]]; then +function are_embedded_examples_active() { + if [[ "${DISABLE_EMBEDDED_EXAMPLES,,}" == "true" ]]; then + return 1 + else + return 0 + fi +} + +function is_data_generation_active() { + if [[ "${DISABLE_DATA_GENERATION,,}" == "true" ]]; then return 1 else return 0