Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 9 additions & 28 deletions multi-stage-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,6 @@
</dependency>

<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.hydromatic</groupId>
<artifactId>quidem</artifactId>
Expand Down Expand Up @@ -246,11 +241,6 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-migrationsupport</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
Expand All @@ -261,41 +251,26 @@
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.druid</groupId>
<artifactId>druid-processing</artifactId>
Expand Down Expand Up @@ -339,6 +314,12 @@
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-testlib</artifactId>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import org.apache.druid.msq.guice.MSQIndexingModule;
import org.apache.druid.msq.test.JUnitAssertions;
import org.apache.druid.msq.test.matchers.CoreMatchers;
import org.apache.druid.segment.TestHelper;
import org.apache.druid.segment.loading.AcquireSegmentResult;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.Objects;

import static org.apache.druid.msq.test.matchers.MatcherAssert.assertThat;

public class CountersSnapshotTreeTest
{
@Test
Expand Down Expand Up @@ -73,11 +74,11 @@ public void testSerdeUnknownCounter() throws Exception
final CounterSnapshotsTree snapshotsTree2 = serializationMapper.readValue(json, CounterSnapshotsTree.class);
final CounterSnapshotsTree snapshotsTree3 = deserializationMapper.readValue(json, CounterSnapshotsTree.class);

Assert.assertEquals(snapshotsTree.copyMap(), snapshotsTree2.copyMap());
Assert.assertNotEquals(snapshotsTree.copyMap(), snapshotsTree3.copyMap());
JUnitAssertions.assertEquals(snapshotsTree.copyMap(), snapshotsTree2.copyMap());
JUnitAssertions.assertNotEquals(snapshotsTree.copyMap(), snapshotsTree3.copyMap());

// Confirm that deserializationMapper reads the TestCounterSnapshot as a NilQueryCounterSnapshot.
MatcherAssert.assertThat(
assertThat(
snapshotsTree3.copyMap().get(1).get(2).getMap().get("ctr"),
CoreMatchers.instanceOf(NilQueryCounterSnapshot.class)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Assert;
import org.junit.Test;
import org.apache.druid.msq.test.JUnitAssertions;
import org.junit.jupiter.api.Test;

public class CpuCountersTest
{
Expand All @@ -34,17 +34,17 @@ public void test_forName_runDoer()
final CpuCounter counter = counters.forName("xyz");
counter.run(() -> { /* Nothing in particular */ });
final CpuCounters.Snapshot snapshot = counters.snapshot();
Assert.assertEquals(ImmutableSet.of("xyz"), snapshot.getCountersMap().keySet());
JUnitAssertions.assertEquals(ImmutableSet.of("xyz"), snapshot.getCountersMap().keySet());
}

@Test
public void test_forName_runReturner()
{
final CpuCounters counters = new CpuCounters();
final CpuCounter counter = counters.forName("xyz");
Assert.assertEquals("boo", counter.run(() -> "boo"));
JUnitAssertions.assertEquals("boo", counter.run(() -> "boo"));
final CpuCounters.Snapshot snapshot = counters.snapshot();
Assert.assertEquals(ImmutableSet.of("xyz"), snapshot.getCountersMap().keySet());
JUnitAssertions.assertEquals(ImmutableSet.of("xyz"), snapshot.getCountersMap().keySet());
}

@Test
Expand All @@ -54,7 +54,7 @@ public void test_forName_accumulate()
final CpuCounter counter = counters.forName("xyz");
counter.accumulate(1L, 1L);
final CpuCounters.Snapshot snapshot = counters.snapshot();
Assert.assertEquals(
JUnitAssertions.assertEquals(
ImmutableMap.of("xyz", new CpuCounter.Snapshot(1L, 1L)),
snapshot.getCountersMap()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.druid.msq.counters;

import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class SegmentGenerationProgressCounterTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.frame.channel.ByteTracker;
import org.apache.druid.msq.guice.MSQIndexingModule;
import org.apache.druid.msq.test.JUnitAssertions;
import org.apache.druid.segment.TestHelper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class StorageCountersTest
{
Expand All @@ -36,12 +36,12 @@ public void testSnapshotWithNoByteTracker()
final StorageCounters counters = new StorageCounters(null);
final StorageCounters.Snapshot snapshot = (StorageCounters.Snapshot) counters.snapshot();

Assert.assertNull(snapshot.getLocalBytesMax());
Assert.assertEquals(0, snapshot.getLocalBytesReserved());
Assert.assertEquals(0, snapshot.getLocalFilesWritten());
Assert.assertEquals(0, snapshot.getLocalBytesWritten());
Assert.assertEquals(0, snapshot.getDurableFileCount());
Assert.assertEquals(0, snapshot.getDurableBytesWritten());
JUnitAssertions.assertNull(snapshot.getLocalBytesMax());
JUnitAssertions.assertEquals(0, snapshot.getLocalBytesReserved());
JUnitAssertions.assertEquals(0, snapshot.getLocalFilesWritten());
JUnitAssertions.assertEquals(0, snapshot.getLocalBytesWritten());
JUnitAssertions.assertEquals(0, snapshot.getDurableFileCount());
JUnitAssertions.assertEquals(0, snapshot.getDurableBytesWritten());
}

@Test
Expand All @@ -53,8 +53,8 @@ public void testSnapshotWithByteTracker()
final StorageCounters counters = new StorageCounters(tracker);

final StorageCounters.Snapshot snapshot = (StorageCounters.Snapshot) counters.snapshot();
Assert.assertEquals(1000L, (long) snapshot.getLocalBytesMax());
Assert.assertEquals(300, snapshot.getLocalBytesReserved());
JUnitAssertions.assertEquals(1000L, (long) snapshot.getLocalBytesMax());
JUnitAssertions.assertEquals(300, snapshot.getLocalBytesReserved());
}

@Test
Expand All @@ -67,14 +67,14 @@ public void testSnapshotWithByteTrackerReflectsCurrentState()

// Take first snapshot
final StorageCounters.Snapshot snapshot1 = (StorageCounters.Snapshot) counters.snapshot();
Assert.assertEquals(300, snapshot1.getLocalBytesReserved());
JUnitAssertions.assertEquals(300, snapshot1.getLocalBytesReserved());

// Change tracker state
tracker.reserve(200);

// Second snapshot reflects new state
final StorageCounters.Snapshot snapshot2 = (StorageCounters.Snapshot) counters.snapshot();
Assert.assertEquals(500, snapshot2.getLocalBytesReserved());
JUnitAssertions.assertEquals(500, snapshot2.getLocalBytesReserved());
}

@Test
Expand All @@ -87,10 +87,10 @@ public void testIncrementLocalFiles()
counters.incrementLocalBytes(300);

final StorageCounters.Snapshot snapshot = (StorageCounters.Snapshot) counters.snapshot();
Assert.assertEquals(2, snapshot.getLocalFilesWritten());
Assert.assertEquals(800, snapshot.getLocalBytesWritten());
Assert.assertEquals(0, snapshot.getDurableFileCount());
Assert.assertEquals(0, snapshot.getDurableBytesWritten());
JUnitAssertions.assertEquals(2, snapshot.getLocalFilesWritten());
JUnitAssertions.assertEquals(800, snapshot.getLocalBytesWritten());
JUnitAssertions.assertEquals(0, snapshot.getDurableFileCount());
JUnitAssertions.assertEquals(0, snapshot.getDurableBytesWritten());
}

@Test
Expand All @@ -103,10 +103,10 @@ public void testIncrementDurableFiles()
counters.incrementDurableBytes(2000);

final StorageCounters.Snapshot snapshot = (StorageCounters.Snapshot) counters.snapshot();
Assert.assertEquals(0, snapshot.getLocalFilesWritten());
Assert.assertEquals(0, snapshot.getLocalBytesWritten());
Assert.assertEquals(2, snapshot.getDurableFileCount());
Assert.assertEquals(3000, snapshot.getDurableBytesWritten());
JUnitAssertions.assertEquals(0, snapshot.getLocalFilesWritten());
JUnitAssertions.assertEquals(0, snapshot.getLocalBytesWritten());
JUnitAssertions.assertEquals(2, snapshot.getDurableFileCount());
JUnitAssertions.assertEquals(3000, snapshot.getDurableBytesWritten());
}

@Test
Expand All @@ -120,7 +120,7 @@ public void testSnapshotSerde() throws Exception
final String json = mapper.writeValueAsString(snapshot);
final StorageCounters.Snapshot deserialized = mapper.readValue(json, StorageCounters.Snapshot.class);

Assert.assertEquals(snapshot, deserialized);
JUnitAssertions.assertEquals(snapshot, deserialized);
}

