Skip to content

Conversation

@satween
Copy link
Contributor

@satween satween commented Jan 14, 2026

What does this PR do?

Adds a new tools/testserver module providing embedded HTTP/HTTPS/QUIC test servers for network integration testing.

Motivation

Network integration tests for libraries like Cronet and OkHttp require a reliable test server to verify behavior without depending on external services. This service gonna be used for both HTTP and QUIC protocol testing in further tasks

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@satween satween requested review from a team as code owners January 14, 2026 17:20
@satween satween changed the title Tvaleev/feature/rum 12640 testserver RUM-12640: Web server for network library integration testing Jan 14, 2026
@satween satween changed the title RUM-12640: Web server for network library integration testing RUM-12640: [Cronet] Web server for network library integration testing Jan 14, 2026
@datadog-official
Copy link

datadog-official bot commented Jan 14, 2026

🎯 Code Coverage
Patch Coverage: 100.00%
Overall Coverage: 65.83% (+0.02%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0006a1f | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.82%. Comparing base (c1d8da1) to head (0006a1f).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3126      +/-   ##
===========================================
+ Coverage    70.69%   70.82%   +0.12%     
===========================================
  Files          893      893              
  Lines        33000    33000              
  Branches      5549     5549              
===========================================
+ Hits         23329    23369      +40     
+ Misses        8122     8090      -32     
+ Partials      1549     1541       -8     

see 38 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@domalessi domalessi self-assigned this Jan 14, 2026
Copy link

@domalessi domalessi left a comment

Choose a reason for hiding this comment

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

One minor tweak but approved!


- **HTTP Server** (`TestServer`) - Plain HTTP server using Netty
- **HTTPS Server** (`SecureTestServer`) - Secure server with self-signed certificate and HTTP/2 support
- Support for all common HTTP methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS

Choose a reason for hiding this comment

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

Suggested change
- Support for all common HTTP methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
- Support for all common HTTP methods: `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS`

Comment on lines +109 to +110
"statusCode": 500,
"method": "GET",
Copy link
Member

Choose a reason for hiding this comment

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

is it useful to have status code and method in the json body? they are already available at the HTTP layer

val server = SecureTestServer(httpsPort = 8443)
server.start()

// Configure Cronet engine with custom certificate
Copy link
Member

Choose a reason for hiding this comment

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

this snippet doesn't show custom key store integration as OkHttp snippet above


plugins {
id("org.jetbrains.kotlin.jvm")
id("com.github.ben-manes.versions")
Copy link
Member

Choose a reason for hiding this comment

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

worth adding id("com.datadoghq.dependency-license") here as well

}

private fun Route.configureErrorEndpointsWithBody() {
get("/error/{code}/get") {
Copy link
Member

Choose a reason for hiding this comment

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

we have a duplication of the method in the path as well, is it worth to have it there?

path = "/post",
body = body,
headers = call.request.headers.entries()
.associate { it.key to it.value.joinToString(", ") }
Copy link
Member

Choose a reason for hiding this comment

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

aren't we missing headers if header key is seen several time? like

HeaderA: firstValue
HeaderA: secondValue


private lateinit var testServer: SecureTestServer
private lateinit var client: OkHttpClient
private lateinit var gson: Gson
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private lateinit var gson: Gson
private val gson: Gson = Gson()


private lateinit var testServer: TestServer
private lateinit var client: OkHttpClient
private lateinit var gson: Gson
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private lateinit var gson: Gson
private val gson: Gson = Gson()

.url("${server.httpsUrl()}/get")
.build()

val response = client.newCall(request).execute()
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify the testing strategy. Is my understanding correct that when we use TestServer in some integration test in the future we will be doing assertions and verifications on the response?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants