-
Notifications
You must be signed in to change notification settings - Fork 17
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
Migrate crosstests to use testcontainers #84
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ MAKEFLAGS += --no-print-directory | |
BIN := .tmp/bin | ||
CACHE := .tmp/cache | ||
LICENSE_HEADER_YEAR_RANGE := 2022-2023 | ||
CROSSTEST_VERSION := 162d496c009e2ffb1a638b4a2ea789e9cc3331bb | ||
LICENSE_HEADER_VERSION := v1.26.1 | ||
PROTOC_VERSION ?= 24.1 | ||
GRADLE_ARGS ?= | ||
|
@@ -26,7 +25,7 @@ $(BIN)/license-headers: Makefile | |
|
||
.PHONY: build | ||
build: generate ## Build the entire project. | ||
./gradlew $(GRADLE_ARGS) build -x test | ||
./gradlew $(GRADLE_ARGS) build | ||
|
||
.PHONY: buildplugin | ||
buildplugin: ## Build the connect-kotlin protoc plugin. | ||
|
@@ -45,19 +44,6 @@ clean: ## Cleans the underlying build. | |
|
||
rm -rf protoc-gen-connect-kotlin/src/test/java/ | ||
|
||
.PHONY: crosstestserverrun | ||
crosstestserverrun: crosstestserverstop ## Run the server for cross tests. | ||
docker run --rm --name serverconnect -p 8080:8080 -p 8081:8081 -d \ | ||
bufbuild/connect-crosstest:$(CROSSTEST_VERSION) \ | ||
/usr/local/bin/serverconnect --h1port "8080" --h2port "8081" --cert "cert/localhost.crt" --key "cert/localhost.key" | ||
docker run --rm --name servergrpc -p 8083:8083 -d \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE: I never saw anything connect to anything other than the h2port of the connect server. If we want to extend the tests to hit the gRPC server we should do that. |
||
bufbuild/connect-crosstest:$(CROSSTEST_VERSION) \ | ||
/usr/local/bin/servergrpc --port "8083" --cert "cert/localhost.crt" --key "cert/localhost.key" | ||
|
||
.PHONY: crosstestserverstop | ||
crosstestserverstop: ## Stop the server for cross tests. | ||
-docker container stop serverconnect servergrpc | ||
|
||
.PHONY: crosstestsrun | ||
crosstestsrun: crosstestsrunjava ## Run the cross tests. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,10 +43,12 @@ import okhttp3.Protocol | |
import org.assertj.core.api.Assertions.assertThat | ||
import org.assertj.core.api.Assertions.fail | ||
import org.junit.Before | ||
import org.junit.ClassRule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
import org.junit.runners.Parameterized.Parameters | ||
import org.testcontainers.containers.GenericContainer | ||
import java.time.Duration | ||
import java.util.Base64 | ||
import java.util.concurrent.CountDownLatch | ||
|
@@ -63,6 +65,8 @@ class CrossTest( | |
private lateinit var testServiceConnectClient: TestServiceClient | ||
|
||
companion object { | ||
const val CROSSTEST_VERSION = "162d496c009e2ffb1a638b4a2ea789e9cc3331bb" | ||
|
||
@JvmStatic | ||
@Parameters(name = "protocol") | ||
fun data(): Iterable<NetworkProtocol> { | ||
|
@@ -71,12 +75,27 @@ class CrossTest( | |
NetworkProtocol.GRPC | ||
) | ||
} | ||
|
||
@JvmField | ||
@ClassRule | ||
val CROSSTEST_CONTAINER = GenericContainer("bufbuild/connect-crosstest:${CROSSTEST_VERSION}") | ||
.withExposedPorts(8080, 8081) | ||
.withCommand( | ||
"/usr/local/bin/serverconnect", | ||
"--h1port", | ||
"8080", | ||
"--h2port", | ||
"8081", | ||
"--cert", | ||
"cert/localhost.crt", | ||
"--key", | ||
"cert/localhost.key", | ||
) | ||
} | ||
|
||
@Before | ||
fun before() { | ||
val port = 8081 | ||
val host = "https://localhost:$port" | ||
val host = "https://localhost:${CROSSTEST_CONTAINER.getMappedPort(8081)}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will use an ephemeral port so it won't fail if something else is bound to 8080/8081. |
||
val (sslSocketFactory, trustManager) = sslContext() | ||
val client = OkHttpClient.Builder() | ||
.protocols(listOf(Protocol.HTTP_2, Protocol.HTTP_1_1)) | ||
|
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.
@smallsamantha - I noticed there were real compile errors in the tests which weren't getting reported in any of the CI checks as part of #79. This should resolve that.