Skip to content

Commit b45b285

Browse files
committed
Add launcher and create tar for trino-gateway
1 parent c59bb7d commit b45b285

File tree

15 files changed

+163
-22
lines changed

15 files changed

+163
-22
lines changed

gateway-ha/src/main/java/io/trino/gateway/ha/HaGatewayLauncher.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ public static void main(String[] args)
109109
throws Exception
110110
{
111111
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
112-
if (args.length != 1) {
113-
throw new IllegalArgumentException("Expected exactly one argument (path of configuration file)");
112+
String configFile = System.getProperty("config");
113+
if (configFile == null) {
114+
throw new IllegalArgumentException("Configuration file not specified. Use -Dconfig=<config-file>");
114115
}
115-
String config = Files.readString(Path.of(args[0]));
116+
String config = Files.readString(Path.of(configFile));
116117
HaGatewayConfiguration haGatewayConfiguration = objectMapper.readValue(replaceEnvironmentVariables(config), HaGatewayConfiguration.class);
117118
FlywayMigration.migrate(haGatewayConfiguration.getDataStore());
118119
List<Module> modules = addModules(haGatewayConfiguration);

gateway-ha/src/test/java/io/trino/gateway/TrinoGatewayRunner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public static void main(String[] args)
6060
mysql.withCopyFileToContainer(forClasspathResource("add_backends_mysql.sql"), "/docker-entrypoint-initdb.d/2-add_backends_mysql.sql");
6161
mysql.setPortBindings(List.of("3306:3306"));
6262
mysql.start();
63-
HaGatewayLauncher.main(new String[] {"gateway-ha/config.yaml"});
63+
System.setProperty("config", "gateway-ha/config.yaml");
64+
HaGatewayLauncher.main(new String[] {});
6465

6566
log.info("======== SERVER STARTED ========");
6667
}

gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaMultipleBackend.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public MockResponse dispatch(RecordedRequest request)
120120
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-template.yml");
121121

122122
// Start Gateway
123-
String[] args = {testConfigFile.getAbsolutePath()};
124-
HaGatewayLauncher.main(args);
123+
System.setProperty("config", testConfigFile.getAbsolutePath());
124+
HaGatewayLauncher.main(new String[] {});
125125
// Now populate the backend
126126
HaGatewayTestUtils.setUpBackend(
127127
"trino1", "http://localhost:" + backend1Port, "externalUrl", true, "adhoc", routerPort);

gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaSingleBackend.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ void setup()
5858
File testConfigFile =
5959
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-template.yml");
6060
// Start Gateway
61-
String[] args = {testConfigFile.getAbsolutePath()};
62-
HaGatewayLauncher.main(args);
61+
System.setProperty("config", testConfigFile.getAbsolutePath());
62+
HaGatewayLauncher.main(new String[] {});
6363
// Now populate the backend
6464
HaGatewayTestUtils.setUpBackend(
6565
"trino1", "http://localhost:" + backendPort, "externalUrl", true, "adhoc", routerPort);

gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaWithRoutingRulesSingleBackend.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ void setup()
5555
File testConfigFile =
5656
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-with-routing-template.yml");
5757
// Start Gateway
58-
String[] args = {testConfigFile.getAbsolutePath()};
59-
HaGatewayLauncher.main(args);
58+
System.setProperty("config", testConfigFile.getAbsolutePath());
59+
HaGatewayLauncher.main(new String[] {});
6060
// Now populate the backend
6161
HaGatewayTestUtils.setUpBackend(
6262
"trino1", "http://localhost:" + backendPort, "externalUrl", true, "system", routerPort);

gateway-ha/src/test/java/io/trino/gateway/ha/TestNoXForwarded.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ void setup()
5757
File testConfigFile =
5858
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-without-x-forwarded-template.yml");
5959
// Start Gateway
60-
String[] args = {testConfigFile.getAbsolutePath()};
61-
HaGatewayLauncher.main(args);
60+
System.setProperty("config", testConfigFile.getAbsolutePath());
61+
HaGatewayLauncher.main(new String[] {});
6262
// Now populate the backend
6363
HaGatewayTestUtils.setUpBackend(
6464
"trino1", "http://localhost:" + backendPort, "externalUrl", true, "adhoc", routerPort);

gateway-ha/src/test/java/io/trino/gateway/ha/TestTrinoResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ void setup()
7070
resourceGroupManager = new HaResourceGroupsManager(connectionManager);
7171

7272
// Start Trino Gateway so migrations are run to create tables before inserting test data
73-
String[] args = {testConfigFile.getAbsolutePath()};
74-
HaGatewayLauncher.main(args);
73+
System.setProperty("config", testConfigFile.getAbsolutePath());
74+
HaGatewayLauncher.main(new String[] {});
7575

7676
prepareData();
7777
}

