Skip to content

Commit 744f96b

Browse files
matthewdaleBenjamin Rewis
authored andcommitted
GODRIVER-2292 Support dedicated load balancer port in tests. (#852)
1 parent 7d50ea3 commit 744f96b

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
@@ -189,6 +189,7 @@ functions:
189189
SSL=${SSL} \
190190
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
191191
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
192+
LOAD_BALANCER=${LOAD_BALANCER} \
192193
sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
193194
- command: expansions.update
194195
params:
@@ -1446,6 +1447,7 @@ tasks:
14461447
TOPOLOGY: "sharded_cluster"
14471448
AUTH: "noauth"
14481449
SSL: "nossl"
1450+
LOAD_BALANCER: "true"
14491451
- func: run-load-balancer
14501452
- func: run-load-balancer-tests
14511453

@@ -1457,6 +1459,7 @@ tasks:
14571459
TOPOLOGY: "sharded_cluster"
14581460
AUTH: "auth"
14591461
SSL: "ssl"
1462+
LOAD_BALANCER: "true"
14601463
- func: run-load-balancer
14611464
- func: run-load-balancer-tests
14621465

@@ -1855,6 +1858,10 @@ axes:
18551858
display_name: "2.6"
18561859
variables:
18571860
VERSION: "2.6"
1861+
- id: "rapid"
1862+
display_name: "rapid"
1863+
variables:
1864+
VERSION: "rapid"
18581865
- id: "latest"
18591866
display_name: "latest"
18601867
variables:
@@ -2155,7 +2162,10 @@ buildvariants:
21552162

21562163
- matrix_name: "load-balancer-test"
21572164
# The LB software is only available on Ubuntu 18.04, so we don't test on all OSes.
2158-
matrix_spec: { version: ["5.0", "latest"], os-ssl-40: ["ubuntu1804-64-go-1-16"] }
2165+
# The new "loadBalancerPort" option is supported starting with server 5.2, which responds
2166+
# correctly to "hello" commands with a service ID when behind a load balancer. Only run load
2167+
# balancer tests on server 5.2+ ("rapid", "latest" are always 5.2+).
2168+
matrix_spec: { version: ["rapid", "latest"], os-ssl-40: ["ubuntu1804-64-go-1-16"] }
21592169
display_name: "Load Balancer Support ${version} ${os-ssl-40}"
21602170
tasks:
21612171
- name: ".load-balancer"

internal/const.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ package internal // import "go.mongodb.org/mongo-driver/internal"
99
// Version is the current version of the driver.
1010
var Version = "local build"
1111

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
16-
1712
// LegacyHello is the legacy version of the hello command.
1813
var LegacyHello = "isMaster"
1914

mongo/description/server.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,6 @@ func NewServer(addr address.Address, response bson.Raw) Server {
286286
desc.LastError = err
287287
return desc
288288
}
289-
290-
if internal.SetMockServiceID {
291-
desc.ServiceID = &desc.TopologyVersion.ProcessID
292-
}
293289
}
294290
}
295291

mongo/integration/initial_dns_seedlist_discovery_test.go

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

79+
// TODO(GODRIVER-2312): Unskip these tests when the DNS SRV records are updated to point to the
80+
// load balancer instead of directly to the mongos.
81+
if strings.HasSuffix(file, "load-balanced/loadBalanced-directConnection.json") ||
82+
strings.HasSuffix(file, "load-balanced/loadBalanced-true-txt.json") ||
83+
strings.HasSuffix(file, "load-balanced/srvMaxHosts-zero-txt.json") ||
84+
strings.HasSuffix(file, "load-balanced/srvMaxHosts-zero.json") {
85+
mt.Skip("skipping because the DNS SRV records need to be updated to work correctly (GODRIVER-2312)")
86+
}
87+
7988
cs, err := connstring.ParseAndValidate(test.URI)
8089
if test.Error {
8190
assert.NotNil(mt, err, "expected URI parsing error, got nil")
@@ -116,7 +125,7 @@ func runSeedlistDiscoveryTest(mt *mtest.T, file string) {
116125
}
117126
for _, host := range test.Hosts {
118127
_, err := getServerByAddress(host, topo)
119-
assert.Nil(mt, err, "did not find host %v", host)
128+
assert.Nil(mt, err, "error finding host %q: %v", host, err)
120129
}
121130
}
122131

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)