From 3de90cf52d1b4fba48d35a60ae38a88eb53ec5ba Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Wed, 30 Nov 2016 17:56:07 +0300
Subject: [PATCH] Fix assertion on invalid replication_source in box.cfg()

Fixes #1962
---
 src/box/box.cc            | 1 +
 test/box-tap/cfg.result   | 3 ++-
 test/box-tap/cfg.test.lua | 8 +++++++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/box/box.cc b/src/box/box.cc
index eed8cb5ce6..debf385a83 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -359,6 +359,7 @@ box_set_replication_source(void)
 		return;
 	}
 
+	box_check_replication_source();
 	box_sync_replication_source();
 
 	/* Start all replicas from the cluster registry */
diff --git a/test/box-tap/cfg.result b/test/box-tap/cfg.result
index 3b5da32a59..dffb9fbc88 100644
--- a/test/box-tap/cfg.result
+++ b/test/box-tap/cfg.result
@@ -1,5 +1,5 @@
 TAP version 13
-1..46
+1..47
 ok - box is not started
 ok - invalid slab_alloc_minimal
 ok - invalid slab_alloc_minimal
@@ -46,3 +46,4 @@ ok - dynamic listen
 ok - dynamic listen
 ok - reuse unix socket
 ok - delete socket at exit
+ok - invalid replication_source
diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua
index ac4198f996..51b1c6e8e7 100755
--- a/test/box-tap/cfg.test.lua
+++ b/test/box-tap/cfg.test.lua
@@ -4,7 +4,7 @@ local tap = require('tap')
 local test = tap.test('cfg')
 local socket = require('socket')
 local fio = require('fio')
-test:plan(46)
+test:plan(47)
 
 --------------------------------------------------------------------------------
 -- Invalid values
@@ -191,5 +191,11 @@ code = " box.cfg{ listen='unix/:'" .. path .. "' } "
 run_script(code)
 test:isnil(fio.stat(path), "delete socket at exit")
 
+--
+-- gh-1962: incorrect replication source
+--
+status, reason = pcall(box.cfg, {replication_source="3303,3304"})
+test:ok(not status and reason:match("Incorrect"), "invalid replication_source")
+
 test:check()
 os.exit(0)
-- 
GitLab