gateway-ha/src/test/java/io/trino/gateway/ha/router/TestRoutingAPI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ void setup()
6363
File testConfigFile =
6464
HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "test-config-with-routing-rules-api.yml");
6565
// Start Gateway
66-
String[] args = {testConfigFile.getAbsolutePath()};
67-
HaGatewayLauncher.main(args);
66+
System.setProperty("config", testConfigFile.getAbsolutePath());
67+
HaGatewayLauncher.main(new String[] {});
6868
// Now populate the backend
6969
HaGatewayTestUtils.setUpBackend(
7070
"trino1", "http://localhost:" + backendPort, "externalUrl", true, "adhoc", routerPort);

gateway-ha/src/test/java/io/trino/gateway/ha/security/TestAuthorization.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ void setup()
5555
{
5656
postgresql.start();
5757
File testConfigFile = HaGatewayTestUtils.buildGatewayConfig(postgresql, routerPort, "auth/auth-test-config.yml");
58-
String[] args = {testConfigFile.getAbsolutePath()};
59-
HaGatewayLauncher.main(args);
58+
System.setProperty("config", testConfigFile.getAbsolutePath());
59+
HaGatewayLauncher.main(new String[] {});
6060
}
6161

6262
@Test

gateway-ha/src/test/java/io/trino/gateway/ha/security/TestOIDC.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ void setup()
146146

147147
File testConfigFile =
148148
HaGatewayTestUtils.buildGatewayConfig(gatewayBackendDatabase, ROUTER_PORT, "auth/oauth-test-config.yml");
149-
String[] args = {testConfigFile.getAbsolutePath()};
150149
System.out.println(ROUTER_PORT);
151-
HaGatewayLauncher.main(args);
150+
System.setProperty("config", testConfigFile.getAbsolutePath());
151+
HaGatewayLauncher.main(new String[] {});
152152
}
153153

154154
@Test

gateway-ha/src/test/java/io/trino/gateway/proxyserver/TestProxyRequestHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public MockResponse dispatch(RecordedRequest request)
8585

8686
File testConfigFile = buildGatewayConfig(postgresql, routerPort, "test-config-template.yml");
8787

88-
String[] args = {testConfigFile.getAbsolutePath()};
89-
HaGatewayLauncher.main(args);
88+
System.setProperty("config", testConfigFile.getAbsolutePath());
89+
HaGatewayLauncher.main(new String[] {});
9090

9191
setUpBackend("custom", "http://localhost:" + customBackendPort, "externalUrl", true, "adhoc", routerPort);
9292
}

