Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Initial work to test mongodb-core on evergreen #287

Merged
merged 39 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
dbf4a2f
fix(test-environments): ensure all servers run on separate ports
mbroadst Jan 7, 2018
3e9675e
test(environment): add compat names for mongo orchestration
mbroadst Jan 8, 2018
a780fa6
chore(evergreen): add initial evergreen configuration
mbroadst Jan 8, 2018
3268a89
fix(evergreen): change nvm path to local
Jan 29, 2018
21afc38
chore(evergreen): add initial evergreen configuration
mbroadst Jan 8, 2018
e56a82c
refactor(evergreen): use type `test` to reduce system failures
mbroadst Jan 30, 2018
08c395f
fix(evergreen): change name to id
Feb 8, 2018
8386f0f
feat(evergreen): use evergreen flag when running tests
Feb 9, 2018
3142eb4
fix(evergreen): pass in flag through npm scripts
Feb 9, 2018
08839c3
feat(evergreen): add evergreen config based on drivers skeleton
mbroadst Mar 9, 2018
2bc6ff0
refactor(test): support environment aliases for evergreen
mbroadst Mar 9, 2018
eebada7
chore(evergreen): ensure variables are passed into run-tests.sh
mbroadst Mar 9, 2018
0d15e6a
chore(evergreen): add node-version to matrix builds
mbroadst Mar 9, 2018
b6b4632
chore(evergreen): name environments to property alias for evg
mbroadst Mar 9, 2018
27022d7
test(evergreen): disable tests that use the topology manager
mbroadst Mar 9, 2018
ccdc2d6
refactor(evergreen): don't show all commands in setup/test scripts
mbroadst Mar 9, 2018
f3b2812
test(evergreen): use internal topology manager for tests
mbroadst Mar 10, 2018
c467957
test(evergreen): add variables into "run tests" tasks
mbroadst Mar 10, 2018
788fff8
test(evergreen): move mongodb download to run-tests
mbroadst Mar 10, 2018
e1619a1
test(evergreen): VERSION -> MONGODB_VERSION
mbroadst Mar 10, 2018
6f9ed15
test(evergreen): make matrix parity with python driver
mbroadst Mar 12, 2018
93ab85f
test(evergreen): enable verbose logging for npm install
mbroadst Mar 12, 2018
68fdaeb
test(evergreen): store all node related artifacts in a local folder
mbroadst Mar 12, 2018
679b6e4
test(evergreen): need to re-export NVM_DIR after curl'd install
mbroadst Mar 12, 2018
3ad7edd
test(evergreen): ensure all node files are relegated to a single dire…
mbroadst Mar 12, 2018
e8ec942
test(evergreen): use $PROJECT_DIRECTORY for temporary node folder
mbroadst Mar 12, 2018
322d931
test(evergreen): temporarily disable auth/ssl builds
mbroadst Mar 19, 2018
e321367
refactor(pool): emit a signal for state changes
mbroadst Mar 19, 2018
9bddb5e
test(evergreen): remove suse 11 because its version of git is too old
mbroadst Mar 20, 2018
ea2f171
test(evergreen): disable windows builds until we have an nvm alternative
mbroadst Mar 20, 2018
5734e5a
test(evergreen): only run boron and carbon builds for ZAP architectures
mbroadst Mar 24, 2018
3c545ba
test(config): ensure that error messages are not truncated
mbroadst Mar 24, 2018
4edfbb5
test(pool): attempt to correct more pool-related flakey tests
mbroadst Mar 24, 2018
fab8a52
test(pool): use `ConnectionSpy` to reduce flakiness of tests
mbroadst Mar 25, 2018
d0e72d5
test(cursor): skip the flakiest test in our suite for now
mbroadst Mar 25, 2018
873aeba
test(server): don't time how long it takes to eval
mbroadst Mar 25, 2018
a3803de
test(evergreen): remove unused bash variables
mbroadst Mar 26, 2018
129986b
chore(cruft): remove deprecated `.evg.yml`
mbroadst Mar 26, 2018
89dfdbd
test(auth): skip whole suite rather than individual tests
mbroadst Mar 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
629 changes: 629 additions & 0 deletions .evergreen/config.yml

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions .evergreen/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
# set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail

NODE_LTS_NAME=${NODE_LTS_NAME:-carbon}
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm"
NPM_TMP_DIR="${NODE_ARTIFATS_PATH}/tmp"

