Package brave.test.http
Class ITHttpServer
java.lang.Object
brave.test.ITRemote
brave.test.http.ITHttpServer
- Direct Known Subclasses:
ITServletContainer
public abstract class ITHttpServer extends ITRemote
-
Field Summary
Fields Modifier and Type Field Description protected HttpTracing
httpTracing
static IllegalStateException
NOT_READY_ISE
Fields inherited from class brave.test.ITRemote
BAGGAGE_FIELD, BAGGAGE_FIELD_KEY, currentTraceContext, globalTimeout, propagationFactory, spanHandler, testName, tracing
-
Constructor Summary
Constructors Constructor Description ITHttpServer()
-
Method Summary
Modifier and Type Method Description void
addsStatusCode_badRequest()
void
async()
Tests that the span propagates between under asynchronous callbacks (even if explicitly)void
childCompletesBeforeServer()
The child completes before the response code is established, so it should be contained completely by the server's interval.void
createsChildSpan()
This ensures thread-state is propagated from trace interceptors to user code.void
createsChildWhenJoinDisabled()
void
customSampler()
void
defaultSpanNameIsMethodNameOrRoute()
protected okhttp3.Response
get(String path)
protected okhttp3.Response
get(okhttp3.Request request)
void
httpPathTagExcludesQueryParams()
void
httpRoute()
The "/items/{itemId}" endpoint should return the itemId in the response body, which proves templating worked (including that it ignores query parameters).void
httpRoute_async()
Sometimes state used to carry http route data is different for async requests.void
httpRoute_nested()
The "/nested/items/{itemId}" endpoint should be implemented by two route expressions: A path prefix: "/nested" and then a relative expression "/items/{itemId}"void
httpStatusCodeSettable_onUncaughtException()
This tests that the actual code is503
, not500
on exception.void
httpStatusCodeSettable_onUncaughtException_async()
void
httpStatusCodeTagMatchesResponse_onUncaughtException()
ThrowNOT_READY_ISE
inside your controller after setting the status code {code 503}.void
httpStatusCodeTagMatchesResponse_onUncaughtException_async()
protected abstract void
init()
recreate the server if neededvoid
notFound()
If http route is supported, then the span name should include itvoid
options()
This tests both that a root path ends up as "/" (slash) not "" (empty), as well that less typical OPTIONS methods can be traced.void
readsBaggage_existingTrace()
void
readsBaggage_newTrace()
void
readsBaggage_unsampled()
void
readsRequestAtResponseTime()
void
reportsClientAddress()
void
reportsClientAddress_XForwardedFor()
void
reportsServerKindToZipkin()
void
reusesPropagatedSpanId()
void
samplingDisabled()
void
setsErrorAndHttpStatusOnUncaughtException()
void
setsErrorAndHttpStatusOnUncaughtException_async()
void
setup()
void
spanHandlerSeesError()
void
spanHandlerSeesException_async()
void
supportsPortableCustomization()
void
supportsPortableCustomizationDeprecated()
Deprecated.protected abstract String
url(String path)
Methods inherited from class brave.test.ITRemote
assertChildOf, assertChildOf, assertChildOf, assertNoError, assertNoErrorTag, assertSameIds, assertSequential, assertSpanInInterval, checkForLeakedScopes, close, currentTraceContextBuilder, newTraceContext, tracingBuilder
-
Field Details
-
Constructor Details
-
ITHttpServer
public ITHttpServer()
-
-
Method Details
-
setup
- Throws:
IOException
-
init
recreate the server if needed- Throws:
IOException
-
url
-
reusesPropagatedSpanId
- Throws:
IOException
-
createsChildWhenJoinDisabled
- Throws:
IOException
-
readsBaggage_newTrace
- Throws:
IOException
-
readsBaggage_unsampled
- Throws:
IOException
-
readsBaggage_existingTrace
- Throws:
IOException
-
samplingDisabled
- Throws:
IOException
-
customSampler
- Throws:
IOException
-
async
Tests that the span propagates between under asynchronous callbacks (even if explicitly)- Throws:
IOException
-
createsChildSpan
This ensures thread-state is propagated from trace interceptors to user code. The endpoint "/child" is expected to create an in-process span. When this works, it should be a child of the "current span", in this case the span representing an incoming server request. When thread state isn't managed properly, the child span will appear as a new trace.- Throws:
IOException
-
childCompletesBeforeServer
The child completes before the response code is established, so it should be contained completely by the server's interval.- Throws:
IOException
-
reportsClientAddress
- Throws:
IOException
-
reportsClientAddress_XForwardedFor
- Throws:
IOException
-
reportsServerKindToZipkin
- Throws:
IOException
-
defaultSpanNameIsMethodNameOrRoute
- Throws:
IOException
-
readsRequestAtResponseTime
- Throws:
IOException
-
supportsPortableCustomization
- Throws:
IOException
-
supportsPortableCustomizationDeprecated
Deprecated.- Throws:
IOException
-
httpRoute
The "/items/{itemId}" endpoint should return the itemId in the response body, which proves templating worked (including that it ignores query parameters). Note the route format is framework specific, ex "/items/:itemId" in vert.x- Throws:
IOException
-
httpRoute_nested
The "/nested/items/{itemId}" endpoint should be implemented by two route expressions: A path prefix: "/nested" and then a relative expression "/items/{itemId}"- Throws:
IOException
-
httpRoute_async
Sometimes state used to carry http route data is different for async requests. This helps ensure we don't miss issues like this.- Throws:
IOException
-
notFound
If http route is supported, then the span name should include it- Throws:
IOException
-
options
This tests both that a root path ends up as "/" (slash) not "" (empty), as well that less typical OPTIONS methods can be traced.- Throws:
IOException
-
addsStatusCode_badRequest
- Throws:
IOException
-
httpPathTagExcludesQueryParams
- Throws:
IOException
-
httpStatusCodeTagMatchesResponse_onUncaughtException
ThrowNOT_READY_ISE
inside your controller after setting the status code {code 503}.Note: Don't throw
UnavailableException
as Jetty ignores the exception message!- Throws:
IOException
-
httpStatusCodeTagMatchesResponse_onUncaughtException_async
- Throws:
IOException
-
httpStatusCodeSettable_onUncaughtException
This tests that the actual code is503
, not500
on exception.Usually, frameworks have an exception wrapper which allow you to control the status code. Other times, you have to set the status before raising the exception.
Note: Some frameworks cannot control the status code upon unhandled error in a controller at all. If this is the case, just override and ignore this test.
- Throws:
IOException
-
httpStatusCodeSettable_onUncaughtException_async
- Throws:
IOException
-
setsErrorAndHttpStatusOnUncaughtException
- Throws:
IOException
-
setsErrorAndHttpStatusOnUncaughtException_async
- Throws:
IOException
-
spanHandlerSeesError
- Throws:
IOException
-
spanHandlerSeesException_async
- Throws:
IOException
-
get
- Throws:
IOException
-
get
- Throws:
IOException
-