Class OpenTracingBaseTests
java.lang.Object
org.jboss.arquillian.testng.Arquillian
org.eclipse.microprofile.opentracing.tck.OpenTracingBaseTests
- All Implemented Interfaces:
org.testng.IHookable,org.testng.ITestNGListener
- Direct Known Subclasses:
ClientRegistrarTests,OpenTracingClientBaseTests,OpenTracingSkipPatternTests
public abstract class OpenTracingBaseTests
extends org.jboss.arquillian.testng.Arquillian
- Author:
- Pavol Loffay
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jboss.arquillian.testng.Arquillian
org.jboss.arquillian.testng.Arquillian.UpdateResultListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected URLServer app URL for the client tests.static final StringFields inherited from class org.jboss.arquillian.testng.Arquillian
ARQUILLIAN_DATA_PROVIDER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassertEqualErrorTrees(ConsumableTree<TestSpan> returnedTree, ConsumableTree<TestSpan> expectedTree) This wrapper method allows for potential post-processing, such as removing tags that we don't care to compare inreturnedTree.protected voidassertEqualTrees(ConsumableTree<TestSpan> returnedTree, ConsumableTree<TestSpan> expectedTree) This wrapper method allows for potential post-processing, such as removing tags that we don't care to compare inreturnedTree.protected voidBefore each test method, clear the tracer.static org.jboss.shrinkwrap.api.spec.WebArchiveDeploy the apps to test.protected voidexecuteNested(String path, int uniqueId, int nestDepth, int nestBreadth, boolean failNest, boolean async) Execute the nested web service.protected jakarta.ws.rs.core.ResponseexecuteRemoteWebServiceRaw(String service, String relativePath, jakarta.ws.rs.core.Response.Status expectedStatus) Execute a remote web service and return the content.protected jakarta.ws.rs.core.ResponseexecuteRemoteWebServiceRaw(String service, String relativePath, Map<String, Object> queryParameters, jakarta.ws.rs.core.Response.Status expectedStatus) Execute a remote web service and return the content.protected TestSpanTreeExecute a remote web service and return the span tree.protected MethodgetEndpointMethod(Class<?> clazz, String mapping) Get REST endpoint java method based on the mapping value inPathannotation.protected TestSpangetExpectedNestedServerSpan(String path, String spanKind, int uniqueId, int nestDepth, int nestBreadth, boolean failNest, boolean isFailed, boolean async) The expected nested span layout.getExpectedSpanTags(String spanKind, String httpMethod, String service, String relativePath, Map<String, Object> queryParameters, int httpStatus, String component) Create a tags collection for expected span tags.getExpectedSpanTagsForError(String service, String spanKind) Create a tags collection for expected span tags with an error.getNestedQueryParameters(int uniqueId, int nestDepth, int nestBreadth, boolean failNest, boolean async) protected StringgetOperationName(String spanKind, String httpMethod, Class<?> clazz, Method method) Get operation name depending on thespanKind.protected intGet a random integer.protected StringgetWebServiceURL(String service, String relativePath) Create web service URL.protected StringCreate web service URL.protected voidtestMultithreadedNestedSpans(String path, int numberOfCalls, int nestDepth, int nestBreadth, boolean failNest, boolean async) protected voidtestNestedSpans(String path, int nestDepth, int nestBreadth, int uniqueId, boolean failNest, boolean async) Do the actual testing and assertion of a nested call.Methods inherited from class org.jboss.arquillian.testng.Arquillian
arquillianAfterClass, arquillianAfterSuite, arquillianAfterTest, arquillianArgumentProvider, arquillianBeforeClass, arquillianBeforeSuite, arquillianBeforeTest, run
-
Field Details
-
JAXRS_COMPONENT
- See Also:
-
deploymentURL
Server app URL for the client tests.
-
-
Constructor Details
-
OpenTracingBaseTests
public OpenTracingBaseTests()
-
-
Method Details
-
createDeployment
public static org.jboss.shrinkwrap.api.spec.WebArchive createDeployment()Deploy the apps to test.- Returns:
- the Deployed apps
-
beforeEachTest
@BeforeMethod protected void beforeEachTest()Before each test method, clear the tracer. In the case that a test fails, other tests may still run, and if the clearTracer call is done at the end of a test, then the next test may still have old spans in its result, which would both fail that test and make debugging harder. -
getWebServiceURL
Create web service URL.- Parameters:
service- Web service pathrelativePath- Web service endpoint- Returns:
- Web service URL
-
getWebServiceURL
protected String getWebServiceURL(String service, String relativePath, Map<String, Object> queryParameters) Create web service URL.- Parameters:
service- Web service pathrelativePath- Web service endpointqueryParameters- Query parameters.- Returns:
- Web service URL
-
executeRemoteWebServiceRaw
protected jakarta.ws.rs.core.Response executeRemoteWebServiceRaw(String service, String relativePath, jakarta.ws.rs.core.Response.Status expectedStatus) Execute a remote web service and return the content.- Parameters:
service- Web service pathrelativePath- Web service endpointexpectedStatus- Expected HTTP status.- Returns:
- Response
-
executeRemoteWebServiceRaw
protected jakarta.ws.rs.core.Response executeRemoteWebServiceRaw(String service, String relativePath, Map<String, Object> queryParameters, jakarta.ws.rs.core.Response.Status expectedStatus) Execute a remote web service and return the content.- Parameters:
service- Web service pathrelativePath- Web service endpointqueryParameters- Query parameters.expectedStatus- Expected HTTP status.- Returns:
- Response
-
executeRemoteWebServiceTracerTree
Execute a remote web service and return the span tree.- Returns:
- TestSpanTree
-
assertEqualTrees
protected void assertEqualTrees(ConsumableTree<TestSpan> returnedTree, ConsumableTree<TestSpan> expectedTree) This wrapper method allows for potential post-processing, such as removing tags that we don't care to compare inreturnedTree. This method removes error related keys.- Parameters:
returnedTree- The returned tree from the web service.expectedTree- The simulated tree that we expect.
-
assertEqualErrorTrees
protected void assertEqualErrorTrees(ConsumableTree<TestSpan> returnedTree, ConsumableTree<TestSpan> expectedTree) This wrapper method allows for potential post-processing, such as removing tags that we don't care to compare inreturnedTree. This method keeps the error related keys.- Parameters:
returnedTree- The returned tree from the web service.expectedTree- The simulated tree that we expect.
-
getRandomNumber
protected int getRandomNumber()Get a random integer.- Returns:
- Random integer.
-
getEndpointMethod
Get REST endpoint java method based on the mapping value inPathannotation.- Parameters:
clazz- class of the endpoint.mapping- endpoint mapping.- Returns:
- endpoint method or null if not found.
-
getOperationName
protected String getOperationName(String spanKind, String httpMethod, Class<?> clazz, Method method) Get operation name depending on thespanKind.- Parameters:
spanKind- The type of span.httpMethod- HTTP methodclazz- resource classmethod- method of the REST endpoint- Returns:
- operation name
-
getExpectedSpanTags
protected Map<String,Object> getExpectedSpanTags(String spanKind, String httpMethod, String service, String relativePath, Map<String, Object> queryParameters, int httpStatus, String component) Create a tags collection for expected span tags.- Parameters:
spanKind- Value forTags.SPAN_KINDhttpMethod- Value forTags.HTTP_METHODservice- First parameter togetWebServiceURL(String, String)relativePath- Second parameter togetWebServiceURL(String, String)queryParameters- Query parameters.httpStatus- Value forTags.HTTP_STATUS- Returns:
- Tags collection.
-
getExpectedSpanTagsForError
Create a tags collection for expected span tags with an error.- Parameters:
service- REST service.spanKind- Value forTags.SPAN_KIND- Returns:
- Tags map.
-
testNestedSpans
protected void testNestedSpans(String path, int nestDepth, int nestBreadth, int uniqueId, boolean failNest, boolean async) Do the actual testing and assertion of a nested call.- Parameters:
uniqueId- Some unique ID.nestDepth- How deep to nest the calls.nestBreadth- Breadth of first level of nested calls.failNest- Whether to fail the nested call.async- Whether to execute nested requests asynchronously.
-
testMultithreadedNestedSpans
protected void testMultithreadedNestedSpans(String path, int numberOfCalls, int nestDepth, int nestBreadth, boolean failNest, boolean async) throws InterruptedException, ExecutionException - Parameters:
numberOfCalls- Number of total web requests.nestDepth- How deep to nest the calls.nestBreadth- Breadth of first level of nested calls.failNest- Whether to fail the nested call.async- Whether to execute nested requests asynchronously.- Throws:
InterruptedException- Problem executing web service.ExecutionException- Thread pool problem.
-
executeNested
protected void executeNested(String path, int uniqueId, int nestDepth, int nestBreadth, boolean failNest, boolean async) Execute the nested web service.- Parameters:
uniqueId- Some unique ID.nestDepth- How deep to nest the calls.nestBreadth- Breadth of first level of nested calls.failNest- Whether to fail the nested call.async- Whether to execute nested requests asynchronously.
-
getNestedQueryParameters
protected Map<String,Object> getNestedQueryParameters(int uniqueId, int nestDepth, int nestBreadth, boolean failNest, boolean async) - Parameters:
uniqueId- Some unique ID.nestDepth- How deep to nest the calls.nestBreadth- Breadth of first level of nested calls.failNest- Whether to fail the nested call.async- Whether to execute nested requests asynchronously.- Returns:
- Query parameters map.
-
getExpectedNestedServerSpan
protected TestSpan getExpectedNestedServerSpan(String path, String spanKind, int uniqueId, int nestDepth, int nestBreadth, boolean failNest, boolean isFailed, boolean async) The expected nested span layout.- Parameters:
spanKind- Span kinduniqueId- The unique ID of the request.nestDepth- Nest depthnestBreadth- Nest breadthfailNest- Whether to fail the nested call.isFailed- Whether this request is expected to fail.async- Whether to execute asynchronously.- Returns:
- Span for the nested call.
-