-
Notifications
You must be signed in to change notification settings - Fork 129
Replace H2 use for testing with PostgreSQL #719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
I ll have to remove that
…On Wed, 9 Jul 2025 at 6:49 AM, Yuya Ebihara ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In webapp/pnpm-lock.yaml
<#719 (comment)>
:
> @@ -1,2936 +0,0 @@
-lockfileVersion: '9.0'
Is this change related to H2 removal?
—
Reply to this email directly, view it on GitHub
<#719 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVL2AZQUV6COWOFPLL5UJO33HRUZXAVCNFSM6AAAAACBBYEIISVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSOJZGQ4DSNRYGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
d8bbdb2 to
c1469cc
Compare
Why do we need to remove |
|
I mean i ll remove that commit
…On Wed, 9 Jul 2025 at 3:24 PM, Yuya Ebihara ***@***.***> wrote:
*ebyhr* left a comment (trinodb/trino-gateway#719)
<#719 (comment)>
I ll have to remove that
Why do we need to remove webapp/pnpm-lock.yaml?
—
Reply to this email directly, view it on GitHub
<#719 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVL2AZXSTFAUPT5SWPXZ7RT3HTREZAVCNFSM6AAAAACBBYEIISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANJRHE2TANZWGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
c1469cc to
414ca10
Compare
|
@ebyhr please review |
gateway-ha/src/main/java/io/trino/gateway/ha/persistence/dao/ExactMatchSourceSelectorsDao.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/persistence/dao/ExactMatchSourceSelectorsDao.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/TestingJdbcConnectionManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/TestingJdbcConnectionManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestSpecificDbResourceGroupsManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestSpecificDbResourceGroupsManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestResourceGroupsManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestResourceGroupsManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestResourceGroupsManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestResourceGroupsManager.java
Outdated
Show resolved
Hide resolved
414ca10 to
52aaeaa
Compare
|
@ebyhr have resolved please review. |
52aaeaa to
d505b71
Compare
|
|
@mosabua please review. |
https://nexus-iq.visa.com/assets/index.html#/vulnerabilities/CVE-2021-42392
|
|
We cut a new release now .. will hopefully be able to test soon .. can you rebase in the meantime |
|
Sure thing!
…On Fri, 19 Sep 2025 at 1:57 AM, Manfred Moser ***@***.***> wrote:
*mosabua* left a comment (trinodb/trino-gateway#719)
<#719 (comment)>
We cut a new release now .. will hopefully be able to test soon .. can you
rebase in the meantime
—
Reply to this email directly, view it on GitHub
<#719 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVL2AZW2ILDDCWBZ7RQEHGD3TMIR3AVCNFSM6AAAAACBBYEIISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGMBZGU4DKMRQGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
d505b71 to
11a5dd7
Compare
|
@mosabua please review |
|
With #780 merged now .. can you rebase and adjust and make sure CI passes? |
|
Sure
…On Sun, 12 Oct 2025 at 4:39 AM, Manfred Moser ***@***.***> wrote:
*mosabua* left a comment (trinodb/trino-gateway#719)
<#719 (comment)>
With #780 <#780> merged now
.. can you rebase and adjust and make sure CI passes?
—
Reply to this email directly, view it on GitHub
<#719 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVL2AZSW5GCHXLTFCR5C4ND3XGE2VAVCNFSM6AAAAACBBYEIISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOJTG4ZDGNZSGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
02e1226 to
48fc01b
Compare
|
please review @mosabua |
|
Can you rebase and resolve conflicts here @Akanksha-kedia ? It would be good to get this in |
|
@mosabua please review i have rebased and resolved conflicts |
1ab7c9d to
4d6bf67
Compare
|
@Akanksha-kedia Could you fix CI failure? |
|
Sure!
…On Thu, 15 Jan 2026 at 6:02 AM, Yuya Ebihara ***@***.***> wrote:
*ebyhr* left a comment (trinodb/trino-gateway#719)
<#719 (comment)>
@Akanksha-kedia <https://github.com/Akanksha-kedia> Could you fix CI
failure?
—
Reply to this email directly, view it on GitHub
<#719 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVL2AZVKICOVEH7WRT4B3HT4G3N3PAVCNFSM6AAAAACBBYEIISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTONJSGMZDINZSGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
mosabua
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I agree with the idea and PR. We definitely need to make sure all tests pass before merging.
One aspect to keep in mind also is that we will hopefully delete all the resource groups table stuff and the related code from Trino Gateway since it really is outside of the scope of the project as has been discussed in our team syncs before
| Jdbi jdbi = HaGatewayProviderModule.createJdbi(db); | ||
| JdbcConnectionManager connectionManager = new JdbcConnectionManager(jdbi, db); | ||
| super.resourceGroupManager = new HaResourceGroupsManager(connectionManager); | ||
| PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:14-alpine") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why such an old version of PostgreSQL? In either case .. it should be same as in other tests and usage within the codebase
gateway-ha/src/test/java/io/trino/gateway/ha/persistence/TestJdbcConnectionManager.java
Show resolved
Hide resolved
|
Ping @Akanksha-kedia |
|
Yes will try asap
…On Thu, 22 Jan 2026 at 11:09 AM, Manfred Moser ***@***.***> wrote:
*mosabua* left a comment (trinodb/trino-gateway#719)
<#719 (comment)>
Ping @Akanksha-kedia <https://github.com/Akanksha-kedia>
—
Reply to this email directly, view it on GitHub
<#719 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVL2AZVB2AW67DO2V3WVX734IBPAXAVCNFSM6AAAAACBBYEIISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTOOBSGU4DOOJWGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
by when or anyhelp needed from my end |
3c528b2 to
25982c4
Compare
| return timestamp != null ? timestamp.toLocalDateTime().format(FORMATTER) : null; | ||
| } | ||
| catch (SQLException e) { | ||
| return LocalDateTime.now(ZoneId.systemDefault()).format(FORMATTER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a code comment why we need this fallback logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does this issue happen? Is it covered by tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on my analysis, the tests do exercise the timestamp mapper (through testReadExactMatchSourceSelectors()), but they don't specifically test the fallback scenario where getTimestamp() throws a SQLException. The fallback is a defensive measure for edge cases with certain database drivers.
| assertThat(resourceGroups.get(0).getMaxQueued()).isEqualTo(200); | ||
| assertThat(resourceGroups.get(0).getJmxExport()).isTrue(); | ||
| assertThat(resourceGroups.get(0).getSoftMemoryLimit()).isEqualTo("80%"); | ||
| assertThat(resourceGroups.getFirst().getResourceGroupId()).isEqualTo(1L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated to H2->PostgreSQL change. Please separate a commit.
| { | ||
| List<ResourceGroupsDetail> resourceGroups = resourceGroupManager.readAllResourceGroups(null); | ||
| long adminResourceGroupId = resourceGroups.stream() | ||
| .filter(rg -> "admin".equals(rg.getName())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .findFirst() | ||
| .orElse(null); | ||
|
|
||
| if (testGroup == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this test non-deterministic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test code in TestResourceGroupsManager.java at line 237-240 is non-deterministic because it uses .stream().filter().findFirst() on a List without guaranteed ordering:
ResourceGroupsDetail testGroup = existingGroups.stream()
.filter(rg -> "selector-test-group".equals(rg.getName()))
.findFirst()
.orElse(null);Root Cause:
-
Database ordering is not guaranteed: The
readAllResourceGroups(null)method returns a List from a database query, but without an explicitORDER BYclause, the database can return rows in any order. -
Test execution order dependency: The test uses
@TestMethodOrder(OrderAnnotation.class)and@Orderannotations, but previous tests create multiple resource groups. The order in which these groups are returned from the database is unpredictable. -
Stream.findFirst() behavior: When filtering a stream,
findFirst()returns the first element that matches the filter predicate. If multiple elements could match (or if the list order changes), the result becomes non-deterministic.
The Problem:
If there are multiple resource groups in the database when this test runs, and the database returns them in different orders on different executions, the test behavior becomes unpredictable. Even though the filter looks for a specific name ("selector-test-group"), the order in which the database returns all groups can vary, affecting test execution timing and state.
Solution:
The code should either:
- Use a deterministic query with explicit ordering in
readAllResourceGroups() - Not rely on list ordering when searching for specific items
- Clean up test data more reliably between test methods
The pattern appears in multiple places in the test file (lines 90-94, 237-240, 268-271, 305-310), making the entire test suite potentially flaky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this change relate to the H2 → PostgreSQL migration?
| assumeTrue("true".equals(System.getenv("GITHUB_ACTIONS")) | ||
| || "x86_64".equalsIgnoreCase(System.getProperty("os.arch")) | ||
| || "true".equals(System.getenv("TG_RUN_ORACLE_TESTS"))); | ||
| return new OracleContainer("gvenzl/oracle-xe:18.4.0-slim"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you downgrade the version? Please revert this change.
25982c4 to
fdd7243
Compare
|
please review @mosabua |
c155698 to
891a4ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing H2 with PostgreSQL is totally fine. However, some test changes don't make sense to me.
| assertThat(resourceGroups.get(0).getHardConcurrencyLimit()).isEqualTo(20); | ||
| assertThat(resourceGroups.get(0).getMaxQueued()).isEqualTo(200); | ||
| assertThat(resourceGroups.get(0).getJmxExport()).isTrue(); | ||
| assertThat(resourceGroups.get(0).getJmxExport()).isEqualTo(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
| // Find the admin resource group and verify its properties | ||
| ResourceGroupsDetail adminGroup = resourceGroups.stream() | ||
| .filter(rg -> "admin".equals(rg.getName())) | ||
| .findFirst() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid findFirst as much as possible. Consider using collect(toOptional()) instead.
| ExactSelectorsDetail exactSelectorDetail) | ||
| { | ||
| // If updateTime is null or empty, set current timestamp | ||
| if (exactSelectorDetail.getUpdateTime() == null || exactSelectorDetail.getUpdateTime().trim().isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getUpdateTime() contains @Nonnull annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change DateTimeFormatter formatter to a constant.
| extends TestResourceGroupsManager | ||
| { | ||
| private String specificDb; | ||
| private String specificDb = "test_db_specific"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it static final and uppercase the constant name.
| catch (Exception e) { | ||
| throw new RuntimeException("Failed to setup test database: " + specificDb, e); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove a redundant catch block.
| String jdbcUrl = postgres.getJdbcUrl(); | ||
| String username = postgres.getUsername(); | ||
| String password = postgres.getPassword(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline.
| String jdbcUrl = postgres.getJdbcUrl(); | ||
| String username = postgres.getUsername(); | ||
| String password = postgres.getPassword(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline.
| import java.io.File; | ||
| import java.nio.file.Path; | ||
| import org.testcontainers.containers.JdbcDatabaseContainer; | ||
| import org.testcontainers.containers.PostgreSQLContainer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid a deprecated class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder.
| postgres.getJdbcUrl(), | ||
| postgres.getUsername(), | ||
| postgres.getPassword(), | ||
| "org.postgresql.Driver", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostgreSQLContainer offers getDriverClassName method.
891a4ba to
dafca77
Compare
|
@ebyhr please review all and let me know wat more chnages i need to do |
|
Please fix build failures: |
31386a1 to
146e761
Compare
done @ebyhr do review its a long pending pr thanks in advance. |
146e761 to
e521905
Compare
|
@mosabua please help to review and merge or else again we have spend time in rebasing and all |
|
|
||
| public static JdbcConnectionManager createTestingJdbcConnectionManager() | ||
| { | ||
| PostgreSQLContainer postgres = new PostgreSQLContainer("postgres:14-alpine") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use TestcontainersUtils.createPostgreSqlContainer?

Release notes
(x) This is not user-visible or is docs only, and no release notes are required.