Skip to content

Commit

Permalink
[agent] Introduced less naive default test #20
Browse files Browse the repository at this point in the history
Fixes #20
  • Loading branch information
nemesifier committed May 12, 2016
1 parent dc4d419 commit 6776271
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions openwisp-config/files/openwisp.agent
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,14 @@ test_configuration() {
apply_configuration $1

if [ -z "$TEST_SCRIPT" ]; then
get_checksum $TEST_CHECKSUM
local test_ret=$?
rm $TEST_CHECKSUM
perform_default_test
local test_result=$?
else
$TEST_SCRIPT
local test_ret=$?
local test_result=$?
fi

if [ $test_ret -gt 0 ]; then
if [ $test_result -gt 0 ]; then
logger -s "Configuration test failed! Restoring previous backup" \
-t openwisp \
-p daemon.err
Expand All @@ -263,6 +262,21 @@ test_configuration() {
return $ret
}

perform_default_test() {
# max 3 attempts to get checksum
for i in $(seq 1 3); do
$($FETCH_COMMAND -i --connect-timeout 5 --max-time 5 $CHECKSUM_URL > $TEST_CHECKSUM)
local result=$?
if [ $result -gt 0 ]; then
sleep 5
else
break
fi
done
rm $TEST_CHECKSUM
return $result
}

# stores unmanaged configuration sections that will be merged
# with the configuration downloaded from the controller
call_store_unmanaged() {
Expand Down

0 comments on commit 6776271

Please sign in to comment.