# this needs to be explicitly exported for the nvm install below
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"

# create node artifacts path if needed
mkdir -p ${NODE_ARTIFACTS_PATH}
mkdir -p ${NPM_CACHE_DIR}
mkdir -p "${NPM_TMP_DIR}"

# install Node.js
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"
nvm install --lts=${NODE_LTS_NAME}

# setup npm cache in a local directory
cat <<EOT > .npmrc
devdir=${NPM_CACHE_DIR}/.node-gyp
init-module=${NPM_CACHE_DIR}/.npm-init.js
cache=${NPM_CACHE_DIR}
tmp=${NPM_TMP_DIR}
EOT

# install node dependencies
npm install
36 changes: 36 additions & 0 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh
# set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail

# Supported/used environment variables:
# AUTH Set to enable authentication. Defaults to "noauth"
# SSL Set to enable SSL. Defaults to "nossl"
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
# MARCH Machine Architecture. Defaults to lowercase uname -m

AUTH=${AUTH:-noauth}
SSL=${SSL:-nossl}
MONGODB_URI=${MONGODB_URI:-}
DRIVERS_TOOLS=${DRIVERS_TOOLS:-}
MONGODB_VERSION=${MONGODB_VERSION:-}

# install MongoDB
# Functions to fetch MongoDB binaries
. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh

get_distro
if [ -z "$MONGODB_DOWNLOAD_URL" ]; then
get_mongodb_download_url_for "$DISTRO" "$MONGODB_VERSION"
fi
# Even though we have the MONGODB_DOWNLOAD_URL, we still call this to get the proper EXTRACT variable
get_mongodb_download_url_for "$DISTRO"
download_and_extract "$MONGODB_DOWNLOAD_URL" "$EXTRACT"

# run tests
echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI"

