Repository: pinpoint-apm/pinpoint
Issue: Replace embedded Cassandra with stubbed Cassandra for Datastax plugin integration tests
Labels: enhancement
module:plugin

#### Description
Starting and stopping embedded Cassandra for every Datastax plugin integration test (for every version of Datastax java driver) was a bit too heavy and took too long.
It would also very occasionally hang the forked JVM process if embedded Cassandra was not started up or initialized correctly/promptly.
Replacing this with a more light-weight stubbed Cassandra should shorten test execution times and hopefully eliminate JVM hangs.

Additionally, we can remove references to **StatementWrapper** from the plugin to add support for Cassandra Datastax java driver versions 2.0.0 to 2.0.9, and 2.1.0 to 2.1.5.
(**StatementWrapper** class is not present in these versions)

Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/agent-it/pom.xml b/agent-it/pom.xml
index 4f49e28169fa..bfd4e9756941 100644
--- a/agent-it/pom.xml
+++ b/agent-it/pom.xml
@@ -207,9 +207,9 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.cassandra</groupId>
-            <artifactId>cassandra-all</artifactId>
-            <version>2.1.13</version>
+            <groupId>org.scassandra</groupId>
+            <artifactId>java-client</artifactId>
+            <version>1.1.2</version>
             <scope>test</scope>
         </dependency>
 
diff --git a/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/CassandraPlugin.java b/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/CassandraPlugin.java
index b197d98e168d..73debadb43b2 100644
--- a/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/CassandraPlugin.java
+++ b/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/CassandraPlugin.java
@@ -54,11 +54,26 @@ public void setup(ProfilerPluginSetupContext context) {
             return;
         }
 
+        addStatementWrapperTransformer();
         addDefaultPreparedStatementTransformer();
         addSessionTransformer(config);
         addClusterTransformer();
     }
 
