-
-
Save ysonggit/5db69667ab302031a332d99b68afff22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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