mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Merge pull request #137 from YunoHost/moar-refactoring
Moar refactoring
This commit is contained in:
commit
af359e9dfe
4 changed files with 24 additions and 16 deletions
|
@ -247,11 +247,11 @@ function fetch_package_to_test() {
|
||||||
# Force the branch master if no branch is specified.
|
# Force the branch master if no branch is specified.
|
||||||
if [ -z "$gitbranch" ]
|
if [ -z "$gitbranch" ]
|
||||||
then
|
then
|
||||||
if git ls-remote --quiet --exit-code $path_to_package_to_test master
|
if git ls-remote --quiet --exit-code $path_to_package_to_test master >/dev/null
|
||||||
then
|
then
|
||||||
gitbranch="-b master"
|
gitbranch="-b master"
|
||||||
else
|
else
|
||||||
if git ls-remote --quiet --exit-code $path_to_package_to_test stable
|
if git ls-remote --quiet --exit-code $path_to_package_to_test stable >/dev/null
|
||||||
then
|
then
|
||||||
gitbranch="-b stable"
|
gitbranch="-b stable"
|
||||||
else
|
else
|
||||||
|
|
|
@ -84,7 +84,8 @@ LOAD_LXC_SNAPSHOT () {
|
||||||
|
|
||||||
LXC_STOP $LXC_NAME
|
LXC_STOP $LXC_NAME
|
||||||
|
|
||||||
lxc restore $LXC_NAME $snapname
|
lxc restore $LXC_NAME $snapname || log_error "Failed to restore snapshot ? The next step may miserably crash because of this ... if this happens to often, maybe restarting the LXD daemon can help ..."
|
||||||
|
|
||||||
lxc start $LXC_NAME
|
lxc start $LXC_NAME
|
||||||
_LXC_START_AND_WAIT $LXC_NAME
|
_LXC_START_AND_WAIT $LXC_NAME
|
||||||
}
|
}
|
||||||
|
@ -100,7 +101,7 @@ LXC_EXEC () {
|
||||||
start_timer
|
start_timer
|
||||||
|
|
||||||
# Execute the command given in argument in the container and log its results.
|
# Execute the command given in argument in the container and log its results.
|
||||||
lxc exec $LXC_NAME --env PACKAGE_CHECK_EXEC=1 -t -- /bin/bash -c "$cmd" | tee -a "$complete_log" $current_test_log
|
lxc exec $LXC_NAME --env PACKAGE_CHECK_EXEC=1 -t -- /bin/bash -c "$cmd" | tee -a "$full_log" $current_test_log
|
||||||
|
|
||||||
# Store the return code of the command
|
# Store the return code of the command
|
||||||
local returncode=${PIPESTATUS[0]}
|
local returncode=${PIPESTATUS[0]}
|
||||||
|
@ -135,7 +136,7 @@ LXC_RESET () {
|
||||||
LXC_STOP $LXC_NAME
|
LXC_STOP $LXC_NAME
|
||||||
|
|
||||||
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
|
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
|
||||||
local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool')
|
local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq -r '.[].expanded_devices.root.pool')
|
||||||
swapoff "$(lxc storage get $current_storage source)/containers/$LXC_NAME/rootfs/swap" 2>/dev/null
|
swapoff "$(lxc storage get $current_storage source)/containers/$LXC_NAME/rootfs/swap" 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ LXC_RESET () {
|
||||||
|
|
||||||
_LXC_START_AND_WAIT() {
|
_LXC_START_AND_WAIT() {
|
||||||
|
|
||||||
restart_container()
|
restart_container()
|
||||||
{
|
{
|
||||||
LXC_STOP $1
|
LXC_STOP $1
|
||||||
lxc start "$1"
|
lxc start "$1"
|
||||||
|
|
|
@ -277,7 +277,7 @@ _VALIDATE_THAT_APP_CAN_BE_ACCESSED () {
|
||||||
then
|
then
|
||||||
# Print the title of the page
|
# Print the title of the page
|
||||||
local page_title=$(grep "<title>" "$curl_output" | cut --delimiter='>' --fields=2 | cut --delimiter='<' --fields=1)
|
local page_title=$(grep "<title>" "$curl_output" | cut --delimiter='>' --fields=2 | cut --delimiter='<' --fields=1)
|
||||||
local page_extract=$(lynx -dump -force_html "$curl_output" | head --lines 20 | tee -a "$complete_log")
|
local page_extract=$(lynx -dump -force_html "$curl_output" | head --lines 20 | tee -a "$full_log")
|
||||||
|
|
||||||
# Check if the page title is neither the YunoHost portail or default NGINX page
|
# Check if the page title is neither the YunoHost portail or default NGINX page
|
||||||
if [ "$page_title" = "YunoHost Portal" ]
|
if [ "$page_title" = "YunoHost Portal" ]
|
||||||
|
@ -355,8 +355,8 @@ TEST_PACKAGE_LINTER () {
|
||||||
start_test "Package linter"
|
start_test "Package linter"
|
||||||
|
|
||||||
# Execute package linter and linter_result gets the return code of the package linter
|
# Execute package linter and linter_result gets the return code of the package linter
|
||||||
./package_linter/package_linter.py "$package_path" | tee -a "$complete_log"
|
./package_linter/package_linter.py "$package_path" | tee -a "$full_log"
|
||||||
./package_linter/package_linter.py "$package_path" --json | tee -a "$complete_log" > $current_test_results
|
./package_linter/package_linter.py "$package_path" --json | tee -a "$full_log" > $current_test_results
|
||||||
|
|
||||||
return ${PIPESTATUS[0]}
|
return ${PIPESTATUS[0]}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,17 @@ source lib/tests.sh
|
||||||
source lib/witness.sh
|
source lib/witness.sh
|
||||||
source lib/legacy.sh
|
source lib/legacy.sh
|
||||||
|
|
||||||
readonly complete_log="./Complete-${WORKER_ID}.log"
|
readonly full_log="./full_log_${WORKER_ID}.log"
|
||||||
|
readonly result_json="./results_${WORKER_ID}.json"
|
||||||
|
readonly summary_png="./summary_${WORKER_ID}.png"
|
||||||
|
|
||||||
# Purge some log files
|
# Purge some log files
|
||||||
rm -f "$complete_log" && touch "$complete_log"
|
rm -f "$full_log" && touch "$full_log"
|
||||||
|
rm -f $result_json
|
||||||
|
rm -f $summary_png
|
||||||
|
|
||||||
# Redirect fd 3 (=debug steam) to complete log
|
# Redirect fd 3 (=debug steam) to full log
|
||||||
exec 3>>$complete_log
|
exec 3>>$full_log
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Misc test helpers & coordination
|
# Misc test helpers & coordination
|
||||||
|
@ -84,15 +88,18 @@ run_all_tests() {
|
||||||
# Print the final results of the tests
|
# Print the final results of the tests
|
||||||
log_title "Tests summary"
|
log_title "Tests summary"
|
||||||
|
|
||||||
python3 lib/analyze_test_results.py $TEST_CONTEXT 2> ./results-${WORKER_ID}.json
|
python3 lib/analyze_test_results.py $TEST_CONTEXT 2> $result_json
|
||||||
[[ -e "$TEST_CONTEXT/summary.png" ]] && cp "$TEST_CONTEXT/summary.png" ./summary.png || rm -f summary.png
|
[[ -e "$TEST_CONTEXT/summary.png" ]] && cp "$TEST_CONTEXT/summary.png" $summary_png || rm -f $summary_png
|
||||||
|
|
||||||
# Restore the started time for the timer
|
# Restore the started time for the timer
|
||||||
starttime=$complete_start_timer
|
starttime=$complete_start_timer
|
||||||
# End the timer for the test
|
# End the timer for the test
|
||||||
stop_timer all_tests
|
stop_timer all_tests
|
||||||
|
|
||||||
echo "You can find the complete log of these tests in $(realpath $complete_log)"
|
if [[ "$IN_YUNORUNNER" != "1" ]]
|
||||||
|
then
|
||||||
|
echo "You can find the complete log of these tests in $(realpath $full_log)"
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue