@Test public void registerForServiceAvailabilityBeforeAndAfterMultiple() throws Throwable { setUp(false); int serviceCount = 100; this.host.testStart(serviceCount * 3); String[] links = new String[serviceCount]; for (int i = 0; i < serviceCount; i++) { URI u = UriUtils.buildUri(this.host, UUID.randomUUID().toString()); links[i] = u.getPath(); this.host.registerForServiceAvailability(this.host.getCompletion(), u.getPath()); this.host.startService(Operation.createPost(u), ExampleService.createFactory()); this.host.registerForServiceAvailability(this.host.getCompletion(), u.getPath()); } this.host.registerForServiceAvailability(this.host.getCompletion(), links); this.host.testWait(); }
private void factorySynchronizationNoChildren() throws Throwable { int factoryCount = Math.max(this.serviceCount, 25); setUp(this.nodeCount); // start many factories, in each host, so when the nodes join there will be a storm // of synchronization requests between the nodes + factory instances TestContext testContext = this.host.testCreate(this.nodeCount * factoryCount); for (VerificationHost h : this.host.getInProcessHostMap().values()) { for (int i = 0; i < factoryCount; i++) { Operation startPost = Operation.createPost( UriUtils.buildUri(h, UriUtils.buildUriPath(ExampleService.FACTORY_LINK, UUID .randomUUID().toString()))) .setCompletion(testContext.getCompletion()); h.startService(startPost, ExampleService.createFactory()); } } testContext.await(); this.host.joinNodesAndVerifyConvergence(this.host.getPeerCount()); }
@Test public void registerForServiceAvailabilityBeforeAndAfterMultiple() throws Throwable { setUp(false); int serviceCount = 100; this.host.testStart(serviceCount * 3); String[] links = new String[serviceCount]; for (int i = 0; i < serviceCount; i++) { URI u = UriUtils.buildUri(this.host, UUID.randomUUID().toString()); links[i] = u.getPath(); this.host.registerForServiceAvailability(this.host.getCompletion(), u.getPath()); this.host.startService(Operation.createPost(u), ExampleService.createFactory()); this.host.registerForServiceAvailability(this.host.getCompletion(), u.getPath()); } this.host.registerForServiceAvailability(this.host.getCompletion(), links); this.host.testWait(); }
private void factorySynchronizationNoChildren() throws Throwable { int factoryCount = Math.max(this.serviceCount, 25); setUp(this.nodeCount); // start many factories, in each host, so when the nodes join there will be a storm // of synchronization requests between the nodes + factory instances TestContext testContext = this.host.testCreate(this.nodeCount * factoryCount); for (VerificationHost h : this.host.getInProcessHostMap().values()) { for (int i = 0; i < factoryCount; i++) { Operation startPost = Operation.createPost( UriUtils.buildUri(h, UriUtils.buildUriPath(ExampleService.FACTORY_LINK, UUID .randomUUID().toString()))) .setCompletion(testContext.getCompletion()); h.startService(startPost, ExampleService.createFactory()); } } testContext.await(); this.host.joinNodesAndVerifyConvergence(this.host.getPeerCount()); }
private void verifyFactoryStartedAndSynchronizedAfterNodeSynch(ExampleServiceHost h, String statName) throws Throwable { // start another instance of the example factory, verify that node synchronization maintenance // happened, even if it was started after the initial synch occurred Service factory = ExampleService.createFactory(); factory.toggleOption(ServiceOption.INSTRUMENTATION, true); Operation post = Operation.createPost( UriUtils.buildUri(h, UUID.randomUUID().toString())) .setCompletion(this.host.getCompletion()); this.host.testStart(1); h.startService(post, factory); this.host.testWait(); URI newExampleFactoryStatsUri = UriUtils.buildStatsUri(factory.getUri()); this.host.waitFor("node group change stat missing", () -> { ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, newExampleFactoryStatsUri); ServiceStat st = stats.entries.get(statName); if (st != null && st.latestValue >= 1) { return true; } return false; }); this.host.waitForServiceAvailable(factory.getUri()); }
private void verifyFactoryStartedAndSynchronizedAfterNodeSynch(ExampleServiceHost h, String statName) throws Throwable { // start another instance of the example factory, verify that node synchronization maintenance // happened, even if it was started after the initial synch occurred Service factory = ExampleService.createFactory(); factory.toggleOption(ServiceOption.INSTRUMENTATION, true); Operation post = Operation.createPost( UriUtils.buildUri(h, UUID.randomUUID().toString())) .setCompletion(this.host.getCompletion()); this.host.testStart(1); h.startService(post, factory); this.host.testWait(); URI newExampleFactoryStatsUri = UriUtils.buildStatsUri(factory.getUri()); this.host.waitFor("node group change stat missing", () -> { ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, newExampleFactoryStatsUri); ServiceStat st = stats.entries.get(statName); if (st != null && st.latestValue >= 1) { return true; } return false; }); this.host.waitForServiceAvailable(factory.getUri()); }
u.getPath()); this.host.startService(Operation.createPost(u), ExampleService.createFactory()); this.host.registerForServiceAvailability(ctx.getCompletion(), true, u.getPath());
@Test public void successMigrateFactoryWithDifferentSelfLink() throws Throwable { // Start a factory with a different self-link on the destination node-group final String newFactoryLink = "/core/examples-new"; for (VerificationHost host : destinationHost.getInProcessHostMap().values()) { host.startServiceAndWait(ExampleService.createFactory(), newFactoryLink, null); } // Create some example services in the source node-group this.host.createExampleServices(getSourceHost(), this.serviceCount, null); // Kick-off the migration task with the destinationFactoryLink set to the new link MigrationTaskService.State migrationState = validMigrationState(ExampleService.FACTORY_LINK); migrationState.destinationFactoryLink = newFactoryLink; Operation op = Operation.createPost(this.destinationFactoryUri).setBody(migrationState); State state = this.sender.sendAndWait(op, State.class); State finalServiceState = waitForServiceCompletion(state.documentSelfLink, getDestinationHost()); assertEquals(TaskStage.FINISHED, finalServiceState.taskInfo.stage); // validate that the new factory got all the documents. ServiceDocumentQueryResult result = this.host .getFactoryState(UriUtils.buildUri( getDestinationHost(), newFactoryLink)); assertEquals(this.serviceCount, result.documentLinks.size()); }
u.getPath()); this.host.startService(Operation.createPost(u), ExampleService.createFactory()); this.host.registerForServiceAvailability(ctx.getCompletion(), true, u.getPath());
@Test public void successMigrateFactoryWithDifferentSelfLink() throws Throwable { // Start a factory with a different self-link on the destination node-group final String newFactoryLink = "/core/examples-new"; for (VerificationHost host : destinationHost.getInProcessHostMap().values()) { host.startServiceAndWait(ExampleService.createFactory(), newFactoryLink, null); } // Create some example services in the source node-group this.host.createExampleServices(getSourceHost(), this.serviceCount, null); // Kick-off the migration task with the destinationFactoryLink set to the new link LegacyMigrationTaskService.State migrationState = validMigrationState(ExampleService.FACTORY_LINK); migrationState.destinationFactoryLink = newFactoryLink; Operation op = Operation.createPost(this.destinationFactoryUri).setBody(migrationState); State state = this.sender.sendAndWait(op, State.class); State finalServiceState = waitForServiceCompletion(state.documentSelfLink, getDestinationHost()); assertEquals(TaskStage.FINISHED, finalServiceState.taskInfo.stage); // validate that the new factory got all the documents. ServiceDocumentQueryResult result = this.host .getFactoryState(UriUtils.buildUri( getDestinationHost(), newFactoryLink)); assertEquals(this.serviceCount, result.documentLinks.size()); }
@Test public void successMigrateFactoryWithDifferentSelfLink() throws Throwable { // Start a factory with a different self-link on the destination node-group final String newFactoryLink = "/core/examples-new"; for (VerificationHost host : destinationHost.getInProcessHostMap().values()) { host.startServiceAndWait(ExampleService.createFactory(), newFactoryLink, null); } // Create some example services in the source node-group this.host.createExampleServices(getSourceHost(), this.serviceCount, null); // Kick-off the migration task with the destinationFactoryLink set to the new link MigrationTaskService.State migrationState = validMigrationState(ExampleService.FACTORY_LINK); migrationState.destinationFactoryLink = newFactoryLink; Operation op = Operation.createPost(this.destinationFactoryUri).setBody(migrationState); State state = this.sender.sendAndWait(op, State.class); State finalServiceState = waitForServiceCompletion(state.documentSelfLink, getDestinationHost()); assertEquals(TaskStage.FINISHED, finalServiceState.taskInfo.stage); // validate that the new factory got all the documents. ServiceDocumentQueryResult result = this.host .getFactoryState(UriUtils.buildUri( getDestinationHost(), newFactoryLink)); assertEquals(this.serviceCount, result.documentLinks.size()); }
ExampleService.createFactory()); this.host.waitForServiceAvailable(ExampleService.FACTORY_LINK);
ExampleService.createFactory()); this.host.waitForServiceAvailable(ExampleService.FACTORY_LINK);