Merge pull request #1505 from metamx/improve-test

Modify test to check for multiple shards for same interval
This commit is contained in:
Fangjin Yang 2015-07-14 08:50:47 -07:00
commit da8e86146e
1 changed files with 33 additions and 16 deletions

View File

@ -58,7 +58,19 @@ public class IndexerSQLMetadataStorageCoordinatorTest
9,
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;
@Before
@ -82,6 +94,7 @@ public class IndexerSQLMetadataStorageCoordinatorTest
private void unUseSegment()
{
for (final DataSegment segment : segments) {
Assert.assertEquals(
1, (int) derbyConnector.getDBI().<Integer>withHandle(
new HandleCallback<Integer>()
@ -92,13 +105,14 @@ public class IndexerSQLMetadataStorageCoordinatorTest
return handle.createStatement(
String.format("UPDATE %s SET used = false WHERE id = :id", tablesConfig.getSegmentsTable())
)
.bind("id", defaultSegment.getIdentifier())
.bind("id", segment.getIdentifier())
.execute();
}
}
)
);
}
}
@Test
public void testSimpleAnnounce() throws IOException
@ -243,7 +257,10 @@ public class IndexerSQLMetadataStorageCoordinatorTest
Assert.assertTrue(
coordinator.getUnusedSegmentsForInterval(
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()
);
}