export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
MONGODB_VERSION=${MONGODB_VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --local
1 change: 1 addition & 0 deletions lib/connection/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ function stateTransition(self, newState) {
// Get current state
var legalStates = legalTransitions[self.state];
if (legalStates && legalStates.indexOf(newState) !== -1) {
self.emit('stateChanged', self.state, newState);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a bug that needs to be fixed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was actually using this to determine when the pool was destroyed, before I opted to use connection spies. It's a harmless addition, but adds flexibility to the design (it's a no-op if nobody is listening) so I'd opt for keeping it in.

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets make sure that when we squash, this is a separate commit so we can track it.

self.state = newState;
} else {
self.logger.error(
Expand Down
5 changes: 5 additions & 0 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
const ConfigurationBase = require('mongodb-test-runner').ConfigurationBase;
const f = require('util').format;

const chai = require('chai');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we are adding these things in?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was actually glad to have found this, we often have cases where we expect(err).to.not.exist, however if it does it shows something like Expected { Object(namespace, message) } to be null which is not helpful at all. The truncation configuration option here expands to show the full message. The other options here are just the defaults, but I'm otherwise codifying that we are indeed using the defaults.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this sounds useful. Like I said above though, lets make sure it is a separate commit when we squash.

chai.config.includeStack = true;
chai.config.showDiff = true;
chai.config.truncateThreshold = 0;

// Configuration for mongodb-core
class CoreConfiguration extends ConfigurationBase {
constructor(options) {
Expand Down
33 changes: 29 additions & 4 deletions test/environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const ReplSetManager = topologyManagers.ReplSet;
const ShardingManager = topologyManagers.Sharded;

class ReplicaSetEnvironment extends EnvironmentBase {
static get displayName() {
return 'replicaset';
}

constructor() {
super();

Expand Down Expand Up @@ -37,11 +41,11 @@ class ReplicaSetEnvironment extends EnvironmentBase {
'mongod',
[
genReplsetConfig(31000, { tags: { loc: 'ny' } }),
genReplsetConfig(31000, { tags: { loc: 'sf' } }),
genReplsetConfig(31001, { tags: { loc: 'sf' } }),
genReplsetConfig(31002, { tags: { loc: 'sf' } }),
genReplsetConfig(31003, { tags: { loc: 'sf' } }),
genReplsetConfig(31000, { tags: { loc: 'sf' } }),
genReplsetConfig(31000, { arbiter: true })
genReplsetConfig(31004, { tags: { loc: 'sf' } }),
genReplsetConfig(31005, { arbiter: true })
],
{
replSet: 'rs'
Expand Down Expand Up @@ -78,6 +82,10 @@ const genConfigServerConfig = (port, options) => {
};

class ShardedEnvironment extends EnvironmentBase {
static get displayName() {
return 'sharded';
}

constructor() {
super();

Expand Down Expand Up @@ -148,6 +156,10 @@ class ShardedEnvironment extends EnvironmentBase {
}

class AuthEnvironment extends EnvironmentBase {
static get displayName() {
return 'auth';
}

constructor() {
super();

Expand All @@ -161,6 +173,10 @@ class AuthEnvironment extends EnvironmentBase {
}

class SingleEnvironment extends EnvironmentBase {
static get displayName() {
return 'single';
}

constructor() {
super();

Expand All @@ -173,6 +189,10 @@ class SingleEnvironment extends EnvironmentBase {
}

class SnappyEnvironment extends EnvironmentBase {
static get displayName() {
return 'snappy';
}

constructor() {
super();

Expand All @@ -190,5 +210,10 @@ module.exports = {
replicaset: ReplicaSetEnvironment,
sharded: ShardedEnvironment,
auth: AuthEnvironment,
snappy: SnappyEnvironment
snappy: SnappyEnvironment,

// for compatability with evergreen template
server: SingleEnvironment,
replica_set: ReplicaSetEnvironment,
sharded_cluster: ShardedEnvironment
};
4 changes: 3 additions & 1 deletion test/tests/functional/basic_single_server_auth_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var expect = require('chai').expect,
Connection = require('../../../lib/connection/connection'),
Bson = require('bson');

describe('Basic single server auth tests', function() {
// Skipped due to use of topology manager
describe.skip('Basic single server auth tests', function() {
it('should fail to authenticate server using scram-sha-1 using connect auth', {
metadata: { requires: { topology: 'auth' } },

Expand Down Expand Up @@ -56,6 +57,7 @@ describe('Basic single server auth tests', function() {
}
});

// Skipped due to use of topology manager
it('should correctly authenticate server using scram-sha-1 using connect auth', {
metadata: { requires: { topology: 'auth' } },

Expand Down
3 changes: 2 additions & 1 deletion test/tests/functional/client_metadata_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ describe('Client metadata tests', function() {
}
});

it('should correctly pass the configuration settings to replset', {
// Skipped due to use of topology manager
it.skip('should correctly pass the configuration settings to replset', {
metadata: { requires: { topology: 'replicaset' } },

test: function(done) {
Expand Down
16 changes: 9 additions & 7 deletions test/tests/functional/cursor_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ describe('Cursor tests', function() {
}
});

it('Should fail cursor correctly after server restart', {
// Skipped due to usage of the topology manager
it.skip('Should fail cursor correctly after server restart', {
metadata: {
requires: { topology: ['single'] }
},
Expand Down Expand Up @@ -582,7 +583,8 @@ describe('Cursor tests', function() {
}
});

it('should not hang if autoReconnect=false and pools sockets all timed out', {
// NOTE: a notoriously flakey test, needs rewriting
it.skip('should not hang if autoReconnect=false and pools sockets all timed out', {
metadata: { requires: { topology: ['single'] } },
test: function(done) {
var configuration = this.configuration,
Expand All @@ -595,15 +597,15 @@ describe('Cursor tests', function() {
port: configuration.port,
bson: new bson(),
// Nasty edge case: small timeout, small pool, no auto reconnect
socketTimeout: 100,
socketTimeout: 250,
size: 1,
reconnect: false
});

var ns = f('%s.cursor7', configuration.db);
server.on('connect', function(_server) {
server.on('connect', function() {
// Execute the write
_server.insert(
server.insert(
ns,
[{ a: 1 }],
{
Expand All @@ -615,7 +617,7 @@ describe('Cursor tests', function() {
expect(results.result.n).to.equal(1);

// Execute slow find
var cursor = _server.cursor(ns, {
var cursor = server.cursor(ns, {
find: ns,
query: { $where: 'sleep(250) || true' },
batchSize: 1
Expand All @@ -625,7 +627,7 @@ describe('Cursor tests', function() {
cursor.next(function(err) {
expect(err).to.exist;

cursor = _server.cursor(ns, {
cursor = server.cursor(ns, {
find: ns,
query: {},
batchSize: 1
Expand Down
Loading