Skip to content

Commit

Permalink
fix timeout test
Browse files Browse the repository at this point in the history
  • Loading branch information
Linuxpizi committed Sep 28, 2021
1 parent 1f8047a commit 5bfb459
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
3 changes: 2 additions & 1 deletion s3/bin/simple_crud.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern crate s3;

use std::str;
use std::time;
use std::ops::Range;

use s3::bucket::Bucket;
Expand Down Expand Up @@ -101,7 +102,7 @@ pub fn main() -> Result<(), S3Error> {
for backend in vec![aws] {
println!("Running {}", backend.name);
// Create Bucket in REGION for BUCKET
let bucket = Bucket::new_with_path_style(&backend.bucket, backend.region, backend.credentials)?;
let bucket = Bucket::new_with_path_style(&backend.bucket, backend.region, time::Duration::from_secs(5),backend.credentials)?;

// List out contents of directory
let results = rt.block_on(bucket.list("".to_string(), None)).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions s3/bin/simple_read.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate s3;

use std::str;
use std::{str, time};
use std::ops::Range;

use s3::bucket::Bucket;
Expand Down Expand Up @@ -74,7 +74,7 @@ pub fn main() -> Result<(), S3Error> {
for backend in vec![aws] {
println!("Running {}", backend.name);
// Create Bucket in REGION for BUCKET
let bucket = Bucket::new_with_path_style(&backend.bucket, backend.region, backend.credentials)?;
let bucket = Bucket::new_with_path_style(&backend.bucket, backend.region,time::Duration::from_secs(5), backend.credentials)?;

// [3052000608..3052000640, 3052000512..3052000544, 3052000544..3052000576, 3052000576..3052000608, 3052000640..3052000672, 3052000672..3052000704, 3052000704..3052000736, 3052000736..3052000768]
let mut ranges = Vec::new();
Expand Down
6 changes: 6 additions & 0 deletions s3/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,7 @@ mod test {
Bucket::new(
"rust-s3-test",
"eu-central-1".parse().unwrap(),
std::time::Duration::from_secs(5),
test_aws_credentials(),
)
.unwrap()
Expand All @@ -1453,6 +1454,7 @@ mod test {
Bucket::new(
"rust-s3",
"wa-eu-central-1".parse().unwrap(),
std::time::Duration::from_secs(5),
test_wasabi_credentials(),
)
.unwrap()
Expand All @@ -1465,6 +1467,7 @@ mod test {
region: "us-east1".to_owned(),
endpoint: "https://storage.googleapis.com".to_owned(),
},
std::time::Duration::from_secs(5),
test_gc_credentials(),
)
.unwrap()
Expand Down Expand Up @@ -1720,6 +1723,7 @@ mod test {
let response = Bucket::create(
&uuid::Uuid::new_v4().to_string(),
"us-east-1".parse().unwrap(),
std::time::Duration::from_secs(5),
test_aws_credentials(),
config,
)
Expand Down Expand Up @@ -1748,6 +1752,7 @@ mod test {
let response = Bucket::create(
&uuid::Uuid::new_v4().to_string(),
"eu-central-1".parse().unwrap(),
std::time::Duration::from_secs(5),
test_aws_credentials(),
config,
)
Expand Down Expand Up @@ -1776,6 +1781,7 @@ mod test {
let response = Bucket::create(
&uuid::Uuid::new_v4().to_string(),
"eu-central-1".parse().unwrap(),
std::time::Duration::from_secs(5),
test_aws_credentials(),
config,
)
Expand Down
18 changes: 9 additions & 9 deletions s3/src/multipart/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ fn issue_104() {
fn issue_114() {
// ::init_log();

fn consume_all<R: BufRead>(mut rdr: R) {
loop {
let consume = rdr.fill_buf().unwrap().len();
if consume == 0 {
return;
}
rdr.consume(consume);
}
}
// fn consume_all<R: BufRead>(mut rdr: R) {
// loop {
// let consume = rdr.fill_buf().unwrap().len();
// if consume == 0 {
// return;
// }
// rdr.consume(consume);
// }
// }

use std::io::Cursor;

Expand Down
12 changes: 6 additions & 6 deletions s3/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern crate md5;
use std::io::{Write, Read};
use std::ops::Range;
use log::warn;

use std::time;
use chrono::{DateTime, Utc};
use maybe_async::maybe_async;
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
Expand Down Expand Up @@ -289,7 +289,7 @@ mod tests {
#[test]
fn url_uses_https_by_default() -> Result<()> {
let region = "custom-region".parse()?;
let bucket = Bucket::new("my-first-bucket", region, fake_credentials())?;
let bucket = Bucket::new("my-first-bucket", region, std::time::Duration::from_secs(5),fake_credentials())?;
let path = "/my-first/path";
let request = Reqwest::new(&bucket, path, Command::GetObject);

Expand All @@ -305,7 +305,7 @@ mod tests {
#[test]
fn url_uses_https_by_default_path_style() -> Result<()> {
let region = "custom-region".parse()?;
let bucket = Bucket::new_with_path_style("my-first-bucket", region, fake_credentials())?;
let bucket = Bucket::new_with_path_style("my-first-bucket", region, std::time::Duration::from_secs(5),fake_credentials())?;
let path = "/my-first/path";
let request = Reqwest::new(&bucket, path, Command::GetObject);

Expand All @@ -321,7 +321,7 @@ mod tests {
#[test]
fn url_uses_scheme_from_custom_region_if_defined() -> Result<()> {
let region = "http://custom-region".parse()?;
let bucket = Bucket::new("my-second-bucket", region, fake_credentials())?;
let bucket = Bucket::new("my-second-bucket", region, std::time::Duration::from_secs(5),fake_credentials())?;
let path = "/my-second/path";
let request = Reqwest::new(&bucket, path, Command::GetObject);

Expand All @@ -336,7 +336,7 @@ mod tests {
#[test]
fn url_uses_scheme_from_custom_region_if_defined_with_path_style() -> Result<()> {
let region = "http://custom-region".parse()?;
let bucket = Bucket::new_with_path_style("my-second-bucket", region, fake_credentials())?;
let bucket = Bucket::new_with_path_style("my-second-bucket", region, std::time::Duration::from_secs(5),fake_credentials())?;
let path = "/my-second/path";
let request = Reqwest::new(&bucket, path, Command::GetObject);

Expand All @@ -352,7 +352,7 @@ mod tests {
#[test]
fn test_get_object_range_header() -> Result<()> {
let region = "http://custom-region".parse()?;
let bucket = Bucket::new_with_path_style("my-second-bucket", region, fake_credentials())?;
let bucket = Bucket::new_with_path_style("my-second-bucket", region, std::time::Duration::from_secs(5),fake_credentials())?;
let path = "/my-second/path";

let request = Reqwest::new(
Expand Down

0 comments on commit 5bfb459

Please sign in to comment.