| 122 | import java.util.concurrent.TimeUnit; |
| 123 | |
| 124 | @SuppressWarnings("ClassEscapesDefinedScope") |
| 125 | public abstract class AbstractCairoTest extends AbstractTest { |
| 126 | |
| 127 | public static final int DEFAULT_SPIN_LOCK_TIMEOUT = 5000; |
| 128 | protected static final Log LOG = LogFactory.getLog(AbstractCairoTest.class); |
| 129 | protected static final String TIMESTAMP_NS_TYPE_NAME = "TIMESTAMP_NS"; |
| 130 | protected static final PlanSink planSink = new TextPlanSink(); |
| 131 | protected static final StringSink sink = new StringSink(); |
| 132 | private static final long[] SNAPSHOT = new long[MemoryTag.SIZE]; |
| 133 | public static String exportRoot = null; |
| 134 | public static StaticOverrides staticOverrides = new StaticOverrides(); |
| 135 | protected static BindVariableService bindVariableService; |
| 136 | protected static NetworkSqlExecutionCircuitBreaker circuitBreaker; |
| 137 | protected static SqlExecutionCircuitBreakerConfiguration circuitBreakerConfiguration; |
| 138 | protected static CairoConfiguration configuration; |
| 139 | protected static TestCairoConfigurationFactory configurationFactory; |
| 140 | protected static long currentMicros = -1; |
| 141 | protected static final MicrosecondClock defaultMicrosecondClock = () -> currentMicros != -1 ? currentMicros : MicrosecondClockImpl.INSTANCE.getTicks(); |
| 142 | protected static MicrosecondClock testMicrosClock = defaultMicrosecondClock; |
| 143 | protected static final NanosecondClock defaultNanosecondClock = () -> currentMicros != -1 ? currentMicros * 1000L : NanosecondClockImpl.INSTANCE.getTicks(); |
| 144 | protected static NanosecondClock testNanoClock = defaultNanosecondClock; |
| 145 | protected static CairoEngine engine; |
| 146 | protected static TestCairoEngineFactory engineFactory; |
| 147 | protected static FactoryProvider factoryProvider; |
| 148 | protected static FilesFacade ff; |
| 149 | protected static String inputRoot = null; |
| 150 | protected static String inputWorkRoot = null; |
| 151 | protected static IOURingFacade ioURingFacade = IOURingFacadeImpl.INSTANCE; |
| 152 | protected static MessageBus messageBus; |
| 153 | protected static QuestDBTestNode node1; |
| 154 | protected static ObjList<QuestDBTestNode> nodes = new ObjList<>(); |
| 155 | protected static SecurityContext securityContext; |
| 156 | protected static long spinLockTimeout = DEFAULT_SPIN_LOCK_TIMEOUT; |
| 157 | protected static SqlExecutionContext sqlExecutionContext; |
| 158 | static boolean[] FACTORY_TAGS = new boolean[MemoryTag.SIZE]; |
| 159 | private static long fdReuseCount; |
| 160 | private static long memoryUsage = -1; |
| 161 | private static long mmapReuseCount; |
| 162 | @Rule |
| 163 | public final TestWatcher flushLogsOnFailure = new TestWatcher() { |
| 164 | @Override |
| 165 | protected void failed(Throwable e, Description description) { |
| 166 | LogFactory.getInstance().flushJobs(); |
| 167 | } |
| 168 | }; |
| 169 | @Rule |
| 170 | public Timeout timeout = Timeout.builder() |
| 171 | .withTimeout(20 * 60 * 1000, TimeUnit.MILLISECONDS) |
| 172 | .withLookingForStuckThread(true) |
| 173 | .build(); |
| 174 | |
| 175 | public static void assertReader(String expected, CharSequence tableName) { |
| 176 | try (TableReader reader = engine.getReader(engine.verifyTableName(tableName))) { |
| 177 | TestUtils.assertReader(expected, reader, sink); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | public static void assertVariableColumns(RecordCursorFactory factory, SqlExecutionContext executionContext) throws SqlException { |
nothing calls this directly
no test coverage detected
searching dependent graphs…