This is my situation. I'm trying to do some integration tests with Testcontainers library.
I use Micronaut also. Testcontainers by default mapping exposed port of cassandra container to some random port, so I use some feature of Micronaut that help me intercept this and update my application.yaml file where store settings such as cassandra.host and cassandra.port which I use to configure JavaSparkContext(they are correctly update). When I try to do writes to or reads from Cassandra like in this tutorial Java Api I receive exception "There are no contact points in the given set of hosts."
SparkConf conf = new SparkConf(true); conf .setAppName("test") .setMaster("local[*]") .set("spark.cassandra.connection.host", getCassandraHost()) .set("spark.cassandra.connection.port", getCassandraPort().toString()); sparkContext = new JavaSparkContext(conf);