HIVE-21940, a postgres metastore related issue has been fixed, and a local reproduction has been provided.
The problem with this solution is that data/conf/hive-site.xml has to be edited manually. My proposal is to introduce a property (-Dmetastore.db=postgres), which can take care of the parameters on the fly. 2 supported solutions could be:
1. simple parameters: -Dmetastore.db=postgres
In this case, tests depend on settings from ITestPostgres class (password, db, etc.)
2. verbose but flexible parameters: see hive-site.xml HIVE-21940's repro patch
In the long term, we should consider running this kind of tests in precommit phase, so maybe -Dmetastore.db=postgres could start metastore db automatically. Also we should consider running some qtests on various metastores. I would not pick randomly, but choose some "metastore-heavy" ones instead.