-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtest_tools.sh
More file actions
executable file
·66 lines (58 loc) · 2.5 KB
/
test_tools.sh
File metadata and controls
executable file
·66 lines (58 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Script to test out and time the various python shell scripts in this directory
echo "The whole command line: $@"
tool_to_test=$1
function exists_in_list() {
LIST=$1
DELIMITER=$2
VALUE=$3
LIST_WHITESPACES=$(echo $LIST | tr "$DELIMITER" " ")
for x in $LIST_WHITESPACES; do
if [ "$x" = "$VALUE" ]; then
return 0
fi
done
return 1
}
scripts_to_not_test="Inventory_Modules.py recovery_stack_ids.py lock_down_stack_sets_role.py ArgumentsClass.py \
account_class.py ALZ_CheckAccount.py CT_CheckAccount.py delete_bucket_objects.py enable_drift_detection.py \
find_my_LZ_versions.py move_stack_instances.py RunOnMultiAccounts.py UpdateRoleToMemberAccounts.py vpc_modules.py \
recover_stack_ids.py setup.py decorators.py read_stackset_results.py"
scripts_that_require_response="enable_drift_detection_stacksets.py"
declare -a arrScripts
#if [[ -n "$tool_to_test" && "$tool_to_test" = "all" ]]; then
# arrScripts=("$tool_to_test")
if [[ -n "$tool_to_test" && "$tool_to_test" != "all" ]]; then
shift
test_params=$@
echo "Running $tool_to_test with params: $test_params"
output_file="test_output_$tool_to_test.txt"
echo $(date) > "$output_file"
echo python "$tool_to_test" "$test_params" >> "$output_file"
# $(python "$tool_to_test" "$test_params" >> "$output_file" ; echo $? >> "$output_file" ; echo $(date) >> "$output_file" ) &
$(python "$tool_to_test" $test_params >> "$output_file" ; echo $? >> "$output_file" ; echo $(date) >> "$output_file" ) &
else
shift
test_params=$@
echo "Running $tool_to_test with params: $test_params"
for file in *.py
do
if exists_in_list "$scripts_to_not_test" " " "$file" ; then
echo "Not trying to run $file"
elif exists_in_list "$scripts_that_require_response" " " "$file"]; then
echo "Skipping because $file needs specific input"
else
echo "Will test run $file"
arrScripts=("${arrScripts[@]}" "$file")
fi
done
fi
summary_file="test_output_summary.$(date).txt"
for item in "${arrScripts[@]}"
do
echo "Running $item"
output_file="test_output_$item.txt"
echo $(date) > "$output_file"
$(echo "Script: $item Params: $test_params" >> $output_file ; python "$item" $test_params >> "$output_file" ; echo $? >> "$output_file" ; echo $(date) >> "$output_file" ) &
$(begin_date=$(date) ; echo -n $item $test_params >> "$summary_file"; echo -n " | " >> "$summary_file"; echo -n $begin_date >> "$summary_file"; echo -n " | " >> "$summary_file"; echo $(date) >> "$summary_file") &
done