+    private void addStatementWrapperTransformer() {
+        transformTemplate.transform("com.datastax.driver.core.StatementWrapper", new TransformCallback() {
+            @Override
+            public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className,
+                                        Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
+                                        byte[] classfileBuffer) throws InstrumentException {
+
+                InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
+                target.addGetter("com.navercorp.pinpoint.plugin.cassandra.field.WrappedStatementGetter", "wrapped");
+                return target.toBytecode();
+            }
+        });
+    }
+
     private void addDefaultPreparedStatementTransformer() {
         TransformCallback transformer = new TransformCallback() {
 
diff --git a/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/field/WrappedStatementGetter.java b/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/field/WrappedStatementGetter.java
new file mode 100644
index 000000000000..b5424969e0cd
--- /dev/null
+++ b/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/field/WrappedStatementGetter.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2018 NAVER Corp.
+ *
+ * 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 com.navercorp.pinpoint.plugin.cassandra.field;
+
+import com.datastax.driver.core.Statement;
+
+/**
+ * @author HyunGil Jeong
+ */
+public interface WrappedStatementGetter {
+    Statement _$PINPOINT$_getStatement();
+}
diff --git a/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/interceptor/CassandraStatementExecuteQueryInterceptor.java b/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/interceptor/CassandraStatementExecuteQueryInterceptor.java
index 8083839541b6..a9e34f4c446f 100644
--- a/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/interceptor/CassandraStatementExecuteQueryInterceptor.java
+++ b/plugins/cassandra/src/main/java/com/navercorp/pinpoint/plugin/cassandra/interceptor/CassandraStatementExecuteQueryInterceptor.java
@@ -22,7 +22,7 @@
 import com.datastax.driver.core.BatchStatement;
 import com.datastax.driver.core.BoundStatement;
 import com.datastax.driver.core.RegularStatement;
-import com.datastax.driver.core.StatementWrapper;
+import com.datastax.driver.core.Statement;
 import com.navercorp.pinpoint.bootstrap.context.DatabaseInfo;
 import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor;
 import com.navercorp.pinpoint.bootstrap.context.ParsingResult;
@@ -38,6 +38,7 @@
 import com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo;
 import com.navercorp.pinpoint.bootstrap.plugin.jdbc.bindvalue.BindValueUtils;
 import com.navercorp.pinpoint.common.util.MapUtils;
+import com.navercorp.pinpoint.plugin.cassandra.field.WrappedStatementGetter;
 
 /**
  * @author dawidmalina
@@ -126,9 +127,8 @@ private String retrieveSql(Object args0) {
             return ((BoundStatement) args0).preparedStatement().getQueryString();
         } else if (args0 instanceof RegularStatement) {
             return ((RegularStatement) args0).getQueryString();
-        } else if (args0 instanceof StatementWrapper) {
-            // method to get wrapped statement is package-private, skip.
-            return null;
+        } else if (args0 instanceof WrappedStatementGetter) {
+            return retrieveWrappedStatement((WrappedStatementGetter) args0);
         } else if (args0 instanceof BatchStatement) {
             // we could unroll all the batched statements and append ; between them if need be but it could be too long.
             return null;
@@ -138,6 +138,11 @@ private String retrieveSql(Object args0) {
         return null;
     }
 
+    private String retrieveWrappedStatement(WrappedStatementGetter wrappedStatementGetter) {
+        Statement wrappedStatement = wrappedStatementGetter._$PINPOINT$_getStatement();
+        return retrieveSql(wrappedStatement);
+    }
+
     private void clean(Object target) {
         if (target instanceof BindValueAccessor) {
             ((BindValueAccessor) target)._$PINPOINT$_setBindValue(new HashMap<Integer, String>());


Test patch:
diff --git a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastaxITBase.java b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastaxITBase.java
index c0da2aca8637..00b88ce46739 100644
--- a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastaxITBase.java
+++ b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastaxITBase.java
@@ -20,8 +20,6 @@
 import com.datastax.driver.core.BoundStatement;
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.Statement;
 import com.datastax.driver.core.StatementWrapper;
@@ -29,11 +27,18 @@
 import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder;
 import com.navercorp.pinpoint.common.util.DefaultSqlParser;
 import com.navercorp.pinpoint.common.util.SqlParser;
-import org.junit.Assert;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
+import org.scassandra.Scassandra;
+import org.scassandra.ScassandraFactory;
+import org.scassandra.http.client.ActivityClient;
+import org.scassandra.http.client.CurrentClient;
+import org.scassandra.http.client.PrimingClient;
 
 import java.lang.reflect.Method;
-import java.util.Iterator;
 
 import static com.navercorp.pinpoint.bootstrap.plugin.test.Expectations.event;
 import static com.navercorp.pinpoint.bootstrap.plugin.test.Expectations.sql;
@@ -44,60 +49,70 @@
 public abstract class CassandraDatastaxITBase {
 
     // com.navercorp.pinpoint.plugin.cassandra.CassandraConstants
-    protected static final String CASSANDRA = "CASSANDRA";
-    protected static final String CASSANDRA_EXECUTE_QUERY = "CASSANDRA_EXECUTE_QUERY";
-
-    protected static final String TEST_KEYSPACE = "mykeyspace";
-    protected static final String TEST_TABLE = "mytable";
-    protected static final String TEST_COL_ID = "id";
-    protected static final String TEST_COL_VALUE = "value";
-
-    protected static final String CQL_CREATE_KEYSPACE = String.format(
-            "CREATE KEYSPACE %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };",
-            TEST_KEYSPACE);
-    protected static final String CQL_CREATE_TABLE = String.format(
-            "CREATE TABLE %s ( %s int PRIMARY KEY, %s text );",
-            TEST_TABLE, TEST_COL_ID, TEST_COL_VALUE);
-    protected static final String CQL_INSERT = String.format(
+    private static final String CASSANDRA = "CASSANDRA";
+    private static final String CASSANDRA_EXECUTE_QUERY = "CASSANDRA_EXECUTE_QUERY";
+
+    private static final String TEST_KEYSPACE = "mykeyspace";
+    private static final String TEST_TABLE = "mytable";
+    private static final String TEST_COL_ID = "id";
+    private static final String TEST_COL_VALUE = "value";
+
+    private static final String CQL_INSERT = String.format(
             "INSERT INTO %s (%s, %s) VALUES (?, ?);",
             TEST_TABLE, TEST_COL_ID, TEST_COL_VALUE);
     // for normalized sql used for sql cache
-    protected static final SqlParser SQL_PARSER = new DefaultSqlParser();
+    private static final SqlParser SQL_PARSER = new DefaultSqlParser();
+
+    private static String HOST = "127.0.0.1";
+    private static final int DEFAULT_PORT = 9042;
+    private static final int DEFAULT_ADMIN_PORT = 9043;
+    private static final int PORT = CassandraTestHelper.findAvailablePortOrDefault(DEFAULT_PORT);
+    private static final int ADMIN_PORT = CassandraTestHelper.findAvailablePortOrDefault(DEFAULT_ADMIN_PORT);
+    private static final String CASSANDRA_ADDRESS = HOST + ":" + PORT;
+
+    private static final Scassandra SERVER = ScassandraFactory.createServer(HOST, PORT, HOST, ADMIN_PORT);
 
-    protected static Cluster cluster;
+    private Cluster cluster;
 
-    // see cassandra/cassandra_${cassandraVersion}.yaml
-    protected static String HOST;
-    protected static int PORT;
-    protected static String CASSANDRA_ADDRESS;
+    private final PrimingClient primingClient = SERVER.primingClient();
+    private final ActivityClient activityClient = SERVER.activityClient();
+    private final CurrentClient currentClient = SERVER.currentClient();
 
-    public static void initializeCluster(String cassandraVersion) throws Exception {
-        CassandraTestHelper.init(cassandraVersion);
-        HOST = CassandraTestHelper.getHost();
-        PORT = CassandraTestHelper.getNativeTransportPort();
-        CASSANDRA_ADDRESS = HOST + ":" + PORT;
+    @BeforeClass
+    public static void startUpBeforeClass() {
+        SERVER.start();
+    }
+
+    @Before
+    public void setUp() {
         cluster = Cluster.builder().addContactPoint(HOST).withPort(PORT).withoutMetrics().build();
-        // Create KeySpace
-        Session emptySession = null;
-        try {
-            emptySession = cluster.connect();
-            emptySession.execute(CQL_CREATE_KEYSPACE);
-        } finally {
-            closeSession(emptySession);
+
+        // scassandra uses http client 4 for stub calls
+        PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
+        verifier.ignoreServiceType("HTTP_CLIENT_4", "HTTP_CLIENT_4_INTERNAL");
+    }
+
+    @After
+    public void tearDown() {
+        if (primingClient != null) {
+            primingClient.clearAllPrimes();
         }
-        // Create Table
-        Session myKeyspaceSession = null;
-        try {
-            myKeyspaceSession = cluster.connect(TEST_KEYSPACE);
-            myKeyspaceSession.execute(CQL_CREATE_TABLE);
-        } finally {
-            closeSession(myKeyspaceSession);
+        if (activityClient != null) {
+            activityClient.clearAllRecordedActivity();
+        }
+        if (cluster != null) {
+            cluster.close();
         }
     }
 
+    @AfterClass
+    public static void tearDownAfterClass() {
+        SERVER.stop();
+    }
+
     @Test
     public void testBoundStatement() throws Exception {
-        final int testId = 99;
+        final String testId ="99";
         final String testValue = "testValue";
 
         PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
@@ -134,11 +149,9 @@ public void testBoundStatement() throws Exception {
 
             // ====================
             // Select Data (String)
-            final String cqlSelect = String.format("SELECT %s, %s FROM %s WHERE %s = %d",
+            final String cqlSelect = String.format("SELECT %s, %s FROM %s WHERE %s = %s",
                     TEST_COL_ID, TEST_COL_VALUE, TEST_TABLE, TEST_COL_ID, testId);
-            verifySelect(myKeyspaceSession.execute(cqlSelect), testId, testValue);
-
-            verifier.printCache();
+            myKeyspaceSession.execute(cqlSelect);
             // SessionManager#execute(String) OR AbstractSession#execute(String)
             execute = sessionClass.getDeclaredMethod("execute", String.class);
             String normalizedSelectSql = SQL_PARSER.normalizedSql(cqlSelect).getNormalizedSql();
@@ -161,9 +174,9 @@ public void testBoundStatement() throws Exception {
 
     @Test
     public void testBatchStatement_and_StatementWrapper() throws Exception {
-        final int testId1 = 998;
+        final String testId1 = "998";
         final String testValue1 = "testValue998";
-        final int testId2 = 999;
+        final String testId2 = "999";
         final String testValue2 = "testValue999";
 
         PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
@@ -217,34 +230,16 @@ public void testBatchStatement_and_StatementWrapper() throws Exception {
             // SessionManager#prepare(String) OR AbstractSession#prepare(String)
             verifier.verifyTrace(event(CASSANDRA, prepare, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(cqlDelete, null)));
             // SessionManager#execute(String, Object[]) OR AbstractSession#execute(String, Object[])
-            verifier.verifyTrace(event(CASSANDRA_EXECUTE_QUERY, execute, null, CASSANDRA_ADDRESS, TEST_KEYSPACE));
+            verifier.verifyTrace(event(CASSANDRA_EXECUTE_QUERY, execute, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(cqlDelete, null)));
         } finally {
             closeSession(myKeyspaceSession);
         }
     }
 
-    private void verifySelect(ResultSet rs, int expectedTestId, String expectedTestValue) {
-        int resultCount = 0;
-        Iterator<Row> iter = rs.iterator();
-        while (iter.hasNext()) {
-            Row row = iter.next();
-            Assert.assertEquals(expectedTestId, row.getInt(0));
-            Assert.assertEquals(expectedTestValue, row.getString(1));
-            ++resultCount;
-        }
-        Assert.assertEquals(1, resultCount);
-    }
-
     private static void closeSession(Session session) {
         if (session != null) {
             session.close();
         }
     }
 
-    public static void cleanUpCluster() {
-        if (cluster != null) {
-            cluster.close();
-        }
-    }
-
 }
diff --git a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_0_x_IT.java b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_0_x_IT.java
index af0d3479b13e..a221f6ff4904 100644
--- a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_0_x_IT.java
+++ b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_0_x_IT.java
@@ -20,32 +20,18 @@
 import com.navercorp.pinpoint.test.plugin.Dependency;
 import com.navercorp.pinpoint.test.plugin.PinpointAgent;
 import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.runner.RunWith;
 
 /**
+ * Integration tests require {@link com.datastax.driver.core.StatementWrapper StatementWrapper}, so we
+ * limit datastax driver version to 2.0.10+.
+ *
  * @author HyunGil Jeong
  */
 @RunWith(PinpointPluginTestSuite.class)
 @PinpointAgent(AgentPath.PATH)
 @Dependency({
-        "com.datastax.cassandra:cassandra-driver-core:[2.0.12,2.0.max]",
-        "org.apache.cassandra:cassandra-all:2.0.17",
-        "com.google.guava:guava:17.0",
-        "org.codehaus.plexus:plexus-utils:3.0.22"})
+        "com.datastax.cassandra:cassandra-driver-core:[2.0.10,2.0.max]",
+        "org.scassandra:java-client:1.1.2"})
 public class CassandraDatastax_2_0_x_IT extends CassandraDatastaxITBase {
-
-    private static final String CASSANDRA_VERSION = "2_0_x";
-
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
-        initializeCluster(CASSANDRA_VERSION);
-    }
-
-    @AfterClass
-    public static void tearDownAfterClass() {
-        cleanUpCluster();
-    }
-
 }
