Skip to content

Commit

Permalink
wow - got logging working by removing the gradleTestKit thing
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesward committed Feb 27, 2024
1 parent 90b70bf commit 5a21122
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
4 changes: 0 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ subprojects {
group = rootProject.group
version = rootProject.version

repositories {
mavenCentral()
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
Expand Down
1 change: 1 addition & 0 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ subprojects {
}

tasks.create("assemble").dependsOn(":server:installDist")

2 changes: 1 addition & 1 deletion examples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ truth-proto-extension = { group = "com.google.truth.extensions", name = "truth-p
okhttp = { group = "com.squareup.okhttp", name = "okhttp", version = "2.7.5" }
javax-annotation-api = { group = "javax.annotation", name = "javax.annotation-api", version = "1.3.2" }
testcontainers = { group = "org.testcontainers", name = "testcontainers", version = "1.19.6" }
slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version = "2.0.12" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
10 changes: 7 additions & 3 deletions integration_testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ kotlin {
}

dependencies {
testImplementation(gradleTestKit())
testImplementation(libs.testcontainers)
testImplementation("org.gradle:gradle-test-kit:6.1")
testImplementation("org.gradle:gradle-test-kit:6.1")
testImplementation("commons-io:commons-io:2.15.1")
testImplementation("org.gradle:gradle-tooling-api:8.6")
testImplementation(libs.junit.jupiter)
testRuntimeOnly(libs.junit.platform.launcher)
testRuntimeOnly(libs.slf4j.simple)
}

tasks.named<Test>("test") {
Expand All @@ -27,7 +31,7 @@ tasks.named<Test>("test") {
testLogging {
showStandardStreams = true
exceptionFormat = TestExceptionFormat.FULL
events(TestLogEvent.STARTED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
events(TestLogEvent.STANDARD_OUT, TestLogEvent.STANDARD_ERROR, TestLogEvent.STARTED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}

retry {
Expand All @@ -48,4 +52,4 @@ tasks.named<Test>("test") {
*/

// todo: cleanup copyExamples.destinationDir or move copy to tests
}
}
18 changes: 15 additions & 3 deletions integration_testing/src/test/kotlin/io/grpc/kotlin/ExamplesTest.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package io.grpc.kotlin

import org.gradle.internal.impldep.org.apache.commons.io.FileUtils
import org.apache.commons.io.FileUtils
import org.gradle.testkit.runner.GradleRunner
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import org.testcontainers.containers.GenericContainer
import org.testcontainers.containers.wait.strategy.Wait
import java.io.File
import java.net.URI
import java.nio.file.Path
import java.util.Properties
import kotlin.io.path.div
import kotlin.io.path.inputStream


class ExamplesTest {

Expand Down Expand Up @@ -50,16 +55,22 @@ class ExamplesTest {
}
settingsGradle.writeText(settingsGradleNewLines.joinToString("\n"))

val gradleWrapperProperties = Properties()
gradleWrapperProperties.load((tempDir / "gradle/wrapper/gradle-wrapper.properties").inputStream())
val distributionUrl = URI.create(gradleWrapperProperties.getProperty("distributionUrl"))

val dependencyResult = GradleRunner.create()
.withProjectDir(tempDir.toFile())
.withArguments(":stub:dependencies")
.withGradleDistribution(distributionUrl)
.build()

assertTrue(dependencyResult.output.contains("io.grpc:grpc-kotlin-stub:$grpcKotlinVersion"))

GradleRunner.create()
.withProjectDir(tempDir.toFile())
.withArguments(":server:jibDockerBuild", "--image=grpc-kotlin-examples-server")
.withGradleDistribution(distributionUrl)
.build()

val container = GenericContainer("grpc-kotlin-examples-server")
Expand All @@ -70,11 +81,12 @@ class ExamplesTest {

val clientResult = GradleRunner.create()
.withProjectDir(tempDir.toFile())
.withEnvironment(mapOf("PORT" to container.getFirstMappedPort().toString()))
.withEnvironment(mapOf("PORT" to container.firstMappedPort.toString()))
.withArguments(":client:HelloWorldClient")
.withGradleDistribution(distributionUrl)
.build()

assertTrue(clientResult.output.contains("Received: Hello world"))
}

}
}
8 changes: 8 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
rootProject.name = "grpc-kotlin"

include("stub", "compiler", "interop_testing", "integration_testing")

dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenCentral()
maven("https://repo.gradle.org/gradle/libs-releases")
}
}

0 comments on commit 5a21122

Please sign in to comment.