@@ -74,7 +74,7 @@ async fn mark_server_as_online() {
74
74
* ping_info = ( at, true ) ;
75
75
}
76
76
77
- /// Check if the server is online by either getting a cached value (cached for `ONLINE_CHECK_TTL_MS`), or by pinging `8.8.8.8` .
77
+ /// Check if the server is online by either getting a cached value (cached for `ONLINE_CHECK_TTL_MS`), or by requesting our repository .
78
78
async fn is_online ( ) -> bool {
79
79
{
80
80
// Has it been checked within the TTL?
@@ -95,20 +95,12 @@ async fn is_online() -> bool {
95
95
}
96
96
97
97
// Head-request our repository to make sure we're online.
98
- // Pings don't work in GitHub Actions runners, so if we're running tests, just pretend
99
- // our ping succeeded.
100
- let ping_successful = if cfg ! ( debug_assertions)
101
- && std:: env:: var ( "GITHUB_ACTIONS" ) . is_ok_and ( |val| val == "true" )
102
- {
103
- true
104
- } else {
105
- let result = CLIENT
106
- . head ( env ! ( "CARGO_PKG_REPOSITORY" ) )
107
- . send ( )
108
- . await
109
- . and_then ( Response :: error_for_status) ;
110
- result. is_ok ( )
111
- } ;
98
+ let result = CLIENT
99
+ . head ( env ! ( "CARGO_PKG_REPOSITORY" ) )
100
+ . send ( )
101
+ . await
102
+ . and_then ( Response :: error_for_status) ;
103
+ let ping_successful = result. is_ok ( ) ;
112
104
113
105
// Write the info
114
106
let now = Utc :: now ( ) . timestamp_millis ( ) ;
@@ -190,7 +182,9 @@ async fn check_impl(
190
182
191
183
retry_limit -= 1 ;
192
184
193
- tokio:: time:: sleep ( RETRY_TIMEOUT ) . await ;
185
+ if !cfg ! ( test) {
186
+ tokio:: time:: sleep ( RETRY_TIMEOUT ) . await ;
187
+ }
194
188
}
195
189
196
190
let response = match response {
@@ -880,7 +874,7 @@ mod tests {
880
874
assert_eq ! ( expected, links. to_message( ) ) ;
881
875
}
882
876
883
- #[ tokio:: test( start_paused = true ) ]
877
+ #[ tokio:: test]
884
878
async fn check_failure_types ( ) {
885
879
// Start a web server so we can do each kinds of checks
886
880
let server_addr = ( "127.0.0.1" , 32750 ) ;
@@ -961,7 +955,7 @@ mod tests {
961
955
}
962
956
}
963
957
964
- #[ tokio:: test( start_paused = true ) ]
958
+ #[ tokio:: test]
965
959
async fn test_retrying ( ) {
966
960
// Start a web server that fails only the first request
967
961
let server_addr = ( "127.0.0.1" , 32752 ) ;
@@ -986,7 +980,14 @@ mod tests {
986
980
} else {
987
981
err_hits_for_server. fetch_add ( 1 , Ordering :: Relaxed ) ;
988
982
// Trigger the request timeout
989
- tokio:: time:: sleep ( Duration :: from_secs ( 1 ) + REQUEST_TIMEOUT ) . await ;
983
+ let sleep = tokio:: time:: sleep ( Duration :: from_secs ( 1 ) + REQUEST_TIMEOUT ) ;
984
+
985
+ // we don't want to wait for realsies
986
+ tokio:: time:: pause ( ) ;
987
+ tokio:: time:: advance ( REQUEST_TIMEOUT - Duration :: from_millis ( 100 ) ) . await ;
988
+ tokio:: time:: resume ( ) ;
989
+
990
+ sleep. await ;
990
991
Response :: builder ( )
991
992
. status ( 500 )
992
993
. body ( Body :: from ( "Retry plz!" ) )
0 commit comments