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 1sHTjW-0081N1-Oj for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Jun 2024 19:34:10 +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 1sHTjU-005muw-Gt for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Jun 2024 19:34:09 +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 1sHTjU-005mso-6x for pgsql-hackers@lists.postgresql.org; Wed, 12 Jun 2024 19:34:09 +0000 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sHTjR-0010Np-Sw for pgsql-hackers@postgresql.org; Wed, 12 Jun 2024 19:34:07 +0000 Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-6b07937b84fso995356d6.1 for ; Wed, 12 Jun 2024 12:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1718220844; x=1718825644; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0kZtHCOxT40j2Z1auLKh5Rj1xJdvy0FufRuS4MtgkSM=; b=ESM4Mid7w/NAZ/ZB54v7NSwtVEDoglJKZWJfBD8MjimZPaHRzhBmkC7HSRXDQULkkM dtpGEULN+oneDa4WDnObdCDsaw8dxNte+CFf7KiOA/M3W8s5nWchF1HcwRWbi6O54nEi 6TZ+u4wmEJdqkKFUAkTX2jQhmdC7ntzNkCMGo6AQ0ur1ILOE+GOdxd6BhtngGmudQMpS uaFcRyRxfJ9mRp7GK28HW8yPbsEyO7HrtgTwAISZsPKRWHcnU/4k9cLs334UWjQH5R3b 68776XxDWZVsQmvGorXREPVbtl4c7cOVpietEVhpxKsnCc/LjkQxcp0GvFz4aE0Na6gV w8/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718220844; x=1718825644; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0kZtHCOxT40j2Z1auLKh5Rj1xJdvy0FufRuS4MtgkSM=; b=wsAjbhleD5Sl/FUhJNIpygTd1LXDY1A/FhaNNt/mTEIDxo0f9aucAtcVuABcCMJGyK 99/LRd0vkrWWe9SgNA9Y7cbseTyh51Se13I4wikNKm1cRPKRPbocl4bNlTrXFWG8RnLh bh/QgZ1Q0xf8D2fob6g/g0NPjBPcEpL3BMz4kpvXIlyi6BlL2S8sffde5t8BfFcAiZd2 5UgI0v/idifYyNmZeDEEib7LHT/1h9Q2ZppmEkjqCsajWt1gqcrlFae6XH7DxijPgVCA +x4gn74qMC5pu7ExiSUVLN4F1mz42Q8wbRsUrue6VpCQEgwaSsBfkFhExTGkPqR3jwVF 2U8w== X-Gm-Message-State: AOJu0YzpOs5+1oDwtjeJBVo6eWGe2HcF76h2uKfpxeKCrH1vvQ2t20az /yiOm6IkbRvLhMjLRB1ultXbRj4fE/8meKJt4/SU7a4pDYozrVhXfZ1jJUt6niDjAURsOyG8+aP Wnl0QlcAIUcFB4rUapFfo6EdP4ZTb/c9KUaLm4/O1IRYVlSo= X-Google-Smtp-Source: AGHT+IGjX1a9qyVwFJLEe/J8RIr7lWup9MH+K6I29dLY0qMjqtV0EGmrVRzsX+eFe+w19/DRRoG4ahSEpjhGWNu6ZQI= X-Received: by 2002:a05:6214:4906:b0:6b0:639b:6f8d with SMTP id 6a1803df08f44-6b1a5fc40edmr28767306d6.29.1718220844551; Wed, 12 Jun 2024 12:34:04 -0700 (PDT) MIME-Version: 1.0 References: <20240610200411.byj6sv2vpgol6wcf@awork3.anarazel.de> <20240612155040.u6cvatdb5tiwcxci@awork3.anarazel.de> In-Reply-To: <20240612155040.u6cvatdb5tiwcxci@awork3.anarazel.de> From: Jacob Champion Date: Wed, 12 Jun 2024 12:33:53 -0700 Message-ID: Subject: Re: RFC: adding pytest as a supported test framework To: Andres Freund Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jun 12, 2024 at 8:50=E2=80=AFAM Andres Freund = wrote: > I think I might have formulated my paragraph above badly - I didn't mean = that > we should move away from perl tests tomorrow, but that we need a path for= ward > that allows folks to write tests without perl. Okay, agreed. > > - Tests aren't cheap, but in my experience, the maintenance-cost math > > for tests is a lot different than the math for implementations. > > At the moment they tend to be *more* expensive often, due to spurious > failures. That's mostly not perl's fault, don't get me wrong, but us not > having better infrastructure for testing complicated behaviour and/or tes= ting > things on a more narrow basis. Well, okay, but I'm not sure how to respond to this in the frame of this discussion. Bad tests will continue to exist. I am trying to add a tool that, in my view, has made it easier for me to test complicated behavior than what we currently have. I can't prove that it will solve other issues too. > > Well, scopes are pretty front and center when you start building > > pytest fixtures, and the complicated longer setups will hopefully > > converge correctly early on and be reused everywhere else. I imagine > > no one wants to build cluster setup from scratch. > > One (the?) prime source of state in our tap tests is the > database. Realistically we can't just tear that one down and reset it bet= ween > tests without causing the test times to explode. So we'll have to live wi= th > some persistent state. Yes? If I've given the impression that I disagree, sorry; I agree. > > On a slight tangent, is this not a problem today? > > It is, but that doesn't mean making it even bigger is unproblematic :) Given all that's been said, I don't understand why you think the problem would get bigger. We would cache expensive state that we need, including the cluster, and pytest lets us do that, and my test suite does that. I've never written a suite that spun up a separate cluster for every single test and then immediately threw it away. (If you want to _enable_ that behavior, to test in extreme isolation, then pytest lets you do that too. But it's not something we should do by default.) > > We do a lot more acceptance testing than internal testing, which came > > up as a major complaint from me and others during the unconference. > > One of the reasons people avoid writing internal tests in Perl is > > because it's very painful to find a rhythm with Test::More. > > What definition of internal tests are you using here? There's a spectrum from unit-testing unexported functions all the way to end-to-end acceptance, and personally I believe that anything finer-grained than end-to-end acceptance is unnecessarily painful. My OAuth suite sits somewhere in the middle, where it mocks the protocol layer and can test the client and server as independent pieces. Super useful for OAuth, which is asymmetrical. I'd like to additionally see better support for unit tests of backend internals, but I don't know those seams as well as all of you do and I should not be driving that. I don't think Python will necessarily help you with it. But it sure helped me break apart the client and the server while enjoying the testing process, and other people want to do that too, so that's what I'm pushing for. > I think a lot of our tests are complicated, fragile and slow because we a= lmost > exclusively do end-to-end tests, because with a few exceptions we don't h= ave a > way to exercise code in a more granular way. Yep. > That's probably not going to fly. It introduces painful circular dependen= cies > between building postgres (for libpq), building psycopg (requiring libpq)= and > testing postgres (requiring psycopg). I am trying very hard not to drag that, which I understand is controversial and is in no way a linchpin of my proposal, into the discussion of whether or not we should try supporting pytest. I get it; I understand that the circular dependency is weird; there are alternatives if it's unacceptable; none of that has anything to do with Python+pytest. > One thing worth thinking about is that such dependencies have to work on = a > relatively large number of platforms / architectures. A lot of projects > don't... Agreed. Thanks, --Jacob