-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Install JDBC drivers for Delta product tests at runtime and upgrade docker-images to version 81
#17667
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
Merged
Merged
Install JDBC drivers for Delta product tests at runtime and upgrade docker-images to version 81
#17667
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
...g/trino-product-tests/src/main/java/io/trino/tests/product/utils/DeltaQueryExecutors.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /* | ||
| * Licensed 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 io.trino.tests.product.utils; | ||
|
|
||
| import com.google.common.collect.ImmutableList; | ||
| import com.google.common.collect.ImmutableMap; | ||
| import dev.failsafe.Failsafe; | ||
| import dev.failsafe.RetryPolicy; | ||
| import io.airlift.log.Logger; | ||
| import io.airlift.resolver.ArtifactResolver; | ||
| import io.airlift.resolver.DefaultArtifact; | ||
| import io.trino.tempto.context.TestContext; | ||
| import io.trino.tempto.query.JdbcConnectionsPool; | ||
| import io.trino.tempto.query.JdbcConnectivityParamsState; | ||
| import io.trino.tempto.query.JdbcQueryExecutor; | ||
|
|
||
| import javax.annotation.concurrent.GuardedBy; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
|
|
||
| import static com.google.common.collect.MoreCollectors.onlyElement; | ||
| import static io.airlift.resolver.ArtifactResolver.MAVEN_CENTRAL_URI; | ||
| import static io.airlift.resolver.ArtifactResolver.USER_LOCAL_REPO; | ||
| import static java.util.Map.entry; | ||
|
|
||
| public final class DeltaQueryExecutors | ||
| { | ||
| private static final Logger log = Logger.get(DeltaQueryExecutors.class); | ||
|
|
||
| private static final Map<String, Map.Entry<String, String>> ARTIFACTS = ImmutableMap.<String, Map.Entry<String, String>>builder() | ||
| .put("org.apache.hive.jdbc.HiveDriver", entry("org.apache.hive:hive-jdbc:jar:standalone:3.1.3", "hive-jdbc-3.1.3-standalone.jar")) | ||
| .put("com.databricks.client.jdbc.Driver", entry("com.databricks:databricks-jdbc:2.6.32", "databricks-jdbc-2.6.32.jar")) | ||
| .buildOrThrow(); | ||
|
|
||
| @GuardedBy("DRIVERS") | ||
| private static final Map<String, String> DRIVERS = new HashMap<>(); | ||
| @GuardedBy("JDBC_EXECUTORS") | ||
| private static final Map<JdbcConnectivityParamsState, JdbcQueryExecutor> JDBC_EXECUTORS = new HashMap<>(); | ||
|
Comment on lines
+49
to
+52
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we use tempto driver please use tempto-configuration.yaml to configure drivers
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sent #18464 |
||
|
|
||
| private static final RetryPolicy<String> loadDatabaseDriverRetryPolicy = RetryPolicy.<String>builder() | ||
| .withMaxRetries(30) | ||
| .withDelay(Duration.ofSeconds(10)) | ||
| .onRetry(event -> log.warn(event.getLastException(), "Download failed on attempt %d, will retry.", event.getAttemptCount())) | ||
| .build(); | ||
|
|
||
| private DeltaQueryExecutors() {} | ||
|
|
||
| public static JdbcQueryExecutor createDeltaQueryExecutor(TestContext testContext) | ||
| { | ||
| JdbcConnectivityParamsState jdbcParamsState = testContext.getDependency(JdbcConnectivityParamsState.class, "delta"); | ||
| JdbcConnectionsPool jdbcConnectionsPool = testContext.getDependency(JdbcConnectionsPool.class); | ||
| synchronized (JDBC_EXECUTORS) { | ||
| return JDBC_EXECUTORS.computeIfAbsent(jdbcParamsState, param -> new JdbcQueryExecutor(withRuntimeJar(param), jdbcConnectionsPool, testContext)); | ||
| } | ||
| } | ||
|
|
||
| private static JdbcConnectivityParamsState withRuntimeJar(JdbcConnectivityParamsState jdbcParamsState) | ||
| { | ||
| String jarFilePath; | ||
| synchronized (DRIVERS) { | ||
| jarFilePath = DRIVERS.computeIfAbsent(jdbcParamsState.driverClass, className -> Failsafe.with(loadDatabaseDriverRetryPolicy) | ||
| .get(() -> loadDatabaseDriverJar(className))); | ||
| } | ||
|
|
||
| return JdbcConnectivityParamsState.builder() | ||
| .setName(jdbcParamsState.getName().orElseThrow()) | ||
| .setDriverClass(jdbcParamsState.driverClass) | ||
| .setUrl(jdbcParamsState.url) | ||
| .setUser(jdbcParamsState.user) | ||
| .setPassword(jdbcParamsState.password) | ||
| .setPooling(jdbcParamsState.pooling) | ||
| .setJar(Optional.of(jarFilePath)) | ||
| .setPrepareStatements(jdbcParamsState.prepareStatements) | ||
| .setKerberosPrincipal(jdbcParamsState.kerberosPrincipal) | ||
| .setKerberosKeytab(jdbcParamsState.kerberosKeytab) | ||
| .build(); | ||
| } | ||
|
|
||
| private static String loadDatabaseDriverJar(String driverClassName) | ||
| { | ||
| // TODO Add support for maven coordinate in tempto | ||
| String coords = ARTIFACTS.get(driverClassName).getKey(); | ||
| String jar = ARTIFACTS.get(driverClassName).getValue(); | ||
|
|
||
| ArtifactResolver resolver = new ArtifactResolver(USER_LOCAL_REPO, ImmutableList.of(MAVEN_CENTRAL_URI)); | ||
| return resolver.resolveArtifacts(new DefaultArtifact(coords)).stream() | ||
| .filter(artifact -> artifact.getFile().getName().equals(jar)) | ||
| .map(artifact -> artifact.getFile().getAbsolutePath()) | ||
| .collect(onlyElement()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.