[CSHARP-4102] Configure LB for local testing Created: 17/Mar/22  Updated: 31/Mar/22

Status: Backlog
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Unknown
Reporter: Dmitry Lukyanov (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

For local testings with RS LB should be configured similar to below where "config1", "repl1", "repl2", "repl2" just folders in the data folder.

  1. Create config server:

mongod --configsvr --replSet test --dbpath config1 --bind_ip localhost --port 27217

2. Initialize config server:

rs.initiate( { _id: "test", configsvr: true, members: [ { _id: 0, host: "localhost:27217" } ] })

mongo should be launched with "–port 27217" argument

3. Create shard RSs:

mongod --shardsvr --replSet testing  --dbpath repl1 --bind_ip localhost --port 27218 --setParameter enableTestCommands=true
mongod --shardsvr --replSet testing  --dbpath repl2 --bind_ip localhost --port 27219 --setParameter enableTestCommands=true
mongod --shardsvr --replSet testing  --dbpath repl3 --bind_ip localhost --port 27220 --setParameter enableTestCommands=true

4. Initialize above rs:

rs.initiate( { _id: "testing", members: [ { _id: 0, host: "localhost:27218" }, { _id: 1, host: "localhost:27219" }, { _id: 2, host: "localhost:27220" }] })

mongo should be launched with "–port 27218" argument

5. Create mongos on default 27017 port:

mongos --configdb test/localhost:27217 --bind_ip localhost --setParameter enableTestCommands=1 --setParameter featureFlagLoadBalancer=true --setParameter loadBalancerPort=27050

6. Initialize cluster on mongos:

sh.addShard("testing/localhost:27218,localhost:27219,localhost:27220")
sh.enableSharding("test")

mongo should be launched with "–port 27017" argument.

7. nginx config should be:

#user  nobody;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
# pid        nginx/logs/nginx.pid;
events {
    worker_connections  1024;
}
stream {
    server {
        listen 8000;
        proxy_pass single_server_backend;
        proxy_protocol on;
    }
    server {
        listen 8001;
        proxy_pass multi_server_backend;
        proxy_protocol on;
    }
    upstream single_server_backend {
        server localhost:27050;
    }    
 
    upstream multi_server_backend {
        server localhost:27050;
    }    
}

starting nginx with: "start nginx" script.

Additionally we need to update our LB test runner connection strings here. It should be set to:

"MONGODB_URI" => "mongodb://localhost:8000?loadBalanced=true"
"MONGODB_URI_WITH_MULTIPLE_MONGOSES" => "mongodb://localhost:8001?loadBalanced=true"

The above creates sharded cluster with RS shards + config server and with single mongos.

The problem is that our tests mostly require multi mongos. So this check will skip RS tests in LB tests suite. For most of cases it's enough just to disable this check, but it will lead to flakiness of some tests. We should investigate how to configure multi mongos nginx configuration. The config configuration should be similar to what we had previously and that is described in this PR

 

 


Generated at Wed Feb 07 21:47:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.