Skip to content

Commit

Permalink
feat(concurrency): Refactor test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
PerfectSlayer committed Jun 11, 2024
1 parent 05629d9 commit 91385b2
Show file tree
Hide file tree
Showing 24 changed files with 68 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.oio.OioEventLoopGroup
import io.netty.util.concurrent.DefaultEventExecutor
import org.apache.tomcat.util.threads.TaskQueue
import runnable.Descendant
import spock.lang.Shared

import java.util.concurrent.ExecutorService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package executor

import com.google.common.util.concurrent.MoreExecutors
import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.api.Trace
import datadog.trace.bootstrap.instrumentation.api.Tags
import datadog.trace.bootstrap.instrumentation.java.concurrent.RunnableWrapper
import datadog.trace.core.DDSpan
import forkjoin.PeriodicTask
import org.apache.tomcat.util.threads.TaskQueue
import runnable.ComparableAsyncChild
import runnable.JavaAsyncChild
import spock.lang.Shared

import java.lang.reflect.InvocationTargetException
Expand Down Expand Up @@ -63,8 +68,8 @@ abstract class ExecutorInstrumentationTest extends AgentTestRunner {
void configurePreAgent() {
super.configurePreAgent()

injectSysConfig("dd.trace.executors", "CustomThreadPoolExecutor")
injectSysConfig("trace.thread-pool-executors.exclude", "ExecutorInstrumentationTest\$ToBeIgnoredExecutor")
injectSysConfig("dd.trace.executors", CustomThreadPoolExecutor.name)
injectSysConfig("trace.thread-pool-executors.exclude", ToBeIgnoredExecutor.name)
}

def "#poolName '#name' propagates"() {
Expand Down Expand Up @@ -482,12 +487,6 @@ abstract class ExecutorInstrumentationTest extends AgentTestRunner {

poolName = poolImpl.class.simpleName
}

static class ToBeIgnoredExecutor extends ThreadPoolExecutor {
ToBeIgnoredExecutor() {
super(1, 1, 0, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10))
}
}
}

class ExecutorInstrumentationForkedTest extends ExecutorInstrumentationTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package executor

import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.api.Trace
import datadog.trace.core.DDSpan
Expand All @@ -6,6 +8,7 @@ import io.netty.channel.epoll.EpollEventLoopGroup
import io.netty.channel.local.LocalEventLoopGroup
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.util.concurrent.DefaultEventExecutorGroup
import runnable.JavaAsyncChild
import spock.lang.Shared

import java.lang.reflect.InvocationTargetException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package executor

import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.core.DDSpan
import executor.recursive.RecursiveThreadPoolExecution
import executor.recursive.RecursiveThreadPoolMixedSubmissionAndExecution
import executor.recursive.RecursiveThreadPoolSubmission
import io.netty.channel.DefaultEventLoopGroup
import spock.lang.Shared

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package executor

import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.api.DDSpanId
import datadog.trace.core.DDSpan
import executor.rejectedexecutionhandler.ExecutingRejectedExecutionHandler
import executor.rejectedexecutionhandler.SwallowingRejectedExecutionHandler
import io.netty.util.concurrent.DefaultEventExecutor
import io.netty.util.concurrent.DefaultThreadFactory
import runnable.JavaAsyncChild

import java.util.concurrent.ArrayBlockingQueue
import java.util.concurrent.CountDownLatch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package executor;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ToBeIgnoredExecutor extends ThreadPoolExecutor {
public ToBeIgnoredExecutor() {
super(1, 1, 0, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(10));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package forkjoin

import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.core.DDSpan

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package runnable

import datadog.trace.agent.test.AgentTestRunner

import java.util.concurrent.ExecutionException
import java.util.concurrent.FutureTask

import static datadog.trace.agent.test.utils.TraceUtils.basicSpan
import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package runnable

import datadog.trace.agent.test.AgentTestRunner

import javax.swing.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package timer

import static datadog.trace.agent.test.utils.TraceUtils.basicSpan
import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package executor;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.AbstractExecutorService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package executor;

import datadog.trace.bootstrap.instrumentation.java.concurrent.Wrapper;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package executor.recursive;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package executor.recursive;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package executor.recursive;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package executor.rejectedexecutionhandler;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package executor.rejectedexecutionhandler;

import io.netty.util.concurrent.SingleThreadEventExecutor;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package forkjoin;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package forkjoin;

import datadog.trace.api.Trace;

public class PeriodicTask implements Runnable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package runnable;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;

import datadog.trace.api.Trace;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package runnable;

public class ComparableAsyncChild implements Runnable, Comparable<ComparableAsyncChild> {

private final int priority;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package runnable;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package runnable;

import datadog.trace.api.Trace;
import java.util.concurrent.Callable;
import java.util.concurrent.ForkJoinTask;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package runnable;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

Expand Down

0 comments on commit 91385b2

Please sign in to comment.