[pgjdbc/pgjdbc] ad7345: Clean up some tests and fix IsValidTest race condi...

Sehrope Sarkuni <[email protected]> Thu, 24 Oct 2019 07:45:50 -0700
Newsgroups gmane.comp.db.postgresql.jdbc
Message-ID <pgjdbc/pgjdbc/push/refs/heads/master/[email protected]>
  Branch: refs/heads/master
  Home:   https://github.com/pgjdbc/pgjdbc
  Commit: ad734574726eb0decf5178071c87a1b513e484f2
      https://github.com/pgjdbc/pgjdbc/commit/ad734574726eb0decf5178071c87a1b513e484f2
  Author: Sehrope Sarkuni <[email protected]>
  Date:   2019-10-24 (Thu, 24 Oct 2019)

  Changed paths:
    M pgjdbc/src/test/java/org/postgresql/test/TestUtil.java
    M pgjdbc/src/test/java/org/postgresql/test/jdbc2/CopyTest.java
    M pgjdbc/src/test/java/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
    M pgjdbc/src/test/java/org/postgresql/test/jdbc4/IsValidTest.java

  Log Message:
  -----------
  Clean up some tests and fix IsValidTest race condition (#1581)

* test: Add some helpers to TestUtil

Adds some helpers to TestUtil to deal with boiler plate of executinga query
and disgarding the results, fetching the backend process id, terminating a
backend process, and fetching the current transaction state.

* test: Clean up IsValidTest

Cleans up IsValidTest and removes a race condition when checking whether
terminated connections are marked as invalid. Also splits out the transaction
state test into three separate ones to better identify what's being tested.

* test: Change CopyTest to use TestUtil backend pid helpers

This also changes the connection termination to use a non-privileged
connection.

* test: Change ConnectionPoolTest to use backend pid TestUtil helpers

This also changes the pg_terminate_backend(...) call to use a non-privileged connection
as a regular user can terminate their own connection.

* fix: Use super user to terminate backend processes in tests

Older versions of the server (<=9.1) restrict calling pg_terminate_backend(...)
to super users so always use that in test helper.