@Test public void throughputPost() throws Throwable { if (this.serviceCacheClearIntervalSeconds == 0) { // effectively disable stop/start behavior while running throughput tests this.serviceCacheClearIntervalSeconds = TimeUnit.MICROSECONDS.toSeconds( ServiceHostState.DEFAULT_OPERATION_TIMEOUT_MICROS); } setUpHost(false); // throughput test for immutable factory URI factoryUri = createImmutableFactoryService(this.host); prePopulateIndexWithServiceDocuments(factoryUri); verifyImmutableEagerServiceStop(factoryUri, this.documentCountAtStart); boolean interleaveQueries = true; long stVersion = doThroughputImmutablePost(0, interleaveQueries, factoryUri); interleaveQueries = false; doThroughputImmutablePost(stVersion, interleaveQueries, factoryUri); // similar test but with regular, mutable, example factory interleaveQueries = true; factoryUri = UriUtils.buildFactoryUri(this.host, ExampleService.class); doMultipleIterationsThroughputPost(interleaveQueries, this.iterationCount, factoryUri); interleaveQueries = false; doMultipleIterationsThroughputPost(interleaveQueries, this.iterationCount, factoryUri); // similar test but with indexed metadata factory factoryUri = createIndexedMetadataFactoryService(this.host); interleaveQueries = true; doMultipleIterationsThroughputPost(interleaveQueries, this.iterationCount, factoryUri); interleaveQueries = false; doMultipleIterationsThroughputPost(interleaveQueries, this.iterationCount, factoryUri); }
@Test public void indexedMetadataServiceQueryLongRunning() throws Throwable { setUpHost(false); URI factoryUri = createIndexedMetadataFactoryService(this.host); doServiceQueryLongRunning(factoryUri, EnumSet.of(QueryOption.INDEXED_METADATA)); }
@Test public void immutableServiceQueryLongRunning() throws Throwable { setUpHost(false); URI factoryUri = createImmutableFactoryService(this.host); doServiceQueryLongRunning(factoryUri, EnumSet.of(QueryOption.INCLUDE_ALL_VERSIONS)); }
private void doServiceHostRestartWithDurableServices() throws Throwable { setUpHost(false); VerificationHost h = VerificationHost.create(); TemporaryFolder tmpFolder = new TemporaryFolder(); null); convertExampleFactoryToIdempotent(h); createOnDemandLoadServices(h, onDemandFactoryLink); Map<URI, ExampleServiceState> beforeState = verifyIdempotentServiceStartDeleteWithStats(h); List<URI> exampleURIs = new ArrayList<>(beforeState.keySet()); verifyInitialStatePost(h); logServiceStats(h); h.stop(); null); verifyIdempotentFactoryAfterHostRestart(h, initialState, exampleURIs, beforeState); verifyOnDemandLoad(h); logServiceStats(h); h.stop(); tmpFolder.delete();
@Test public void corruptIndexWhileRunning() throws Throwable { setUpHost(false); this.host.setOperationTimeOutMicros(TimeUnit.SECONDS.toMicros(5)); this.host.setServiceStateCaching(false); }, UriUtils.buildUri(this.host, ExampleService.FACTORY_LINK)); exampleServices = updateUriMapWithNewPort(this.host.getPort(), exampleServices); updateServices(exampleServices, true); corruptLuceneIndexFiles(); updateServices(exampleServices, true); this.host .log("Host never stopped after index corruption, but appears healthy, verifiying"); updateServices(exampleServices, true); break;
.build(); setUpHost(false); URI factoryUri = createImmutableFactoryService(this.host); this.indexService.toggleOption(ServiceOption.INSTRUMENTATION, true); this.host.log("Starting throughout POST, expiration: %d", this.expirationSeconds); 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()); 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);
@Test public void throughputSelfLinkQuery() throws Throwable { setUpHost(false); this.indexService.toggleOption(ServiceOption.INSTRUMENTATION, true); URI immutableFactoryUri = createImmutableFactoryService(this.host); doThroughputSelfLinkQuery(immutableFactoryUri, null, doPostOrUpdates, interleaveUpdate, null); doThroughputSelfLinkQuery(immutableFactoryUri, null, doPostOrUpdates, interleaveUpdate, null); doThroughputSelfLinkQuery(exampleFactoryUri, this.updateCount, doPostOrUpdates, interleaveUpdate, null); doPostOrUpdates = false; interleaveUpdate = true; doThroughputSelfLinkQuery(exampleFactoryUri, this.updateCount, doPostOrUpdates, interleaveUpdate, null); URI indexedMetadataFactoryUri = createIndexedMetadataFactoryService(this.host); doThroughputSelfLinkQuery(indexedMetadataFactoryUri, this.updateCount, true, false, this.serviceCount * this.updateCount); doThroughputSelfLinkQuery(indexedMetadataFactoryUri, this.updateCount, false, true, null); doThroughputSelfLinkQuery(inMemExampleFactoryUri, this.updateCount, doPostOrUpdates, interleaveUpdate, null); doPostOrUpdates = false; interleaveUpdate = true; doThroughputSelfLinkQuery(inMemExampleFactoryUri, this.updateCount, doPostOrUpdates, interleaveUpdate, null);
@Test public void immutableServiceLifecycle() throws Throwable { setUpHost(false); URI factoryUri = createImmutableFactoryService(this.host); doThroughputPostWithNoQueryResults(false, factoryUri); ServiceDocumentQueryResult res = this.host.getFactoryState(factoryUri); assertEquals(this.serviceCount, res.documentLinks.size());
@Test public void corruptedIndexRecovery() throws Throwable { setUpHost(false); this.doDurableServiceUpdate(Action.PUT, MinimalTestService.class, 100, 2, null); Thread.sleep(this.host.getMaintenanceIntervalMicros() / 1000); this.host.setPort(0); corruptLuceneIndexFiles();
@Test public void throughputPostWithAuthz() throws Throwable { setUpHost(true); URI factoryUri = UriUtils.buildFactoryUri(this.host, ExampleService.class); userLinks.add(buildExampleUserLink(i)); OperationContext.getAuthorizationContext().getClaims().getSubject(), this.serviceCount); doThroughputPostWithNoQueryResults(false, factoryUri); this.host.deleteAllChildServices(factoryUri); this.serviceCount); long start = System.nanoTime(); doThroughputPostWithNoQueryResults(false, factoryUri); long end = System.nanoTime(); durationPerSubject.put(userLink, end - start);
private void doMetadataIndexingWithForcedIndexUpdate() throws Throwable { setUpHost(false); URI indexedMetadataFactoryUri = createIndexedMetadataFactoryService(this.host);
private void createUsersAndRoles() { TestContext ctx = this.host.testCreate(this.authUserCount); AuthorizationSetupHelper.AuthSetupCompletion authCompletion = (ex) -> { if (ex == null) { ctx.completeIteration(); } else { ctx.failIteration(ex); } }; this.host.setSystemAuthorizationContext(); for (int i = 0; i < this.authUserCount; i++) { AuthorizationSetupHelper.create() .setHost(this.host) .setUserEmail(buildExampleUserEmail(i)) .setUserPassword(buildExampleUserEmail(i)) .setUserSelfLink(buildExampleUserLink(i)) .setIsAdmin(false) .setUpdateUserGroupForUser(true) .setDocumentKind(Utils.buildKind(ExampleServiceState.class)) .setCompletion(authCompletion) .start(); } this.host.testWait(ctx); this.host.resetAuthorizationContext(); }
private void verifyInitialStatePost(VerificationHost h) throws Throwable { URI factoryUri = createImmutableFactoryService(h); doThroughputPostWithNoQueryResults(false, factoryUri); ServiceDocumentQueryResult r = this.host.getFactoryState(factoryUri); assertEquals(this.serviceCount, (long) r.documentCount); TestContext ctx = h.testCreate(this.serviceCount); for (String link : r.documentLinks) { Operation get = Operation.createGet(h, link).setCompletion((o, e) -> { if (e != null) { ctx.fail(e); return; } ExampleServiceState rsp = o.getBody(ExampleServiceState.class); if (rsp.name == null) { ctx.fail(new IllegalStateException("missing name field value")); return; } ctx.complete(); }); h.send(get); } h.testWait(ctx); }
createInMemoryExampleServiceFactory(this.host); createUsersAndRoles();
@Test public void testDocumentMetadataIndexing() throws Throwable { LuceneDocumentIndexService.setMetadataUpdateMaxQueueDepth((int) this.serviceCount / 2); try { doDocumentMetadataIndexing(); } finally { LuceneDocumentIndexService.setMetadataUpdateMaxQueueDepth( LuceneDocumentIndexService.DEFAULT_METADATA_UPDATE_MAX_QUEUE_DEPTH); } }
private void doServiceHostRestartWithDurableServices() throws Throwable { setUpHost(false); VerificationHost h = VerificationHost.create(); TemporaryFolder tmpFolder = new TemporaryFolder(); null); convertExampleFactoryToIdempotent(h); createOnDemandLoadServices(h, onDemandFactoryLink); Map<URI, ExampleServiceState> beforeState = verifyIdempotentServiceStartDeleteWithStats(h); List<URI> exampleURIs = new ArrayList<>(beforeState.keySet()); verifyInitialStatePost(h); logServiceStats(h); h.stop(); null); verifyIdempotentFactoryAfterHostRestart(h, initialState, exampleURIs, beforeState); verifyOnDemandLoad(h); logServiceStats(h); h.stop(); tmpFolder.delete();
@Test public void corruptIndexWhileRunning() throws Throwable { setUpHost(false); this.host.setOperationTimeOutMicros(TimeUnit.SECONDS.toMicros(5)); this.host.setServiceStateCaching(false); }, UriUtils.buildUri(this.host, ExampleService.FACTORY_LINK)); exampleServices = updateUriMapWithNewPort(this.host.getPort(), exampleServices); updateServices(exampleServices, true); corruptLuceneIndexFiles(); updateServices(exampleServices, true); this.host .log("Host never stopped after index corruption, but appears healthy, verifiying"); updateServices(exampleServices, true); break;
.build(); setUpHost(false); URI factoryUri = createImmutableFactoryService(this.host); this.indexService.toggleOption(ServiceOption.INSTRUMENTATION, true); this.host.log("Starting throughout POST, expiration: %d", this.expirationSeconds); 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()); 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);
@Test public void throughputSelfLinkQuery() throws Throwable { setUpHost(false); this.indexService.toggleOption(ServiceOption.INSTRUMENTATION, true); URI immutableFactoryUri = createImmutableFactoryService(this.host); doThroughputSelfLinkQuery(immutableFactoryUri, null, doPostOrUpdates, interleaveUpdate, null); doThroughputSelfLinkQuery(immutableFactoryUri, null, doPostOrUpdates, interleaveUpdate, null); doThroughputSelfLinkQuery(exampleFactoryUri, this.updateCount, doPostOrUpdates, interleaveUpdate, null); doPostOrUpdates = false; interleaveUpdate = true; doThroughputSelfLinkQuery(exampleFactoryUri, this.updateCount, doPostOrUpdates, interleaveUpdate, null); URI indexedMetadataFactoryUri = createIndexedMetadataFactoryService(this.host); doThroughputSelfLinkQuery(indexedMetadataFactoryUri, this.updateCount, true, false, this.serviceCount * this.updateCount); doThroughputSelfLinkQuery(indexedMetadataFactoryUri, this.updateCount, false, true, null); doThroughputSelfLinkQuery(inMemExampleFactoryUri, this.updateCount, doPostOrUpdates, interleaveUpdate, null); doPostOrUpdates = false; interleaveUpdate = true; doThroughputSelfLinkQuery(inMemExampleFactoryUri, this.updateCount, doPostOrUpdates, interleaveUpdate, null);
@Test public void indexedMetadataServiceQueryLongRunning() throws Throwable { setUpHost(false); URI factoryUri = createIndexedMetadataFactoryService(this.host); doServiceQueryLongRunning(factoryUri, EnumSet.of(QueryOption.INDEXED_METADATA)); }