Skip to content

Instantly share code, notes, and snippets.

@ponkin
Last active December 16, 2017 21:44
Show Gist options
  • Save ponkin/40db34dde4477f84e711 to your computer and use it in GitHub Desktop.
Save ponkin/40db34dde4477f84e711 to your computer and use it in GitHub Desktop.
class CasandraSpec extends FunSuite
with Eventually
with BeforeAndAfterAll
with LocalSparkContext
with EmbeddedCassandra
with Logging{
val testKeyspace = "test1"
val testTable = "table1"
var conn: CassandraConnector = _
override def beforeAll(): Unit = {
useCassandraConfig(Seq("cassandra-default.yaml.template"))
conn = CassandraConnector(Set(EmbeddedCassandra.getHost(0)))
conn.withSessionDo { session =>
session.execute( s"""DROP KEYSPACE IF EXISTS $testKeyspace""")
session.execute( s"""CREATE KEYSPACE $testKeyspace
|WITH replication = {
|'class': 'SimpleStrategy',
|'replication_factor':1}
|""".stripMargin)
session.execute(s"""CREATE TABLE $testKeyspace.$testTable(
| partitionKey text,
| clusterKey text,
| someValue int,
| PRIMARY KEY (partitionKey, clusterKey))
| WITH
| compaction = { 'class' : 'SizeTieredCompactionStrategy'} AND
| compression = { 'sstable_compression' : 'SnappyCompressor' }
| """.stripMargin)
}
}
override def clearCache: Unit = Unit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment