From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id AE5B443D67A for ; Sun, 13 Oct 2019 18:04:33 +0300 (MSK) From: Vladislav Shpilevoy Date: Sun, 13 Oct 2019 17:09:28 +0200 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH test-run 1/1] Wait_upstream/downstream should be ready to nil info List-Id: Tarantool development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org Cc: tarantool-patches@freelists.org, avtikhon@tarantool.org, alexander.turenko@tarantool.org Wait_upstream/downstream are helper functions of a test-run object. They are used to wait until a certain state of upstream/downstream is reached such as error message, replication status. They take these attributes from box.info.replication[id].upstream/downstream, which sometimes can be nil, and it led to an error. Now these waiters check upstream/downstream for nil. The bug was discovered in Tarantool in replication/show_error_on_disconnect test: https://github.com/tarantool/tarantool/issues/4563. It appeared, because after my patch reconfiguration of replication with 0 quorum always returns immediately. And right after the reconfiguration the upstream/downstream may still do not exist. This is why test_run:wait_upstream/downstream might fail like this: [002] test_run:wait_upstream(other_id, {status = 'stopped', message_re = 'Missing'}) [002] --- [002] -- true [002] +- error: '.../Workspaces/gitlab/test/var/002_replication/test_run.lua:250: attempt [002] + to index local ''info'' (a nil value)' --- Branch: https://github.com/tarantool/test-run/tree/gerold103/gh-tarantool-4563-box.info.repl.upstream-nil Issue: https://github.com/tarantool/tarantool/issues/4563 test_run.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test_run.lua b/test_run.lua index 8f13491..09d53af 100644 --- a/test_run.lua +++ b/test_run.lua @@ -234,10 +234,15 @@ local function log_box_info_replication_cond(id, field, ok, info, opts) status = opts.status, message_re = opts.message_re, }) - local got = json.encode({ - status = info.status, - message = info.message, - }) + local got + if info then + got = json.encode({ + status = info.status, + message = info.message, + }) + else + got = json.encode('info is nil') + end log.info('wait_%s(%d, ...); exp = %s; got = %s; result = %s', field, id, exp, got, tostring(ok)) end @@ -247,7 +252,7 @@ local function gen_box_info_replication_cond(id, field, opts) local info = box.info.replication[id][field] local ok = true if opts.status ~= nil then - ok = ok and info.status == opts.status + ok = ok and info and info.status == opts.status end if opts.message_re ~= nil then -- regex match -- 2.21.0 (Apple Git-122)