diff --git a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_1_x_IT.java b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_1_x_IT.java
index 7a6ad19c7cc6..81aef4b9ac64 100644
--- a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_1_x_IT.java
+++ b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_1_x_IT.java
@@ -20,32 +20,18 @@
 import com.navercorp.pinpoint.test.plugin.Dependency;
 import com.navercorp.pinpoint.test.plugin.PinpointAgent;
 import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.runner.RunWith;
 
 /**
+ * Integration tests require {@link com.datastax.driver.core.StatementWrapper StatementWrapper}, so we
+ * limit datastax driver version to 2.1.6+.
+ *
  * @author HyunGil Jeong
  */
 @RunWith(PinpointPluginTestSuite.class)
 @PinpointAgent(AgentPath.PATH)
 @Dependency({
-        "com.datastax.cassandra:cassandra-driver-core:[2.1.9,2.1.max]",
-        "org.apache.cassandra:cassandra-all:2.1.13",
-        "com.google.guava:guava:17.0",
-        "org.codehaus.plexus:plexus-utils:3.0.22"})
+        "com.datastax.cassandra:cassandra-driver-core:[2.1.6,2.1.max]",
+        "org.scassandra:java-client:1.1.2"})
 public class CassandraDatastax_2_1_x_IT extends CassandraDatastaxITBase {
-
-    private static final String CASSANDRA_VERSION = "2_1_x";
-
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
-        initializeCluster(CASSANDRA_VERSION);
-    }
-
-    @AfterClass
-    public static void tearDownAfterClass() {
-        cleanUpCluster();
-    }
-
 }
