Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Jan 4, 2024
1 parent 10bd0ef commit 545c404
Show file tree
Hide file tree
Showing 34 changed files with 155 additions and 67 deletions.
5 changes: 3 additions & 2 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ timeout:
ls -la
functions:
fetch-source:
# Executes git clone and applies the submitted patch, if any
# Executes clone and applies the submitted patch, if any
- command: git.get_project
type: system
params:
Expand Down Expand Up @@ -1522,8 +1522,8 @@ tasks:
- func: run-atlas-data-lake-test

- name: test-docker-runner
tags: ["pullrequest"]
commands:
- func: bootstrap-mongo-orchestration
- func: run-docker-test

- name: test-load-balancer-noauth-nossl
Expand Down Expand Up @@ -2579,6 +2579,7 @@ buildvariants:
- name: "test-atlas-data-lake"

- name: docker-runner-test
tags: ["pullrequest"]
display_name: "Docker Runner Test"
run_on:
- ubuntu2204-large
Expand Down
1 change: 0 additions & 1 deletion .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ fi

export GOROOT="${GOROOT}"
export PATH="${GOROOT}/bin:${GCC_PATH}:$GOPATH/bin:$PATH"
export PATH="${MONGODB_BINARIES:-$DRIVERS_TOOLS/mongodb/bin}:$PATH"
export PROJECT="${project}"
export PKG_CONFIG_PATH=$(pwd)/install/libmongocrypt/lib64/pkgconfig:$(pwd)/install/mongo-c-driver/lib/pkgconfig
export LD_LIBRARY_PATH=$(pwd)/install/libmongocrypt/lib64
Expand Down
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ COPY etc/install-libmongocrypt.sh /root/install-libmongocrypt.sh
RUN cd /root && bash ./install-libmongocrypt.sh


# Inherit from the drivers-evergreen-tools image and copy in the files
# from the libmongocrypt build stage.
FROM drivers-evergreen-tools
# Copy in the files from the libmongocrypt build stage.
FROM ubuntu:20.04

# Install common deps.
RUN export DEBIAN_FRONTEND=noninteractive && \
export TZ=Etc/UTC && \
apt-get -qq update && \
apt-get -qqy install --reinstall --no-install-recommends \
git \
ca-certificates \
curl \
wget \
sudo \
tzdata \
ca-certificates \
pkg-config \
Expand All @@ -50,4 +54,6 @@ COPY ./etc/docker_entry.sh /root/docker_entry.sh

COPY --from=libmongocrypt /root/install /root/install

ENV DOCKER_RUNNING=true

