Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tLhve-00GTio-Sf for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2024 12:04:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tLhvb-00AZC0-TK for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2024 12:04:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tLhvb-00AZBl-4j for pgsql-hackers@lists.postgresql.org; Thu, 12 Dec 2024 12:04:24 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tLhvZ-002RKl-4N for pgsql-hackers@lists.postgresql.org; Thu, 12 Dec 2024 12:04:23 +0000 Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id 81B3C1140196; Thu, 12 Dec 2024 07:04:19 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Thu, 12 Dec 2024 07:04:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1734005059; x=1734091459; bh=Qc8iFX16op nMMneKBLDFKllcyfQhg+EbOHzd+y4b+6E=; b=PoPkjmyOR5lkzMcT8ILypUuQWk tWmcHFJ5jvSaCC3mSAKyMXso0iYE3/CWGo3SKLNYp1fPg/n+qSynieBmhxbJQ1oX Vpo+fraprxA2n3vgejtLBpvFh6pSZdLVljESfMcUVXKzGOh91nP41Q296SJ4lDAb DqHwSfrUfmxJNXhuZvyuj41ZsQDnZjed/ATx8jm3Z8T5exDvxGoI47hkTm1WYZyI aEpHG/xMrOxesK/Ao4h3xHAKxxztixcQ9dhPi3qRf2x1FyxU/8GQHFH4J3yjPGax QJk7s7KpLF4IG1mSlmfcbchK6V4+q42TwW1wT6ipF2MGW0ZbrTvfkMP7ovlw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1734005059; x=1734091459; bh=Qc8iFX16opnMMneKBLDFKllcyfQhg+EbOHz d+y4b+6E=; b=k9vqdZSlss/9nFdLORa3JSDo+U9S5IAFmUuhn+RwyWDlQA9DSiV 0kwzETN8HPWrSEK7mcuLOnyudo4Wd1qG2xnQ/TaczLUEEfd3GD9nFOEDs4lrtTuF u6gi1IUEk3XUxh0BVCND48pR3eONmM8oVRuDs97e0J2jBF+ckBRZsUPQq4J9srV4 f5nxPGmHE8/MA5A1o5857IYY8ykGzhncq64JhJJXlCUgm98S6b86MsYTp42MTMDx ljwmK/t6C8kC86xfJBkGncGMgztWhi7GrUbjPum5kgaZIQ2ybRBqjVm1Rbe+oOR8 Na6HvNN8NwRJsLNbLxj6XRW3FKSDEpLRSFQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrkeehgdefgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhvfevufhfffgjkfgfgggtsehmtderredtreejnecu hfhrohhmpeffrghgfhhinhhnucfklhhmrghrihcuofgrnhhnshonkhgvrhcuoehilhhmrg hrihesihhlmhgrrhhirdhorhhgqeenucggtffrrghtthgvrhhnpedvvdfhhedtfeekudfg tedufeehgffggeejieejheeugfethefggedtleegteetjeenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehilhhmrghrihesihhlmhgrrhhirdho rhhgpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhope hpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdp rhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruhhspdhrtghpthhtohepmhhitg hhrggvlhesphgrqhhuihgvrhdrgiihiidprhgtphhtthhopehsmhhithhhphgsvddvhedt sehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Dec 2024 07:04:18 -0500 (EST) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Peter Smith Cc: Michael Paquier , Tom Lane , PostgreSQL Hackers Subject: Re: pg_createsubscriber TAP test wrapping makes command options hard to read. References: <556792.1733967676@sss.pgh.pa.us> <564915.1733971586@sss.pgh.pa.us> Date: Thu, 12 Dec 2024 12:04:16 +0000 In-Reply-To: (Peter Smith's message of "Thu, 12 Dec 2024 15:24:42 +1100") Message-ID: <87pllx5cqn.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Peter Smith writes: > On Thu, Dec 12, 2024 at 2:53 PM Michael Paquier wrote: > ... > >> > So, AFAICT I can workaround the perltidy wrapping just by putting all >> > the noarg options at the bottom of the command, then all the >> > option/optarg pairs (ie 2s) will stay together. I can post another >> > patch to do it this way unless you think it is too hacky. >> >> This trick works for me if that makes the long list of option easier >> to read. With two elements of the array perl line, I would just put >> some --dry-run or --verbose at the end of their respective arrays. >> -- >> Michael > > Hi Michael. > > Yes, that is the workaround that I was proposing. A better option, IMO, is to use the fat comma (=>) between options and their values. This makes it clear both to humans and perltidy that they belong together, and we can put all the valueless options first without things being rewrapped. - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v3-0001-Modify-wrapping-to-make-command-options-easier-to.patch From e972f1a5f87499390f401e7db2c079fb87533553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Thu, 12 Dec 2024 11:56:15 +0000 Subject: [PATCH v3] Modify wrapping to make command options easier to read Use fat comma after options that take values, both to make it clearer to humans, and to stop perltidy from re-wrapping them. --- .../t/040_pg_createsubscriber.pl | 169 +++++++++--------- 1 file changed, 89 insertions(+), 80 deletions(-) diff --git a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl index 0a900edb656..0f7bb103177 100644 --- a/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl +++ b/src/bin/pg_basebackup/t/040_pg_createsubscriber.pl @@ -168,41 +168,44 @@ sub generate_db # Run pg_createsubscriber on a promoted server command_fails( [ - 'pg_createsubscriber', '--verbose', - '--dry-run', '--pgdata', - $node_t->data_dir, '--publisher-server', - $node_p->connstr($db1), '--socketdir', - $node_t->host, '--subscriber-port', - $node_t->port, '--database', - $db1, '--database', - $db2 + 'pg_createsubscriber', + '--verbose', + '--dry-run', + '--pgdata' => $node_t->data_dir, + '--publisher-server' => $node_p->connstr($db1), + '--socketdir' => $node_t->host, + '--subscriber-port' => $node_t->port, + '--database' => $db1, + '--database' => $db2, ], 'target server is not in recovery'); # Run pg_createsubscriber when standby is running command_fails( [ - 'pg_createsubscriber', '--verbose', - '--dry-run', '--pgdata', - $node_s->data_dir, '--publisher-server', - $node_p->connstr($db1), '--socketdir', - $node_s->host, '--subscriber-port', - $node_s->port, '--database', - $db1, '--database', - $db2 + 'pg_createsubscriber', + '--verbose', + '--dry-run', + '--pgdata' => $node_s->data_dir, + '--publisher-server' => $node_p->connstr($db1), + '--socketdir' => $node_s->host, + '--subscriber-port' => $node_s->port, + '--database' => $db1, + '--database' => $db2, ], 'standby is up and running'); # Run pg_createsubscriber on about-to-fail node F command_fails( [ - 'pg_createsubscriber', '--verbose', - '--pgdata', $node_f->data_dir, - '--publisher-server', $node_p->connstr($db1), - '--socketdir', $node_f->host, - '--subscriber-port', $node_f->port, - '--database', $db1, - '--database', $db2 + 'pg_createsubscriber', + '--verbose', + '--pgdata' => $node_f->data_dir, + '--publisher-server' => $node_p->connstr($db1), + '--socketdir' => $node_f->host, + '--subscriber-port' => $node_f->port, + '--database' => $db1, + '--database' => $db2 ], 'subscriber data directory is not a copy of the source database cluster'); @@ -216,14 +219,15 @@ sub generate_db # Run pg_createsubscriber on node C (P -> S -> C) command_fails( [ - 'pg_createsubscriber', '--verbose', - '--dry-run', '--pgdata', - $node_c->data_dir, '--publisher-server', - $node_s->connstr($db1), '--socketdir', - $node_c->host, '--subscriber-port', - $node_c->port, '--database', - $db1, '--database', - $db2 + 'pg_createsubscriber', + '--verbose', + '--dry-run', + '--pgdata' => $node_c->data_dir, + '--publisher-server' => $node_s->connstr($db1), + '--socketdir' => $node_c->host, + '--subscriber-port' => $node_c->port, + '--database' => $db1, + '--database' => $db2, ], 'primary server is in recovery'); @@ -239,14 +243,16 @@ sub generate_db $node_s->stop; command_fails( [ - 'pg_createsubscriber', '--verbose', - '--dry-run', '--pgdata', - $node_s->data_dir, '--publisher-server', - $node_p->connstr($db1), '--socketdir', - $node_s->host, '--subscriber-port', - $node_s->port, '--database', - $db1, '--database', - $db2 + 'pg_createsubscriber', + '--verbose', + '--dry-run', + '--pgdata' => $node_s->data_dir, + '--publisher-server' => $node_p->connstr($db1), + '--socketdir' => $node_s->host, + '--subscriber-port' => $node_s->port, + '--database' => $db1, + '--database' => $db2, + ], 'primary contains unmet conditions on node P'); # Restore default settings here but only apply it after testing standby. Some @@ -268,14 +274,15 @@ sub generate_db }); command_fails( [ - 'pg_createsubscriber', '--verbose', - '--dry-run', '--pgdata', - $node_s->data_dir, '--publisher-server', - $node_p->connstr($db1), '--socketdir', - $node_s->host, '--subscriber-port', - $node_s->port, '--database', - $db1, '--database', - $db2 + 'pg_createsubscriber', + '--verbose', + '--dry-run', + '--pgdata' => $node_s->data_dir, + '--publisher-server' => $node_p->connstr($db1), + '--socketdir' => $node_s->host, + '--subscriber-port' => $node_s->port, + '--database' => $db1, + '--database' => $db2, ], 'standby contains unmet conditions on node S'); $node_s->append_conf( @@ -321,19 +328,20 @@ sub generate_db # dry run mode on node S command_ok( [ - 'pg_createsubscriber', '--verbose', - '--recovery-timeout', "$PostgreSQL::Test::Utils::timeout_default", - '--dry-run', '--pgdata', - $node_s->data_dir, '--publisher-server', - $node_p->connstr($db1), '--socketdir', - $node_s->host, '--subscriber-port', - $node_s->port, '--publication', - 'pub1', '--publication', - 'pub2', '--subscription', - 'sub1', '--subscription', - 'sub2', '--database', - $db1, '--database', - $db2 + 'pg_createsubscriber', + '--verbose', + '--dry-run', + '--recovery-timeout' => $PostgreSQL::Test::Utils::timeout_default, + '--pgdata' => $node_s->data_dir, + '--publisher-server' => $node_p->connstr($db1), + '--socketdir' => $node_s->host, + '--subscriber-port' => $node_s->port, + '--publication' => 'pub1', + '--publication' => 'pub2', + '--subscription' => 'sub1', + '--subscription' => 'sub2', + '--database' => $db1, + '--database' => $db2, ], 'run pg_createsubscriber --dry-run on node S'); @@ -346,32 +354,33 @@ sub generate_db # pg_createsubscriber can run without --databases option command_ok( [ - 'pg_createsubscriber', '--verbose', - '--dry-run', '--pgdata', - $node_s->data_dir, '--publisher-server', - $node_p->connstr($db1), '--socketdir', - $node_s->host, '--subscriber-port', - $node_s->port, '--replication-slot', - 'replslot1' + 'pg_createsubscriber', + '--verbose', + '--dry-run', + '--pgdata' => $node_s->data_dir, + '--publisher-server' => $node_p->connstr($db1), + '--socketdir' => $node_s->host, + '--subscriber-port' => $node_s->port, + '--replication-slot' => 'replslot1', ], 'run pg_createsubscriber without --databases'); # Run pg_createsubscriber on node S command_ok( [ - 'pg_createsubscriber', '--verbose', - '--recovery-timeout', "$PostgreSQL::Test::Utils::timeout_default", - '--verbose', '--pgdata', - $node_s->data_dir, '--publisher-server', - $node_p->connstr($db1), '--socketdir', - $node_s->host, '--subscriber-port', - $node_s->port, '--publication', - 'pub1', '--publication', - 'Pub2', '--replication-slot', - 'replslot1', '--replication-slot', - 'replslot2', '--database', - $db1, '--database', - $db2 + 'pg_createsubscriber', + '--verbose', + '--recovery-timeout' => "$PostgreSQL::Test::Utils::timeout_default", + '--pgdata' => $node_s->data_dir, + '--publisher-server' => $node_p->connstr($db1), + '--socketdir' => $node_s->host, + '--subscriber-port' => $node_s->port, + '--publication' => 'pub1', + '--publication' => 'pub2', + '--replication-slot' => 'replslot1', + '--replication-slot' => 'replslot2', + '--database' => $db1, + '--database' => $db2, ], 'run pg_createsubscriber on node S'); -- 2.47.1 --=-=-=--