-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use testcontainer for write tests #51594
fix: use testcontainer for write tests #51594
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still confused about the parallel tests fighting each other thing - in principle, every test is operating on <random namespace>.<hardcoded stream name(s)>
? So they shouldn't ever be touching the same MSSQL table. Kind of worried that randomizing the stream name is just papering over some underlying problem
otherwise lgtm 🚛
|
||
@Test | ||
open fun testBasicWrite() { | ||
val streamName = generateStreamName() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still necessary?
@edgao From what I discovered, I think that the issue is that the random schema is per test suite, not per test. Therefore, each test uses the same schema name AND the same stream name before this change. If that is not the intent, we should fix the base integration test classes to use a random schema name per test and not per suite. |
ugh. There's probably some magic junit configuration that I forgot about somewhere... I'm pretty sure (85%) that s3/iceberg are creating a new instance of the test class per test method execution :/ |
@@ -114,9 +135,21 @@ class MSSQLDataCleaner : DestinationCleaner { | |||
} | |||
} | |||
|
|||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually derp, I missed this on my readthrough - why do we need this? I'm pretty sure this is the problem behind #51594 (comment)
(i.e. if you remove this, it should work as expected, b/c the default is PER_METHOD)
@edgao I can look at the iceberg tests tomorrow to see if I missed something. It may also be that we had to use per class test instances to avoid starting and stopping the test container after each test. If that is what is causing this, I'd rather use the random stream name that incur the cost of spin up/spin down of the container on each test. |
the pattern we've used in other tests is to actually share the test container across test classes, via some singleton object. roughly object SharedTestContainer {
private val isStarted: AtomicBoolean
fun start() { ... }
}
class TestClass1 {
@BeforeAll fun setup() { SharedTestContainer.start() }
}
class TestClass2 {
@BeforeAll fun setup() { SharedTestContainer.start() }
} e.g. https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/destination-s3-data-lake/src/test-integration/kotlin/io/airbyte/integrations/destination/s3_data_lake/NessieTestContainers.kt. IIRC the old postgres/mysql destinations also do something along these lines (we don't need to explicitly call |
@edgao That doesn't work in Kotlin. You cannot use |
6e27019
to
46c0e54
Compare
@edgao I am able to make the tests pass without the random stream name by using the |
medium strength opinion: I don't see this as a hack. JvmStatic is annoying, yes, but that's more a function of us using junit in kotlin than anything? If we were on kotest, it would be a perfectly normal also, I think our tests are already sufficiently complicated... Randomizing the namespace was annoying, but probably unavoidable - I'd like to avoid adding even more dynamicly-generated stuff when possible and more broadly:
|
@edgao I guess I was referring to the use of a companion object to work around this as a hack, which it is -- its to make this work with Java-based JUnit. That being said, I don't feel strongly about it. I'd rather have us agree upon what level should be dynamically generated. It is currently the namespace and it sounds like we don't believe that it needs to be done at the name level of the stream. I'm not sure that I am sold on that yet, but given that it works now that I have introduced the companion object and static designation, we can pause this discussion for now. Thanks for the review/feedback. |
f5becbb
into
move/destination-mssql-v2
What
How
Review guide
BasicFunctionalityIntegrationTest.kt
MSSQLConfiguration.kt
MSSQLContainerHelper.kt
MSSQLWriterTest.kt
Can this PR be safely reverted and rolled back?