Skip to content

Commit 251e88f

Browse files
fix build errors
1 parent c5755fb commit 251e88f

File tree

9 files changed

+502
-296
lines changed

9 files changed

+502
-296
lines changed

airbyte-cdk/java/airbyte-cdk/core/build.gradle

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
3+
14
java {
25
// TODO: rewrite code to avoid javac wornings in the first place
36
compileJava {
@@ -11,6 +14,18 @@ java {
1114
}
1215
}
1316

17+
compileTestFixturesKotlin {
18+
compilerOptions {
19+
jvmTarget = JvmTarget.JVM_21
20+
languageVersion = KotlinVersion.KOTLIN_1_9
21+
allWarningsAsErrors = false
22+
freeCompilerArgs = ["-Xjvm-default=all"]
23+
}
24+
dependsOn {
25+
tasks.matching { it.name == 'generate' }
26+
}
27+
}
28+
1429
dependencies {
1530

1631
api 'com.datadoghq:dd-trace-api:1.28.0'

airbyte-cdk/java/airbyte-cdk/core/src/testFixtures/kotlin/io/airbyte/cdk/extensions/LoggingInvocationInterceptor.kt

+166-81
Large diffs are not rendered by default.

airbyte-cdk/java/airbyte-cdk/core/src/testFixtures/kotlin/io/airbyte/cdk/integrations/base/ssh/SshBastionContainer.kt

+77-43
Original file line numberDiff line numberDiff line change
@@ -8,83 +8,109 @@ import com.google.common.collect.ImmutableMap
88
import io.airbyte.cdk.integrations.util.HostPortResolver
99
import io.airbyte.cdk.testutils.ContainerFactory
1010
import io.airbyte.commons.json.Jsons
11+
import java.io.IOException
12+
import java.util.*
13+
import java.util.function.Consumer
1114
import org.apache.commons.lang3.tuple.ImmutablePair
1215
import org.testcontainers.containers.Container
1316
import org.testcontainers.containers.GenericContainer
1417
import org.testcontainers.containers.JdbcDatabaseContainer
1518
import org.testcontainers.containers.Network
1619
import org.testcontainers.images.builder.ImageFromDockerfile
1720
import org.testcontainers.utility.DockerImageName
18-
import java.io.IOException
19-
import java.util.*
20-
import java.util.function.Consumer
2121

2222
class SshBastionContainer : AutoCloseable {
23-
class SshBastionContainerFactory : ContainerFactory<GenericContainer<*>?>() {
23+
class SshBastionContainerFactory : ContainerFactory<GenericContainer<*>>() {
2424
override fun createNewContainer(imageName: DockerImageName?): GenericContainer<*>? {
25-
val container: GenericContainer<*> = GenericContainer<Any?>(ImageFromDockerfile("bastion-test")
26-
.withFileFromClasspath("Dockerfile", "bastion/Dockerfile"))
25+
val container: GenericContainer<*> =
26+
GenericContainer<Nothing>(
27+
ImageFromDockerfile("bastion-test")
28+
.withFileFromClasspath("Dockerfile", "bastion/Dockerfile")
29+
)
2730
.withExposedPorts(22)
2831
return container
2932
}
3033

31-
fun exclusive(network: Network?): GenericContainer<*>? {
32-
val imageModifier = Consumer { c: GenericContainer<*>? ->
33-
c!!.withNetwork(network)
34-
}
35-
val container = super.exclusive("bastion-test", NamedContainerModifierImpl("withNetwork", imageModifier))
34+
fun exclusive(network: Network): GenericContainer<*>? {
35+
val imageModifier = Consumer { c: GenericContainer<*> -> c!!.withNetwork(network) }
36+
val container =
37+
super.exclusive(
38+
"bastion-test",
39+
NamedContainerModifierImpl("withNetwork", imageModifier)
40+
)
3641
return container
3742
}
3843
}
3944

4045
var container: GenericContainer<*>? = null
4146
private set
4247

43-
fun initAndStartBastion(network: Network?) {
48+
fun initAndStartBastion(network: Network) {
4449
container = factory!!.exclusive(network)
4550
container!!.start()
4651
}
4752

4853
@Throws(IOException::class, InterruptedException::class)
49-
fun getTunnelMethod(tunnelMethod: SshTunnel.TunnelMethod?,
50-
innerAddress: Boolean): JsonNode? {
51-
val containerAddress = if (innerAddress) getInnerContainerAddress(container) else getOuterContainerAddress(container)
52-
return Jsons.jsonNode(ImmutableMap.builder<Any?, Any?>()
53-
.put("tunnel_host",
54-
Objects.requireNonNull(containerAddress!!.left))
54+
fun getTunnelMethod(tunnelMethod: SshTunnel.TunnelMethod?, innerAddress: Boolean): JsonNode? {
55+
val containerAddress =
56+
if (innerAddress) getInnerContainerAddress(container)
57+
else getOuterContainerAddress(container)
58+
return Jsons.jsonNode(
59+
ImmutableMap.builder<Any?, Any?>()
60+
.put("tunnel_host", Objects.requireNonNull(containerAddress!!.left))
5561
.put("tunnel_method", tunnelMethod)
5662
.put("tunnel_port", containerAddress.right)
5763
.put("tunnel_user", SSH_USER)
58-
.put("tunnel_user_password", if (tunnelMethod == SshTunnel.TunnelMethod.SSH_PASSWORD_AUTH) SSH_PASSWORD else "")
59-
.put("ssh_key", if (tunnelMethod == SshTunnel.TunnelMethod.SSH_KEY_AUTH) container!!.execInContainer("cat", "var/bastion/id_rsa").stdout else "")
60-
.build())
64+
.put(
65+
"tunnel_user_password",
66+
if (tunnelMethod == SshTunnel.TunnelMethod.SSH_PASSWORD_AUTH) SSH_PASSWORD
67+
else ""
68+
)
69+
.put(
70+
"ssh_key",
71+
if (tunnelMethod == SshTunnel.TunnelMethod.SSH_KEY_AUTH)
72+
container!!.execInContainer("cat", "var/bastion/id_rsa").stdout
73+
else ""
74+
)
75+
.build()
76+
)
6177
}
6278

6379
@Throws(IOException::class, InterruptedException::class)
64-
fun getTunnelConfig(tunnelMethod: SshTunnel.TunnelMethod?,
65-
builderWithSchema: ImmutableMap.Builder<Any?, Any?>?,
66-
innerAddress: Boolean): JsonNode? {
67-
return Jsons.jsonNode(builderWithSchema
80+
fun getTunnelConfig(
81+
tunnelMethod: SshTunnel.TunnelMethod?,
82+
builderWithSchema: ImmutableMap.Builder<Any?, Any?>?,
83+
innerAddress: Boolean
84+
): JsonNode? {
85+
return Jsons.jsonNode(
86+
builderWithSchema!!
6887
.put("tunnel_method", getTunnelMethod(tunnelMethod, innerAddress))
69-
.build())
88+
.build()
89+
)
7090
}
7191

7292
fun getBasicDbConfigBuider(db: JdbcDatabaseContainer<*>?): ImmutableMap.Builder<Any?, Any?>? {
7393
return getBasicDbConfigBuider(db, db!!.databaseName)
7494
}
7595

76-
fun getBasicDbConfigBuider(db: JdbcDatabaseContainer<*>?, schemas: MutableList<String?>?): ImmutableMap.Builder<Any?, Any?>? {
96+
fun getBasicDbConfigBuider(
97+
db: JdbcDatabaseContainer<*>?,
98+
schemas: MutableList<String?>?
99+
): ImmutableMap.Builder<Any?, Any?>? {
77100
return getBasicDbConfigBuider(db, db!!.databaseName)!!.put("schemas", schemas)
78101
}
79102

80-
fun getBasicDbConfigBuider(db: JdbcDatabaseContainer<*>?, schemaName: String?): ImmutableMap.Builder<Any?, Any?>? {
103+
fun getBasicDbConfigBuider(
104+
db: JdbcDatabaseContainer<*>?,
105+
schemaName: String?
106+
): ImmutableMap.Builder<Any?, Any?>? {
81107
return ImmutableMap.builder<Any?, Any?>()
82-
.put("host", Objects.requireNonNull(HostPortResolver.resolveHost(db)))
83-
.put("username", db!!.username)
84-
.put("password", db.password)
85-
.put("port", HostPortResolver.resolvePort(db))
86-
.put("database", schemaName)
87-
.put("ssl", false)
108+
.put("host", Objects.requireNonNull(HostPortResolver.resolveHost(db)))
109+
.put("username", db!!.username)
110+
.put("password", db.password)
111+
.put("port", HostPortResolver.resolvePort(db))
112+
.put("database", schemaName)
113+
.put("ssl", false)
88114
}
89115

90116
fun stopAndCloseContainers(db: JdbcDatabaseContainer<*>?) {
@@ -109,29 +135,37 @@ class SshBastionContainer : AutoCloseable {
109135
private val SSH_PASSWORD: String? = "secret"
110136

111137
/**
112-
* Returns the inner docker network ip address and port of a container. This can be used to reach a
113-
* container from another container running on the same network
138+
* Returns the inner docker network ip address and port of a container. This can be used to
139+
* reach a container from another container running on the same network
114140
*
115141
* @param container container
116142
* @return a pair of host and port
117143
*/
118144
fun getInnerContainerAddress(container: Container<*>?): ImmutablePair<String?, Int?>? {
119145
return ImmutablePair.of(
120-
container!!.containerInfo.networkSettings.networks.entries.stream().findFirst().get().value.ipAddress,
121-
container.exposedPorts.stream().findFirst().get())
146+
container!!
147+
.containerInfo
148+
.networkSettings
149+
.networks
150+
.entries
151+
.stream()
152+
.findFirst()
153+
.get()
154+
.value
155+
.ipAddress,
156+
container.exposedPorts.stream().findFirst().get()
157+
)
122158
}
123159

124160
/**
125-
* Returns the outer docker network ip address and port of a container. This can be used to reach a
126-
* container from the host machine
161+
* Returns the outer docker network ip address and port of a container. This can be used to
162+
* reach a container from the host machine
127163
*
128164
* @param container container
129165
* @return a pair of host and port
130166
*/
131167
fun getOuterContainerAddress(container: Container<*>?): ImmutablePair<String?, Int?>? {
132-
return ImmutablePair.of(
133-
container!!.host,
134-
container.firstMappedPort)
168+
return ImmutablePair.of(container!!.host, container.firstMappedPort)
135169
}
136170
}
137171
}

airbyte-cdk/java/airbyte-cdk/core/src/testFixtures/kotlin/io/airbyte/cdk/integrations/util/HostPortResolver.kt

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*/
44
package io.airbyte.cdk.integrations.util
55

6-
import org.testcontainers.containers.GenericContainer
76
import java.util.*
7+
import org.testcontainers.containers.GenericContainer
88

99
object HostPortResolver {
1010
@JvmStatic
@@ -22,11 +22,17 @@ object HostPortResolver {
2222
}
2323

2424
private fun getIpAddress(container: GenericContainer<*>?): String? {
25-
return Objects.requireNonNull(container!!.containerInfo
25+
return Objects.requireNonNull(
26+
container!!
27+
.containerInfo
2628
.networkSettings
2729
.networks
28-
.entries.stream()
30+
.entries
31+
.stream()
2932
.findFirst()
30-
.get().value.ipAddress)
33+
.get()
34+
.value
35+
.ipAddress
36+
)
3137
}
3238
}

0 commit comments

Comments
 (0)