Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

fix tests for mongodb 3.4 #188

Merged
merged 1 commit into from
Feb 22, 2017
Merged

fix tests for mongodb 3.4 #188

merged 1 commit into from
Feb 22, 2017

Conversation

saghm
Copy link
Contributor

@saghm saghm commented Feb 22, 2017

Two tests were failing when run against 3.4, both due to the order of things being returned having changed. Along with fixing them, I added 3.4 testing to the travis config.


script:
- mkdir -p ./data/db30 ./data/db30-ssl ./data/db32 ./data/db32-ssl
- mkdir -p ./data/db30 ./data/db30-ssl ./data/db32 ./data/db32-ssl ./data/db34 ./data/db34-ssl
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 starting to get a bit messy; we should try to look into using mongo orchestration or some other method of managing testing against the different server versions, ideally before 3.6 comes out and we have to add that as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Added a tracking issue for Morc (this is a thing now. i'm making this name happen)

@@ -54,7 +54,7 @@ fn read_first_non_monitor_line(file: &mut BufReader<&File>, line: &mut String) {

#[test]
fn logging() {
let _ = fs::remove_file("test_apm_log.txt");
let _ = fs::remove_file("test_log.txt");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason the old name of this file didn't match the name I put in the .gitignore way back when this test was created, so I fixed that.

Copy link
Contributor

Choose a reason for hiding this comment

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

That might have been my fault -- i changed a lot of stringy fields to be more specific when I was parallelizing all of the tests.

@@ -170,5 +180,5 @@ fn logging() {

coll.drop().unwrap();

fs::remove_file("test_apm_log.txt").unwrap();
fs::remove_file("test_log.txt").unwrap();
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 noticed/started to get annoyed that the test file doesn't get cleaned up when the tests fail above this line, so I'm thinking we should change the tests so this file doesn't clutter things up. Given that the file should only be about a dozen lines, I think reading the whole thing into a string and then iterating over the lines should be fine.

Copy link
Contributor

@kyeah kyeah Feb 22, 2017

Choose a reason for hiding this comment

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

Makes sense to me for now. In an ideal future we would allow the client to take in a generic Write-implementing object and pass in a string-like IO object for testing purposes; if with_log_file(str) is part of the spec, it can be added as a utility method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea; it would be much more idiomatic that way.

@@ -35,7 +35,7 @@ fn create_collection() {

let db1 = if v3_1 { "test1" } else { "test2" };
let db2 = if v3_1 { "test2" } else { "test1" };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See, rustfmt does actually help sometimes; empty lines shouldn't have extra whitespace

Copy link
Contributor

Choose a reason for hiding this comment

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

a rare win, but still on thin ice. i'm watching you, rustfmt

@@ -101,6 +101,17 @@ fn create_and_get_users() {
db.drop_database().unwrap();
db.drop_all_users(None).unwrap();

let kevin_options = CreateUserOptions {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that versions below 3.4 return the users in the order they're created and 3.4 returns them in lexicographical order, the easiest fix for this is to just create the users in the order where all versions expect the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice.

Copy link
Contributor

@kyeah kyeah left a comment

Choose a reason for hiding this comment

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

cool, looks good for merging once tests are passing on Travis.

@@ -54,7 +54,7 @@ fn read_first_non_monitor_line(file: &mut BufReader<&File>, line: &mut String) {

#[test]
fn logging() {
let _ = fs::remove_file("test_apm_log.txt");
let _ = fs::remove_file("test_log.txt");
Copy link
Contributor

Choose a reason for hiding this comment

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

That might have been my fault -- i changed a lot of stringy fields to be more specific when I was parallelizing all of the tests.

let insert_one_line_start = if v3_3 {
"COMMAND.insert_one 127.0.0.1:27017 COMPLETED: { ok: 1, n: 1 } ("
} else {
"COMMAND.insert_one 127.0.0.1:27017 COMPLETED: { n: 1, ok: 1 } ("
Copy link
Contributor

Choose a reason for hiding this comment

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

argh, drives me crazy. this is the expected apm behavior for drivers, yeah? to print it out as ordered by the server, rather than always be lexicographic?

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'll double check, but I'd guess that the spec doesn't even mention it

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, makes sense as long as we're supposed to print document fields in insert order (most likely) and read server responses in insert order (probably doesn't even mention this in any of the documentation, but we wouldn't want to do any extra work here to alphabetize anyways).

@@ -170,5 +180,5 @@ fn logging() {

coll.drop().unwrap();

fs::remove_file("test_apm_log.txt").unwrap();
fs::remove_file("test_log.txt").unwrap();
Copy link
Contributor

@kyeah kyeah Feb 22, 2017

Choose a reason for hiding this comment

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

Makes sense to me for now. In an ideal future we would allow the client to take in a generic Write-implementing object and pass in a string-like IO object for testing purposes; if with_log_file(str) is part of the spec, it can be added as a utility method.

@@ -35,7 +35,7 @@ fn create_collection() {

let db1 = if v3_1 { "test1" } else { "test2" };
let db2 = if v3_1 { "test2" } else { "test1" };

Copy link
Contributor

Choose a reason for hiding this comment

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

a rare win, but still on thin ice. i'm watching you, rustfmt

@@ -101,6 +101,17 @@ fn create_and_get_users() {
db.drop_database().unwrap();
db.drop_all_users(None).unwrap();

let kevin_options = CreateUserOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice.

};

db.create_user("kevin",
"ihavenosenseofhumorandthereforeihatepuns!",
Copy link
Contributor

Choose a reason for hiding this comment

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

lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha, I had forgotten about that until I made this change, but I'm not even slightly surprised that did this

@saghm
Copy link
Contributor Author

saghm commented Feb 22, 2017

I'm a bit confused about why Github shows Travis as "not yet completed" when the task clearly finished last night...

@saghm saghm merged commit f1967c9 into mongodb-labs:master Feb 22, 2017
@saghm saghm mentioned this pull request Feb 23, 2017
@saghm saghm deleted the fix-34-tests branch April 14, 2017 05:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants