long actualDocs = 0;
int actualShards = 0;
for (FileStatus dir : fs.listStatus(outDir)) { // for each shard
if (dir.getPath().getName().startsWith("part") && dir.isDirectory()) {
actualShards++;
EmbeddedSolrServer solr = SolrRecordWriter.createEmbeddedSolrServer(
new Path(solrHomeDir.getAbsolutePath()), fs, dir.getPath());
try {
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
QueryResponse resp = solr.query(query);
long numDocs = resp.getResults().getNumFound();
actualDocs += numDocs;
} finally {
solr.shutdown();
}
}
}
assertEquals(expectedShards, actualShards);
assertEquals(expectedDocs, actualDocs);