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
  • Field Details

    • JAXRS_COMPONENT

      public static final String JAXRS_COMPONENT
      See Also:
    • deploymentURL

      @ArquillianResource protected URL 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

      protected String getWebServiceURL(String service, String relativePath)
      Create web service URL.
      Parameters:
      service - Web service path
      relativePath - 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 path
      relativePath - Web service endpoint
      queryParameters - 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 path
      relativePath - Web service endpoint
      expectedStatus - 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 path
      relativePath - Web service endpoint
      queryParameters - Query parameters.
      expectedStatus - Expected HTTP status.
      Returns:
      Response
    • executeRemoteWebServiceTracerTree

      protected TestSpanTree 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 in returnedTree. 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 in returnedTree. 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

      protected Method getEndpointMethod(Class<?> clazz, String mapping)
      Get REST endpoint java method based on the mapping value in Path annotation.
      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 the spanKind.
      Parameters:
      spanKind - The type of span.
      httpMethod - HTTP method
      clazz - resource class
      method - 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 for Tags.SPAN_KIND
      httpMethod - Value for Tags.HTTP_METHOD
      service - First parameter to getWebServiceURL(String, String)
      relativePath - Second parameter to getWebServiceURL(String, String)
      queryParameters - Query parameters.
      httpStatus - Value for Tags.HTTP_STATUS
      Returns:
      Tags collection.
    • getExpectedSpanTagsForError

      protected Map<String,Object> getExpectedSpanTagsForError(String service, String spanKind)
      Create a tags collection for expected span tags with an error.
      Parameters:
      service - REST service.
      spanKind - Value for Tags.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 kind
      uniqueId - The unique ID of the request.
      nestDepth - Nest depth
      nestBreadth - Nest breadth
      failNest - 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.