From 1a5c8319ff677cbaa507dc7e430748d618a46ae6 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 20 Nov 2017 16:22:09 +0100 Subject: [PATCH 1/6] Missing interrupt --- sub_scripts/testing_process.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 98a79ea..82a56be 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -528,6 +528,9 @@ CHECK_SETUP () { RESULT_check_root=$check_result_setup RESULT_check_remove_root=$check_result_remove fi + + # Make a break if auto_remove is set + break_before_continue } CHECK_UPGRADE () { From 13f26431057323f14db31c0b5b009e708d03f3e1 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 16 Mar 2018 00:52:44 +0100 Subject: [PATCH 2/6] Don't use default path for multi_instance test --- sub_scripts/testing_process.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index be45b3e..1792e50 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -865,8 +865,13 @@ CHECK_MULTI_INSTANCE () { local manifest_args_mod="$manifest_arguments" # Replace manifest key for the test - replace_manifest_key "path" "$test_path" - check_path=$test_path + if [ "$install_type" = "subdir" ]; then + local check_path=$test_path + elif [ "$install_type" = "root" ]; then + local check_path=/ + fi + replace_manifest_key "path" "$check_path" + replace_manifest_key "user" "$test_user" replace_manifest_key "public" "$public_public_arg" From 9a4d284332cc0952454999c70bd4eee84b98a58d Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 16 Mar 2018 12:56:19 +0100 Subject: [PATCH 3/6] Fix bad variable for multi_instance --- sub_scripts/testing_process.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 1792e50..65a416f 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -865,9 +865,9 @@ CHECK_MULTI_INSTANCE () { local manifest_args_mod="$manifest_arguments" # Replace manifest key for the test - if [ "$install_type" = "subdir" ]; then + if [ "$previous_install" = "subdir" ]; then local check_path=$test_path - elif [ "$install_type" = "root" ]; then + elif [ "$previous_install" = "root" ]; then local check_path=/ fi replace_manifest_key "path" "$check_path" From e4359d9c6b05b9c82c04fe8360b3e9eeda23953f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 7 Apr 2018 13:23:25 +0200 Subject: [PATCH 4/6] Add network usage tracking --- sub_scripts/launcher.sh | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/sub_scripts/launcher.sh b/sub_scripts/launcher.sh index 1341375..b027eb2 100755 --- a/sub_scripts/launcher.sh +++ b/sub_scripts/launcher.sh @@ -10,6 +10,48 @@ arg_ssh="-tt" snapshot_path="/var/lib/lxcsnaps/$lxc_name" current_snapshot=snap0 +#================================================= +# Network usage +#================================================= + +start_network_usage () { + start_rx_usage=0 + start_tx_usage=0 + + # package_check initialization + if [ -e "/sys/class/net/${lxc_bridge}/statistics/rx_bytes" ] + then + start_rx_usage=$(cat "/sys/class/net/${lxc_bridge}/statistics/rx_bytes") + start_tx_usage=$(cat "/sys/class/net/${lxc_bridge}/statistics/tx_bytes") + fi +} + +stop_network_usage () { + local stop_rx_usage=0 + local stop_tx_usage=0 + + if [ -e "/sys/class/net/${lxc_bridge}/statistics/rx_bytes" ] + then + local stop_rx_usage=$(cat "/sys/class/net/${lxc_bridge}/statistics/rx_bytes") + local stop_tx_usage=$(cat "/sys/class/net/${lxc_bridge}/statistics/tx_bytes") + fi + + local rx_usage=$(numfmt --to=iec-i --suffix=B --padding=7 $(($stop_rx_usage-$start_rx_usage))) + local tx_usage=$(numfmt --to=iec-i --suffix=B --padding=7 $(($stop_tx_usage-$start_tx_usage))) + local rx_tx_usage=$(numfmt --to=iec-i --suffix=B --padding=7 $(($stop_rx_usage+$stop_tx_usage-$start_rx_usage-$start_tx_usage))) + + if [ $1 -eq 2 ]; then + ECHO_FORMAT "Nextwork usage for this test: " "blue" + elif [ $1 -eq 3 ]; then + ECHO_FORMAT "Global network usage for all tests: " "blue" + else + ECHO_FORMAT "Network usage: " "blue" + fi + + + ECHO_FORMAT "${rx_tx_usage} (rx: ${rx_usage}, tx: ${tx_usage}).\n" "blue" +} + #================================================= # TIMER #================================================= @@ -69,6 +111,8 @@ create_temp_backup () { snap_number=$1 start_timer + start_network_usage + # Check all the witness files, to verify if them still here check_witness_files >&2 @@ -98,6 +142,7 @@ create_temp_backup () { current_snapshot=snap$snap_number stop_timer 1 >&2 + stop_network_usage 1 >&2 # Restart the container, after the snapshot LXC_START "true" >&2 @@ -109,6 +154,7 @@ use_temp_snapshot () { current_snapshot=$1 start_timer + start_network_usage # Fix the missing hostname in the hosts file... echo "127.0.0.1 $lxc_name" | sudo tee --append "$snapshot_path/$current_snapshot/rootfs/etc/hosts" > /dev/null @@ -116,6 +162,7 @@ use_temp_snapshot () { sudo rsync --acls --archive --delete --executability --itemize-changes --xattrs "$snapshot_path/$current_snapshot/rootfs/" "/var/lib/lxc/$lxc_name/rootfs/" > /dev/null 2>> "$test_result" stop_timer 1 + stop_network_usage 1 # Retrieve the app id in the log. To manage the app after ynh_app_id=$(sudo tac "$yunohost_log" | grep --only-matching --max-count=1 "YNH_APP_INSTANCE_NAME=[^ ]*" | cut --delimiter='=' --fields=2) @@ -142,6 +189,8 @@ LXC_INIT () { sudo iptables --append FORWARD --in-interface $lxc_bridge --out-interface $main_iface --jump ACCEPT | tee --append "$test_result" 2>&1 sudo iptables --append FORWARD --in-interface $main_iface --out-interface $lxc_bridge --jump ACCEPT | tee --append "$test_result" 2>&1 sudo iptables --table nat --append POSTROUTING --source $ip_range.0/24 --jump MASQUERADE | tee --append "$test_result" 2>&1 + + } LXC_START () { @@ -149,6 +198,7 @@ LXC_START () { # $1 = Command to execute in the container start_timer + start_network_usage # Try to start the container 3 times. local max_try=3 local i=0 @@ -212,6 +262,7 @@ LXC_START () { ECHO_FORMAT "Boot log:\n" clog cat "$script_dir/lxc_boot.log" | tee --append "$test_result" stop_timer 1 + stop_network_usage 1 return 1 fi done @@ -231,6 +282,7 @@ LXC_START () { sudo cat "/var/lib/lxc/$lxc_name/rootfs/home/pchecker/temp_yunohost-cli.log" >> "$temp_log" stop_timer 1 + stop_network_usage 1 # Return the exit code of the ssh command return $returncode } @@ -239,6 +291,7 @@ LXC_STOP () { # Stop and restore the LXC container start_timer + start_network_usage # Stop the LXC container if is_lxc_running; then echo "Stop the LXC container" | tee --append "$test_result" @@ -264,6 +317,7 @@ LXC_STOP () { echo "Restore the previous snapshot." | tee --append "$test_result" sudo rsync --acls --archive --delete --executability --itemize-changes --xattrs "$snapshot_path/$current_snapshot/rootfs/" "/var/lib/lxc/$lxc_name/rootfs/" > /dev/null 2>> "$test_result" stop_timer 1 + stop_network_usage 1 } LXC_TURNOFF () { From 6a54faa0773ad31021d1647ba33246a21129a547 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 7 Apr 2018 13:47:43 +0200 Subject: [PATCH 5/6] Add network usage for global network --- package_check.sh | 1 + sub_scripts/testing_process.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/package_check.sh b/package_check.sh index f91a40c..bf9ec7b 100755 --- a/package_check.sh +++ b/package_check.sh @@ -1211,6 +1211,7 @@ echo "You can find the complete log of these tests in $complete_log" starttime=$complete_start_timer # End the timer for the test stop_timer 3 +stop_network_usage 3 #================================================= # Notification grade diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 65a416f..82c72f8 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -1431,6 +1431,7 @@ TEST_LAUNCHER () { starttime=$global_start_timer # End the timer for the test stop_timer 2 + stop_network_usage 2 # Update the lock file with the date of the last finished test. echo "$1 $2:$(date +%s)" > "$lock_file" From 8fd0ce63755998a95f2846a051cb6bcc64b32c06 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 7 Apr 2018 14:28:33 +0200 Subject: [PATCH 6/6] Fix network usage tracking un global results --- package_check.sh | 19 +++++++++++++++++++ sub_scripts/testing_process.sh | 11 +++++++++++ 2 files changed, 30 insertions(+) diff --git a/package_check.sh b/package_check.sh index bf9ec7b..7c54a75 100755 --- a/package_check.sh +++ b/package_check.sh @@ -777,6 +777,16 @@ start_timer # And keep this value separately complete_start_timer=$starttime +#================================================= +# Set the network followup for all tests +#================================================= + +# Start the network usage followup +start_network_usage +# And keep these values separately +complete_start_rx_usage=$start_rx_usage +complete_start_tx_usage=$start_tx_usage + #================================================= # Initialize tests #================================================= @@ -1211,6 +1221,15 @@ echo "You can find the complete log of these tests in $complete_log" starttime=$complete_start_timer # End the timer for the test stop_timer 3 + +#================================================= +# Ending the network usage followup +#================================================= + +# Restore the orgin values +start_rx_usage=$complete_start_rx_usage +start_tx_usage=$complete_start_tx_usage +# End the followup stop_network_usage 3 #================================================= diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 82c72f8..3ee5a7e 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -1418,6 +1418,12 @@ TEST_LAUNCHER () { # And keep this value separately local global_start_timer=$starttime + # Start the network usage followup + start_network_usage + # And keep these values separately + local complete_start_rx_usage=$start_rx_usage + local complete_start_tx_usage=$start_tx_usage + # Execute the test $1 $2 @@ -1431,6 +1437,11 @@ TEST_LAUNCHER () { starttime=$global_start_timer # End the timer for the test stop_timer 2 + + # Restore the orgin values + start_rx_usage=$complete_start_rx_usage + start_tx_usage=$complete_start_tx_usage + # End the followup stop_network_usage 2 # Update the lock file with the date of the last finished test.