Skip to content

Commit

Permalink
SDC-10281. Prevent override of Dropwizard Metrics version in Cassandr…
Browse files Browse the repository at this point in the history
…a library

Change-Id: I9d48ab877d05abdc524bbb14c0e4dc24f6f35f40
Reviewed-on: https://review.streamsets.net/17284
Reviewed-by: Jarcec Cecho <jarcec@streamsets.com>
  • Loading branch information
Adam Kunicki committed Oct 11, 2018
1 parent 0fa87a6 commit 9f871e1
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 90 deletions.
44 changes: 16 additions & 28 deletions cassandra-protolib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
<packaging>jar</packaging>

<properties>
<cassandra-driver.version>3.2.0</cassandra-driver.version>
<cassandra-driver.version>3.6.0</cassandra-driver.version>
<commons-io.version>2.4</commons-io.version>
<dse-driver.version>1.2.4</dse-driver.version>
<cassandra-unit.version>3.1.3.2</cassandra-unit.version>
<dse-driver.version>1.7.0</dse-driver.version>
<lz4.version>1.3.0</lz4.version>
<snappy.version>1.0.5</snappy.version>
</properties>
Expand All @@ -46,6 +45,12 @@
<dependency>
<groupId>com.streamsets</groupId>
<artifactId>streamsets-datacollector-api</artifactId>
<exclusions>
<exclusion>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -66,7 +71,8 @@
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<scope>provided</scope>
<version>3.2.2</version> <!-- from upstream datastax -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.streamsets</groupId>
Expand Down Expand Up @@ -125,6 +131,12 @@
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>cassandra</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -135,30 +147,6 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit</artifactId>
<version>${cassandra-unit.version}</version>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-mapping</artifactId>
</exclusion>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-extras</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@
import com.streamsets.pipeline.api.Target;
import com.streamsets.pipeline.sdk.RecordCreator;
import com.streamsets.pipeline.sdk.TargetRunner;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.thrift.transport.TTransportException;
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.CassandraContainer;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand All @@ -53,31 +51,33 @@
public class TestCassandraTarget {
private static final Logger LOG = LoggerFactory.getLogger(TestCassandraTarget.class);

@ClassRule
public static CassandraContainer cassandra = new CassandraContainer();

private static final Double EPSILON = 1e-15;
private static final long CASSANDRA_STARTUP_TIMEOUT = 20000;
private static final String SAMPLE_TIMEUUID = "474b1386-0379-11e7-bdfe-fa245441bcee";
private static final String SAMPLE_UUID = "46c5379c-a083-4ccd-bfac-c4a8d17574c7";
private static int CASSANDRA_NATIVE_PORT = 9142;
private static int CASSANDRA_NATIVE_PORT = 9042;

private static Cluster cluster = null;
private static Session session = null;

@SuppressWarnings("unchecked")
@BeforeClass
public static void setUpClass() throws InterruptedException, TTransportException, ConfigurationException, IOException {
EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_STARTUP_TIMEOUT);
cluster = Cluster.builder()
.addContactPoint("127.0.0.1")
.withPort(CASSANDRA_NATIVE_PORT)
.withProtocolVersion(ProtocolVersion.V4)
.build();
public static void setUpClass() {
cluster = cassandra.getCluster();
session = cluster.connect();
}

@AfterClass
public static void tearDownClass() {
session.close();
cluster.close();
if (session != null) {
session.close();
}

if (cluster != null) {
cluster.close();
}
}

@Before
Expand Down Expand Up @@ -106,6 +106,7 @@ public void setUp() {
session.execute(
"CREATE TABLE IF NOT EXISTS test.test_null_values (a varchar, b varchar, PRIMARY KEY(a));"
);
LOG.info("Finished table setup");
}

@After
Expand All @@ -130,8 +131,8 @@ public void testWriteEmptyBatch() throws InterruptedException, StageException {
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down Expand Up @@ -163,8 +164,8 @@ public void testWriteSingleRecord() throws InterruptedException, StageException
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down Expand Up @@ -227,8 +228,8 @@ public void testCollectionTypes() throws InterruptedException, StageException {
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down Expand Up @@ -279,8 +280,8 @@ public void testWriteRecordsOnErrorDiscard() throws Exception {
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down Expand Up @@ -332,8 +333,8 @@ public void testWriteRecordsOnErrorToError() throws Exception {
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down Expand Up @@ -386,8 +387,8 @@ public void testWriteRecordsOnErrorStopPipeline() throws Exception {
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down Expand Up @@ -439,8 +440,8 @@ public void testWriteRecordWithMissingFields() throws InterruptedException, Stag
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down Expand Up @@ -498,8 +499,8 @@ public void testMalformedTableName() throws Exception {
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down Expand Up @@ -527,8 +528,8 @@ public void testInternalSubBatching() throws Exception {
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down Expand Up @@ -576,8 +577,8 @@ public void testWriteNullValuedColumns() throws Exception {
);

CassandraTargetConfig conf = new CassandraTargetConfig();
conf.contactPoints.add("localhost");
conf.port = CASSANDRA_NATIVE_PORT;
conf.contactPoints.add(cassandra.getContainerIpAddress());
conf.port = cassandra.getMappedPort(CASSANDRA_NATIVE_PORT);
conf.protocolVersion = ProtocolVersion.V4;
conf.authProviderOption = AuthProviderOption.NONE;
conf.compression = CassandraCompressionCodec.NONE;
Expand Down
46 changes: 19 additions & 27 deletions cassandra_3-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@
<packaging>jar</packaging>

<properties>
<cassandra-driver.version>3.2.0</cassandra-driver.version>
<cassandra-unit.version>3.1.3.2</cassandra-unit.version>
<cassandra-driver.version>3.6.0</cassandra-driver.version>
</properties>

<dependencies>
<dependency>
<groupId>com.streamsets</groupId>
<artifactId>streamsets-datacollector-api</artifactId>
<exclusions>
<exclusion>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -58,11 +63,6 @@
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.streamsets</groupId>
<artifactId>streamsets-datacollector-sdk</artifactId>
Expand All @@ -79,26 +79,6 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit</artifactId>
<version>${cassandra-unit.version}</version>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-mapping</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.streamsets</groupId>
Expand Down Expand Up @@ -131,6 +111,18 @@
<version>${cassandra-driver.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.2.2</version> <!-- from upstream datastax -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>cassandra</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down

0 comments on commit 9f871e1

Please sign in to comment.