Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUST-656 Run tests against serverless in evergreen #504

Merged
merged 21 commits into from
Nov 8, 2021

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Oct 28, 2021

RUST-656

This adds evergreen configuration to run a subset of tests on serverless, and fixes various test runner bugs that were preventing those tests from passing.

This also closes RUST-983.

@abr-egn abr-egn marked this pull request as ready for review November 1, 2021 19:31
cargo test ${DEFAULT_FEATURES} --features $FEATURE_FLAGS $1 $OPTIONS
}

cargo_test test::spec::crud
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the subset of tests listed by the spec; running the full suite had a lot of noisy errors (unsupported operations, failures due to restrictions, db cleanup issues) that didn't seem worth individually chasing down.

.get_or_insert_with(Default::default)
.push(BulkWriteError { index, ..err });
Err(e) => {
let labels = e.labels().clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github diff is misleading here - the only change is cloning the labels before the match to accommodate the labels field no longer being visible.

@@ -1190,6 +1190,9 @@ impl ClientOptions {
/// Applies the options in other to these options if a value is not already present
#[cfg(test)]
pub(crate) fn merge(&mut self, other: ClientOptions) {
if self.hosts.is_empty() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super thrilled about the behavior here but I can't think of a clean solution.

  • TestClient and EventClient have a with_additional_options constructor fn that, semantically, takes a passed-in ClientOptions and merges in the set of "test-default" options there for any unset fields, with preference given to the passed-in fields where both were set.
  • Prior to this change, hosts was not included in the merge, so the passed-in ClientOptions would always determine hosts. This caused the label_not_added_first_read_error / label_not_added_second_read_error tests to break on serverless because those tests were not setting hosts and the default value was not valid in those cases.
  • Ideally, the semantics for hosts would be the same as for the rest of the fields - if unset, it would use the "test default". However, because it's populated in the builder by default, there's no way to actually determine "if unset"; testing against the default value causes other tests to fail because those are specifically constructing a hosts vec that, coincidentally, is equal to the default value, and should not be overridden by the test default.
  • Again ideally, this could be fixed by changing hosts to an Option<Vec<_>> or not populating it by default so vec[] would be a reasonable signal for "unset", but either of those would be a breaking change.
  • Calling with_additional_options with a ClientOptions constructed via builder with the default hosts is a nasty pitfall that's easy to hit - from the call site it looks like you'll be constructing a client with only the options specified, and the default hosts value will coincidentally work in most but not all testing environments.
  • Existing tests with the exception of the two that broke avoid this by either explicitly populating hosts or copying the ClientOptions from the CLIENT_OPTIONS value.

.evergreen/config.yml Outdated Show resolved Hide resolved
.evergreen/run-serverless-tests.sh Outdated Show resolved Hide resolved
src/error.rs Outdated

/// Labels categorizing the error.
#[serde(rename = "errorLabels", default)]
pub labels: Vec<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error labels are only ever actually returned at the top level of an error response, and it's merely a quirk / bug in the spec tests that they appear in the write concern error. @isabelatkinson actually just put up a PR to fix that: mongodb/specifications#1086.

For that reason, I don't think we should include public API support for this case, and if need be we can just skip the affected tests until the PR is merged. I think I remember you saying we may have to wait for a serverless change on this too to support the labels being specified in the correct place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The serverless proxy apparently enforces that they appear here; I've removed this field from the public API but I'd prefer to leave it and the related logic in place so the tests can continue to pass.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have we confirmed that this behavior is correct/desired on the serverless end? it seems like a weird inconsistency. I think it's fine to have it within the driver right now so that we can run the tests but in the long run it would be nice not to have to maintain a special case like this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in the process of following up about this on the serverless side - it looks like this isn't expected behavior. I'll make sure to send a follow-up PR for the driver (even if it's just a TODO with a bug reference) once that gets sorted out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM to leave this in temporarily until serverless fixes the issue on their end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added todos here referencing CLOUDP-105256.

@abr-egn abr-egn force-pushed the RUST-656/serverless-test branch from eb834f7 to 0715c6b Compare November 2, 2021 19:53
@@ -1232,6 +1236,10 @@ impl ClientOptions {
original_uri
]
);
#[cfg(test)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need #[cfg(test)] here? The method already has it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derp, fixed.

@@ -179,6 +179,8 @@ async fn run_spec_tests() {
.await
.unwrap();
}

let _ = client.database(&db_name).drop(None).await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should unwrap here to make sure this doesn't silently fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@abr-egn abr-egn force-pushed the RUST-656/serverless-test branch from 62d8f8f to 932207f Compare November 8, 2021 17:12
@abr-egn abr-egn force-pushed the RUST-656/serverless-test branch from 932207f to 2682541 Compare November 8, 2021 20:00
@abr-egn abr-egn merged commit 8311c41 into mongodb:master Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants