Skip to content

Commit

Permalink
Move TestingFailureInjector* to test classpath
Browse files Browse the repository at this point in the history
  • Loading branch information
losipiuk committed Sep 2, 2024
1 parent b9784ef commit 62e0209
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.execution;

import io.airlift.units.Duration;
import io.trino.spi.ErrorType;

import java.util.Optional;

public class NoOpFailureInjector
implements FailureInjector
{
@Override
public void injectTaskFailure(String traceToken, int stageId, int partitionId, int attemptId, InjectedFailureType injectionType, Optional<ErrorType> errorType)
{
}

@Override
public Optional<InjectedFailure> getInjectedFailure(String traceToken, int stageId, int partitionId, int attemptId)
{
return Optional.empty();
}

@Override
public Duration getRequestTimeout()
{
throw new IllegalArgumentException("getRequestTimeout should not be called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@
import io.trino.execution.FailureInjector;
import io.trino.execution.LocationFactory;
import io.trino.execution.MemoryRevokingScheduler;
import io.trino.execution.NoOpFailureInjector;
import io.trino.execution.NodeTaskMap;
import io.trino.execution.QueryManagerConfig;
import io.trino.execution.SqlTaskManager;
import io.trino.execution.TableExecuteContextManager;
import io.trino.execution.TaskManagementExecutor;
import io.trino.execution.TaskManagerConfig;
import io.trino.execution.TestingFailureInjectionConfig;
import io.trino.execution.TestingFailureInjector;
import io.trino.execution.executor.TaskExecutor;
import io.trino.execution.executor.dedicated.ThreadPerDriverTaskExecutor;
import io.trino.execution.executor.timesharing.MultilevelSplitQueue;
Expand Down Expand Up @@ -278,8 +277,7 @@ protected void setup(Binder binder)
new TopologyAwareNodeSelectorModule()));

// task execution
configBinder(binder).bindConfig(TestingFailureInjectionConfig.class);
newOptionalBinder(binder, FailureInjector.class).setDefault().to(TestingFailureInjector.class).in(Scopes.SINGLETON);
newOptionalBinder(binder, FailureInjector.class).setDefault().to(NoOpFailureInjector.class).in(Scopes.SINGLETON);
jaxrsBinder(binder).bind(TaskResource.class);
newExporter(binder).export(TaskResource.class).withGeneratedName();
binder.bind(TaskManagementExecutor.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.trino.plugin.bigquery;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.testing.BaseFailureRecoveryTest;
Expand All @@ -40,7 +41,8 @@ public BaseBigQueryFailureRecoveryTest(RetryPolicy retryPolicy)
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
return BigQueryQueryRunner.builder()
Expand All @@ -52,6 +54,7 @@ protected QueryRunner createQueryRunner(
.put("exchange.base-directories", System.getProperty("java.io.tmpdir") + "/trino-local-file-system-exchange-manager")
.buildOrThrow());
})
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.trino.plugin.deltalake;

import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.exchange.filesystem.containers.MinioStorage;
Expand Down Expand Up @@ -54,7 +55,8 @@ protected BaseDeltaFailureRecoveryTest(RetryPolicy retryPolicy)
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
HiveMinioDataLake hiveMinioDataLake = closeAfterClass(new HiveMinioDataLake(bucketName));
Expand All @@ -72,6 +74,7 @@ protected QueryRunner createQueryRunner(
.addMetastoreProperties(hiveMinioDataLake.getHiveHadoop())
.addS3Properties(hiveMinioDataLake.getMinio(), bucketName)
.addDeltaProperty("delta.enable-non-concurrent-writes", "true")
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.trino.plugin.hive;

import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.exchange.filesystem.containers.MinioStorage;
Expand Down Expand Up @@ -49,7 +50,8 @@ public TestHiveQueryFailureRecoveryTest()
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
String bucketName = "test-hive-insert-overwrite-" + randomNameSuffix(); // randomizing bucket name to ensure cached TrinoS3FileSystem objects are not reused
Expand All @@ -66,6 +68,7 @@ protected QueryRunner createQueryRunner(
runner.installPlugin(new FileSystemExchangePlugin());
runner.loadExchangeManager("filesystem", getExchangeManagerProperties(minioStorage));
})
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.trino.plugin.hive;

import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.exchange.filesystem.containers.MinioStorage;
Expand Down Expand Up @@ -49,7 +50,8 @@ public TestHiveTaskFailureRecoveryTest()
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
String bucketName = "test-hive-insert-overwrite-" + randomNameSuffix(); // randomizing bucket name to ensure cached TrinoS3FileSystem objects are not reused
Expand All @@ -66,6 +68,7 @@ protected QueryRunner createQueryRunner(
runner.installPlugin(new FileSystemExchangePlugin());
runner.loadExchangeManager("filesystem", getExchangeManagerProperties(minioStorage));
})
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.trino.plugin.iceberg;

import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.exchange.filesystem.containers.MinioStorage;
Expand Down Expand Up @@ -46,7 +47,8 @@ protected TestIcebergQueryFailureRecoveryTest()
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
this.minioStorage = closeAfterClass(new MinioStorage("test-exchange-spooling-" + randomNameSuffix()));
Expand All @@ -59,6 +61,7 @@ protected QueryRunner createQueryRunner(
runner.installPlugin(new FileSystemExchangePlugin());
runner.loadExchangeManager("filesystem", getExchangeManagerProperties(minioStorage));
})
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.trino.plugin.iceberg;

