Checking mirror status only if necessary

When doing an update, we check to see if a mirror is stale, this only
needs to be done if there is a mirror set and if the upstream server is
up and reachable.

This commit checks to see if a mirror is set and there is an upstream
server to compare against, and only then it checks to see if it is stale.

Closes #922

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit is contained in:
Castulo Martinez
2019-07-03 16:10:46 -07:00
committed by Castulo J. Martinez
parent 659d12aa82
commit 515c7c71fe
10 changed files with 135 additions and 44 deletions
@@ -53,10 +53,16 @@ test_teardown() {
Warning: This is an insecure connection
The --allow-insecure-http flag was used, be aware that this poses a threat to the system
Error: Curl - Communicating with server timed out
Error: Failed to connect to update server: http://localhost:$port
Possible solutions for this problem are:
.Check if your network connection is working
.Fix the system clock
.Run 'swupd info' to check if the urls are correct
.Check if the server SSL certificate is trusted by your system \('clrtrust generate' may help\)
Error: Updater failed to initialize, exiting now.
EOM
)
assert_is_output "$expected_output"
assert_regex_is_output "$expected_output"
assert_file_not_exists "$TARGETDIR"/test_file1
}
@@ -77,10 +83,16 @@ test_teardown() {
Warning: This is an insecure connection
The --allow-insecure-http flag was used, be aware that this poses a threat to the system
Error: Curl - Communicating with server timed out
Error: Failed to connect to update server: http://localhost:$port
Possible solutions for this problem are:
.Check if your network connection is working
.Fix the system clock
.Run 'swupd info' to check if the urls are correct
.Check if the server SSL certificate is trusted by your system \('clrtrust generate' may help\)
Error: Updater failed to initialize, exiting now.
EOM
)
assert_is_output "$expected_output"
assert_regex_is_output "$expected_output"
assert_file_not_exists "$TARGETDIR"/test_file1
}
@@ -99,7 +111,10 @@ test_teardown() {
assert_status_is 0
expected_output=$(cat <<-EOM
Update started.
Error: Curl - Communicating with server timed out - '.*/version/formatstaging/latest'
Checking mirror status
Error: Curl - Communicating with server timed out - 'http://localhost:$port//version/formatstaging/latest'
Warning: Upstream server http://localhost:$port/ not responding, cannot determine upstream version
Warning: Unable to determine if the mirror is up to date
Preparing to update from 10 to 20
Downloading packs for:
- os-core
@@ -33,6 +33,7 @@ test_setup() {
assert_status_is 0
expected_output=$(cat <<-EOM
Update started.
Checking mirror status
Preparing to update from 10 to 20
Downloading packs for:
- test-bundle1
@@ -34,7 +34,9 @@ test_setup() {
assert_status_is 0
expected_output=$(cat <<-EOM
Update started.
Warning: removing stale mirror configuration. Mirror version (20) is too far behind upstream version (1000)
Checking mirror status
Warning: the mirror version (20) is too far behind upstream version (1000)
Removing mirror configuration
Preparing to update from 10 to 1000
Downloading packs for:
- test-bundle1
@@ -35,6 +35,7 @@ test_setup() {
assert_status_is 0
expected_output=$(cat <<-EOM
Update started.
Checking mirror status
Warning: mirror version (20) is behind upstream version (100)
Preparing to update from 10 to 20
Downloading packs for: