@Before public void prepare() throws Throwable { // Wait for the example and example task factories to start because the host does not // wait for them since since they are not core services. Note that production code // should be asynchronous and not wait like this this.host.waitForServiceAvailable(ExampleService.FACTORY_LINK); this.host.waitForServiceAvailable(ExampleTaskService.FACTORY_LINK); this.sender = new TestRequestSender(this.host); }
private void convertExampleFactoryToIdempotent(VerificationHost h) { URI exampleFactoryUri = UriUtils.buildUri(h, ExampleService.FACTORY_LINK); h.waitForServiceAvailable(exampleFactoryUri); this.host.toggleServiceOptions(exampleFactoryUri, EnumSet.of(ServiceOption.IDEMPOTENT_POST), null); }
private void startFactoryService() throws Throwable { if (this.host.getServiceStage(this.factoryUri.getPath()) != null) { return; } this.host.startService( Operation.createPost(this.factoryUri), new SomeFactoryService()); this.host.waitForServiceAvailable(SomeFactoryService.SELF_LINK); }
@Override @Before public void setUp() throws Throwable { sender = host.getTestRequestSender(); startServices(host); host.waitForServiceAvailable(LongURIGetService.SELF_LINK, ElasticPlacementZoneConfigurationService.SELF_LINK); }
@Test public void testHostDirectPing() throws Throwable { mockDockerHost.waitForServiceAvailable(MockDockerHostService.SELF_LINK + MockDockerPathConstants._PING); ContainerHostRequest request = prepareDirectHostOperationRequest( ContainerHostOperationType.PING); sendContainerHostRequest(request); }
private void restartStatefulHost(VerificationHost h) throws Throwable { VerificationHost.restartStatefulHost(h, false); h.setMaintenanceIntervalMicros(TimeUnit.MILLISECONDS.toMicros( VerificationHost.FAST_MAINT_INTERVAL_MILLIS)); h.waitForServiceAvailable(ExampleService.FACTORY_LINK); this.host.addPeerNode(h); this.host.joinNodesAndVerifyConvergence(this.nodeCount); }
private SynchTestFactoryService startSynchFactoryService(VerificationHost h) throws Throwable { SynchTestFactoryService factoryService = new SynchTestFactoryService(); h.startService( Operation.createPost(this.factoryUri), factoryService); h.waitForServiceAvailable(SynchTestFactoryService.SELF_LINK); return factoryService; }
private void startFactoryService() throws Throwable { if (this.host.getServiceStage(this.factoryUri.getPath()) != null) { return; } this.host.startService( Operation.createPost(this.factoryUri), new SomeFactoryService()); this.host.waitForServiceAvailable(SomeFactoryService.SELF_LINK); }
@Test public void testDirectHostInfo() throws Throwable { mockDockerHost.waitForServiceAvailable(MockDockerHostService.SELF_LINK + MockDockerPathConstants.INFO); ContainerHostRequest request = prepareDirectHostOperationRequest( ContainerHostOperationType.INFO); sendContainerHostRequest(request); }
@Before public void setup() { URI sandbox = this.host.getStorageSandbox(); this.host.log("Sandbox in %s", sandbox); DirectoryContentService dirService = new DirectoryContentService(new File(sandbox).toPath()); this.host.startService(Operation.createPost(UriUtils.buildUri(this.host, SELF_LINK)), dirService); this.host.waitForServiceAvailable(SELF_LINK); }
private void checkReusableHostAndCleanup(VerificationHost host) throws Throwable { if (host.isStopping() || !host.isStarted()) { host.start(); host.startFactory(new MigrationTaskService()); host.startFactory(new ImmutableExampleService()); host.waitForServiceAvailable(ExampleService.FACTORY_LINK); host.waitForServiceAvailable(ImmutableExampleService.FACTORY_LINK); host.waitForServiceAvailable(MigrationTaskService.FACTORY_LINK); } host.deleteAllChildServices(UriUtils.buildUri(host, MigrationTaskService.FACTORY_LINK)); host.deleteAllChildServices(UriUtils.buildUri(host, ExampleService.FACTORY_LINK)); }
private void createBackupFileService(URI localFileUri, String serviceLink) { LocalFileServiceState initialState = new LocalFileServiceState(); initialState.fileOptions = EnumSet.of(StandardOpenOption.WRITE); initialState.localFileUri = localFileUri; Operation post = Operation.createPost(this.host, serviceLink).setBody(initialState); this.host.startService(post, new LocalFileService()); this.host.waitForServiceAvailable(serviceLink); }
private void checkReusableHostAndCleanup(VerificationHost host) throws Throwable { if (host.isStopping() || !host.isStarted()) { host.start(); host.startFactory(new LegacyMigrationTaskService()); host.startFactory(new ImmutableExampleService()); host.waitForServiceAvailable(ExampleService.FACTORY_LINK); host.waitForServiceAvailable(ImmutableExampleService.FACTORY_LINK); host.waitForServiceAvailable(LegacyMigrationTaskService.FACTORY_LINK); } host.deleteAllChildServices(UriUtils.buildUri(host, LegacyMigrationTaskService.FACTORY_LINK)); host.deleteAllChildServices(UriUtils.buildUri(host, ExampleService.FACTORY_LINK)); }
protected ComputeState requestDockerHostOperation(String mockDockerPath, ContainerHostOperationType operationType) throws Throwable { mockDockerHost.waitForServiceAvailable(MockDockerHostService.SELF_LINK + mockDockerPath); sendContainerHostRequest(operationType, UriUtils.buildUri(host, dockerHostState.documentSelfLink)); // wait for provisioning task stage to change to finish waitForPropertyValue(provisioningTaskLink, MockTaskState.class, TASK_INFO_STAGE, TaskState.TaskStage.FINISHED); dockerHostState = retrieveDockerHostState(); return dockerHostState; }
@Override protected final void startRequiredServices() throws Throwable { super.startRequiredServices(); PhotonModelTaskServices.startServices(getHost()); getHost().waitForServiceAvailable(PhotonModelTaskServices.LINKS); PhotonModelAdaptersRegistryAdapters.startServices(getHost()); getHost().waitForServiceAvailable(PhotonModelAdaptersRegistryAdapters.LINKS); MockAdapter.startFactories(this); } }
@Before public void setup() throws Throwable { this.service = new EventStreamService(EVENTS, INITIAL_DELAY_MS, EVENT_EMIT_PERIOD_MS, TimeUnit.MILLISECONDS, PARALLELISM, 1); this.host.startService(this.service); this.torrent = new EventStreamService(EVENTS, 0, 0, TimeUnit.MILLISECONDS, PARALLELISM, (this.eventsPerConnection / EVENTS.size()) + 1); this.host.startService(Operation.createPost(UriUtils.buildUri(this.host, "/torrent")), this.torrent); this.host.waitForServiceAvailable("/torrent", EventStreamService.SELF_LINK); }
private void createRestoreFileService(URI localFileUri, String serviceLink) { LocalFileServiceState initialState = new LocalFileServiceState(); initialState.localFileUri = localFileUri; Operation post = Operation.createPost(this.host, serviceLink).setBody(initialState); this.host.startService(post, new LocalFileService()); this.host.waitForServiceAvailable(serviceLink); }
private void createRestoreFileService(URI localFileUri, String serviceLink) { LocalFileServiceState initialState = new LocalFileServiceState(); initialState.localFileUri = localFileUri; Operation post = Operation.createPost(this.host, serviceLink).setBody(initialState); this.host.startService(post, new LocalFileService()); this.host.waitForServiceAvailable(serviceLink); }
@Before public void setup() throws Throwable { this.service = new EventStreamService(EVENTS, INITIAL_DELAY_MS, EVENT_EMIT_PERIOD_MS, TimeUnit.MILLISECONDS, PARALLELISM, 1); this.host.startService(this.service); this.torrent = new EventStreamService(EVENTS, 0, 0, TimeUnit.MILLISECONDS, PARALLELISM, (this.eventsPerConnection / EVENTS.size()) + 1); this.host.startService(Operation.createPost(UriUtils.buildUri(this.host, "/torrent")), this.torrent); this.host.waitForServiceAvailable("/torrent", EventStreamService.SELF_LINK); }
private VerificationHost createVerificationHost() throws Throwable { VerificationHost host = VerificationHost.create(0); host.start(); // in-memory index related services host.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); InMemoryLuceneDocumentIndexService inMemoryIndexService = new InMemoryLuceneDocumentIndexService(); Service inMemoryExampleFactory = InMemoryExampleService.createFactory(); host.startService(Operation.createPost(host, ServiceUriPaths.CORE_IN_MEMORY_DOCUMENT_INDEX), inMemoryIndexService); host.startService(Operation.createPost(host, InMemoryExampleService.FACTORY_LINK), inMemoryExampleFactory); host.waitForServiceAvailable(ServiceUriPaths.CORE_IN_MEMORY_DOCUMENT_INDEX, InMemoryExampleService.FACTORY_LINK); return host; }