Skip to content
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

Add unit tests for SqlServer #503

Merged

Conversation

kokosing
Copy link
Member

Add unit tests for SqlServer

@kokosing
Copy link
Member Author

This is first attempt to use docker image in unit tests. Things to improve:

  • use dynamic RDBMS port on host
  • then we can run a sql server docker container per each test class.

domain = pushDownDomain(client, session, column, domain);
builder.add(toPredicate(column.getColumnName(), domain, column, accumulator));
}
}
return builder.build();
}

protected boolean isAcceptedDomain(Domain domain)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert, this is a responsibility of pushDownDomain.

@@ -266,8 +266,8 @@ private String toPredicate(String columnName, String operator, Object value, Jdb

private String quote(String name)
{
name = name.replace(quote, quote + quote);
return quote + name + quote;
name = name.replace(identifierQoute, identifierQoute + identifierQoute);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline

public class SqlServerQueryBuilder
extends QueryBuilder
{
// SqlServer supports 2100 parameters in preparared statement, 100 is left for other parameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we would support queries with 1 large IN but not queries with 2 INs?

public PreparedStatement buildSql(ConnectorSession session, Connection connection, JdbcSplit split, List<JdbcColumnHandle> columnHandles)
throws SQLException
{
return new SqlServerQueryBuilder().buildSql(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the identifierQuote selection logic is in 2 places:

  • SqlServerQueryBuilder::new
  • SqlServerClient::new

IMO it would be better to pass this.identifierQuote to the QueryBuilder constructor

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Let's solve it separate PR.

throws Exception
{
this.dockerContainer = new TemporaryDockerContainer(
"microsoft/mssql-server-linux:2017-CU6",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the version we're using in product tests.


RetryPolicy<Object> retryPolicy = new RetryPolicy<>()
.withMaxDuration(Duration.of(5, MINUTES))
.withMaxAttempts(Integer.MAX_VALUE) // limited by MaxDuration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the default if you don't set this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3

RetryPolicy<Object> retryPolicy = new RetryPolicy<>()
.withMaxDuration(Duration.of(5, MINUTES))
.withMaxAttempts(Integer.MAX_VALUE) // limited by MaxDuration
.onRetry(event -> LOG.info("Waiting for sql-server..."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"SQL Server" ?

presto-sqlserver/pom.xml Show resolved Hide resolved
</dependency>
<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-tests</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this up, eg after presto-main

@kokosing kokosing force-pushed the origin/master/110_unit_tests_for_sqlserver branch from f4ab75e to 827328c Compare March 25, 2019 10:39
Copy link
Member Author

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@findepi Comments addressed.

public PreparedStatement buildSql(ConnectorSession session, Connection connection, JdbcSplit split, List<JdbcColumnHandle> columnHandles)
throws SQLException
{
return new SqlServerQueryBuilder().buildSql(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Let's solve it separate PR.


RetryPolicy<Object> retryPolicy = new RetryPolicy<>()
.withMaxDuration(Duration.of(5, MINUTES))
.withMaxAttempts(Integer.MAX_VALUE) // limited by MaxDuration
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3

}

@Test
public void testDropTable()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me fix this in separate PR. Add this AbstractTestIntegrationSmokeTest could blow up.

@Test
public void testInsert()
{
executeInSqlServer("CREATE TABLE test_insert (x bigint, y varchar(100))");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you CREATE TABLE in Presto?

Because test is focused on INSERT.

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments about TemporaryDockerContainer

This is really nice!


public class SqlServerClient
extends BaseJdbcClient
{
private static final Joiner DOT_JOINER = Joiner.on(".");

private static final Map<Type, WriteMapping> WRITE_MAPPINGS = ImmutableMap.<Type, WriteMapping>builder()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does sql server have all the types used here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know. There is no logical change here. I don't want to fix mapping in SqlServer now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so. So let's not inline this from basejdbc.
Instead, you can call super and then add DISABLE_UNSUPPORTED_PUSHDOWN. This is a hack, but at least it does not pretend it is not a hack. You then can adorn the code with // TODO implement explicit type mappings.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was first idea. However, after our offline discussion I understood that you prefer inlinining. Maybe, it was because I promised you that I will handle mapping end-to-end. I would like to, but I don't have time right now for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for mis-communication.

Ideally we should inline & retain only the necessary bits. And add TypeMapping test.

I am aware you might not have the cycles to reach this ideal, so I would really prefer no inlining at all.

int columnSize = type.getColumnSize();
switch (type.getJdbcType()) {
case Types.BIT:
case Types.BOOLEAN:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does sql server have bit data type? And boolean?

Same for all the mappings.

return decimalColumnMapping(decimalType, UnaryOperator.identity());
}

public static ColumnMapping decimalColumnMapping(DecimalType decimalType, UnaryOperator<Domain> pushDownConverter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: pushDownConverter → pushdownConverter

However, i think this is a wrong abstraction level.
Why do you need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to avoid inlining more code into SqlServer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see 45e0c2f#r268709657. Then you should be able to revert this change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to revert changes in StandardColumnMappings.java now?
they are in Fix large IN queries agains SqlServer cmt, but look no longer needed here.


private int extractPort(Map.Entry<String, List<PortBinding>> entry)
{
return Integer.parseInt(entry.getKey().replace("/tcp", "").replace("/udp", ""));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, Docker for Mac does not handle UDP correctly, so let's not pretend this is supported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when eg 88/tcp and 88/udp are bound but mapped to a different host port?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed UDP support

.collect(toImmutableMap(
entry -> extractPort(entry),
entry -> entry.getValue().stream()
.filter(portBinding -> portBinding.hostIp().equals(hostIp))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can there by anything else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think so.

.map(PortBinding::hostPort)
.collect(toOptional())
.map(Integer::parseInt)
.orElseThrow(() -> new IllegalStateException("Could not find port mapping for: " + entry.getKey()))));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Could not extract port mapping from " + entry

}

@Override
public void close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it as the last instance method

LOG.info("Auto-assigned host ports are %s", hostPorts);
}

public int getHostPort(int port)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it below calculateHostPorts

public static final String PASSWORD = "SQLServerPass1";

private static TemporaryDockerContainer dockerContainer = new TemporaryDockerContainer(
"microsoft/mssql-server-linux:2017-CU6",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated version


private static TemporaryDockerContainer dockerContainer = new TemporaryDockerContainer(
"microsoft/mssql-server-linux:2017-CU6",
"sqlserver-master",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just sqlserver

{
TestingSqlServerServer.waitForSqlServer();

DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is deprecated (😞)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe simply undeprecate this?

}
}

private static synchronized void provisionTables(Session session, QueryRunner queryRunner, Iterable<TpchTable<?>> tables)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure this is no longer static synchronized when you move container init to be once-per-test-class.

}

@Test
public void testDropTable()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine, so don't add them here.


private AutoCloseable withTable(String tableName, String tableDefinition)
{
executeInSqlServer(format("CREATE TABLE %s%s", tableName, tableDefinition));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"CREATE TABLE %s %s" would be slightly more readable

@@ -110,6 +110,7 @@
<module>presto-geospatial</module>
<module>presto-geospatial-toolkit</module>
<module>presto-benchmark</module>
<module>presto-testing-docker</module>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a new module for this? Can't we put it in presto-tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do. Otherwise it fails due conflict of classes and native libs with cassandra. I tried to solve this, but shading native libraries is not an easy thing to do.

@kokosing kokosing force-pushed the origin/master/110_unit_tests_for_sqlserver branch from 827328c to 263d4b3 Compare March 27, 2019 11:53
Copy link
Member Author

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed comments as fixups


public class SqlServerClient
extends BaseJdbcClient
{
private static final Joiner DOT_JOINER = Joiner.on(".");

private static final Map<Type, WriteMapping> WRITE_MAPPINGS = ImmutableMap.<Type, WriteMapping>builder()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know. There is no logical change here. I don't want to fix mapping in SqlServer now.

return decimalColumnMapping(decimalType, UnaryOperator.identity());
}

public static ColumnMapping decimalColumnMapping(DecimalType decimalType, UnaryOperator<Domain> pushDownConverter)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to avoid inlining more code into SqlServer.

@@ -110,6 +110,7 @@
<module>presto-geospatial</module>
<module>presto-geospatial-toolkit</module>
<module>presto-benchmark</module>
<module>presto-testing-docker</module>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do. Otherwise it fails due conflict of classes and native libs with cassandra. I tried to solve this, but shading native libraries is not an easy thing to do.

public TemporaryDockerContainer(String image, String hostName, List<Integer> ports, Map<String, String> environment)
{
this.image = requireNonNull(image, "image is null");
this.hostName = requireNonNull(hostName, "hostName is null");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used internally, I can remove it from here for now.

.withMaxDuration(Duration.of(5, MINUTES))
.withMaxAttempts(Integer.MAX_VALUE) // limited by MaxDuration
.onRetry(event -> LOG.info(format("Waiting for %s...", hostName)))
.withDelay(Duration.of(5, SECONDS));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis does not complain for such things. It would complain if I would raise it above 10 minutes. Anyway, I changed this to 10s.


ports.forEach(port -> {
RetryPolicy<Object> retryPolicy = new RetryPolicy<>()
.withMaxDuration(Duration.of(5, MINUTES))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing this the same value is used twice, does not mean it is the same timeout. For me waiting on container or a service in it is a bit different.

.collect(toImmutableMap(
entry -> extractPort(entry),
entry -> entry.getValue().stream()
.filter(portBinding -> portBinding.hostIp().equals(hostIp))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think so.


private int extractPort(Map.Entry<String, List<PortBinding>> entry)
{
return Integer.parseInt(entry.getKey().replace("/tcp", "").replace("/udp", ""));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed UDP support

dockerClient = null;
}

protected boolean isDebug()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be more complicated. It was checking environment variables.


public class SqlServerClient
extends BaseJdbcClient
{
private static final Joiner DOT_JOINER = Joiner.on(".");

private static final Map<Type, WriteMapping> WRITE_MAPPINGS = ImmutableMap.<Type, WriteMapping>builder()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so. So let's not inline this from basejdbc.
Instead, you can call super and then add DISABLE_UNSUPPORTED_PUSHDOWN. This is a hack, but at least it does not pretend it is not a hack. You then can adorn the code with // TODO implement explicit type mappings.

return decimalColumnMapping(decimalType, UnaryOperator.identity());
}

public static ColumnMapping decimalColumnMapping(DecimalType decimalType, UnaryOperator<Domain> pushDownConverter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see 45e0c2f#r268709657. Then you should be able to revert this change.

implements Closeable
{

private static final boolean DEBUG = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put after logger (logger should be the first)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't know why logger is that important in every class. For me it should be defined at the bottom.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i know some folks want to put weird things at the bottom. Like private Ctor() {}.
However, it's not about importance. It's just a convention -- i am used to look at the top to see wether a logger is already defined. Or "utility class constructor".

private Map<Integer, Integer> hostPorts;

public TemporaryDockerContainer(String image, String hostName, List<Integer> ports, Map<String, String> environment)
public TemporaryDockerContainer(String image, List<Integer> ports, Map<String, String> environment, CheckedConsumer<HostPortProvider> verifier)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verifier -> healthCheck ?

Failsafe.with(retryPolicy).run(() -> verifier.accept(this::getHostPort));
}

private boolean isContainerUp()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it before waitForContainer since it's called earlier

same for createContainer

*/
package io.prestosql.testing;

public interface HostPortProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can define this as an inner class in TemporaryDockerContainer.

@@ -24,112 +24,119 @@
import io.airlift.log.Logger;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change package name to io.prestosql.testing.docker -- presto-testing-docker module should have its own "namespace"

{
TestingSqlServerServer.waitForSqlServer();

DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe simply undeprecate this?

{
return format("jdbc:sqlserver://localhost:%s", dockerContainer.getHostPort(1433));
this.dockerContainer = new TemporaryDockerContainer(
"microsoft/mssql-server-linux:2017-CU6",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public TemporaryDockerContainer(String image, String hostName, List<Integer> ports, Map<String, String> environment)
{
this.image = requireNonNull(image, "image is null");
this.hostName = requireNonNull(hostName, "hostName is null");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is needed internally, then i'm OK

(i am aware you removed this... so up to you)

@kokosing kokosing force-pushed the origin/master/110_unit_tests_for_sqlserver branch from 263d4b3 to 1016708 Compare March 27, 2019 21:21
Copy link
Member Author

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments addressed


public class SqlServerClient
extends BaseJdbcClient
{
private static final Joiner DOT_JOINER = Joiner.on(".");

private static final Map<Type, WriteMapping> WRITE_MAPPINGS = ImmutableMap.<Type, WriteMapping>builder()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was first idea. However, after our offline discussion I understood that you prefer inlinining. Maybe, it was because I promised you that I will handle mapping end-to-end. I would like to, but I don't have time right now for this.

implements Closeable
{

private static final boolean DEBUG = false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't know why logger is that important in every class. For me it should be defined at the bottom.

}

@Test
public void testDropTable()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? It is better to have test for single connector vs for none.

@Test
public void testInsert()
{
executeInSqlServer("CREATE TABLE test_insert (x bigint, y varchar(100))");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will move it to AbstractTestIntegrationSmokeTest in separate PR.

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@@ -81,7 +81,11 @@ public static ColumnMapping blockMapping(Type prestoType, BlockReadFunction read
private final WriteFunction writeFunction;
private final UnaryOperator<Domain> pushdownConverter;

private ColumnMapping(Type type, ReadFunction readFunction, WriteFunction writeFunction, UnaryOperator<Domain> pushdownConverter)
/**
* Prefer factory methods instead over calling constructor directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deprecated Prefer factory methods ...

@@ -37,6 +43,17 @@
{
private static final Joiner DOT_JOINER = Joiner.on(".");

// SqlServer supports 2100 parameters in prepared statement, let's create a space for for about 4 big IN predicates
static final int SQL_SERVER_MAX_LIST_EXPRESSIONS = 500;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private or @VisibleForTesting


import javax.inject.Inject;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Optional;
import java.util.function.UnaryOperator;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix large IN queries agains SqlServer

typo in cmt msg: "against"

@@ -37,6 +43,17 @@
{
private static final Joiner DOT_JOINER = Joiner.on(".");

// SqlServer supports 2100 parameters in prepared statement, let's create a space for for about 4 big IN predicates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"for for"

return decimalColumnMapping(decimalType, UnaryOperator.identity());
}

public static ColumnMapping decimalColumnMapping(DecimalType decimalType, UnaryOperator<Domain> pushDownConverter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to revert changes in StandardColumnMappings.java now?
they are in Fix large IN queries agains SqlServer cmt, but look no longer needed here.

import static java.time.temporal.ChronoUnit.SECONDS;
import static java.util.Objects.requireNonNull;

public final class DockerContainer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rename.

now the cmt msg Introduce TemporaryDockerContainer can be changed to Introduce DockerContainer for testing or sth like that.

createContainer(ports);
}

checkState(isContainerUp(), "Container was not started properly");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this fails, will the container be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Tested manually.


LOG.info("Auto-assigned host ports are %s", hostPorts);

waitForContainer(healthCheck);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this fails, will the container be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Thanks for asking. It appeared that when method throws in abortOn then failsafe continue to retry. I fixed that.


private static void execute(HostPortProvider hostPortProvider, String sql)
{
try (Connection conn = DriverManager.getConnection(getJdbcUrl(hostPortProvider.getHostPort(SQL_SERVER_PORT)), USER, PASSWORD);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extract getJdbcUrl(hostPortProvider.getHostPort(SQL_SERVER_PORT)) as a variable?

This way it is consistent with BaseJdbcClient
DockerContainer is an utility to make it easier to use external services
managed provided with docker images for unit testing.
@kokosing kokosing force-pushed the origin/master/110_unit_tests_for_sqlserver branch from 1016708 to ca154eb Compare March 28, 2019 05:34
Copy link
Member Author

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments addressed Thanks for reviewing.

createContainer(ports);
}

checkState(isContainerUp(), "Container was not started properly");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Tested manually.


LOG.info("Auto-assigned host ports are %s", hostPorts);

waitForContainer(healthCheck);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Thanks for asking. It appeared that when method throws in abortOn then failsafe continue to retry. I fixed that.

@kokosing kokosing merged commit d1bec03 into trinodb:master Mar 28, 2019
@kokosing kokosing deleted the origin/master/110_unit_tests_for_sqlserver branch March 28, 2019 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants