@Test
public void throughputPostWithExpirationLongRunning() throws Throwable {

    if (this.serviceCacheClearIntervalSeconds == 0) {
        // effectively disable ODL stop/start behavior while running throughput tests
        this.serviceCacheClearIntervalSeconds = TimeUnit.MICROSECONDS.toSeconds(
                ServiceHostState.DEFAULT_OPERATION_TIMEOUT_MICROS);
    }
    // This code path is designed to simulate POST and query throughput under heavy load,
    // processing queries which match many results.
    QueryTask queryTask = QueryTask.Builder.createDirectTask()
            .setQuery(QueryTask.Query.Builder.create()
                    .addKindFieldClause(ExampleServiceState.class)
                    .build())
            .build();
    setUpHost(false);
    // Set the document expiration limit to something low enough that document expiration will
    // be forced to run in batches.
    LuceneDocumentIndexService.setExpiredDocumentSearchThreshold(10);
    URI factoryUri = createImmutableFactoryService(this.host);
    this.indexService.toggleOption(ServiceOption.INSTRUMENTATION, true);
    this.host.log("Starting throughout POST, expiration: %d", this.expirationSeconds);
    Long expirationMicros = null;
    if (this.expirationSeconds != null) {
        expirationMicros = TimeUnit.SECONDS.toMicros(this.expirationSeconds);
    }
    long testExpiration = Utils.getSystemNowMicrosUtc()
            + TimeUnit.SECONDS.toMicros(this.testDurationSeconds);
    do {
        this.host.log("Starting POST test to %s, count:%d", factoryUri, this.serviceCount);
        doThroughputPost(true, factoryUri, expirationMicros, queryTask);
        Map<String, ServiceStat> stats = this.host.getServiceStats(
                this.host.getDocumentIndexServiceUri());
        ServiceStat expiredDocumentStat = stats.get(
                LuceneDocumentIndexService.STAT_NAME_DOCUMENT_EXPIRATION_COUNT
                        + ServiceStats.STAT_NAME_SUFFIX_PER_DAY);
        if (expiredDocumentStat != null) {
            this.host.log("Expired documents: %f", expiredDocumentStat.latestValue);
        }
    } while (this.testDurationSeconds > 0 && Utils.getSystemNowMicrosUtc() < testExpiration);
    Map<String, ServiceStat> indexServiceStats = this.host.getServiceStats(
            this.host.getDocumentIndexServiceUri());
    logServiceStatHistogram(indexServiceStats,
            LuceneDocumentIndexService.STAT_NAME_COMMIT_DURATION_MICROS);
    logServiceStatHistogram(indexServiceStats,
            LuceneDocumentIndexService.STAT_NAME_MAINTENANCE_DOCUMENT_EXPIRATION_DURATION_MICROS);
    logServiceStatHistogram(indexServiceStats,
            LuceneDocumentIndexService.STAT_NAME_QUERY_DURATION_MICROS);
    logServiceStatHistogram(indexServiceStats,
            LuceneDocumentIndexService.STAT_NAME_RESULT_PROCESSING_DURATION_MICROS);
}