diff --git a/.github/ci/select-nightly-checks.sh b/.github/ci/select-nightly-checks.sh index e71b821e08..f269132ea1 100755 --- a/.github/ci/select-nightly-checks.sh +++ b/.github/ci/select-nightly-checks.sh @@ -103,7 +103,7 @@ grep -vE "$RUNNER|$DOCKER_E2E" "$work/selected.txt" > "$work/standard.txt" || tr # Timeouts in minutes: each group's checks run one after another, plus about twenty minutes for compilation, the image # and the prefetch (see nightly-checks.yml). docker-e2e's tests took about 23 minutes in the shards on 2026-11-23. matrix='[]' -for entry in standard:359 docker-runner:214 docker-e2e:60; do +for entry in standard:359 docker-runner:221 docker-e2e:60; do group="${entry%%:*}" timeout="${entry##*:}" count=$(wc -l < "$work/$group.txt" | tr -d ' ') diff --git a/.github/workflows/nightly-checks.yml b/.github/workflows/nightly-checks.yml index 417f3e43be..79c4f96270 100644 --- a/.github/workflows/nightly-checks.yml +++ b/.github/workflows/nightly-checks.yml @@ -77,8 +77,8 @@ jobs: # EmrClusterShrinkNightlyIntegrationTest's sixteen-minute method and two-minute setup, and # EmrContainersSparkNightlyIntegrationTest's three six-minute methods, eleven-minute method, two-minute setup before # each and 21-minute image pull, EmrContainersGatewayNightlyIntegrationTest's twenty-four-minute, seven-minute and - # eighteen-minute methods and 21-minute image pull, and EmrTrinoNightlyIntegrationTest's two seven-minute methods - # and ten-minute image pull, 194 minutes. docker-e2e holds the *DockerNightlyIntegrationTest + # eighteen-minute methods and 21-minute image pull, and EmrTrinoNightlyIntegrationTest's three seven-minute + # methods and ten-minute image pull, 201 minutes. docker-e2e holds the *DockerNightlyIntegrationTest # classes, about 23 minutes of tests on 2026-11-23 when they still ran in the shards. A check added, or a bound # raised, raises its group's timeout with it, so a slow check fails with its own message. strategy: diff --git a/docs/services/emr.md b/docs/services/emr.md index 8dc102f54a..1a405b5d87 100644 --- a/docs/services/emr.md +++ b/docs/services/emr.md @@ -830,23 +830,31 @@ holding the driver and its executors, or a command or a script. The cluster itse image steps run in. floci.services.emr.pig.enabled adds Apache Pig to it."). * **Trino**: no AWS image carries Trino, so Floci runs it on a cluster whose `Applications` name it only with `trino.enabled` on (`FLOCI_SERVICES_EMR_TRINO_ENABLED=true`), off by default, as its image is the Trino project's, - about 1 GB to pull. The cluster's primary node then runs Trino's coordinator, which runs the queries too, as a - cluster of one node's does, in a container of its own that shares the node's network, as a daemon of the node: from + about 1 GB to pull. The cluster's primary node then runs Trino's coordinator, which runs the queries too, as a cluster + of one node's does, in a container of its own that shares the node's network, as a daemon of the node: from `trino.image`, `trinodb/trino:%s` by default, `%s` the Trino version the release's page in the Release Guide gives - without AWS's `-amzn-N` suffix (446 for `emr-7.5.0`), with `trino.memory-mb` of memory, 2048 by default, 80% of - which the image gives Trino's heap. It listens on 8889: "By default, Amazon EMR configures the Presto web interface - on the Presto coordinator to use port 8889 (for PrestoDB and Trino)". EMR installs `hive-client` and - `hcatalog-server` with Trino, so the cluster's image has Hive and its primary node runs Hive's metastore service, as - on a cluster with HCatalog (see **Storage**), and Trino's catalog, `hive`, is that metastore, its warehouse in the - cluster's HDFS and its tables' S3 locations on Floci's S3. With `trino-connector-hive` setting `hive.metastore` to - `glue`, as the Release Guide's "Launch an Amazon EMR cluster with Trino" does, the catalog is Floci's Glue Data - Catalog instead; the classification's other properties go into the catalog after Floci's, a later configuration's - winning. Trino reaches S3 and Glue as the cluster's EC2 instance profile's role, with a session of its own, as the - metastore does. A step runs `trino-cli`, as the Release Guide's "Start the Trino CLI by running trino-cli" does on - the primary node, through `command-runner.jar`: the CLI of the same Trino, which Floci copies into the cluster's - image from Trino's image as it makes it, on the image's Java 17, connects to the coordinator unless the step names a - `--server` of its own. The cluster's first step starts Trino, with its HDFS, and waits up to three minutes for it to - answer, a Trino that does not failing the step. It goes before its primary node, whose network it shares, when the + without AWS's `-amzn-N` suffix (446 for `emr-7.5.0`), with `trino.memory-mb` of memory, 2048 by default, 80% of which + the image gives Trino's heap. It listens on 8889: "By default, Amazon EMR configures the Presto web interface on the + Presto coordinator to use port 8889 (for PrestoDB and Trino)", or on the `http-server.http.port` of the cluster's + `trino-config`, which changes "Trino's config.properties file": its properties go there after Floci's, a coordinator + that runs the queries too. EMR installs `hive-client` and `hcatalog-server` with Trino, so the cluster's image has + Hive and its primary node runs Hive's metastore service, as on a cluster with HCatalog (see **Storage**), and Trino's + `hive` catalog is that metastore, its warehouse in the cluster's HDFS and its tables' S3 locations on Floci's S3. With + `trino-connector-hive` setting `hive.metastore` to `glue`, as the Release Guide's "Launch an Amazon EMR cluster with + Trino" does, the catalog is Floci's Glue Data Catalog instead. Each `trino-connector-` classification, which + changes "Trino's `.properties` file", adds that catalog, of the connector of its name, Trino's `delta_lake` + for `delta` and `raptor_legacy` for `raptor`, unless it names its own; `delta`, `hudi` and `iceberg` are on the + cluster's metastore at `thrift://localhost:9083`, as the Release Guide's Delta Lake and Iceberg tutorials have them, + or on Floci's Glue with `hive.metastore` set to `glue`, Iceberg's `iceberg.catalog.type` for Iceberg, and on Floci's + S3, as `hive` is. A classification's properties go into its catalog after Floci's, a later configuration's winning. + The image's own catalogs go, as EMR's Trino has those the cluster configures. Trino reaches S3 and Glue as the + cluster's EC2 instance profile's role, with a session of its own, as the metastore does. A step runs `trino-cli`, as + the Release Guide's "Start the Trino CLI by running trino-cli" does on the primary node, through `command-runner.jar`: + the CLI of the same Trino, which Floci copies into the cluster's image from Trino's image as it makes it, on the + image's Java 17, connects to the coordinator unless the step names a `--server` of its own. The cluster's first step + starts Trino, with its HDFS, and waits up to three minutes until it has answered a query for ten seconds, as Trino + runs a query that reads a catalog once it has learnt that its node serves the catalog, a Trino that does not failing + the step; the cluster's next steps have it at once. It goes before its primary node, whose network it shares, when the cluster ends, on a reset and on a shutdown, and one an earlier Floci left goes when the EMR service starts, whatever its cluster, as its session went with that Floci: the cluster's next step starts another. * **S3DistCp**: the image has no `s3-dist-cp`, so a `command-runner.jar` step whose @@ -1065,14 +1073,15 @@ holding the driver and its executors, or a command or a script. The cluster itse - **Pig is Apache's 0.18.0, and only with `pig.enabled`.** EMR's 7.x releases ship Pig 0.17.0, whose Apache build is for Hadoop 2; no AWS image carries Pig, so Floci downloads Apache's 0.18.0, for Hadoop 3, when it is enabled, and runs it on the image's Tez (see **Pig steps**). -- **Trino is the Trino project's build, from the first step, with its `hive` catalog alone, and only with - `trino.enabled`.** EMR ships its own `-amzn` builds; Floci runs the Trino project's image of the same version (see - **Trino**). The cluster's first step starts it, as it does the primary node's HDFS, where EMR's runs once the - cluster is up, and Floci gives no address to reach it from outside the cluster's network. Its one catalog is - `hive`: no other `trino-connector-*` classification, nor `trino-config`, applies yet. With `docker-network` set to - `host`, `container:` or `none` it does not run, as the metastore service does not. From `emr-7.14.0` on, "When - you select Trino as the only application at launch, Amazon EMR no longer starts YARN and HDFS"; Floci's primary node - still runs the HDFS, beside the metastore. +- **Trino is the Trino project's build, from the first step, and only with `trino.enabled`.** EMR ships its own + `-amzn` builds; Floci runs the Trino project's image of the same version (see **Trino**), so a connector that + image has no plugin for stops Trino, with what it logged, and the step. The cluster's first step starts it, as it + does the primary node's HDFS, where EMR's runs once the cluster is up, and Floci gives no address to reach it from + outside the cluster's network. Its `trino-connector-*` classifications and `trino-config` apply; `trino-node`, + `trino-log`, `trino-env`, `trino-password-authenticator` and `trino-exchange-manager` do not yet. With + `docker-network` set to `host`, `container:` or `none` it does not run, as the metastore service does not. From + `emr-7.14.0` on, "When you select Trino as the only application at launch, Amazon EMR no longer starts YARN and + HDFS"; Floci's primary node still runs the HDFS, beside the metastore. - **Tez's intermediate data is not compressed on YARN.** The images name the LZO codec for it, whose native library they lack, so Floci turns that compression off, which a `tez-site` classification can turn back on with a codec they have. - **No Hive metastore service in a network namespace the steps share.** With `docker-network` set to `host` or diff --git a/src/main/java/io/floci/aws/services/emr/ClusterStorage.java b/src/main/java/io/floci/aws/services/emr/ClusterStorage.java index 61da94a278..eb43993b54 100644 --- a/src/main/java/io/floci/aws/services/emr/ClusterStorage.java +++ b/src/main/java/io/floci/aws/services/emr/ClusterStorage.java @@ -123,10 +123,11 @@ public interface ClusterStorage { /** * Trino's coordinator on a cluster's primary node: the {@code image} it runs from, the memory its container gets, - * and the cluster's {@code trino-connector-hive} properties, which its {@code hive} catalog gets after Floci's - * (see {@link EmrTrino#hiveCatalog}). It reaches S3 and Glue as the metastore does. + * the cluster's {@code trino-connector-} properties by catalog, which its catalogs get after Floci's (see + * {@link EmrTrino#catalogs}), and its {@code trino-config} properties, which its {@code config.properties} gets + * after Floci's (see {@link EmrTrino#config}). It reaches S3 and Glue as the metastore does. */ - record Trino(String image, int memoryMb, Map hiveConnector) { + record Trino(String image, int memoryMb, Map> connectors, Map config) { } /** diff --git a/src/main/java/io/floci/aws/services/emr/EmrClusterStorage.java b/src/main/java/io/floci/aws/services/emr/EmrClusterStorage.java index af7b79f543..e944d580db 100644 --- a/src/main/java/io/floci/aws/services/emr/EmrClusterStorage.java +++ b/src/main/java/io/floci/aws/services/emr/EmrClusterStorage.java @@ -1598,19 +1598,19 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown { // Known before it starts, so a teardown while it starts removes it. runningTrino.add(name); try { - lifecycleManager.createAndStart(containerBuilder.newContainer(imageId) + ContainerBuilder.Builder spec = containerBuilder.newContainer(imageId) .withName(name) .withNetworkMode(network) .withMemoryMb(trino.memoryMb()) .withEntrypoint(List.of("/bin/bash", "-c", EmrTrino.ENTRYPOINT)) .withEnv(awsEnv.sdkBaselineEnv(region, Optional.empty(), endpoint, credentials, accountId)) - .withEnv(EmrTrino.CONFIG_VARIABLE, EmrTrino.CONFIG) - .withEnv(EmrTrino.CATALOG_VARIABLE, - EmrTrino.properties(EmrTrino.hiveCatalog(trino.hiveConnector(), endpoint, region))) + .withEnv(EmrTrino.CONFIG_VARIABLE, EmrTrino.properties(EmrTrino.config(trino.config()))) .withJavaTrustStore() .withLogRotation() - .withLabels(labels(clusterId, accountId, region, EmrTrino.COMPONENT)) - .build()); + .withLabels(labels(clusterId, accountId, region, EmrTrino.COMPONENT)); + EmrTrino.catalogs(trino.connectors(), endpoint, region).forEach((catalog, properties) -> + spec.withEnv(EmrTrino.CATALOG_PREFIX + catalog, EmrTrino.properties(properties))); + lifecycleManager.createAndStart(spec.build()); } catch (RuntimeException e) { releaseSession(name); throw e; @@ -1619,7 +1619,7 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown { stopIfStopped(clusterId, teardown, stopped); LOG.infov("Started the Trino of EMR cluster {0}", clusterId); } - awaitTrino(clusterId, name, teardown, stopped); + awaitTrino(clusterId, name, EmrTrino.port(trino.config()), teardown, stopped); readyTrino.add(name); } @@ -1658,10 +1658,10 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown { } } - // Waits for the Trino container named so to have run a query for TRINO_SETTLE, within TRINO_START_TIMEOUT: until - // its node manager has learnt that it serves its catalogs, a query that reads one fails "No nodes available to run - // query", one with none running already. - private void awaitTrino(String clusterId, String name, long teardown, BooleanSupplier stopped) { + // Waits for the Trino container named so to have run a query on port for TRINO_SETTLE, within TRINO_START_TIMEOUT: + // until its node manager has learnt that it serves its catalogs, a query that reads one fails "No nodes available + // to run query", one with none running already. + private void awaitTrino(String clusterId, String name, int port, long teardown, BooleanSupplier stopped) { long deadline = nanoTime.getAsLong() + TRINO_START_TIMEOUT.toNanos(); long answering = Long.MIN_VALUE; while (teardowns.get() == teardown && !stopped.getAsBoolean()) { @@ -1674,7 +1674,7 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown { ContainerExec.Result query; try { query = ContainerExec.run(lifecycleManager.getDockerClient(), name, - EmrTrino.READY_QUERY.toArray(String[]::new), 30); + EmrTrino.readyQuery(port).toArray(String[]::new), 30); } catch (RuntimeException e) { // It may have stopped after it was looked at, which makes Docker refuse the exec: the next look // says so. diff --git a/src/main/java/io/floci/aws/services/emr/EmrService.java b/src/main/java/io/floci/aws/services/emr/EmrService.java index 79ccef89d3..c25e3a9d0f 100644 --- a/src/main/java/io/floci/aws/services/emr/EmrService.java +++ b/src/main/java/io/floci/aws/services/emr/EmrService.java @@ -3107,7 +3107,8 @@ public class EmrService implements Resettable, StoredResourceArns, ContainerTear Supplier nodeYarn = runsYarn(cluster) ? currentYarn(cluster, accountId, region) : null; String trinoImage = trinoImage(cluster); ClusterStorage.Trino trino = trinoImage == null ? null : new ClusterStorage.Trino(trinoImage, trinoMemoryMb, - EmrSparkSteps.trinoHiveConnector(cluster.getConfigurations(), SNAPSHOT_MAPPER)); + EmrSparkSteps.trinoConnectors(cluster.getConfigurations(), SNAPSHOT_MAPPER), + EmrSparkSteps.trinoConfig(cluster.getConfigurations(), SNAPSHOT_MAPPER)); ClusterStorage.HiveMetastore hiveMetastore = withHiveImage(cluster) ? new ClusterStorage.HiveMetastore(instanceProfileRole(cluster, accountId), EmrSparkSteps.hiveMetastoreSettings(cluster.getConfigurations(), SNAPSHOT_MAPPER), trino) @@ -3165,7 +3166,9 @@ public class EmrService implements Resettable, StoredResourceArns, ContainerTear application != null ? application : List.of(), command, Duration.ZERO, EmrSparkSteps.logFolder(cluster, step), null, stepEnvironment(step, cluster, command != null && pig, - trinoImage(cluster) != null ? EmrTrino.server(masterPrivateDnsName(cluster)) : null), + trinoImage(cluster) != null ? EmrTrino.server(masterPrivateDnsName(cluster), + EmrTrino.port(EmrSparkSteps.trinoConfig(cluster.getConfigurations(), + SNAPSHOT_MAPPER))) : null), List.of(), storage, EmrSparkSteps.coreSite(cluster.getConfigurations(), SNAPSHOT_MAPPER), EmrSparkSteps.sparkLog4j2(cluster.getConfigurations(), SNAPSHOT_MAPPER), diff --git a/src/main/java/io/floci/aws/services/emr/EmrSparkSteps.java b/src/main/java/io/floci/aws/services/emr/EmrSparkSteps.java index e96977c835..bc1df62503 100644 --- a/src/main/java/io/floci/aws/services/emr/EmrSparkSteps.java +++ b/src/main/java/io/floci/aws/services/emr/EmrSparkSteps.java @@ -278,9 +278,32 @@ final class EmrSparkSteps { return installs(releaseLabel, applications, objectMapper, EmrTrino.APPLICATION); } - /** The properties of a cluster's {@code trino-connector-hive}, which its Trino's {@code hive} catalog gets. */ - static Map trinoHiveConnector(String configurations, ObjectMapper objectMapper) { - return properties(configurations, objectMapper, EmrTrino.HIVE_CONNECTOR); + /** + * The properties of a cluster's {@code trino-connector-} classifications by catalog, in the order they + * come, a later configuration's winning, each of which changes "Trino's {@code .properties} file". One + * whose catalog is not a name Trino takes ({@link EmrTrino#CATALOG_NAME}) names none. + */ + static Map> trinoConnectors(String configurations, ObjectMapper objectMapper) { + Map> connectors = new LinkedHashMap<>(); + for (JsonNode configuration : stored(configurations, objectMapper)) { + String classification = configuration.path("Classification").asText(); + if (!classification.startsWith(EmrTrino.CONNECTOR_PREFIX)) { + continue; + } + String catalog = classification.substring(EmrTrino.CONNECTOR_PREFIX.length()); + if (!EmrTrino.CATALOG_NAME.matcher(catalog).matches()) { + continue; + } + Map properties = connectors.computeIfAbsent(catalog, name -> new LinkedHashMap<>()); + configuration.path("Properties").properties() + .forEach(property -> properties.put(property.getKey(), property.getValue().asText())); + } + return connectors; + } + + /** The properties of a cluster's {@code trino-config}, which its Trino's {@code config.properties} gets. */ + static Map trinoConfig(String configurations, ObjectMapper objectMapper) { + return properties(configurations, objectMapper, EmrTrino.CONFIG_CLASSIFICATION); } // Whether a cluster's Applications name any of names, in any case, unless its release is of the AWS runtime for diff --git a/src/main/java/io/floci/aws/services/emr/EmrTrino.java b/src/main/java/io/floci/aws/services/emr/EmrTrino.java index 9650084b0a..e8fbcd1ab8 100644 --- a/src/main/java/io/floci/aws/services/emr/EmrTrino.java +++ b/src/main/java/io/floci/aws/services/emr/EmrTrino.java @@ -3,6 +3,8 @@ package io.floci.aws.services.emr; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -11,19 +13,32 @@ import java.util.stream.Collectors; * too, as a cluster of one node's does, runs from the Trino project's image of the version the release's page in the * Release Guide gives, in a container of its own that shares the primary node's network, as a daemon of that node. * "By default, Amazon EMR configures the Presto web interface on the Presto coordinator to use port 8889 (for PrestoDB - * and Trino)", where it listens. EMR installs {@code hcatalog-server} with Trino, so its {@code hive} catalog is the - * cluster's Hive metastore, unless the cluster's {@code trino-connector-hive} classification sets - * {@code hive.metastore} to {@code glue}, as the Release Guide's "Launch an Amazon EMR cluster with Trino" does. Its - * steps run {@code trino-cli}, EMR's command for Trino's CLI, which this class writes for the image they run in. + * and Trino)", where it listens unless the cluster's {@code trino-config} sets {@code http-server.http.port}, which + * classification changes "Trino's config.properties file". Its catalogs are the {@code hive} one and those the + * cluster's {@code trino-connector-} classifications name, each of which changes "Trino's + * {@code .properties} file". EMR installs {@code hcatalog-server} with Trino, so the catalogs whose tables + * are in S3, {@code hive}, {@code delta}, {@code hudi} and {@code iceberg}, are on the cluster's Hive metastore, as + * the Release Guide's Delta Lake and Iceberg tutorials have them at {@code thrift://localhost:9083}, unless the + * classification puts them in the Glue Data Catalog, as "Launch an Amazon EMR cluster with Trino" does. Its steps run + * {@code trino-cli}, EMR's command for Trino's CLI, which this class writes for the image they run in. */ final class EmrTrino { /** The application's name, as the Release Guide's list of applications spells it. */ static final String APPLICATION = "Trino"; - /** The port Trino listens on, on the primary node. */ + /** The port Trino listens on, on the primary node, unless the cluster's {@code trino-config} names another. */ static final int PORT = 8889; - /** The classification whose properties go into the {@code hive} catalog. */ - static final String HIVE_CONNECTOR = "trino-connector-hive"; + /** The prefix of the classifications that each change a catalog, the rest of whose name names it. */ + static final String CONNECTOR_PREFIX = "trino-connector-"; + /** The classification that changes Trino's {@code config.properties}. */ + static final String CONFIG_CLASSIFICATION = "trino-config"; + /** The catalog every Trino cluster has. */ + static final String HIVE = "hive"; + /** + * A catalog's name as Floci takes it: Trino's own, letters, digits and underscores, which the entrypoint passes as + * the name of a shell variable. + */ + static final Pattern CATALOG_NAME = Pattern.compile("[a-z][a-z0-9_]*"); /** The component label of a cluster's Trino container, which goes with its primary node's. */ static final String COMPONENT = "emr-trino"; /** The variable a step's {@code trino-cli} reads the coordinator's address from. */ @@ -50,30 +65,28 @@ final class EmrTrino { done exec "$java" -jar %1$s --server "${%2$s:-localhost:%3$d}" "$@" """.formatted(CLI, SERVER_VARIABLE, PORT); - /** What tells the Trino container is ready: a query, run with the CLI of its image. */ - static final List READY_QUERY = List.of(IMAGE_CLI, "--server", "localhost:" + PORT, "--execute", - "SELECT 1"); - /** The variables the Trino container's entrypoint writes its configuration from. */ + /** The variable the Trino container's entrypoint writes its {@code config.properties} from. */ static final String CONFIG_VARIABLE = "FLOCI_TRINO_CONFIG"; - static final String CATALOG_VARIABLE = "FLOCI_TRINO_CATALOG_HIVE"; + /** The prefix of the variables it writes its catalogs from, one each, the rest of whose name names it. */ + static final String CATALOG_PREFIX = "FLOCI_TRINO_CATALOG_"; /** - * The Trino container's entrypoint: its configuration, and its {@code hive} catalog alone, as EMR's Trino has the - * catalogs the cluster configures, then Trino, as its image starts it. Its image names the node after its host, + * The Trino container's entrypoint: its configuration, and the catalogs Floci gives it alone, as EMR's Trino has + * the catalogs the cluster configures, then Trino, as its image starts it. Its image names the node after its host, * which is the primary node's, whose dots Trino refuses in a node's id, so the node is named with hyphens instead. */ static final String ENTRYPOINT = "printf '%s\\n' \"$" + CONFIG_VARIABLE + "\" > /etc/trino/config.properties" + " && rm -f /etc/trino/catalog/*.properties" - + " && printf '%s\\n' \"$" + CATALOG_VARIABLE + "\" > /etc/trino/catalog/hive.properties" + + " && for catalog in ${!" + CATALOG_PREFIX + "@}; do printf '%s\\n' \"${!catalog}\"" + + " > \"/etc/trino/catalog/${catalog#" + CATALOG_PREFIX + "}.properties\" || exit; done" + " && printf 'node.id=%s\\n' \"${HOSTNAME//./-}\" >> /etc/trino/node.properties" + " && exec /usr/lib/trino/bin/run-trino"; - /** A coordinator that runs the queries too, on {@link #PORT}. */ - static final String CONFIG = """ - coordinator=true - node-scheduler.include-coordinator=true - http-server.http.port=%1$d - discovery.uri=http://localhost:%1$d""".formatted(PORT); private static final String GLUE = "glue"; + private static final String METASTORE_URI = "hive.metastore.uri"; + // The catalogs of EMR's classifications whose connector Trino names otherwise; the others are named as theirs. + private static final Map CONNECTORS = Map.of("delta", "delta_lake", "raptor", "raptor_legacy"); + // The catalogs whose tables are in S3, their metadata in a Hive metastore or the Glue Data Catalog. + private static final Set LAKES = Set.of(HIVE, "delta", "hudi", "iceberg"); private EmrTrino() { } @@ -97,33 +110,91 @@ final class EmrTrino { .orElse(null); } + /** The port Trino listens on: the {@code http-server.http.port} of the cluster's {@code trino-config}, or EMR's. */ + static int port(Map config) { + String port = config.get("http-server.http.port"); + if (port != null) { + try { + return Integer.parseInt(port.trim()); + } catch (NumberFormatException ignored) { + // Trino refuses it as it starts, and says so in its log. + } + } + return PORT; + } + /** The address a step's {@code trino-cli} reaches the coordinator at, on the primary node named {@code host}. */ - static String server(String host) { - return "http://" + host + ":" + PORT; + static String server(String host, int port) { + return "http://" + host + ":" + port; + } + + /** What tells the Trino container is ready: a query, run with the CLI of its image on {@code port}. */ + static List readyQuery(int port) { + return List.of(IMAGE_CLI, "--server", "localhost:" + port, "--execute", "SELECT 1"); } /** - * The {@code hive} catalog: the cluster's metastore, which runs beside Trino on the primary node, or, with - * {@code hive.metastore} set to {@code glue}, Floci's Glue; Floci's S3 at {@code endpoint} in {@code region}, by - * path, the HDFS of the cluster's warehouse through Hadoop's file system; and the cluster's - * {@code trino-connector-hive} properties after these, each in its place. Credentials come from the container's - * environment, as neither file system has a setting for a session's token. + * The coordinator's {@code config.properties}: a coordinator that runs the queries too, on its {@link #port}, its + * discovery at that port unless the cluster's {@code trino-config} names another, and that classification's + * properties after these, each in its place. */ - static Map hiveCatalog(Map classification, String endpoint, String region) { + static Map config(Map classification) { + Map config = new LinkedHashMap<>(); + config.put("coordinator", "true"); + config.put("node-scheduler.include-coordinator", "true"); + config.put("http-server.http.port", String.valueOf(PORT)); + config.put("discovery.uri", "http://localhost:" + port(classification)); + config.putAll(classification); + return config; + } + + /** + * Trino's catalogs, by name: {@code hive}, then each that {@code connectors}, the cluster's + * {@code trino-connector-} classifications' properties by catalog, name (see {@link #catalog}). + */ + static Map> catalogs(Map> connectors, String endpoint, + String region) { + Map> catalogs = new LinkedHashMap<>(); + catalogs.put(HIVE, catalog(HIVE, connectors.getOrDefault(HIVE, Map.of()), endpoint, region)); + connectors.forEach((name, classification) -> catalogs.computeIfAbsent(name, + catalog -> catalog(catalog, classification, endpoint, region))); + return catalogs; + } + + /** + * A catalog: the connector of its name, as the Release Guide's Delta Lake tutorial gives {@code delta} no + * {@code connector.name} of its own; for {@code hive}, {@code delta}, {@code hudi} and {@code iceberg}, the + * cluster's metastore, which runs beside Trino on the primary node, or Floci's Glue where the classification says + * {@code glue} ({@code hive.metastore}, or Iceberg's {@code iceberg.catalog.type}), and Floci's S3 at + * {@code endpoint} in {@code region}, by path, with the HDFS of the cluster's warehouse through Hadoop's file + * system; for {@code delta}, writes to S3, which the tutorial makes with only a metastore configured; and the + * classification's properties after these, each in its place. Credentials come from the container's environment, + * as neither file system has a setting for a session's token. + */ + static Map catalog(String name, Map classification, String endpoint, + String region) { Map catalog = new LinkedHashMap<>(); - catalog.put("connector.name", "hive"); - if (GLUE.equalsIgnoreCase(classification.get("hive.metastore"))) { - catalog.put("hive.metastore", GLUE); - catalog.put("hive.metastore.glue.region", region); - catalog.put("hive.metastore.glue.endpoint-url", endpoint); - } else { - catalog.put("hive.metastore.uri", "thrift://localhost:" + EmrClusterStorage.HIVE_METASTORE_PORT); + catalog.put("connector.name", CONNECTORS.getOrDefault(name, name)); + if (LAKES.contains(name)) { + String type = "iceberg".equals(name) ? classification.get("iceberg.catalog.type") + : classification.get("hive.metastore"); + if (GLUE.equalsIgnoreCase(type)) { + catalog.put("iceberg".equals(name) ? "iceberg.catalog.type" : "hive.metastore", GLUE); + catalog.put("hive.metastore.glue.region", region); + catalog.put("hive.metastore.glue.endpoint-url", endpoint); + } else if (type == null || "thrift".equalsIgnoreCase(type) || "hive_metastore".equalsIgnoreCase(type)) { + catalog.put(METASTORE_URI, "thrift://localhost:" + EmrClusterStorage.HIVE_METASTORE_PORT); + } + catalog.put("fs.native-s3.enabled", "true"); + catalog.put("fs.hadoop.enabled", "true"); + catalog.put("s3.endpoint", endpoint); + catalog.put("s3.region", region); + catalog.put("s3.path-style-access", "true"); + } + if ("delta".equals(name)) { + // The tutorial's INSERT INTO a table in S3, which Trino refuses there unless told it may. + catalog.put("delta.enable-non-concurrent-writes", "true"); } - catalog.put("fs.native-s3.enabled", "true"); - catalog.put("fs.hadoop.enabled", "true"); - catalog.put("s3.endpoint", endpoint); - catalog.put("s3.region", region); - catalog.put("s3.path-style-access", "true"); catalog.putAll(classification); return catalog; } diff --git a/src/test/java/io/floci/aws/services/emr/EmrClusterStorageTest.java b/src/test/java/io/floci/aws/services/emr/EmrClusterStorageTest.java index 0a74f5e895..9c924d7d2e 100644 --- a/src/test/java/io/floci/aws/services/emr/EmrClusterStorageTest.java +++ b/src/test/java/io/floci/aws/services/emr/EmrClusterStorageTest.java @@ -127,7 +127,7 @@ class EmrClusterStorageTest { // The same with Trino beside it, from the image of emr-7.5.0's Trino. private static final ClusterStorage.HiveMetastore TRINO_METASTORE = new ClusterStorage.HiveMetastore("arn:aws:iam::123456789012:role/r", Map.of(), - new ClusterStorage.Trino("trinodb/trino:446", 2048, Map.of())); + new ClusterStorage.Trino("trinodb/trino:446", 2048, Map.of(), Map.of())); private final EmulatorConfig config = mock(EmulatorConfig.class, RETURNS_DEEP_STUBS); private final DockerClient docker = mock(DockerClient.class); @@ -2003,9 +2003,9 @@ class EmrClusterStorageTest { verify(trinoSpec).withNetworkMode("container:c6c6c6"); verify(trinoSpec).withMemoryMb(2048); verify(trinoSpec).withEnv(List.of("AWS_ACCESS_KEY_ID=ASIATRINO")); - verify(trinoSpec).withEnv(EmrTrino.CONFIG_VARIABLE, EmrTrino.CONFIG); - verify(trinoSpec).withEnv(EmrTrino.CATALOG_VARIABLE, EmrTrino.properties(EmrTrino.hiveCatalog(Map.of(), - "http://host.docker.internal:4566", "us-east-1"))); + verify(trinoSpec).withEnv(EmrTrino.CONFIG_VARIABLE, EmrTrino.properties(EmrTrino.config(Map.of()))); + verify(trinoSpec).withEnv(EmrTrino.CATALOG_PREFIX + "hive", EmrTrino.properties(EmrTrino.catalog("hive", + Map.of(), "http://host.docker.internal:4566", "us-east-1"))); verify(trinoSpec).withEntrypoint(List.of("/bin/bash", "-c", EmrTrino.ENTRYPOINT)); verify(trinoSpec).withJavaTrustStore(); verify(trinoSpec).withLabels(argThat(labels -> diff --git a/src/test/java/io/floci/aws/services/emr/EmrServiceContainerStepsTest.java b/src/test/java/io/floci/aws/services/emr/EmrServiceContainerStepsTest.java index f9949813dc..35a5ef1985 100644 --- a/src/test/java/io/floci/aws/services/emr/EmrServiceContainerStepsTest.java +++ b/src/test/java/io/floci/aws/services/emr/EmrServiceContainerStepsTest.java @@ -1108,7 +1108,8 @@ class EmrServiceContainerStepsTest { EmrCluster requested = cluster("trino", true, query); requested.setApplications(TRINO); requested.setConfigurations("[{\"Classification\": \"trino-connector-hive\", \"Properties\": " - + "{\"hive.metastore\": \"glue\"}}]"); + + "{\"hive.metastore\": \"glue\"}}, {\"Classification\": \"trino-connector-tpch\"}, " + + "{\"Classification\": \"trino-config\", \"Properties\": {\"http-server.http.port\": \"8890\"}}]"); withTrino.runJobFlow(requested, REGION); fixture.runStepThread(); @@ -1119,12 +1120,14 @@ class EmrServiceContainerStepsTest { "public.ecr.aws/emr-serverless/hive/emr-7.5.0:latest", "true", "false")), fixture.releaseImages.asked); assertEquals(List.of("trinodb/trino:446"), fixture.releaseImages.trinoImages); - assertEquals(new ClusterStorage.Trino("trinodb/trino:446", 2048, Map.of("hive.metastore", "glue")), + assertEquals(new ClusterStorage.Trino("trinodb/trino:446", 2048, Map.of("hive", Map.of("hive.metastore", + "glue"), "tpch", Map.of()), Map.of("http-server.http.port", "8890")), fixture.clusterStorage.metastores.get(0).trino()); SparkJobRunner.Job job = runner.jobs.get(0); assertEquals(args, job.command()); String host = fixture.clusterStorage.hdfs.get(0).get(1); - assertEquals("http://" + host + ":8889", job.environment().get("FLOCI_TRINO_SERVER")); + // On the port its trino-config names. + assertEquals("http://" + host + ":8890", job.environment().get("FLOCI_TRINO_SERVER")); } @Test diff --git a/src/test/java/io/floci/aws/services/emr/EmrSparkStepsTest.java b/src/test/java/io/floci/aws/services/emr/EmrSparkStepsTest.java index 5160ff1b17..d97c6ab5a8 100644 --- a/src/test/java/io/floci/aws/services/emr/EmrSparkStepsTest.java +++ b/src/test/java/io/floci/aws/services/emr/EmrSparkStepsTest.java @@ -246,18 +246,28 @@ class EmrSparkStepsTest { } @Test - void trinosHiveCatalogGetsTheClustersTrinoConnectorHiveALaterConfigurationWinning() { + void trinosCatalogsAreTheClustersTrinoConnectorsALaterConfigurationWinning() { String configurations = """ [{"Classification": "trino-connector-hive", "Properties": {"hive.metastore": "glue", "hive.metastore.glue.catalogid": "111122223333"}}, {"Classification": "hive-site", "Properties": {"hive.metastore.uris": "thrift://elsewhere:9083"}}, + {"Classification": "trino-connector-iceberg", "Properties": {"connector.name": "iceberg"}}, {"Classification": "trino-connector-hive", - "Properties": {"hive.metastore.glue.catalogid": "444455556666"}}] + "Properties": {"hive.metastore.glue.catalogid": "444455556666"}}, + {"Classification": "trino-connector-tpch"}, + {"Classification": "trino-connector-Bad-Name", "Properties": {"connector.name": "memory"}}, + {"Classification": "trino-config", "Properties": {"http-server.http.port": "8890"}}] """; + Map> connectors = EmrSparkSteps.trinoConnectors(configurations, objectMapper); + + assertEquals(List.of("hive", "iceberg", "tpch"), List.copyOf(connectors.keySet())); assertEquals(Map.of("hive.metastore", "glue", "hive.metastore.glue.catalogid", "444455556666"), - EmrSparkSteps.trinoHiveConnector(configurations, objectMapper)); - assertEquals(Map.of(), EmrSparkSteps.trinoHiveConnector(null, objectMapper)); + connectors.get("hive")); + assertEquals(Map.of(), connectors.get("tpch")); + assertEquals(Map.of("http-server.http.port", "8890"), EmrSparkSteps.trinoConfig(configurations, + objectMapper)); + assertEquals(Map.of(), EmrSparkSteps.trinoConnectors(null, objectMapper)); } @Test diff --git a/src/test/java/io/floci/aws/services/emr/EmrTrinoNightlyIntegrationTest.java b/src/test/java/io/floci/aws/services/emr/EmrTrinoNightlyIntegrationTest.java index c3bc1ff7be..cb3f43d78e 100644 --- a/src/test/java/io/floci/aws/services/emr/EmrTrinoNightlyIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/emr/EmrTrinoNightlyIntegrationTest.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -49,7 +50,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * cluster whose {@code Applications} name Trino runs its coordinator on its primary node, and a step runs EMR's * {@code trino-cli} against it, as the Release Guide's "Connect to the primary node for the Amazon EMR cluster and run * queries" does, over a CSV in Floci's S3. Its {@code hive} catalog is the cluster's Hive metastore, or, with - * {@code trino-connector-hive} setting {@code hive.metastore} to {@code glue}, Floci's Glue Data Catalog. + * {@code trino-connector-hive} setting {@code hive.metastore} to {@code glue}, Floci's Glue Data Catalog. The + * cluster's other {@code trino-connector-} classifications add catalogs, Iceberg's on Glue as the Release + * Guide's "Use an Iceberg cluster with Trino" has it, and its {@code trino-config} moves Trino to another port. * *

