Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-software-pl committed Sep 2, 2024
1 parent 0f87125 commit e34192a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 23 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
44 changes: 24 additions & 20 deletions scenario-examples-bootstrapper/data/keep-sending.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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
2 changes: 1 addition & 1 deletion scenario-examples-bootstrapper/run-mocks-setup-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions scenario-examples-bootstrapper/utils/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e34192a

Please sign in to comment.