Package brave.test

Class ITRemote


  • @Timeout(value=20L,
             unit=MINUTES)
    public abstract class ITRemote
    extends Object
    This is the base class for remote integration tests. It has a few features to ensure tests cover common instrumentation bugs. Most of this optimizes for instrumentation occurring on a different thread than main (which does the assertions).

    Timeout

    We use a global rule instead of surefire config as this could be executed in gradle, sbt, etc. This way, there's visibility on which method hung without asking the end users to edit build config.

    Normal tests will pass in less than 5 seconds. This timeout is set to 20 to be higher than needed even in an overloaded CI server or extreme garbage collection pause.

    • Constructor Detail

      • ITRemote

        protected ITRemote()
    • Method Detail

      • newTraceContext

        protected TraceContext newTraceContext​(SamplingFlags flags)
        Returns a trace context for use in propagation tests.
      • close

        @AfterEach
        protected void close()
                      throws Exception
        This closes the current instance of tracing, to prevent it from being accidentally visible to other test classes which call Tracing.current().

        This also checks for scope leaks. It is important that you have closed all resources prior to this method call. Otherwise, in-flight request cleanup may be mistaken for scope leaks. This may involve blocking on completion, if using executors.

        Ex.

        {@code
        Throws:
        Exception
      • checkForLeakedScopes

        protected void checkForLeakedScopes()
                                     throws IOException
        Override to disable scope leak enforcement.
        Throws:
        IOException
      • assertSpanInInterval

        protected void assertSpanInInterval​(MutableSpan span,
                                            long startTimestamp,
                                            long finishTimestamp)
        Ensures the inputs are parent and child, the parent starts before the child, and the duration of the child is inside the parent's duration.
      • assertSequential

        protected void assertSequential​(MutableSpan span1,
                                        MutableSpan span2)
        Ensures the first finished before the other started.
      • assertNoError

        protected void assertNoError​(MutableSpan result)
      • assertNoErrorTag

        protected void assertNoErrorTag​(MutableSpan result)