-
Notifications
You must be signed in to change notification settings - Fork 34
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
Implement infrastructure to check recorded trace #510
base: develop
Are you sure you want to change the base?
Conversation
ea27b16
to
29c81c3
Compare
ProjectToTest("kotlinx.collections.immutable", "592f05fce02a1ad9e26cc6f3fdb55cdd97910599") | ||
) | ||
|
||
fun Project.registerIntegrationTestsTasks() { |
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.
Consider renaming to registerIntegrationTestsPrerequisites
so that the name matches with the registered gradle task name.
} | ||
} | ||
|
||
tasks.register("integrationTestsPrerequisites") { |
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.
Should we rename to traceDebuggerIntegrationTestsPrerequisites
?
tasks.register("integrationTestsPrerequisites") { | ||
prerequisite.forEach { dependsOn(it) } | ||
} | ||
} |
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.
Also, consider moving this file into TraceDebuggerTasks.kt
since this functionality is related to the trace debugger specifically.
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 renamed IntegrationTestsTasks
file into TraceDebuggerIntegrationTestsTasks
. I don't really want to push everything into one big file and it is better to separate test and release stuff.
|
||
val isInTraceDebuggerMode = System.getProperty("lincheck.traceDebuggerMode", "false").toBoolean() | ||
private const val traceDebuggerModeProperty = "lincheck.traceDebuggerMode" |
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.
By convention in the Lincheck repo we usually use CAPITAL_CASE
for constants.
Assert.assertEquals(goldDataFile.readText(), tmpFile.readText()) | ||
} else { | ||
copy(tmpFile, goldDataFile) | ||
Assert.fail("The gold data file was created. Please rerun the test.") |
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.
Let's fail test in this case. To overwrite the expected test output, let's use a gradle property.
We already have one used for similar purposes in Lincheck representation tests, so we can re-use it here (it is called overwriteRepresentationTestsOutput
).
See the links below:
if (OVERWRITE_REPRESENTATION_TESTS_OUTPUT) { internal val OVERWRITE_REPRESENTATION_TESTS_OUTPUT: Boolean = Line 22 in a758c54
overwriteRepresentationTestsOutput=false
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.
What do you mean? The test will be failed with Assert.fail
. This branch means that golden test data wasn't found and it will be created automatically. It is not exactly overwrite
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.
Oh, sorry, I missed the Assert.fail
.
Yet still, not sure that the golden data should be automatically created in this case.
IMO, better have one single mechanism to overwrite golden data (e.g., when special flag is set), and in case when there is no file with golden data just output that file was not found.
|
||
@Test | ||
fun `tests contract list GuavaImmutableListTest_list`() { | ||
// runGradleTest( |
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.
Please use @Ignore
instead and TODO comment explaining why the test is disabled for now.
import java.io.FileOutputStream | ||
import java.util.* | ||
|
||
abstract class AbstractIntegrationTest { |
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.
abstract class AbstractIntegrationTest { | |
abstract class AbstractTraceDebuggerIntegrationTest { |
|
||
import org.junit.Test | ||
|
||
class KotlinImmutableCollectionsIntegrationTest: AbstractIntegrationTest() { |
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.
class KotlinImmutableCollectionsIntegrationTest: AbstractIntegrationTest() { | |
class KotlinImmutableCollectionsTraceDebuggerIntegrationTest: AbstractTraceDebuggerIntegrationTest() { |
* with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package org.jetbrains.kotlinx.lincheck_test.integration |
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.
Also please move the package to trace_debugger.integration
.
Thanks for the review! I will fix everything on Monday. |
29c81c3
to
3241b60
Compare
All changes are in |
3241b60
to
3b7b9b4
Compare
Also added @ndkoval to have a final look before we merge. |
@@ -30,6 +30,7 @@ fun Project.registerTraceDebuggerTasks() { | |||
|
|||
val traceDebuggerFatJar = tasks.register<Jar>("traceDebuggerFatJar") { | |||
archiveBaseName.set("fat-trace-debugger") | |||
archiveVersion.set("SNAPSHOT") |
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.
should it always be SNAPSHOT
? Can we use the default version instead?
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.
What do you mean by "default version"? If we leave it as is, then the version will be different for each release. It is hard to work with that because we should manually update this version in the plugin.
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.
You can obtain the current version of Lincheck from the code, see
internal val lincheckVersion by lazy { |
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.
Yes, but it will not work for the plugin and the plugin has exactly the same logic
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.
It's fine to change the jar
name but please do not change the version.
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.
This one is our internal fat jar. It is not published anywhere (yet). We can push it as is and I will create a task to think about how to extract lincheck version for the plugin.
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.
You don't need to extract anything, you can just change the JAR name to "lincheck-fat-jar.jar"
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.
Please note that it should not be fat-trace-debugger
, this is just Lincheck
protected fun runGradleTest( | ||
testClassName: String, | ||
testMethodName: String, | ||
vararg gradleCommand: String, |
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.
Can gradleCommand
vary or should it always be jvmTest
/test
?
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.
Let's also do not use vararg
here, as it makes the test code less intuitive
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.
Can gradleCommand vary or should it always be jvmTest/test?
Yes, it can change and it can depend on the project's infra that we are testing
Let's also do not use vararg here, as it makes the test code less intuitive
Do you propose to use an array here? Or do you mean to pass it as comma-separated string and parse later? I would like to keep it flexible to allow running multiple commands
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.
list?
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.
Yeah, if you think this is better, no problem.
@Ignore | ||
@Test | ||
fun `tests contract list GuavaImmutableListTest_list`() { | ||
runGradleTest( |
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.
please always add argument names
} | ||
|
||
// TODO decide how to test: with gold data or run twice? | ||
val goldDataFile = File(getGolderDataPathFor(testClassName, testMethodName)) |
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.
In Lincheck, we use the "expected output" term. Please use it here as well for consistency.
|
||
@Ignore | ||
@Test | ||
fun `tests contract list GuavaImmutableListTest_list`() { |
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.
where can I find the expected output file?
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.
Will add an example
import java.io.FileOutputStream | ||
import java.util.* | ||
|
||
abstract class AbstractTraceDebuggerIntegrationTest { |
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.
Let's run these tests only in the trace debugger mode
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.
We are running these tests in this mode, please check buildGradleInitScriptToDumpTrace
val jvmTest = named<Test>("jvmTest") { | ||
dependsOn(traceDebuggerIntegrationTestsPrerequisites) |
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.
Let's create a separate source set and a separate task for integration tests for Trace Debugger, and perform all the related logic only in the trace debugger mode
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.
Let's do it separately for every trace debugger test. I will create a ticket for that
The earlier version was "2.36-SNAPSHOT". What would mean that every time the new version of lincheck comes out, the corresponding path to fat jar must be changed in every project that uses trace debugger.
After the dump was published, we finished the execution because otherwise we stuck awaiting a plugin that is not necessarily present.
…s for integration tests
3b7b9b4
to
ad95102
Compare
@ivandev0 can we please use the same human-readable output format as we use in other trace representation tests? |
Can you please point me where to look? |
I guess you need the |
This PR contains changes only about infrastructure. There are no new tests, only the example of how to write one. For now with each rerun we get a new trace (if I did everything right). We need to investigate it.