Skip to content

Commit 46f5dc9

Browse files
authored
Merge pull request #3 from ponchotitlan/NSO-00001
Updated pipeline for real test escaping based on status
2 parents 30b1c87 + ff8a934 commit 46f5dc9

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ prepare-test-network:
1717

1818
run-tests:
1919
@pipeline/scripts/install-testing-libraries.sh nso_node
20-
@pipeline/scripts/run-robot-tests.sh nso_node
20+
status=$$(pipeline/scripts/run-robot-tests.sh nso_node); \
21+
if [ "$$status" = "failed" ]; then \
22+
echo "🤖❌ At least one test failed!"; \
23+
exit 1; \
24+
else \
25+
echo "🤖✅ All tests were successful!"; \
26+
fi
2127

2228
create-artifact-packages:
2329
@pipeline/scripts/create-artifact-packages.sh nso_node

pipeline/scripts/run-robot-tests.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@ run_robot_test(){
1212
local container_name="$1"
1313
local service_name="$2"
1414

15-
docker exec -i $container_name bash -lc "cd /nso/run/packages/$service_name/tests && robot $service_name.robot"
15+
local TOKEN_SUCCESS="0 failed"
16+
local output=$(docker exec -i $container_name bash -lc "cd /nso/run/packages/$service_name/tests && robot $service_name.robot")
17+
18+
if echo "$output" | grep -q "$TOKEN_SUCCESS"; then
19+
# This test passed!
20+
echo 1
21+
else
22+
# This test didn't pass!
23+
echo 0
24+
fi
1625
}
1726

1827
YAML_FILE_CONFIG="pipeline/setup/config.yaml"
@@ -25,8 +34,6 @@ if [ -z "$1" ]; then
2534
exit 1
2635
fi
2736

28-
echo "##### [🤖] Executing Robot tests of each service.... #####"
29-
3037
# Extract the name of the container and remove quotes
3138
CONTAINER_NAME_PATH=".services.$1.container_name"
3239
container_name=$(yq "$CONTAINER_NAME_PATH" "$YAML_FILE_DOCKER")
@@ -39,6 +46,7 @@ ned_packages=$(yq "$NEDS_PATH" "$YAML_FILE_CONFIG")
3946
all_packages=($(ls -d "$PACKAGES_DIR"/*/ | xargs -n 1 basename))
4047

4148
# Iterate over each folder and check if it's in the excluded list
49+
all_tests_passed=1
4250
for package in "${all_packages[@]}"; do
4351

4452
is_ned=0
@@ -51,8 +59,19 @@ for package in "${all_packages[@]}"; do
5159
done
5260

5361
if [[ $is_ned == 0 ]]; then
54-
run_robot_test $container_name $package
62+
this_test_pass=$(run_robot_test $container_name $package)
63+
64+
# If at least one test didn't pass. This job is declared a failure
65+
if [[ $this_test_pass == 0 ]]; then
66+
all_tests_passed=0
67+
fi
5568
fi
5669
done
5770

58-
echo "[🤖] Robot test cases done!"
71+
if [[ $all_tests_passed == 0 ]]; then
72+
# The job failed
73+
echo "failed"
74+
else
75+
# The job is successful
76+
echo "pass"
77+
fi

0 commit comments

Comments
 (0)