Skip to content

Commit

Permalink
renaming some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysGonchar committed Nov 24, 2023
1 parent 698002a commit 197a24e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions integration_test/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function compile_file() {
erlc -o "$output_dir" "$erl_file"
}

function contains() {
function contains_all() {
local output="$(cat -)"
local ret= acc=0
for pattern in "$@"; do
Expand All @@ -30,7 +30,7 @@ function contains() {
test "$(($acc))" -eq 0
}

function doesnt_contain() {
function doesnt_contain_any() {
local output="$(cat -)"
local ret= acc=0
for pattern in "$@"; do
Expand Down
6 changes: 3 additions & 3 deletions integration_test/test_add_new_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ enable_strict_mode

docker_compose up --wait --wait-timeout 100 amoc-worker-3

amoc_eval amoc-worker-3 "amoc_controller:get_status()." | contains dummy_scenario running
amoc_eval amoc-worker-3 "binary_to_list(amoc_config:get(test))." | contains "test_value"
amoc_eval amoc-worker-3 "dummy_helper:test_amoc_dist()." | contains 'amoc_dist_works_as_expected'
amoc_eval amoc-worker-3 "amoc_controller:get_status()." | contains_all dummy_scenario running
amoc_eval amoc-worker-3 "binary_to_list(amoc_config:get(test))." | contains_all "test_value"
amoc_eval amoc-worker-3 "dummy_helper:test_amoc_dist()." | contains_all 'amoc_dist_works_as_expected'
echo "amoc_dist_works_as_expected"
18 changes: 9 additions & 9 deletions integration_test/test_amoc_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ source "$(dirname "$0")/helper.sh"
enable_strict_mode

echo "checking that clustering is done properly"
amoc_eval amoc-master "nodes()." | contains amoc-worker-1 amoc-worker-2
amoc_eval amoc-worker-1 "nodes()." | contains amoc-master amoc-worker-2
amoc_eval amoc-worker-2 "nodes()." | contains amoc-master amoc-worker-1
amoc_eval amoc-master "nodes()." | contains_all amoc-worker-1 amoc-worker-2
amoc_eval amoc-worker-1 "nodes()." | contains_all amoc-master amoc-worker-2
amoc_eval amoc-worker-2 "nodes()." | contains_all amoc-master amoc-worker-1

echo "checking that setting AMOC_EXTRA_CODE_PATHS env works as expected"
amoc_eval amoc-master "amoc_code_server:list_scenario_modules()." | contains dummy_scenario
amoc_eval amoc-master "amoc_code_server:list_configurable_modules()." | contains dummy_helper
amoc_eval amoc-worker-1 "amoc_code_server:list_scenario_modules()." | doesnt_contain dummy_scenario
amoc_eval amoc-worker-1 "amoc_code_server:list_configurable_modules()." | doesnt_contain dummy_helper
amoc_eval amoc-worker-2 "amoc_code_server:list_scenario_modules()." | doesnt_contain dummy_scenario
amoc_eval amoc-worker-2 "amoc_code_server:list_configurable_modules()." | doesnt_contain dummy_helper
amoc_eval amoc-master "amoc_code_server:list_scenario_modules()." | contains_all dummy_scenario
amoc_eval amoc-master "amoc_code_server:list_configurable_modules()." | contains_all dummy_helper
amoc_eval amoc-worker-1 "amoc_code_server:list_scenario_modules()." | doesnt_contain_any dummy_scenario
amoc_eval amoc-worker-1 "amoc_code_server:list_configurable_modules()." | doesnt_contain_any dummy_helper
amoc_eval amoc-worker-2 "amoc_code_server:list_scenario_modules()." | doesnt_contain_any dummy_scenario
amoc_eval amoc-worker-2 "amoc_code_server:list_configurable_modules()." | doesnt_contain_any dummy_helper
20 changes: 10 additions & 10 deletions integration_test/test_distribute_scenario.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ function distribute_modules() {
amoc_eval "${1}" "amoc_code_server:distribute_modules('amoc@${2}')."
}

ensure_modules_loaded amoc-master "${modules[@]}" | contains "${modules[@]}"
ensure_modules_loaded amoc-worker-1 "${modules[@]}" | doesnt_contain "${modules[@]}"
ensure_modules_loaded amoc-worker-2 "${modules[@]}" | doesnt_contain "${modules[@]}"
ensure_modules_loaded amoc-master "${modules[@]}" | contains_all "${modules[@]}"
ensure_modules_loaded amoc-worker-1 "${modules[@]}" | doesnt_contain_any "${modules[@]}"
ensure_modules_loaded amoc-worker-2 "${modules[@]}" | doesnt_contain_any "${modules[@]}"

list_scenarios_and_helpers amoc-worker-2 | doesnt_contain "${modules[@]}"
list_scenarios_and_helpers amoc-worker-1 | doesnt_contain "${modules[@]}"
list_scenarios_and_helpers amoc-worker-2 | doesnt_contain_any "${modules[@]}"
list_scenarios_and_helpers amoc-worker-1 | doesnt_contain_any "${modules[@]}"

echo "Distributing scenario and helper module from the amoc-master node"
## amoc_controller is added to the list as an example of module
## that already exists on all the slave amoc nodes
add_module amoc-master "${modules[@]}" amoc_controller
distribute_modules amoc-master amoc-worker-1 | contains "${modules[@]}" amoc_controller
distribute_modules amoc-master amoc-worker-1 | contains_all "${modules[@]}" amoc_controller

ensure_modules_loaded amoc-worker-1 "${modules[@]}" | contains "${modules[@]}"
ensure_modules_loaded amoc-worker-2 "${modules[@]}" | doesnt_contain "${modules[@]}"
ensure_modules_loaded amoc-worker-1 "${modules[@]}" | contains_all "${modules[@]}"
ensure_modules_loaded amoc-worker-2 "${modules[@]}" | doesnt_contain_any "${modules[@]}"

list_scenarios_and_helpers amoc-worker-1 | contains "${modules[@]}"
list_scenarios_and_helpers amoc-worker-2 | doesnt_contain "${modules[@]}"
list_scenarios_and_helpers amoc-worker-1 | contains_all "${modules[@]}"
list_scenarios_and_helpers amoc-worker-2 | doesnt_contain_any "${modules[@]}"
2 changes: 1 addition & 1 deletion integration_test/test_run_scenario.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ result="$(run_scenario amoc-master dummy_scenario 10)"

echo "$result"

if echo "$result" | contains "ok" "'amoc@amoc-worker-1'" "'amoc@amoc-worker-2'" ; then
if echo "$result" | contains_all "ok" "'amoc@amoc-worker-1'" "'amoc@amoc-worker-2'" ; then
echo "Scenario executed"
exit 0
else
Expand Down

0 comments on commit 197a24e

Please sign in to comment.