Skip to content

Commit d9b384e

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

File tree

15 files changed

+152
-22
lines changed

15 files changed

+152
-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

0 commit comments

Comments
 (0)