import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.exchange.filesystem.containers.MinioStorage;
Expand Down Expand Up @@ -46,7 +47,8 @@ protected TestIcebergTaskFailureRecoveryTest()
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
this.minioStorage = closeAfterClass(new MinioStorage("test-exchange-spooling-" + randomNameSuffix()));
Expand All @@ -59,6 +61,7 @@ protected QueryRunner createQueryRunner(
runner.installPlugin(new FileSystemExchangePlugin());
runner.loadExchangeManager("filesystem", getExchangeManagerProperties(minioStorage));
})
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.trino.plugin.mariadb;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.jdbc.BaseJdbcFailureRecoveryTest;
Expand All @@ -37,7 +38,7 @@ public BaseMariaDbFailureRecoveryTest(RetryPolicy retryPolicy)
}

@Override
protected QueryRunner createQueryRunner(List<TpchTable<?>> requiredTpchTables, Map<String, String> configProperties, Map<String, String> coordinatorProperties)
protected QueryRunner createQueryRunner(List<TpchTable<?>> requiredTpchTables, Map<String, String> configProperties, Map<String, String> coordinatorProperties, Module failureInjectionModule)
throws Exception
{
TestingMariaDbServer server = closeAfterClass(new TestingMariaDbServer());
Expand All @@ -50,6 +51,7 @@ protected QueryRunner createQueryRunner(List<TpchTable<?>> requiredTpchTables, M
runner.loadExchangeManager("filesystem", ImmutableMap.of(
"exchange.base-directories", System.getProperty("java.io.tmpdir") + "/trino-local-file-system-exchange-manager"));
})
.setAdditionalModule(failureInjectionModule)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.trino.plugin.mongodb;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.testing.BaseFailureRecoveryTest;
Expand All @@ -39,7 +40,8 @@ public BaseMongoFailureRecoveryTest(RetryPolicy retryPolicy)
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
return MongoQueryRunner.builder(closeAfterClass(new MongoServer()))
Expand All @@ -50,6 +52,7 @@ protected QueryRunner createQueryRunner(
runner.loadExchangeManager("filesystem", ImmutableMap.of(
"exchange.base-directories", System.getProperty("java.io.tmpdir") + "/trino-local-file-system-exchange-manager"));
})
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.trino.plugin.mysql;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.jdbc.BaseJdbcFailureRecoveryTest;
Expand All @@ -40,7 +41,8 @@ public BaseMySqlFailureRecoveryTest(RetryPolicy retryPolicy)
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
return MySqlQueryRunner.builder(closeAfterClass(new TestingMySqlServer()))
Expand All @@ -51,6 +53,7 @@ protected QueryRunner createQueryRunner(
runner.loadExchangeManager("filesystem", ImmutableMap.of(
"exchange.base-directories", System.getProperty("java.io.tmpdir") + "/trino-local-file-system-exchange-manager"));
})
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.trino.plugin.oracle;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.jdbc.BaseJdbcFailureRecoveryTest;
Expand All @@ -40,7 +41,8 @@ public BaseOracleFailureRecoveryTest(RetryPolicy retryPolicy)
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
TestingOracleServer oracleServer = closeAfterClass(new TestingOracleServer());
Expand All @@ -53,6 +55,7 @@ protected QueryRunner createQueryRunner(
"exchange.base-directories", System.getProperty("java.io.tmpdir") + "/trino-local-file-system-exchange-manager"));
})
.setInitialTables(requiredTpchTables)
.setAdditionalModule(failureInjectionModule)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.trino.plugin.postgresql;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.jdbc.BaseJdbcFailureRecoveryTest;
Expand All @@ -40,7 +41,8 @@ public BasePostgresFailureRecoveryTest(RetryPolicy retryPolicy)
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
return PostgreSqlQueryRunner.builder(closeAfterClass(new TestingPostgreSqlServer()))
Expand All @@ -51,6 +53,7 @@ protected QueryRunner createQueryRunner(
runner.loadExchangeManager("filesystem", ImmutableMap.of(
"exchange.base-directories", System.getProperty("java.io.tmpdir") + "/trino-local-file-system-exchange-manager"));
})
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package io.trino.plugin.redshift;

import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import io.trino.operator.RetryPolicy;
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.jdbc.BaseJdbcFailureRecoveryTest;
Expand All @@ -40,7 +41,8 @@ public BaseRedshiftFailureRecoveryTest(RetryPolicy retryPolicy)
protected QueryRunner createQueryRunner(
List<TpchTable<?>> requiredTpchTables,
Map<String, String> configProperties,
Map<String, String> coordinatorProperties)
Map<String, String> coordinatorProperties,
Module failureInjectionModule)
throws Exception
{
return RedshiftQueryRunner.builder()
Expand All @@ -51,6 +53,7 @@ protected QueryRunner createQueryRunner(
runner.loadExchangeManager("filesystem", ImmutableMap.of(
"exchange.base-directories", System.getProperty("java.io.tmpdir") + "/trino-local-file-system-exchange-manager"));
})
.setAdditionalModule(failureInjectionModule)
.setInitialTables(requiredTpchTables)
.build();
}
Expand Down
Loading

0 comments on commit 62e0209

Please sign in to comment.