Skip to content

Commit 3d0ec19

Browse files
authored
RUST-452 Fix tests with async-std 1.6.x (#182)
1 parent 52f3f64 commit 3d0ec19

File tree

5 files changed

+46
-9
lines changed

5 files changed

+46
-9
lines changed

.evergreen/config.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,23 @@ functions:
5353
5454
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
5555
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
56+
export UPLOAD_BUCKET="${project}"
5657
export PROJECT_DIRECTORY="$(pwd)"
5758
5859
cat <<EOT > expansion.yml
5960
CURRENT_VERSION: "$CURRENT_VERSION"
6061
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
6162
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
6263
MONGODB_BINARIES: "$MONGODB_BINARIES"
64+
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
6365
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
6466
PREPARE_SHELL: |
6567
set -o errexit
6668
set -o xtrace
6769
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
6870
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
6971
export MONGODB_BINARIES="$MONGODB_BINARIES"
72+
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
7073
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
7174
export DRIVERS_TOOLS_X509="$DRIVERS_TOOLS/.evergreen/x509gen"
7275
@@ -163,13 +166,29 @@ functions:
163166
${PREPARE_SHELL}
164167
.evergreen/check-clippy.sh
165168
166-
"cleanup":
169+
"upload-mo-artifacts":
167170
- command: shell.exec
168171
params:
169172
script: |
170173
${PREPARE_SHELL}
171-
rm -rf ~/.rustup
172-
174+
find $MONGO_ORCHESTRATION_HOME -name \*.log | xargs tar czf mongodb-logs.tar.gz
175+
- command: s3.put
176+
params:
177+
aws_key: ${aws_key}
178+
aws_secret: ${aws_secret}
179+
local_file: mongodb-logs.tar.gz
180+
remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-mongodb-logs.tar.gz
181+
bucket: mciuploads
182+
permissions: public-read
183+
content_type: ${content_type|application/x-gzip}
184+
display_name: "mongodb-logs.tar.gz"
185+
186+
"stop mongo orchestration":
187+
- command: shell.exec
188+
params:
189+
script: |
190+
${PREPARE_SHELL}
191+
173192
cd "$MONGO_ORCHESTRATION_HOME"
174193
# source the mongo-orchestration virtualenv if it exists
175194
if [ -f venv/bin/activate ]; then
@@ -178,7 +197,14 @@ functions:
178197
. venv/Scripts/activate
179198
fi
180199
mongo-orchestration stop
181-
cd -
200+
201+
202+
"cleanup":
203+
- command: shell.exec
204+
params:
205+
script: |
206+
${PREPARE_SHELL}
207+
rm -rf ~/.rustup
182208
rm -rf $DRIVERS_TOOLS || true
183209
184210
"fix absolute paths":
@@ -229,6 +255,8 @@ pre:
229255
- func: "install dependencies"
230256

231257
post:
258+
- func: "stop mongo orchestration"
259+
- func: "upload-mo-artifacts"
232260
- func: "cleanup"
233261

234262
tasks:

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bson = "1.0.0"
2424
chrono = "0.4.7"
2525
derivative = "2.1.1"
2626
err-derive = "0.2.3"
27-
futures = "0.3.4"
27+
futures = "0.3.5"
2828
futures-intrusive = "0.3.0"
2929
hex = "0.4.0"
3030
hmac = "0.7.1"
@@ -49,7 +49,7 @@ webpki = "0.21.0"
4949
webpki-roots = "0.18.0"
5050

5151
[dependencies.async-std]
52-
version = "~1.5.0"
52+
version = "1.6.2"
5353
optional = true
5454

5555
[dependencies.pbkdf2]

src/client/options/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,15 @@ impl ClientOptions {
722722
Ok(options)
723723
}
724724

725+
#[cfg(test)]
726+
pub(crate) fn parse_without_srv_resolution(s: &str) -> Result<Self> {
727+
let parser = ClientOptionsParser::parse(s)?;
728+
let options: Self = parser.into();
729+
options.validate()?;
730+
731+
Ok(options)
732+
}
733+
725734
/// Gets the original SRV hostname specified when this ClientOptions was parsed from a URI.
726735
pub(crate) fn original_srv_hostname(&self) -> Option<&String> {
727736
self.original_srv_hostname.as_ref()

src/runtime/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl AsyncRuntime {
6969
/// Run a future in the foreground, blocking on it completing.
7070
///
7171
/// This will panic if called from a sychronous context when tokio is being used.
72-
#[cfg_attr(not(feature = "sync"), cfg(test))]
72+
#[cfg(feature = "sync")]
7373
pub(crate) fn block_on<F, T>(self, fut: F) -> T
7474
where
7575
F: Future<Output = T> + Send,

src/test/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ pub(crate) use self::{
1414
use lazy_static::lazy_static;
1515

1616
use self::util::TestLock;
17-
use crate::{options::ClientOptions, RUNTIME};
17+
use crate::options::ClientOptions;
1818

1919
const MAX_POOL_SIZE: u32 = 100;
2020

2121
lazy_static! {
2222
pub(crate) static ref CLIENT_OPTIONS: ClientOptions = {
2323
let uri = std::env::var("MONGODB_URI")
2424
.unwrap_or_else(|_| "mongodb://localhost:27017".to_string());
25-
let mut options = RUNTIME.block_on(ClientOptions::parse(&uri)).unwrap();
25+
let mut options = ClientOptions::parse_without_srv_resolution(&uri).unwrap();
2626
options.max_pool_size = Some(MAX_POOL_SIZE);
2727

2828
options

0 commit comments

Comments
 (0)