Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pondzix committed Aug 21, 2024
1 parent 63a7aed commit 13b8305
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config/loader/aws/databricks.config.reference.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"oauth": {
"clientId": "client-id"
"clientSecret": ${OAUTH_CLIENT_SECRET}
}
},
# Optional. Override the Databricks default catalog, e.g. with a Unity catalog name.
"catalog": "hive_metastore",
# DB schema
Expand Down
4 changes: 4 additions & 0 deletions config/loader/azure/databricks.config.reference.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
"parameterName": "snowplow.databricks.password"
}
},
"oauth": {
"clientId": "client-id"
"clientSecret": ${OAUTH_CLIENT_SECRET}
},
# Optional. Override the Databricks default catalog, e.g. with a Unity catalog name.
"catalog": "hive_metastore",
# DB schema
Expand Down
4 changes: 4 additions & 0 deletions config/loader/gcp/databricks.config.reference.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"parameterName": "snowplow.databricks.password"
}
},
"oauth": {
"clientId": "client-id"
"clientSecret": ${OAUTH_CLIENT_SECRET}
},
# Optional. Override the Databricks default catalog, e.g. with a Unity catalog name.
"catalog": "hive_metastore",
# DB schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class ConfigSpec extends Specification {
val result = getConfigFromResource("/loader/aws/databricks.config.minimal.hocon", testParseConfig)
val storage = ConfigSpec.exampleStorage.copy(
catalog = None,
password = StorageTarget.PasswordConfig.PlainText("Supersecret1")
password = Some(StorageTarget.PasswordConfig.PlainText("Supersecret1")),
oauth = None
)
val cloud = Config.Cloud.AWS(RegionSpec.DefaultTestRegion, exampleMessageQueue.copy(region = Some(RegionSpec.DefaultTestRegion)))
val retries = exampleRetries.copy(cumulativeBound = Some(20.minutes))
Expand Down Expand Up @@ -140,7 +141,8 @@ class ConfigSpec extends Specification {
val result = getConfigFromResource("/loader/gcp/databricks.config.minimal.hocon", testParseConfig)
val storage = ConfigSpec.exampleStorage.copy(
catalog = None,
password = StorageTarget.PasswordConfig.PlainText("Supersecret1")
password = Some(StorageTarget.PasswordConfig.PlainText("Supersecret1")),
oauth = None
)
val retries = exampleRetries.copy(cumulativeBound = Some(20.minutes))
val readyCheck = exampleReadyCheck.copy(strategy = Config.Strategy.Constant, backoff = 15.seconds)
Expand All @@ -167,7 +169,8 @@ class ConfigSpec extends Specification {
val result = getConfigFromResource("/loader/azure/databricks.config.minimal.hocon", testParseConfig)
val storage = ConfigSpec.exampleStorage.copy(
catalog = None,
password = StorageTarget.PasswordConfig.PlainText("Supersecret1")
password = Some(StorageTarget.PasswordConfig.PlainText("Supersecret1")),
oauth = None
)
val retries = exampleRetries.copy(cumulativeBound = Some(20.minutes))
val readyCheck = exampleReadyCheck.copy(strategy = Config.Strategy.Constant, backoff = 15.seconds)
Expand Down Expand Up @@ -200,7 +203,8 @@ object ConfigSpec {
"atomic",
443,
"/databricks/http/path",
StorageTarget.PasswordConfig.EncryptedKey(StorageTarget.EncryptedConfig("snowplow.databricks.password")),
Some(StorageTarget.PasswordConfig.EncryptedKey(StorageTarget.EncryptedConfig("snowplow.databricks.password"))),
Some(StorageTarget.Databricks.OAuth("client-id", "client-secret")),
None,
"snowplow-rdbloader-oss",
StorageTarget.LoadAuthMethod.NoCreds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ object DatabricksSpec {
"snowplow",
443,
"some/path",
StorageTarget.PasswordConfig.PlainText("xxx"),
Some(StorageTarget.PasswordConfig.PlainText("xxx")),
None,
None,
"useragent",
StorageTarget.LoadAuthMethod.NoCreds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CliConfigSpec extends Specification {
val result = CliConfig.parse[IO](cli).value.unsafeRunSync()

result must beRight.like { case CliConfig(config, _, resolverConfig) =>
config.storage.password.getUnencrypted must beEqualTo("Supersecret password from substitution!")
config.storage.credentials.get.password.getUnencrypted must beEqualTo("Supersecret password from substitution!")
resolverConfig must beEqualTo(expectedResolver)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ class StorageTargetSpec extends Specification {
"port": 443,
"httpPath": "http/path",
"password": "Supersecret1",
"oauth": {
"clientId": "client-id",
"clientSecret": "client-secret"
},
"userAgent": "snowplow-rdbloader-oss",
"eventsOptimizePeriod": "2 days",
"loadAuthMethod": {
Expand All @@ -177,7 +181,8 @@ class StorageTargetSpec extends Specification {
schema = "snowplow",
port = 443,
httpPath = "http/path",
password = StorageTarget.PasswordConfig.PlainText("Supersecret1"),
password = Some(StorageTarget.PasswordConfig.PlainText("Supersecret1")),
oauth = Some(StorageTarget.Databricks.OAuth("client-id", "client-secret")),
sshTunnel = None,
userAgent = "snowplow-rdbloader-oss",
loadAuthMethod = StorageTarget.LoadAuthMethod.NoCreds,
Expand Down
8 changes: 7 additions & 1 deletion project/BuildSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,13 @@ object BuildSettings {
Docker / packageName := "rdb-loader-databricks",
initialCommands := "import com.snowplowanalytics.snowplow.loader.databricks._",
Compile / mainClass := Some("com.snowplowanalytics.snowplow.loader.databricks.Main"),
Compile / unmanagedJars += file("DatabricksJDBC42.jar")
Compile / unmanagedJars += file("DatabricksJDBC42.jar"),
// used in extended configuration parsing unit tests
Test / envVars := Map(
"OAUTH_CLIENT_SECRET" -> "client-secret"
),
// envVars works only when fork is enabled
Test / fork := true
) ++ buildSettings ++ addExampleConfToTestCp ++ assemblySettings ++ dynVerSettings

lazy val transformerBatchBuildSettings =
Expand Down

0 comments on commit 13b8305

Please sign in to comment.