From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (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 0987C46970E for ; Mon, 30 Dec 2019 06:09:05 +0300 (MSK) Date: Mon, 30 Dec 2019 06:09:04 +0300 From: Alexander Turenko Message-ID: <20191230030904.ajxcgod553i424e2@tkn_work_nb> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH v2 test-run 1/1] sql: add another way to change SQL default engine List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org > >> diff --git a/lib/tarantool_server.py b/lib/tarantool_server.py > >> index 6f71b5b..20a398e 100644 > >> --- a/lib/tarantool_server.py > >> +++ b/lib/tarantool_server.py > >> @@ -145,12 +145,19 @@ class LuaTest(Test): > >> return True > >> > >> engine = self.run_params['engine'] > >> - command = "pragma sql_default_engine='{}'".format(engine) > >> - result = self.send_command(command, ts, 'sql') > >> - result = result.replace('\r\n', '\n') > >> - if result != '---\n- row_count: 0\n...\n': > >> - sys.stdout.write(result) > >> - return False > >> + > >> + command_new = ("UPDATE \"_session_settings\" SET \"value\" = '{}' " + \ > >> + "WHERE \"name\" = 'sql_default_engine'").format(engine) > >> + result_new = self.send_command(command_new, ts, 'sql') > >> + result_new = result_new.replace('\r\n', '\n') > >> + > >> + command_old = "pragma sql_default_engine='{}'".format(engine) > >> + result_old = self.send_command(command_old, ts, 'sql') > >> + result_old = result_old.replace('\r\n', '\n') > >> + if result_new != '---\n- row_count: 1\n...\n': > >> + if result_old != '---\n- row_count: 0\n...\n': > >> + sys.stdout.write(result_old) > >> + return False > > > > I would make it like so: > > > > 1. Send "pragma ...", await a result. > > - If succeeds, return True. > > - Otherwise proceed with the step 2. > > 2. Send "UPDATE ...", await a result. > > - If succeeds, return True. > > - Otherwise return False. > > > Fixed. Ouch, occasionally I misdirected you. Sorry. I intend to say that we should send the new-style command first and only then (if it fails) send old-style "pragma ..." command. This way we'll optimize the case when the new tarantool is tested that will be most often case after some time. > > This way we'll save one extra hop on a fresh tarantool. Not so big > > overhead for an action that is run once for a test, but we can overcome > > it and pay nothing, so it looks worthful for me.