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 1sHMLQ-006VM5-Gv for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Jun 2024 11:40:49 +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 1sHMLP-00Gp8n-1a for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Jun 2024 11:40:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHMLO-00Gp8f-Ny for pgsql-hackers@lists.postgresql.org; Wed, 12 Jun 2024 11:40:47 +0000 Received: from mail-yb1-f173.google.com ([209.85.219.173]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sHMLM-001GJ9-Px for pgsql-hackers@postgresql.org; Wed, 12 Jun 2024 11:40:47 +0000 Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-dfe41f7852cso711358276.1 for ; Wed, 12 Jun 2024 04:40:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718192443; x=1718797243; h=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=76fF9Ggheeng4D4DevOude5eR56ProizIyYN0OmFrhw=; b=kMbFBZsLqubrT3dZWvwz9505sv20WSaqzwr+nZfEZhNkkFpaoyJQqL6pIwAI405Wn/ rQZ1bCW8GuG2O/4Ibx4RaM++sqONRkZY9MSa+htHJ5cRC8IIocOcSXJayNNTFYTO9lyO /UIPnWvfZMFwUJwuw1QiXJZuhxdvI0z9XrbIniBj6LMEwrhpbZxPbtUTgwtm2xAG6Yyd +bhQ60UF9Q/1Y1tIcuhUfd3rsr6IH2/K+/IJjZdFmXbpxcE7CUpr0I7sF8KIx0FdamcY j3VmIuRaK4SjuIcUIw+EBHWAKJjTedm1F3ChRHC00PQB+ZowaZZXL4xo86BJPgqMcEVI rz1w== X-Forwarded-Encrypted: i=1; AJvYcCUM+Xyj7Mxga6nEATRTzW01Z96p4hOrFFd3vFfzMTtFxfFLPV1tS6zbLX/UVCO+F6TtQEPV4YjsDw4r/QK0v2RgNOhN+oPj4j/j1ebv X-Gm-Message-State: AOJu0YzBLwR3YIZfzjY5IzjYekhp3+erecSTklfxqyLpO5Y8k9UKJtwl 2JxK1yjMnbz9cdhU4dL5yPh4cGXuoNtfORu3rEcVIV7ZPTBjbVFsDuxzYhBM9RqNGwd81jSe1ku KPZCazZBxJrtwWlR8lBLBuJTCIZQV1CGBj4q1Zg== X-Google-Smtp-Source: AGHT+IE5uCa9mgg9yhhkkLaVXfMWrVARB1HC3dgzWAIqn/6fU0oA+Rbn7s7kKGgsb/rJ0SN/6hN33F0D3l+OtlQz3+E= X-Received: by 2002:a25:ac11:0:b0:dfb:56d:21ec with SMTP id 3f1490d57ef6-dfe691018b0mr1462472276.55.1718192442988; Wed, 12 Jun 2024 04:40:42 -0700 (PDT) MIME-Version: 1.0 References: <20240610200411.byj6sv2vpgol6wcf@awork3.anarazel.de> <00c5efe6-1abb-42f8-a9a7-ed3a055c4b92@dunslane.net> <20240611014911.khxuai5fy2ssbmiw@awork3.anarazel.de> <20240611234829.9d@rfd.leadboat.com> In-Reply-To: <20240611234829.9d@rfd.leadboat.com> From: Jelte Fennema-Nio Date: Wed, 12 Jun 2024 13:40:30 +0200 Message-ID: Subject: Re: RFC: adding pytest as a supported test framework To: Noah Misch Cc: Andres Freund , Andrew Dunstan , Jacob Champion , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 12 Jun 2024 at 01:48, Noah Misch wrote: > If we're going to test in a non-Perl language, I'd pick C over Python. There > would be several other unlikely-community-choice languages I'd pick over > Python (C#, Java, C++). My main goals of this thread are: 1. Allowing people to quickly write tests 2. Have those tests do what the writer intended them to do 3. Have good error reporting by default Those goals indeed don't necesitate python. But I think those are really hard to achieve with any C based framework, and probably with C++ too. Also manual memory management in tests seems to add tons of complexity for basically no benefit. I think C#, Java, Go, Rust, Kotlin, and Swift would be acceptable choices for me (and possibly some more). They allow some type of introspection, they have a garbage collector, and their general tooling is quite good. But I think a dynamically typed scripting language is much more fitting for writing tests like this. I love static typing for production code, but imho it really doesn't have much benefit for tests. As scripting languages go, the ones that are still fairly heavily in use are Javascript, Python, Ruby, and PHP. I think all of those could probably work, but my personal order of preference would be Python, Ruby, Javascript, PHP. Finally, I'm definitely biased towards using Python myself. But I think there's good reasons for that: 1. In the data space, that Postgres in, Python is very heavily used for analysis 2. Everyone coming out of university these days knows it to some extent 3. Multiple people in the community have been writing Postgres related tests in python and have enjoyed doing so (me[1], Jacob[2], Alexander[3]) What language people want to write tests in is obviously very subjective. And obviously we cannot allow every language for writing tests. But I think if ~25% of the community prefers to write their tests in Python. Then that should be enough of a reason to allow them to do so. TO CLARIFY: This thread is not a proposal to replace Perl with Python. It's a proposal to allow people to also write tests in Python. > I also want the initial scope to be the new language coexisting with the > existing Perl tests. If a bulk translation ever happens, it should happen > long after the debut of the new framework. That said, I don't much trust a > human-written bulk language translation to go through without some tests > accidentally ceasing to test what they test in Perl today. I definitely don't think we should rewrite all the tests that we have in Perl today into some other language. But I do think that whatever language we choose, that language should make it as least as easy to write tests, as easy to read them and as easy to see that they are testing the intended thing, as is currently the case for Perl. Rewriting a few Perl tests into the new language, even if not merging the rewrite, is a good way of validating that imho. PS. For PgBouncer I actually hand-rewrote all the tests that we had in bash (which is the worst testing language ever) in Python and doing so actually found more bugs in PgBouncer code that our bash tests wouldn't catch. So it's not necessarily the case that you lose coverage by rewriting tests. [1]: https://github.com/pgbouncer/pgbouncer/tree/master/test [2]: https://github.com/jchampio/pg-pytest-suite [3]: https://github.com/postgrespro/testgres