snuyanzin commented on code in PR #3:
URL: 
https://github.com/apache/flink-connector-jdbc/pull/3#discussion_r1342484168


##########
flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/testutils/databases/trino/TrinoDatabasePost.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.jdbc.testutils.databases.trino;
+
+import org.apache.flink.connector.jdbc.testutils.DatabaseExtension;
+import org.apache.flink.connector.jdbc.testutils.DatabaseMetadata;
+import 
org.apache.flink.connector.jdbc.testutils.databases.postgres.PostgresDatabase;
+import 
org.apache.flink.connector.jdbc.testutils.databases.postgres.PostgresImages;
+import org.apache.flink.util.FlinkRuntimeException;
+
+import org.testcontainers.containers.BindMode;
+import org.testcontainers.containers.PostgreSQLContainer;
+import org.testcontainers.containers.TrinoContainer;
+import org.testcontainers.utility.MountableFile;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+/** A Trino database for testing. */
+public class TrinoDatabasePost extends DatabaseExtension implements 
TrinoImages, PostgresImages {
+
+    private static final PostgreSQLContainer<?> CONTAINER_DB =
+            new PostgresDatabase.PostgresXaContainer(POSTGRES_15)
+                    .withMaxConnections(10)
+                    .withMaxTransactions(50);
+
+    private static final TrinoContainer CONTAINER = new 
TrinoContainer(TRINO_IMAGE);
+
+    private static TrinoMetadata metadata;
+
+    public static TrinoMetadata getMetadata() {
+        if (!CONTAINER.isRunning()) {
+            throw new FlinkRuntimeException("Container is stopped.");
+        }
+        if (metadata == null) {
+            metadata = new TrinoMetadata(CONTAINER);
+        }
+        return metadata;
+    }
+
+    @Override
+    protected DatabaseMetadata startDatabase() throws Exception {
+        CONTAINER_DB.start();
+
+        Path tempFile = Files.createTempFile(null, null);
+        String postgresContent =
+                "connector.name=postgresql\n"
+                        + String.format("connection-url=%s\n", 
CONTAINER_DB.getJdbcUrl())
+                        + String.format("connection-user=%s\n", 
CONTAINER_DB.getUsername())
+                        + String.format("connection-password=%s", 
CONTAINER_DB.getPassword());
+        Files.write(tempFile, 
postgresContent.getBytes(StandardCharsets.UTF_8));
+        MountableFile file = MountableFile.forHostPath(tempFile);
+
+        CONTAINER
+                .withDatabaseName("postgres/public")
+                .withFileSystemBind(
+                        tempFile.toFile().getAbsolutePath(),
+                        "/etc/trino/catalog/postgres.properties",
+                        BindMode.READ_WRITE);
+        // .withCopyFileToContainer(file, 
"/etc/trino/catalog/postgres.properties");

Review Comment:
   can we remove this comment or do we need it for something (in that case 
probably would be great more details in comment as well)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to