make the repair_backoff test more robust (#1095)
* more the repair_backoff test more robust * fix names and magic numbers
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							25d7dc7b96
						
					
				
				
					commit
					fb4b33b81b
				
			| @@ -1056,6 +1056,9 @@ mod test { | ||||
|     } | ||||
|     #[test] | ||||
|     pub fn test_repair_backoff() { | ||||
|         let num_tests = 100; | ||||
|         let res: usize = (0..num_tests) | ||||
|             .map(|_| { | ||||
|                 let mut last = 0; | ||||
|                 let mut times = 0; | ||||
|                 let total: usize = (0..127) | ||||
| @@ -1067,12 +1070,16 @@ mod test { | ||||
|                     .sum(); | ||||
|                 assert_eq!(times, 128); | ||||
|                 assert_eq!(last, 1); | ||||
|         assert!(total > 0); | ||||
|         assert!(total < 127); | ||||
|                 repair_backoff(&mut last, &mut times, 1); | ||||
|                 assert_eq!(times, 64); | ||||
|                 repair_backoff(&mut last, &mut times, 2); | ||||
|                 assert_eq!(times, 2); | ||||
|                 assert_eq!(last, 2); | ||||
|                 total | ||||
|             }) | ||||
|             .sum(); | ||||
|         let avg = res / num_tests; | ||||
|         assert!(avg >= 3); | ||||
|         assert!(avg <= 5); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user