Skip to content

Instantly share code, notes, and snippets.

@ysonggit
Forked from ponkin/CassandraEmbeded.scala
Created December 14, 2017 19:05
Show Gist options
  • Save ysonggit/5db69667ab302031a332d99b68afff22 to your computer and use it in GitHub Desktop.
Save ysonggit/5db69667ab302031a332d99b68afff22 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