Skip to content

Commit e4487b4

Browse files
matthewdaleBenjamin Rewis
authored andcommitted
GODRIVER-2292 Support dedicated load balancer port in tests. (#852)
1 parent 19700d1 commit e4487b4

File tree

6 files changed

+21
-31
lines changed

6 files changed

+21
-31
lines changed

.evergreen/config.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ functions:
196196
SSL=${SSL} \
197197
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
198198
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
199+
LOAD_BALANCER=${LOAD_BALANCER} \
199200
sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
200201
- command: expansions.update
201202
params:
@@ -1386,6 +1387,7 @@ tasks:
13861387
TOPOLOGY: "sharded_cluster"
13871388
AUTH: "noauth"
13881389
SSL: "nossl"
1390+
LOAD_BALANCER: "true"
13891391
- func: run-load-balancer
13901392
- func: run-load-balancer-tests
13911393

@@ -1397,6 +1399,7 @@ tasks:
13971399
TOPOLOGY: "sharded_cluster"
13981400
AUTH: "auth"
13991401
SSL: "ssl"
1402+
LOAD_BALANCER: "true"
14001403
- func: run-load-balancer
14011404
- func: run-load-balancer-tests
14021405

@@ -1767,6 +1770,10 @@ axes:
17671770
display_name: "2.6"
17681771
variables:
17691772
VERSION: "2.6"
1773+
- id: "rapid"
1774+
display_name: "rapid"
1775+
variables:
1776+
VERSION: "rapid"
17701777
- id: "latest"
17711778
display_name: "latest"
17721779
variables:
@@ -2017,7 +2024,10 @@ buildvariants:
20172024

20182025
- matrix_name: "load-balancer-test"
20192026
# The LB software is only available on Ubuntu 18.04, so we don't test on all OSes.
2020-
matrix_spec: { version: ["5.0", "latest"], os-ssl-40: ["ubuntu1804-64-go-1-16"] }
2027+
# The new "loadBalancerPort" option is supported starting with server 5.2, which responds
2028+
# correctly to "hello" commands with a service ID when behind a load balancer. Only run load
2029+
# balancer tests on server 5.2+ ("rapid", "latest" are always 5.2+).
2030+
matrix_spec: { version: ["rapid", "latest"], os-ssl-40: ["ubuntu1804-64-go-1-16"] }
20212031
display_name: "Load Balancer Support ${version} ${os-ssl-40}"
20222032
tasks:
20232033
- name: ".load-balancer"

internal/const.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,3 @@ package internal // import "go.mongodb.org/mongo-driver/internal"
88

99
// Version is the current version of the driver.
1010
var Version = "local build"
11-
12-
// SetMockServiceID enables a mode in which the driver mocks server support for returning a "serviceId" field in "hello"
13-
// command responses by using the value of "topologyVersion.processId". This is used for testing load balancer support
14-
// until an upstream service can support running behind a load balancer.
15-
var SetMockServiceID = false

mongo/description/server.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,6 @@ func NewServer(addr address.Address, response bson.Raw) Server {
272272
desc.LastError = err
273273
return desc
274274
}
275-
276-
if internal.SetMockServiceID {
277-
desc.ServiceID = &desc.TopologyVersion.ProcessID
278-
}
279275
}
280276
}
281277

mongo/integration/initial_dns_seedlist_discovery_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ func runSeedlistDiscoveryTest(mt *mtest.T, file string) {
7171
mt.Skip("skipping to avoid go1.11 problem with multiple strings in one TXT record")
7272
}
7373

74+
// TODO(GODRIVER-2312): Unskip these tests when the DNS SRV records are updated to point to the
75+
// load balancer instead of directly to the mongos.
76+
if strings.HasSuffix(file, "load-balanced/loadBalanced-directConnection.json") ||
77+
strings.HasSuffix(file, "load-balanced/loadBalanced-true-txt.json") ||
78+
strings.HasSuffix(file, "load-balanced/srvMaxHosts-zero-txt.json") ||
79+
strings.HasSuffix(file, "load-balanced/srvMaxHosts-zero.json") {
80+
mt.Skip("skipping because the DNS SRV records need to be updated to work correctly (GODRIVER-2312)")
81+
}
82+
7483
cs, err := connstring.ParseAndValidate(test.URI)
7584
if test.Error {
7685
assert.NotNil(mt, err, "expected URI parsing error, got nil")
@@ -97,7 +106,7 @@ func runSeedlistDiscoveryTest(mt *mtest.T, file string) {
97106

98107
for _, host := range test.Hosts {
99108
_, err := getServerByAddress(host, topo)
100-
assert.Nil(mt, err, "did not find host %v", host)
109+
assert.Nil(mt, err, "error finding host %q: %v", host, err)
101110
}
102111
}
103112

mongo/integration/main_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,12 @@ package integration
99
import (
1010
"log"
1111
"os"
12-
"strings"
1312
"testing"
1413

15-
"go.mongodb.org/mongo-driver/internal"
1614
"go.mongodb.org/mongo-driver/mongo/integration/mtest"
1715
)
1816

1917
func TestMain(m *testing.M) {
20-
// If the cluster is behind a load balancer, enable the SetMockServiceID flag to mock server-side LB support.
21-
if strings.Contains(os.Getenv("MONGODB_URI"), "loadBalanced=true") {
22-
internal.SetMockServiceID = true
23-
defer func() {
24-
internal.SetMockServiceID = false
25-
}()
26-
}
27-
2818
if err := mtest.Setup(); err != nil {
2919
log.Fatal(err)
3020
}

mongo/integration/unified/main_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,12 @@ package unified
99
import (
1010
"log"
1111
"os"
12-
"strings"
1312
"testing"
1413

15-
"go.mongodb.org/mongo-driver/internal"
1614
"go.mongodb.org/mongo-driver/mongo/integration/mtest"
1715
)
1816

1917
func TestMain(m *testing.M) {
20-
// If the cluster is behind a load balancer, enable the SetMockServiceID flag to mock server-side LB support.
21-
if strings.Contains(os.Getenv("MONGODB_URI"), "loadBalanced=true") {
22-
internal.SetMockServiceID = true
23-
defer func() {
24-
internal.SetMockServiceID = false
25-
}()
26-
}
27-
2818
if err := mtest.Setup(); err != nil {
2919
log.Fatal(err)
3020
}

0 commit comments

Comments
 (0)