Search in sources :

Example 1 with TemporaryTestDbConfiguration

use of org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration in project legend-engine by finos.

the class TestLocalH2ConnectionState method setup.

@Before
public void setup() throws Exception {
    // The manager is a singleton. Reset singleton to avoid interference from other tests
    ConcurrentHashMap connectionPools = (ConcurrentHashMap) ReflectionUtils.getFieldUsingReflection(ConnectionStateManager.class, ConnectionStateManager.getInstance(), "connectionPools");
    connectionPools.clear();
    this.connectionManagerSelector = new ConnectionManagerSelector(new TemporaryTestDbConfiguration(-1), Collections.emptyList());
}
Also used : TemporaryTestDbConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration) ConcurrentHashMap(org.eclipse.collections.impl.map.mutable.ConcurrentHashMap) ConnectionStateManager(org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.ConnectionStateManager) ConnectionManagerSelector(org.finos.legend.engine.plan.execution.stores.relational.connection.manager.ConnectionManagerSelector) Before(org.junit.Before)

Example 2 with TemporaryTestDbConfiguration

use of org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration in project legend-engine by finos.

the class RelationalStoreExecutorBuilder method build.

@Override
public StoreExecutor build(StoreExecutorConfiguration storeExecutorConfiguration) {
    if (!(storeExecutorConfiguration instanceof RelationalExecutionConfiguration)) {
        String message = String.format("Invalid argument. Expected %s but found %s", RelationalExecutionConfiguration.class.getCanonicalName(), storeExecutorConfiguration.getClass().getCanonicalName());
        throw new RuntimeException(message);
    }
    RelationalExecutionConfiguration relationalExecutionConfiguration = (RelationalExecutionConfiguration) storeExecutorConfiguration;
    if (relationalExecutionConfiguration.tempPath == null) {
        relationalExecutionConfiguration.tempPath = DEFAULT_TEMP_PATH;
    }
    if (relationalExecutionConfiguration.temporarytestdb == null) {
        relationalExecutionConfiguration.temporarytestdb = new TemporaryTestDbConfiguration(DEFAULT_PORT);
    }
    Optional<DatabaseAuthenticationFlowProvider> flowProviderHolder = this.configureDatabaseAuthenticationFlowProvider(relationalExecutionConfiguration);
    RelationalStoreState state = new RelationalStoreState(relationalExecutionConfiguration.temporarytestdb, relationalExecutionConfiguration, flowProviderHolder);
    return new RelationalStoreExecutor(state);
}
Also used : RelationalExecutionConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration) TemporaryTestDbConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration) DatabaseAuthenticationFlowProvider(org.finos.legend.engine.authentication.provider.DatabaseAuthenticationFlowProvider)

Example 3 with TemporaryTestDbConfiguration

use of org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration in project legend-engine by finos.

the class TestExecutionScope method buildTestExecutor.

public static RelationalExecutor buildTestExecutor(int port) {
    RelationalExecutionConfiguration relationalExecutionConfiguration = new RelationalExecutionConfiguration();
    relationalExecutionConfiguration.tempPath = "/tmp/";
    TemporaryTestDbConfiguration temporaryTestDbConfiguration = new TemporaryTestDbConfiguration();
    temporaryTestDbConfiguration.port = port;
    return new RelationalExecutor(temporaryTestDbConfiguration, relationalExecutionConfiguration);
}
Also used : RelationalExecutionConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration) TemporaryTestDbConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration)

Example 4 with TemporaryTestDbConfiguration

use of org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration in project legend-engine by finos.

the class ExternalIntegration_TestConnectionAcquisitionWithFlowProvider_BigQuery method setup.

@Before
public void setup() {
    LegendDefaultDatabaseAuthenticationFlowProvider flowProvider = new LegendDefaultDatabaseAuthenticationFlowProvider();
    assertBigQueryFlowIsAvailable(flowProvider);
    this.connectionManagerSelector = new ConnectionManagerSelector(new TemporaryTestDbConfiguration(-1), Collections.emptyList(), Optional.of(flowProvider));
}
Also used : LegendDefaultDatabaseAuthenticationFlowProvider(org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProvider) TemporaryTestDbConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration) ConnectionManagerSelector(org.finos.legend.engine.plan.execution.stores.relational.connection.manager.ConnectionManagerSelector) Before(org.junit.Before)

Example 5 with TemporaryTestDbConfiguration

use of org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration in project legend-engine by finos.

the class ExternalIntegration_TestConnectionAcquisitionWithFlowProvider_SqlServer method setup.

@Before
public void setup() throws Exception {
    startMSSQLServerContainer();
    LegendDefaultDatabaseAuthenticationFlowProvider flowProvider = new LegendDefaultDatabaseAuthenticationFlowProvider();
    assertStaticSQLServerFlowProviderIsAvailable(flowProvider);
    this.connectionManagerSelector = new ConnectionManagerSelector(new TemporaryTestDbConfiguration(-1), Collections.emptyList(), Optional.of(flowProvider));
    Properties properties = new Properties();
    properties.put("sqlServerAccount.user", "SA");
    properties.put("sqlServerAccount.password", "A_Str0ng_Required_Password");
    this.vaultImplementation = new PropertiesVaultImplementation(properties);
    Vault.INSTANCE.registerImplementation(this.vaultImplementation);
}
Also used : LegendDefaultDatabaseAuthenticationFlowProvider(org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProvider) TemporaryTestDbConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration) Properties(java.util.Properties) ConnectionManagerSelector(org.finos.legend.engine.plan.execution.stores.relational.connection.manager.ConnectionManagerSelector) PropertiesVaultImplementation(org.finos.legend.engine.shared.core.vault.PropertiesVaultImplementation)

Aggregations

TemporaryTestDbConfiguration (org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration)16 ConnectionManagerSelector (org.finos.legend.engine.plan.execution.stores.relational.connection.manager.ConnectionManagerSelector)12 Before (org.junit.Before)9 LegendDefaultDatabaseAuthenticationFlowProvider (org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProvider)6 RelationalExecutionConfiguration (org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration)4 DatabaseAuthenticationFlowProvider (org.finos.legend.engine.authentication.provider.DatabaseAuthenticationFlowProvider)2 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 Properties (java.util.Properties)1 ConcurrentHashMap (org.eclipse.collections.impl.map.mutable.ConcurrentHashMap)1 LegendDefaultDatabaseAuthenticationFlowProviderConfiguration (org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProviderConfiguration)1 AlloyH2Server (org.finos.legend.engine.plan.execution.stores.relational.AlloyH2Server)1 ConnectionStateManager (org.finos.legend.engine.plan.execution.stores.relational.connection.ds.state.ConnectionStateManager)1 RelationalResult (org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult)1 PropertiesVaultImplementation (org.finos.legend.engine.shared.core.vault.PropertiesVaultImplementation)1 Server (org.h2.tools.Server)1 Test (org.junit.Test)1