Skip to content
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

Integration test project #3307

Merged
merged 18 commits into from Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Projects.kt
Expand Up @@ -12,8 +12,8 @@ val testModule = "kotlinx-coroutines-test"

val multiplatform = setOf(coreModule, testModule)
// Not applicable for Kotlin plugin
val sourceless = setOf("kotlinx.coroutines", "kotlinx-coroutines-bom", "integration-testing")
val internal = setOf("kotlinx.coroutines", "benchmarks", "integration-testing")
val sourceless = setOf("kotlinx.coroutines", "kotlinx-coroutines-bom")
val internal = setOf("kotlinx.coroutines", "benchmarks")
// Not published
val unpublished = internal + setOf("example-frontend-js", "android-unit-tests")

Expand Down
1 change: 1 addition & 0 deletions bump-version.sh
Expand Up @@ -21,6 +21,7 @@ update_version "kotlinx-coroutines-debug/README.md"
update_version "kotlinx-coroutines-test/README.md"
update_version "ui/coroutines-guide-ui.md"
update_version "gradle.properties"
update_version "integration-test/gradle.properties"

# Escape dots, e.g. 1.0.0 -> 1\.0\.0
escaped_old_version=$(echo $old_version | sed s/[.]/\\\\./g)
Expand Down
15 changes: 7 additions & 8 deletions integration-testing/README.md
@@ -1,14 +1,13 @@
# Integration tests

This is a supplementary subproject of kotlinx.coroutines that provides
integration tests.
This is a supplementary project that provides integration tests.

The tests are the following:
* `NpmPublicationValidator` tests that version of NPM artifact is correct and that it has neither source nor package dependencies on atomicfu
In order for the test to work, one needs to run gradle with `-PdryRun=true`.
`-PdryRun` affects `npmPublish` so that it only provides a packed publication
and does not in fact attempt to send the build for publication.
* `MavenPublicationValidator` depends on the published artifacts and tests artifacts binary content and absence of atomicfu in the classpath
* `MavenPublicationValidator` depends on the published artifacts and tests artifacts binary content and absence of atomicfu in the classpath.
* `CoreAgentTest` checks that `kotlinx-coroutines-core` can be run as a Java agent.
* `DebugAgentTest` checks that the coroutine debugger can be run as a Java agent.
* `smokeTest` builds the test project that depends on coroutines.

All the available tests can be run with `integration-testing:test`.
The `integration-testing` project is expected to be in a subdirectory of the main `kotlinx.coroutines` project.

To run all the available tests: `cd integration-testing` + `./gradlew check`.
58 changes: 30 additions & 28 deletions integration-testing/build.gradle
Expand Up @@ -5,30 +5,52 @@
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType

plugins {
id("kotlin-jvm-conventions")
id "org.jetbrains.kotlin.jvm"
}

repositories {
mavenLocal()
mavenCentral()
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}

sourceSets {
mavenTest {
kotlin
compileClasspath += sourceSets.test.runtimeClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath

dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
}
}
debugAgentTest {
kotlin
compileClasspath += sourceSets.test.runtimeClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath
}

dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version"
}
}
coreAgentTest {
kotlin
compileClasspath += sourceSets.test.runtimeClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath

dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
}
}
}

Expand All @@ -39,53 +61,33 @@ compileDebugAgentTestKotlin {
}

task mavenTest(type: Test) {
environment "version", version
environment "version", coroutines_version
def sourceSet = sourceSets.mavenTest
dependsOn(project(':').getTasksByName("publishToMavenLocal", true))
testClassesDirs = sourceSet.output.classesDirs
classpath = sourceSet.runtimeClasspath
// we can't depend on the subprojects because we need to test the classfiles that are published in the end.
// also, we can't put this in the `dependencies` block because the resolution would happen before publication.
def mavenTestClasspathConfiguration = project.configurations.detachedConfiguration(
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"),
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"))

mavenTestClasspathConfiguration.attributes {
attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
}

classpath += mavenTestClasspathConfiguration
}

task debugAgentTest(type: Test) {
def sourceSet = sourceSets.debugAgentTest
dependsOn(project(':kotlinx-coroutines-debug').shadowJar)
jvmArgs ('-javaagent:' + project(':kotlinx-coroutines-debug').shadowJar.outputs.files.getFiles()[0])
def coroutinesDebugJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-debug-${coroutines_version}.jar" }.singleFile
jvmArgs ('-javaagent:' + coroutinesDebugJar)
testClassesDirs = sourceSet.output.classesDirs
classpath = sourceSet.runtimeClasspath
systemProperties project.properties.subMap(["overwrite.probes"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, that's an issue.

This flag control the functionality in integration-testing/src/debugAgentTest/kotlin/PrecompiledDebugProbesTest.kt that allows us to replace DebugProbesKt.bin, a file in the repository, with a new version. I'm sure this functionality is now broken. We should either fix this or adapt in some other way. @qwwdfsad, do we still need -Poverwrite.probes? Does anyone rely but us on this, or can we provide a more fitting interface? Also, is the comment below still relevant (from the file with the test)?

ensure that classfile has major version equal to 50 (Java 6 compliance)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is indeed redundant.

We should either fix this or adapt in some other way

Right. @mvicsokolova please ensure that ./gradlew debugAgentTest -Poverwrite.probes=true properly works. For now it fails with FileNotFoundException

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from that, ./gradlew publishToMavenLocal + cd integration-testing + ./gradlew debugAgentTest fails locally at PrecompiledDebugProbesTest. It shouldn't be be the case, please investigate

}

task coreAgentTest(type: Test) {
def sourceSet = sourceSets.coreAgentTest
dependsOn(project(':kotlinx-coroutines-core').jvmJar)
jvmArgs ('-javaagent:' + project(':kotlinx-coroutines-core').jvmJar.outputs.files.getFiles()[0])
def coroutinesCoreJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-core-jvm-${coroutines_version}.jar" }.singleFile
jvmArgs ('-javaagent:' + coroutinesCoreJar)
testClassesDirs = sourceSet.output.classesDirs
classpath = sourceSet.runtimeClasspath
}

dependencies {
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testImplementation 'junit:junit:4.12'
debugAgentTestImplementation project(':kotlinx-coroutines-core')
debugAgentTestImplementation project(':kotlinx-coroutines-debug')
coreAgentTestImplementation project(':kotlinx-coroutines-core')
}

compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

check {
dependsOn([mavenTest, debugAgentTest, coreAgentTest])
dependsOn([mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build'])
}
4 changes: 4 additions & 0 deletions integration-testing/gradle.properties
@@ -0,0 +1,4 @@
kotlin_version=1.6.21
coroutines_version=1.6.2-SNAPSHOT

kotlin.code.style=official
Binary file not shown.
5 changes: 5 additions & 0 deletions integration-testing/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists