|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# sets up an encrypted mongodb cluster |
| 4 | + |
| 5 | +if [ -d "encrypted-cluster" ]; then |
| 6 | + cd encrypted-cluster |
| 7 | +else |
| 8 | + mkdir encrypted-cluster |
| 9 | + cd encrypted-cluster |
| 10 | + |
| 11 | + if [-d drivers-evergreen-tools]; then |
| 12 | + git clone --depth=1 "https://github.com/mongodb-labs/drivers-evergreen-tools.git" |
| 13 | + fi |
| 14 | + |
| 15 | + export DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools |
| 16 | + export MONGODB_VERSION=8.0 |
| 17 | + export AUTH=true |
| 18 | + export MONGODB_BINARIES=$DRIVERS_TOOLS/mongodb/bin |
| 19 | + export NODE_DRIVER=~/dev/node-mongodb-native |
| 20 | + export MONGO_ORCHESTRATION_HOME=$DRIVERS_TOOLS/mo |
| 21 | + export PROJECT_ORCHESTRATION_HOME=$DRIVERS_TOOLS/.evergreen/orchestration |
| 22 | + export TOPOLOGY=sharded_cluster |
| 23 | + export SSL=nossl |
| 24 | + |
| 25 | + cd $DRIVERS_TOOLS |
| 26 | + rm -rf mongosh mongodb mo |
| 27 | + mkdir mo |
| 28 | + cd - |
| 29 | + |
| 30 | + rm expansions.sh 2> /dev/null |
| 31 | + |
| 32 | + bash $DRIVERS_TOOLS/.evergreen/run-orchestration.sh |
| 33 | +fi |
| 34 | + |
| 35 | +# IMPORTANT: extracts mongodb-uri, and starts the cluster of servers, store the uri for GitHub output |
| 36 | + |
| 37 | +read -r -d '' SOURCE_SCRIPT << EOM |
| 38 | +const fs = require('fs'); |
| 39 | +const file = fs.readFileSync('mo-expansion.yml', { encoding: 'utf-8' }) |
| 40 | + .trim().split('\\n'); |
| 41 | +const regex = /^(?<key>.*): "(?<value>.*)"$/; |
| 42 | +const variables = file.map( |
| 43 | + (line) => regex.exec(line.trim()).groups |
| 44 | +).map( |
| 45 | + ({key, value}) => \`export \${key}='\${value}'\` |
| 46 | +).join('\n'); |
| 47 | +
|
| 48 | +process.stdout.write(variables); |
| 49 | +process.stdout.write('\n'); |
| 50 | +EOM |
| 51 | + |
| 52 | +node --eval "$SOURCE_SCRIPT" | tee expansions.sh |
| 53 | +source expansions.sh |
| 54 | + |
| 55 | +export MONGOOSE_TEST_URI=$MONGODB_URI |
| 56 | + |
| 57 | +npm run test-encryption |
0 commit comments