@Test
Expand All @@ -136,7 +136,7 @@ public void testSnapshotSerdeViaCounterSnapshots() throws Exception
final String json = mapper.writeValueAsString(tree);
final CounterSnapshotsTree deserialized = mapper.readValue(json, CounterSnapshotsTree.class);

Assert.assertEquals(
JUnitAssertions.assertEquals(
snapshot,
deserialized.copyMap().get(0).get(0).getMap().get(CounterNames.storage())
);
Expand All @@ -152,13 +152,13 @@ public void testCounterTrackerDefensiveCheck()

// First call creates the counter
final StorageCounters counters = counterTracker.storage(tracker1);
Assert.assertSame(tracker1, counters.getLocalByteTracker());
JUnitAssertions.assertSame(tracker1, counters.getLocalByteTracker());

// Second call with same tracker succeeds
Assert.assertSame(counters, counterTracker.storage(tracker1));
JUnitAssertions.assertSame(counters, counterTracker.storage(tracker1));

// Call with different tracker fails
Assert.assertThrows(IllegalStateException.class, () -> counterTracker.storage(tracker2));
JUnitAssertions.assertThrows(IllegalStateException.class, () -> counterTracker.storage(tracker2));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.druid.msq.dart.worker.WorkerId;
import org.apache.druid.msq.exec.WorkerManager;
import org.apache.druid.msq.exec.WorkerStats;
import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -124,7 +123,7 @@ public void test_launchWorkersIfNeeded()
Assertions.assertTrue(workerManager.launchWorkersIfNeeded(0).isEmpty()); // Does nothing, less than WORKERS.size()
Assertions.assertTrue(workerManager.launchWorkersIfNeeded(1).isEmpty()); // Does nothing, less than WORKERS.size()
Assertions.assertTrue(workerManager.launchWorkersIfNeeded(2).isEmpty()); // Does nothing, equal to WORKERS.size()
Assert.assertThrows(
Assertions.assertThrows(
DruidException.class,
() -> workerManager.launchWorkersIfNeeded(3)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.apache.druid.msq.sql.DartQueryKitSpecFactory;
import org.apache.druid.msq.test.MSQTestBase;
import org.apache.druid.msq.test.MSQTestControllerContext;
import org.apache.druid.msq.test.matchers.CoreMatchers;
import org.apache.druid.query.DefaultQueryConfig;
import org.apache.druid.query.QueryContext;
import org.apache.druid.query.QueryContexts;
Expand Down Expand Up @@ -94,7 +95,6 @@
import org.apache.druid.sql.http.SqlResourceQueryResultPusherFactory;
import org.apache.druid.sql.http.StandardQueryState;
import org.apache.druid.sql.http.SupportedEnginesResponse;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -117,7 +117,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.apache.druid.msq.test.matchers.MatcherAssert.assertThat;

/**
* Functional test of {@link SqlResource}, {@link DartSqlEngine}, and {@link DartQueryMaker}.
Expand Down
Loading
Loading