A nightly check: it pulls the Trino image of {@code emr-7.5.0}'s Trino, 446, about 1 GB, and the release's Spark * and Hive images. @@ -160,6 +163,39 @@ class EmrTrinoNightlyIntegrationTest { .stream().map(Table::name).sorted().toList()); } + @Test + @Timeout(value = 7, unit = TimeUnit.MINUTES) + void trinoConnectorClassificationsAddCatalogsAndTrinoConfigMovesTheCoordinatorsPort() { + String schema = bucket.replace('-', '_'); + GlueClient glue = AwsTestClients.create(GlueClient.builder(), "000000000000", Region.US_EAST_1); + cleanup.register(glue::close); + cleanup.register(() -> { + for (Table table : glue.getTables(request -> request.databaseName(schema)).tableList()) { + glue.deleteTable(request -> request.databaseName(schema).name(table.name())); + } + glue.deleteDatabase(request -> request.name(schema)); + }); + // The Release Guide's Iceberg catalog on the Glue Data Catalog, a TPC-H one, and another port. + startCluster(""" + [{"Classification": "trino-connector-iceberg", + "Properties": {"connector.name": "iceberg", "iceberg.catalog.type": "glue"}}, + {"Classification": "trino-connector-tpch", "Properties": {}}, + {"Classification": "trino-config", "Properties": {"http-server.http.port": "8890"}}]"""); + + String step = trinoStep("SHOW CATALOGS; CREATE SCHEMA iceberg." + schema + " WITH (location = '" + + s3Uri("iceberg/") + "'); CREATE TABLE iceberg." + schema + ".nation AS SELECT nationkey, name FROM " + + "tpch.tiny.nation; SELECT count(*) FROM iceberg." + schema + ".nation"); + + assertEquals("COMPLETED", state(step), () -> logs(step)); + String logs = logs(step); + assertTrue(logs.contains("\"hive\"\n\"iceberg\"\n\"system\"\n\"tpch\""), logs); + assertTrue(logs.contains("\"25\""), logs); + // An Iceberg table, in Floci's Glue, its files in the schema's folder of Floci's S3. + assertEquals("ICEBERG", glue.getTable(request -> request.databaseName(schema).name("nation")).table() + .parameters().get("table_type").toUpperCase(Locale.ROOT)); + assertFalse(s3.listObjectsV2(request -> request.bucket(bucket).prefix("iceberg/")).contents().isEmpty()); + } + // A schema in the bucket's warehouse folder, an external table over the CSV, a table of each item's sum, then the // sums. private String tables(String schema) { diff --git a/src/test/java/io/floci/aws/services/emr/EmrTrinoTest.java b/src/test/java/io/floci/aws/services/emr/EmrTrinoTest.java index 64045009a1..5c893b21ff 100644 --- a/src/test/java/io/floci/aws/services/emr/EmrTrinoTest.java +++ b/src/test/java/io/floci/aws/services/emr/EmrTrinoTest.java @@ -42,7 +42,7 @@ class EmrTrinoTest { @Test void theHiveCatalogIsTheClustersMetastoreOnFlocisS3() { - Map catalog = EmrTrino.hiveCatalog(Map.of(), ENDPOINT, "us-east-1"); + Map catalog = EmrTrino.catalog("hive", Map.of(), ENDPOINT, "us-east-1"); assertEquals(List.of("connector.name=hive", "hive.metastore.uri=thrift://localhost:9083", "fs.native-s3.enabled=true", "fs.hadoop.enabled=true", "s3.endpoint=" + ENDPOINT, @@ -57,7 +57,7 @@ class EmrTrinoTest { classification.put("hive.metastore.glue.catalogid", "111122223333"); classification.put("s3.path-style-access", "false"); - Map catalog = EmrTrino.hiveCatalog(classification, ENDPOINT, "eu-west-1"); + Map catalog = EmrTrino.catalog("hive", classification, ENDPOINT, "eu-west-1"); assertEquals(List.of("connector.name=hive", "hive.metastore=glue", "hive.metastore.glue.region=eu-west-1", "hive.metastore.glue.endpoint-url=" + ENDPOINT, "fs.native-s3.enabled=true", @@ -67,25 +67,100 @@ class EmrTrinoTest { } @Test - void theCoordinatorRunsTheQueriesTooOnEmrsPort() { - assertEquals(List.of("coordinator=true", "node-scheduler.include-coordinator=true", - "http-server.http.port=8889", "discovery.uri=http://localhost:8889"), - List.of(EmrTrino.CONFIG.split("\n"))); + void deltaIsTrinosDeltaLakeConnectorOnTheClustersMetastoreAsTheGuidesTutorialHasIt() { + // "trino-connector-delta" with "hive.metastore.uri":"thrift://localhost:9083" and no connector of its own. + Map catalog = EmrTrino.catalog("delta", Map.of("hive.metastore.uri", + "thrift://localhost:9083"), ENDPOINT, "us-east-1"); + + assertEquals("delta_lake", catalog.get("connector.name")); + assertEquals("thrift://localhost:9083", catalog.get("hive.metastore.uri")); + assertEquals(ENDPOINT, catalog.get("s3.endpoint")); + // Its INSERT INTO a table in S3, which Trino makes only so; the classification may say otherwise. + assertEquals("true", catalog.get("delta.enable-non-concurrent-writes")); + assertEquals("false", EmrTrino.catalog("delta", Map.of("delta.enable-non-concurrent-writes", "false"), + ENDPOINT, "us-east-1").get("delta.enable-non-concurrent-writes")); } @Test - void theEntrypointWritesTheConfigurationTheHiveCatalogAloneAndANodeIdTrinoTakes(@TempDir Path etc) + void icebergIsOnFlocisGlueWithItsCatalogTypeGlueElseOnTheClustersMetastore() { + Map glue = EmrTrino.catalog("iceberg", Map.of("connector.name", "iceberg", + "iceberg.catalog.type", "glue"), ENDPOINT, "us-east-1"); + Map metastore = EmrTrino.catalog("iceberg", Map.of("connector.name", "iceberg"), ENDPOINT, + "us-east-1"); + Map rest = EmrTrino.catalog("iceberg", Map.of("iceberg.catalog.type", "rest"), ENDPOINT, + "us-east-1"); + + assertEquals("glue", glue.get("iceberg.catalog.type")); + assertEquals(ENDPOINT, glue.get("hive.metastore.glue.endpoint-url")); + assertEquals("us-east-1", glue.get("hive.metastore.glue.region")); + assertNull(glue.get("hive.metastore.uri")); + // Trino's Iceberg catalog is a Hive metastore by default. + assertEquals("thrift://localhost:9083", metastore.get("hive.metastore.uri")); + assertNull(metastore.get("hive.metastore.glue.endpoint-url")); + // Another kind of catalog is the classification's alone, on Floci's S3. + assertNull(rest.get("hive.metastore.uri")); + assertNull(rest.get("hive.metastore.glue.endpoint-url")); + assertEquals(ENDPOINT, rest.get("s3.endpoint")); + } + + @Test + void aCatalogNotInS3IsItsConnectorAndTheClassificationsPropertiesAlone() { + assertEquals(Map.of("connector.name", "tpch"), EmrTrino.catalog("tpch", Map.of(), ENDPOINT, "us-east-1")); + assertEquals(Map.of("connector.name", "raptor_legacy"), EmrTrino.catalog("raptor", Map.of(), ENDPOINT, + "us-east-1")); + assertEquals(Map.of("connector.name", "postgresql", "connection-url", "jdbc:postgresql://db:5432/app"), + EmrTrino.catalog("postgresql", Map.of("connection-url", "jdbc:postgresql://db:5432/app"), ENDPOINT, + "us-east-1")); + } + + @Test + void theCatalogsAreHiveThenEachTheClusterConfigures() { + Map> connectors = new LinkedHashMap<>(); + connectors.put("tpch", Map.of()); + connectors.put("hive", Map.of("hive.metastore", "glue")); + + Map> catalogs = EmrTrino.catalogs(connectors, ENDPOINT, "us-east-1"); + + assertEquals(List.of("hive", "tpch"), List.copyOf(catalogs.keySet())); + assertEquals("glue", catalogs.get("hive").get("hive.metastore")); + assertEquals(List.of("hive"), List.copyOf(EmrTrino.catalogs(Map.of(), ENDPOINT, "us-east-1").keySet())); + } + + @Test + void theCoordinatorRunsTheQueriesTooOnEmrsPortOrTheOneTrinoConfigNames() { + assertEquals(List.of("coordinator=true", "node-scheduler.include-coordinator=true", + "http-server.http.port=8889", "discovery.uri=http://localhost:8889"), + List.of(EmrTrino.properties(EmrTrino.config(Map.of())).split("\n"))); + // "To change the port, use the presto-config configuration classification to set the http-server.http.port + // property", trino-config for Trino: its discovery follows. + Map moved = EmrTrino.config(Map.of("http-server.http.port", "8890", + "query.max-memory", "1GB")); + assertEquals(List.of("coordinator=true", "node-scheduler.include-coordinator=true", + "http-server.http.port=8890", "discovery.uri=http://localhost:8890", "query.max-memory=1GB"), + List.of(EmrTrino.properties(moved).split("\n"))); + assertEquals(8890, EmrTrino.port(moved)); + assertEquals(8889, EmrTrino.port(Map.of("http-server.http.port", "eighty"))); + assertEquals("http://ip-10-0-0-1.ec2.internal:8890", EmrTrino.server("ip-10-0-0-1.ec2.internal", 8890)); + assertEquals(List.of("/usr/bin/trino", "--server", "localhost:8890", "--execute", "SELECT 1"), + EmrTrino.readyQuery(8890)); + } + + @Test + void theEntrypointWritesTheConfigurationTheCatalogsFlociGivesAloneAndANodeIdTrinoTakes(@TempDir Path etc) throws Exception { Files.createDirectories(etc.resolve("catalog")); - Files.writeString(etc.resolve("catalog/tpch.properties"), "connector.name=tpch\n"); + Files.writeString(etc.resolve("catalog/tpcds.properties"), "connector.name=tpcds\n"); Files.writeString(etc.resolve("node.properties"), "node.environment=docker\n"); // The image's /etc/trino here, and its Trino left out. String entrypoint = EmrTrino.ENTRYPOINT.replace("/etc/trino", etc.toString()) .replace("exec /usr/lib/trino/bin/run-trino", "true"); assertTrue(EmrTrino.ENTRYPOINT.endsWith("exec /usr/lib/trino/bin/run-trino")); ProcessBuilder builder = new ProcessBuilder("bash", "-c", entrypoint).redirectErrorStream(true); - builder.environment().put(EmrTrino.CONFIG_VARIABLE, EmrTrino.CONFIG); - builder.environment().put(EmrTrino.CATALOG_VARIABLE, "connector.name=hive"); + String config = EmrTrino.properties(EmrTrino.config(Map.of())); + builder.environment().put(EmrTrino.CONFIG_VARIABLE, config); + builder.environment().put(EmrTrino.CATALOG_PREFIX + "hive", "connector.name=hive"); + builder.environment().put(EmrTrino.CATALOG_PREFIX + "iceberg", + "connector.name=iceberg\niceberg.catalog.type=glue"); // The primary node's host name, which the container shares. builder.environment().put("HOSTNAME", "ip-10-0-0-1.ec2.internal"); Process process = builder.start(); @@ -93,11 +168,14 @@ class EmrTrinoTest { assertTrue(process.waitFor(30, TimeUnit.SECONDS)); assertEquals(0, process.exitValue(), output); - assertEquals(EmrTrino.CONFIG + "\n", Files.readString(etc.resolve("config.properties"))); + assertEquals(config + "\n", Files.readString(etc.resolve("config.properties"))); try (Stream catalogs = Files.list(etc.resolve("catalog"))) { - assertEquals(List.of("hive.properties"), catalogs.map(path -> path.getFileName().toString()).toList()); + assertEquals(List.of("hive.properties", "iceberg.properties"), + catalogs.map(path -> path.getFileName().toString()).sorted().toList()); } assertEquals("connector.name=hive\n", Files.readString(etc.resolve("catalog/hive.properties"))); + assertEquals("connector.name=iceberg\niceberg.catalog.type=glue\n", + Files.readString(etc.resolve("catalog/iceberg.properties"))); // Trino takes letters, digits, hyphens and underscores in a node's id, and the image's run-trino names none // once node.properties does. assertEquals("node.environment=docker\nnode.id=ip-10-0-0-1-ec2-internal\n",