ENTRYPOINT ["/bin/bash", "/root/docker_entry.sh"]
41 changes: 39 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,56 @@ The usage of host.docker.internal comes from the [Docker networking documentatio

There is currently no arm64 support for the go1.x runtime, see [here](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html). Known issues running on linux/arm64 include the inability to network with the localhost from the public.ecr.aws/lambda/go Docker image.

### Load Balancer

To launch the load balancer on MacOS, run the following.

- `brew install haproxy`
- Clone drivers-evergreen-tools and save the path as `DRIVERS_TOOLS`.
- Start the servers using (or use the docker-based method below):

```bash
LOAD_BALANCER=true TOPOLOGY=sharded_cluster AUTH=noauth SSL=nossl MONGODB_VERSION=6.0 DRIVERS_TOOLS=$PWD/drivers-evergreen-tools MONGO_ORCHESTRATION_HOME=$PWD/drivers-evergreen-tools/.evergreen/orchestration $PWD/drivers-evergreen-tools/.evergreen/run-orchestration.sh
```

- Start the load balancer using:

```bash
MONGODB_URI='mongodb://localhost:27017,localhost:27018/' $PWD/drivers-evergreen-tools/.evergreen/run-load-balancer.sh start
```

- Run the load balancer tests (or use the docker runner below with `evg-test-load-balancers`):

```bash
make evg-test-load-balancers
```

### Testing in Docker

We support local testing in Docker. To test using docker, you will need to set the `DRIVERS_TOOLs` environment variable to point to a local clone of the drivers-evergreen-tools repository. This is essential for running the testing matrix in a container. You can set the `DRIVERS_TOOLS` variable in your shell profile or in your project-specific environment.

1. First, start the drivers-tools server docker container, as:

```bash
bash $DRIVERS_TOOLS/.evergreen/docker/start-server.sh
```

See the readme in `$DRIVERS_TOOLS/.evergreen/docker` for more information on usage.

2. Next, start any other required services in another terminal, like a load balancer.

1. Finally, run the Go Driver tests using the following script in this repo:

```bash
bash etc/run_docker.sh
```

The script takes an optional argument for the `MAKEFILE_TARGET` and allows for some environment variable overrides.
The docker container has the required binaries, including libmongocrypt.
The entry script starts a MongoDB topology, and then executes the desired `MAKEFILE_TARGET`.
The entry script executes the desired `MAKEFILE_TARGET`.

For example, to test against a sharded cluster, using enterprise auth, run:
For example, to test against a sharded cluster (make sure you started the server with a sharded_cluster),
using enterprise auth, run:

```bash
TOPOLOGY=sharded_cluster bash etc/run_docker.sh evg-test-enterprise-auth
Expand Down
7 changes: 2 additions & 5 deletions etc/docker_entry.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#!/usr/bin/env bash
#
# Entry point for Dockerfile for launching a server and running a go test.
# Entry point for Dockerfile for running a go test.
#
set -eux

# Start the server.
bash /root/base-entrypoint.sh
source $DRIVERS_TOOLS/.evergreen/mo-expansion.sh

# Prep files.
cd /src
rm -f test.suite
cp -r $HOME/install ./install

export PATH="$MONGODB_BINARIES:$PATH"

# Run the test.
Expand Down
24 changes: 4 additions & 20 deletions etc/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,17 @@ if [ -z "$DRIVERS_TOOLS" ]; then
exit 1
fi
PLATFORM=${DOCKER_PLATFORM:-}

pushd $DRIVERS_TOOLS/.evergreen/docker/ubuntu20.04
docker build $PLATFORM -t drivers-evergreen-tools .
popd
docker build $PLATFORM -t go-test .

# Handle environment variables and optional positional arg for the makefile target.

MAKEFILE_TARGET=${1:-evg-test-versioned-api}
MONGODB_VERSION=${MONGODB_VERSION:-latest}
TOPOLOGY=${TOPOLOGY:-replica_set}
ORCHESTRATION_FILE=${ORCHESTRATION_FILE:-basic.json}
AUTH=${AUTH:-""}
SSL=${SSL:=""}
GO_BUILD_TAGS=${GO_BUILD_TAGS:-""}

ENV="-e MONGODB_VERSION=$MONGODB_VERSION -e TOPOLOGY=$TOPOLOGY"
ENV="$ENV -e MAKEFILE_TARGET=$MAKEFILE_TARGET -e AUTH=$AUTH"
ENV="$ENV -e ORCHESTRATION_FILE=$ORCHESTRATION_FILE -e SSL=$SSL"
ENV="$ENV -e GO_BUILD_TAGS=$GO_BUILD_TAGS"

VOL="-v `pwd`:/src"
VOL="$VOL -v $DRIVERS_TOOLS:/root/drivers-evergreen-tools"
USE_TTY=""
test -t 1 && USE_TTY="-t"
ARGS=" -e MAKEFILE_TARGET=$MAKEFILE_TARGET"
ARGS="$ARGS -e GO_BUILD_TAGS=$GO_BUILD_TAGS"
ARGS="$ARGS go-test"

docker run $PLATFORM --rm $VOL $ENV -i $USE_TTY go-test
$DRIVERS_TOOLS/.evergreen/docker/run-client.sh $ARGS
if [ -f "test.suite" ]; then
tail test.suite
fi
2 changes: 1 addition & 1 deletion event/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package event // import "go.mongodb.org/mongo-driver/event"
package event

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion internal/benchmark/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package benchmark // import "go.mongodb.org/mongo-driver/benchmark"
package benchmark

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion internal/integration/mtest/opmsg_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

const (
serverAddress = address.Address("localhost:27017")
serverAddress = address.Address("127.0.0.1:27017")
maxDocumentSize uint32 = 16777216
maxMessageSize uint32 = 48000000
maxBatchCount uint32 = 100000
Expand Down
2 changes: 1 addition & 1 deletion mongo/address/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

// Package address provides structured representations of network addresses.
package address // import "go.mongodb.org/mongo-driver/mongo/address"
package address

import (
"net"
Expand Down
3 changes: 3 additions & 0 deletions mongo/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ func TestClient(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test in short mode")
}
if os.Getenv("DOCKER_RUNNING") != "" {
t.Skip("skipping test in docker environment")
}

t.Run(tc.name, func(t *testing.T) {
// Setup a client and skip the test based on server version.
Expand Down
2 changes: 1 addition & 1 deletion mongo/description/description.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

// Package description contains types and functions for describing the state of MongoDB clusters.
package description // import "go.mongodb.org/mongo-driver/mongo/description"
package description

// Unknown is an unknown server or topology kind.
const Unknown = 0
2 changes: 1 addition & 1 deletion mongo/gridfs/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package gridfs // import "go.mongodb.org/mongo-driver/mongo/gridfs"
package gridfs

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package mongo // import "go.mongodb.org/mongo-driver/mongo"
package mongo

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion mongo/options/clientoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package options // import "go.mongodb.org/mongo-driver/mongo/options"
package options

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion mongo/readconcern/readconcern.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// For more information about MongoDB read concerns, see
// https://www.mongodb.com/docs/manual/reference/read-concern/
package readconcern // import "go.mongodb.org/mongo-driver/mongo/readconcern"
package readconcern

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion mongo/readpref/readpref.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

// Package readpref defines read preferences for MongoDB queries.
package readpref // import "go.mongodb.org/mongo-driver/mongo/readpref"
package readpref

import (
"bytes"
Expand Down
4 changes: 4 additions & 0 deletions mongo/with_transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"math"
"os"
"strconv"
"strings"
"testing"
Expand All @@ -37,6 +38,9 @@ func TestConvenientTransactions(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test in short mode")
}
if os.Getenv("DOCKER_RUNNING") != "" {
t.Skip("skipping test in docker environment")
}

client := setupConvenientTransactions(t)
db := client.Database("TestConvenientTransactions")
Expand Down
2 changes: 1 addition & 1 deletion mongo/writeconcern/writeconcern.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// For more information about MongoDB write concerns, see
// https://www.mongodb.com/docs/manual/reference/write-concern/
package writeconcern // import "go.mongodb.org/mongo-driver/mongo/writeconcern"
package writeconcern

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion tag/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// For more information about read preference tags, see
// https://www.mongodb.com/docs/manual/core/read-preference-tags/
package tag // import "go.mongodb.org/mongo-driver/tag"
package tag

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"uri": "mongodb+srv://TEST1.TEST.BUILD.10GEN.CC",
"seeds": [
"localhost.test.build.10gen.cc:27017",
"localhost.test.build.10gen.cc:27018"
],
"hosts": [
"localhost:27017",
"localhost:27018",
"localhost:27019"
],
"options": {
"ssl": true
},
"ping": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
uri: "mongodb+srv://TEST1.TEST.BUILD.10GEN.CC"
seeds:
- localhost.test.build.10gen.cc:27017
- localhost.test.build.10gen.cc:27018
hosts:
- localhost:27017
- localhost:27018
- localhost:27019
options:
ssl: true
ping: true
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

// Package version defines the Go Driver version.
package version // import "go.mongodb.org/mongo-driver/version"
package version

// Driver is the current version of the driver.
var Driver = "v2.0.0-prerelease"
2 changes: 1 addition & 1 deletion x/bsonx/bsoncore/bsoncore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package bsoncore // import "go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
package bsoncore

import (
"bytes"
Expand Down
3 changes: 1 addition & 2 deletions x/mongo/driver/auth/scram.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ package auth

import (
"context"
"fmt"

"github.com/xdg-go/scram"
"github.com/xdg-go/stringprep"
Expand Down Expand Up @@ -53,7 +52,7 @@ func newScramSHA1Authenticator(cred *Cred) (Authenticator, error) {
func newScramSHA256Authenticator(cred *Cred) (Authenticator, error) {
passprep, err := stringprep.SASLprep.Prepare(cred.Password)
if err != nil {
return nil, newAuthError(fmt.Sprintf("error SASLprepping password '%s'", cred.Password), err)
return nil, newAuthError("error SASLprepping password", err)
}
client, err := scram.SHA256.NewClientUnprepped(cred.Username, passprep, "")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/mongo/driver/connstring/connstring.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package connstring // import "go.mongodb.org/mongo-driver/x/mongo/driver/connstring"
package connstring

import (
"errors"
Expand Down
Loading

0 comments on commit 545c404

Please sign in to comment.