gateway-server/pom.xml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>io.trino.gateway</groupId>
6+
<artifactId>trino-gateway-parent</artifactId>
7+
<version>16-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>gateway-server</artifactId>
11+
<packaging>provisio</packaging>
12+
<description>Trino Gateway - Server package</description>
13+
14+
<properties>
15+
<dep.takari.version>2.1.4</dep.takari.version>
16+
<server.tar.package>gateway-server-${project.version}</server.tar.package>
17+
18+
<!-- Launcher properties -->
19+
<main-class>io.trino.gateway.ha.HaGatewayLauncher</main-class>
20+
<process-name>${project.artifactId}</process-name>
21+
22+
<!-- Special consideration for Takari Lifecycle -->
23+
<!-- This works as trino-server have no sources (is just provisio packaged) -->
24+
<takari.skip>false</takari.skip>
25+
</properties>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>org.junit.jupiter</groupId>
30+
<artifactId>junit-jupiter-api</artifactId>
31+
<scope>test</scope>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>org.junit.jupiter</groupId>
36+
<artifactId>junit-jupiter-engine</artifactId>
37+
<scope>test</scope>
38+
</dependency>
39+
</dependencies>
40+
41+
<!-- Needed for provisio to resolve transitive dependencies for server assembly -->
42+
<repositories>
43+
<repository>
44+
<snapshots>
45+
<enabled>false</enabled>
46+
</snapshots>
47+
<id>confluent</id>
48+
<url>https://packages.confluent.io/maven/</url>
49+
</repository>
50+
</repositories>
51+
52+
<build>
53+
<plugins>
54+
<plugin>
55+
<groupId>ca.vanzyl.provisio.maven.plugins</groupId>
56+
<artifactId>provisio-maven-plugin</artifactId>
57+
<version>1.0.24</version>
58+
<extensions>true</extensions>
59+
<executions>
60+
<execution>
61+
<id>pack</id>
62+
<goals>
63+
<goal>provision</goal>
64+
</goals>
65+
<configuration>
66+
<descriptorDirectory>${project.basedir}/src/main/provisio</descriptorDirectory>
67+
<outputDirectory>${project.build.directory}/${server.tar.package}</outputDirectory>
68+
</configuration>
69+
</execution>
70+
</executions>
71+
</plugin>
72+
73+
<plugin>
74+
<groupId>io.takari.maven.plugins</groupId>
75+
<artifactId>takari-lifecycle-plugin</artifactId>
76+
<version>${dep.takari.version}</version>
77+
<configuration>
78+
<proc>none</proc>
79+
<skip>${takari.skip}</skip>
80+
</configuration>
81+
</plugin>
82+
83+
<plugin>
84+
<groupId>org.basepom.maven</groupId>
85+
<artifactId>duplicate-finder-maven-plugin</artifactId>
86+
<configuration>
87+
<ignoredResourcePatterns combine.children="append">
88+
<ignoredResourcePattern>aircompressor.*</ignoredResourcePattern>
89+
</ignoredResourcePatterns>
90+
</configuration>
91+
</plugin>
92+
</plugins>
93+
</build>
94+
95+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<runtime>
2+
<!-- Target -->
3+
<archive name="${project.artifactId}-${project.version}.tar.gz" hardLinkIncludes="**/*.jar" />
4+
5+
<!-- Launcher -->
6+
<artifactSet to="bin">
7+
<artifact id="io.airlift:launcher:tar.gz:bin:${dep.airlift.launcher.version}">
8+
<unpack />
9+
</artifact>
10+
<artifact id="io.airlift:launcher:tar.gz:properties:${dep.airlift.launcher.version}">
11+
<unpack filter="true" />
12+
</artifact>
13+
</artifactSet>
14+
15+
<!-- Gateway Server -->
16+
<artifactSet to="lib">
17+
<artifact id="${project.groupId}:gateway-ha:${project.version}" />
18+
</artifactSet>
19+
20+
</runtime>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package io.trino.gateway.server;
15+
16+
import org.junit.jupiter.api.Test;
17+
18+
public class TestDummy
19+
{
20+
@Test
21+
public void buildRequiresTestToExist() {}
22+
}

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
<modules>
3131
<module>gateway-ha</module>
32+
<module>gateway-server</module>
3233
</modules>
3334
<scm>
3435
<connection>scm:git:git://github.com/trinodb/trino-gateway.git</connection>
@@ -44,6 +45,7 @@
4445
<air.check.skip-spotbugs>true</air.check.skip-spotbugs>
4546
<air.check.skip-pmd>true</air.check.skip-pmd>
4647
<air.release.preparation-goals>clean verify -DskipTests</air.release.preparation-goals>
48+
<dep.airlift.launcher.version>303</dep.airlift.launcher.version>
4749
</properties>
4850

4951
<dependencyManagement>

0 commit comments

Comments
 (0)