Modify test to check for multiple shards for same interval

Modify test to check for multiple shards for same interval.
This commit is contained in:
Nishant 2015-07-09 20:35:31 +05:30
parent 66d105940d
commit 1766341648
1 changed files with 33 additions and 16 deletions

View File

@ -58,7 +58,19 @@ public class IndexerSQLMetadataStorageCoordinatorTest
9, 9,
100 100
); );
private final Set<DataSegment> segments = ImmutableSet.of(defaultSegment);
private final DataSegment defaultSegment2 = new DataSegment(
"dataSource",
Interval.parse("2015-01-01T00Z/2015-01-02T00Z"),
"version",
ImmutableMap.<String, Object>of(),
ImmutableList.of("dim1"),
ImmutableList.of("m1"),
new LinearShardSpec(1),
9,
100
);
private final Set<DataSegment> segments = ImmutableSet.of(defaultSegment, defaultSegment2);
IndexerSQLMetadataStorageCoordinator coordinator; IndexerSQLMetadataStorageCoordinator coordinator;
@Before @Before
@ -82,22 +94,24 @@ public class IndexerSQLMetadataStorageCoordinatorTest
private void unUseSegment() private void unUseSegment()
{ {
Assert.assertEquals( for (final DataSegment segment : segments) {
1, (int) derbyConnector.getDBI().<Integer>withHandle( Assert.assertEquals(
new HandleCallback<Integer>() 1, (int) derbyConnector.getDBI().<Integer>withHandle(
{ new HandleCallback<Integer>()
@Override
public Integer withHandle(Handle handle) throws Exception
{ {
return handle.createStatement( @Override
String.format("UPDATE %s SET used = false WHERE id = :id", tablesConfig.getSegmentsTable()) public Integer withHandle(Handle handle) throws Exception
) {
.bind("id", defaultSegment.getIdentifier()) return handle.createStatement(
.execute(); String.format("UPDATE %s SET used = false WHERE id = :id", tablesConfig.getSegmentsTable())
)
.bind("id", segment.getIdentifier())
.execute();
}
} }
} )
) );
); }
} }
@Test @Test
@ -243,7 +257,10 @@ public class IndexerSQLMetadataStorageCoordinatorTest
Assert.assertTrue( Assert.assertTrue(
coordinator.getUnusedSegmentsForInterval( coordinator.getUnusedSegmentsForInterval(
defaultSegment.getDataSource(), defaultSegment.getDataSource(),
new Interval(defaultSegment.getInterval().getStart().minus(1), defaultSegment.getInterval().getStart().plus(1)) new Interval(
defaultSegment.getInterval().getStart().minus(1),
defaultSegment.getInterval().getStart().plus(1)
)
).isEmpty() ).isEmpty()
); );
} }