|
1 | 1 | local fio = require('fio') |
2 | 2 | local json = require('json') |
3 | 3 | local urilib = require('uri') |
| 4 | +local yaml = require('yaml') |
4 | 5 |
|
5 | 6 | local t = require('luatest') |
6 | 7 | local g = t.group() |
@@ -492,6 +493,61 @@ g.after_test('test_no_socket_collision_with_duplicate_alias', function() |
492 | 493 | g.s2:drop() |
493 | 494 | end) |
494 | 495 |
|
| 496 | +g.test_net_box_uri_is_taken_from_matching_replicaset = function() |
| 497 | + local tempdir = fio.tempdir() |
| 498 | + local config_path = fio.pathjoin(tempdir, 'config.yaml') |
| 499 | + |
| 500 | + local config = { |
| 501 | + groups = { |
| 502 | + ['group-001'] = { |
| 503 | + replicasets = { |
| 504 | + ['rs-1'] = { |
| 505 | + iproto = { |
| 506 | + listen = {{ |
| 507 | + uri = 'unix/:./{{ instance_name }}.iproto' |
| 508 | + }}, |
| 509 | + }, |
| 510 | + instances = { |
| 511 | + ['router-1'] = {}, |
| 512 | + }, |
| 513 | + }, |
| 514 | + ['rs-2'] = { |
| 515 | + iproto = { |
| 516 | + listen = {{ |
| 517 | + uri = 'unix/:./{{ instance_name }}.iproto' |
| 518 | + }}, |
| 519 | + }, |
| 520 | + instances = { |
| 521 | + ['storage-1'] = {}, |
| 522 | + }, |
| 523 | + }, |
| 524 | + }, |
| 525 | + }, |
| 526 | + }, |
| 527 | + } |
| 528 | + |
| 529 | + local fh = fio.open(config_path, {'O_CREAT', 'O_WRONLY', 'O_TRUNC'}, |
| 530 | + tonumber('644', 8)) |
| 531 | + fh:write(yaml.encode(config)) |
| 532 | + fh:close() |
| 533 | + |
| 534 | + local s1 = Server:new({ |
| 535 | + alias = 'storage-1', |
| 536 | + config_file = config_path, |
| 537 | + }) |
| 538 | + local s2 = Server:new({ |
| 539 | + alias = 'router-1', |
| 540 | + config_file = config_path, |
| 541 | + }) |
| 542 | + |
| 543 | + t.assert_equals(s1.net_box_uri, 'unix/:nil/storage-1.iproto') |
| 544 | + t.assert_equals(s2.net_box_uri, 'unix/:nil/router-1.iproto') |
| 545 | + s1:drop() |
| 546 | + s2:drop() |
| 547 | + |
| 548 | + fio.rmtree(tempdir) |
| 549 | +end |
| 550 | + |
495 | 551 | g.test_netbox_uri_is_not_overridden = function() |
496 | 552 | local socket = ('%s/my-custom.sock'):format(Server.vardir) |
497 | 553 | g.s1 = Server:new({net_box_uri = socket}) |
|
0 commit comments