diff --git a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_2_x_IT.java b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_2_x_IT.java
index 828b922bc97a..6daf92c3cc1d 100644
--- a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_2_x_IT.java
+++ b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_2_2_x_IT.java
@@ -20,8 +20,6 @@
 import com.navercorp.pinpoint.test.plugin.Dependency;
 import com.navercorp.pinpoint.test.plugin.PinpointAgent;
 import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.runner.RunWith;
 
 /**
@@ -30,22 +28,7 @@
 @RunWith(PinpointPluginTestSuite.class)
 @PinpointAgent(AgentPath.PATH)
 @Dependency({
-        "com.datastax.cassandra:cassandra-driver-core:[2.2.0-rc3,2.2.max]",
-        "org.apache.cassandra:cassandra-all:2.1.13",
-        "com.google.guava:guava:17.0",
-        "org.codehaus.plexus:plexus-utils:3.0.22"})
+        "com.datastax.cassandra:cassandra-driver-core:[2.2.min,2.2.max]",
+        "org.scassandra:java-client:1.1.2"})
 public class CassandraDatastax_2_2_x_IT extends CassandraDatastaxITBase {
-
-    private static final String CASSANDRA_VERSION = "2_2_x";
-
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
-        initializeCluster(CASSANDRA_VERSION);
-    }
-
-    @AfterClass
-    public static void tearDownAfterClass() {
-        cleanUpCluster();
-    }
-
 }
diff --git a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_3_0_x_IT.java b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_3_0_x_IT.java
index 6568afae08a1..fb7a58f22a4c 100644
--- a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_3_0_x_IT.java
+++ b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraDatastax_3_0_x_IT.java
@@ -20,8 +20,6 @@
 import com.navercorp.pinpoint.test.plugin.Dependency;
 import com.navercorp.pinpoint.test.plugin.PinpointAgent;
 import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.runner.RunWith;
 
 /**
@@ -30,22 +28,7 @@
 @RunWith(PinpointPluginTestSuite.class)
 @PinpointAgent(AgentPath.PATH)
 @Dependency({
-        "com.datastax.cassandra:cassandra-driver-core:[3.0.0,3.0.max]",
-        "org.apache.cassandra:cassandra-all:2.1.13",
-        "com.google.guava:guava:17.0",
-        "org.codehaus.plexus:plexus-utils:3.0.22"})
+        "com.datastax.cassandra:cassandra-driver-core:[3.0.0,)",
+        "org.scassandra:java-client:1.1.2"})
 public class CassandraDatastax_3_0_x_IT extends CassandraDatastaxITBase {
-
-    private static final String CASSANDRA_VERSION = "3_0_x";
-
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
-        initializeCluster(CASSANDRA_VERSION);
-    }
-
-    @AfterClass
-    public static void tearDownAfterClass() {
-        cleanUpCluster();
-    }
-
 }
diff --git a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraTestHelper.java b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraTestHelper.java
index 592ccd05d6ba..e87290abc89a 100644
--- a/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraTestHelper.java
+++ b/agent-it/src/test/java/com/navercorp/pinpoint/plugin/jdk7/cassandra/CassandraTestHelper.java
@@ -16,64 +16,31 @@
 
 package com.navercorp.pinpoint.plugin.jdk7.cassandra;
 
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.exceptions.ConfigurationException;
-import org.apache.cassandra.service.EmbeddedCassandraService;
-import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
+import java.net.ServerSocket;
 
 /**
  * @author HyunGil Jeong
  */
 public class CassandraTestHelper {
 
-    private static final String CASSANDRA_HOME = "target/test-classes/cassandra";
-
     private CassandraTestHelper() {
     }
 
-    public static void init(final String cassandraVersion) throws IOException, ConfigurationException {
-        final String cassandraStorageDir = String.format("%s/data_%s", CASSANDRA_HOME, cassandraVersion);
-        final String cassandraConfigFile = String.format("cassandra/cassandra_%s.yaml", cassandraVersion);
-        System.setProperty("cassandra.storagedir", cassandraStorageDir);
-        System.setProperty("cassandra.config", cassandraConfigFile);
-        prepareEnvironment();
-        EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
-        cassandra.start();
-    }
-
-    public static String getHost() {
-        return DatabaseDescriptor.getListenAddress().getHostAddress();
-    }
-
-    public static int getNativeTransportPort() {
-        return DatabaseDescriptor.getNativeTransportPort();
-    }
-
-    private static void prepareEnvironment() throws IOException {
+    public static int findAvailablePortOrDefault(int defaultPort) {
         try {
-            cleanUpFiles();
-        } catch (IOException e) {
-            // ignore - just let the server start
-        }
-    }
-
-    private static void cleanUpFiles() throws IOException {
-        Set<String> fileLocations = new HashSet<String>();
-        for (String dataFileLocation : DatabaseDescriptor.getAllDataFileLocations()) {
-            fileLocations.add(dataFileLocation);
-        }
-        fileLocations.add(DatabaseDescriptor.getCommitLogLocation());
-        fileLocations.add(DatabaseDescriptor.getSavedCachesLocation());
-        for (String fileLocation : fileLocations) {
-            File location = new File(fileLocation);
-            if (location.exists() && location.isDirectory()) {
-                FileUtils.deleteDirectory(fileLocation);
+            ServerSocket ss = null;
+            try {
+                ss = new ServerSocket(0);
+                ss.setReuseAddress(true);
+                return ss.getLocalPort();
+            } finally {
+                if (ss != null) {
+                    ss.close();
+                }
             }
+        } catch (Exception e) {
+            // just ignore and return default
+            return defaultPort;
         }
     }
 }