protected URI register(VerificationHost host, Class<? extends Service> type) throws Exception { try { TestContext ctx = testCreate(1); Field f = type.getField("SELF_LINK"); String path = (String) f.get(null); host.registerForServiceAvailability(ctx.getCompletion(), path); ctx.await(); } catch (Throwable e) { throw new Exception(e); } return UriUtils.buildUri(host, type); }
protected void waitForServiceAvailability(ServiceHost h, String... serviceLinks) throws Throwable { if (serviceLinks == null || serviceLinks.length == 0) { throw new IllegalArgumentException("null or empty serviceLinks"); } TestContext ctx = testCreate(serviceLinks.length); h.registerForServiceAvailability(ctx.getCompletion(), serviceLinks); ctx.await(); }
public void waitForServiceAvailable(String... links) { for (String link : links) { TestContext ctx = testCreate(1); this.registerForServiceAvailability(ctx.getCompletion(), link); ctx.await(); } }
public void waitForServiceAvailable(String... links) { for (String link : links) { TestContext ctx = testCreate(1); this.registerForServiceAvailability(ctx.getCompletion(), link); ctx.await(); } }
private static void waitForDefaultRegistryCreated(ManagementHost host) { TestContext ctx = new TestContext(1, Duration.ofSeconds(120)); host.log(Level.INFO, "Waiting for default registry to start."); host.registerForServiceAvailability(ctx.getCompletion(), RegistryService.DEFAULT_INSTANCE_LINK); ctx.await(); host.log(Level.INFO, "Default registry started."); }
private void createUserServices(URI userFactorURI, List<URI> userServices) throws Throwable { TestContext ctx = this.host.testCreate(this.serviceCount); for (int i = 0; i < this.serviceCount; i++) { UserService.UserState s = new UserService.UserState(); s.email = UUID.randomUUID().toString() + "@example.org"; userServices.add(UriUtils.buildUri(this.host.getUri(), ExampleService.FACTORY_LINK, s.documentSelfLink)); this.host.send(Operation.createPost(userFactorURI) .setBody(s) .setCompletion(ctx.getCompletion())); } this.host.testWait(ctx); }
private void createUserServices(URI userFactorURI, List<URI> userServices) throws Throwable { TestContext ctx = this.host.testCreate(this.serviceCount); for (int i = 0; i < this.serviceCount; i++) { UserService.UserState s = new UserService.UserState(); s.email = UUID.randomUUID().toString() + "@example.org"; userServices.add(UriUtils.buildUri(this.host.getUri(), ExampleService.FACTORY_LINK, s.documentSelfLink)); this.host.send(Operation.createPost(userFactorURI) .setBody(s) .setCompletion(ctx.getCompletion())); } this.host.testWait(ctx); }
public Operation createServiceStartPost(TestContext ctx) { Operation post = Operation.createPost(null); post.setUri(UriUtils.buildUri(this, "service/" + post.getId())); return post.setCompletion(ctx.getCompletion()); }
public Operation createServiceStartPost(TestContext ctx) { Operation post = Operation.createPost(null); post.setUri(UriUtils.buildUri(this, "service/" + post.getId())); return post.setCompletion(ctx.getCompletion()); }
@Test public void testNoHarborProperty() throws Exception { TestContext t = new TestContext(1, Duration.ofSeconds(15)); harborInitRegistryService.handleStart(Operation .createGet(null) .setCompletion(t.getCompletion())); t.await(); RegistryState harborRegistry = getHarborRegistry(false); assertNull(harborRegistry); }
Operation createMinimalTestServicePatch(String servicePath, TestContext ctx) { MinimalTestServiceState body = new MinimalTestServiceState(); body.id = Utils.buildUUID("foo"); Operation patch = Operation .createPatch(UriUtils.buildUri(this.host, servicePath)) .setBody(body); if (ctx != null) { patch.setCompletion(ctx.getCompletion()); } return patch; }
@Override public Operation createServiceStartPost(TestContext ctx) { if (!enablePostgres) { return super.createServiceStartPost(ctx); } Operation post = Operation.createPost(null); post.setUri(UriUtils.buildUri(this, createServiceFactoryLink + "/" + post.getId())); return post.setCompletion(ctx.getCompletion()); }
Operation createMinimalTestServicePatch(String servicePath, TestContext ctx) { MinimalTestServiceState body = new MinimalTestServiceState(); body.id = Utils.buildUUID("foo"); Operation patch = Operation .createPatch(UriUtils.buildUri(this.host, servicePath)) .setBody(body); if (ctx != null) { patch.setCompletion(ctx.getCompletion()); } return patch; }
public static void stopContinuousQuerySubscription(TestRequestSender s, ServiceHost host, URI notificationTarget, QueryTask qt) { TestContext ctx = new TestContext(1, s.getTimeout()); Operation delete = Operation .createDelete(UriUtils.buildUri(notificationTarget, qt.documentSelfLink)) .setReferer(host.getUri()) .setCompletion(ctx.getCompletion()); host.stopSubscriptionService(delete, notificationTarget); ctx.await(); }
public static void stopContinuousQuerySubscription(TestRequestSender s, ServiceHost host, URI notificationTarget, QueryTask qt) { TestContext ctx = new TestContext(1, s.getTimeout()); Operation delete = Operation .createDelete(UriUtils.buildUri(notificationTarget, qt.documentSelfLink)) .setReferer(host.getUri()) .setCompletion(ctx.getCompletion()); host.stopSubscriptionService(delete, notificationTarget); ctx.await(); }
private void doOperation(Action action, Object state) throws Throwable { TestContext ctx = testCreate(2); this.activeContext = ctx; // wait also for the update notification to get called in the handler. Operation op = new Operation(); op.setUri(UriUtils.buildUri(host, this.state.documentSelfLink)) .setAction(action) .setBody(state) .setCompletion(ctx.getCompletion()); host.send(op); testWait(ctx); }
protected void stopService(Service s) throws Throwable { if (s == null || s.getSelfLink() == null || s.getSelfLink().isEmpty()) { return; } TestContext ctx = testCreate(1); Operation deleteOp = Operation.createDelete(UriUtils.buildUri(host, s.getSelfLink())) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_NO_INDEX_UPDATE) .setReplicationDisabled(true) .setCompletion(ctx.getCompletion()) .setReferer(host.getUri()); host.send(deleteOp); ctx.await(); }
protected void startInitialBootService( Class<? extends AbstractInitialBootService> serviceClass, String bootServiceSelfLink) throws Throwable { // simulate a restart of the service host host.startServiceAndWait(serviceClass, bootServiceSelfLink); TestContext ctx = testCreate(1); // start initialization of system documents host.sendRequest(Operation.createPost( UriUtils.buildUri(host, serviceClass)) .setReferer(host.getUri()) .setBody(new ServiceDocument()) .setCompletion(ctx.getCompletion())); ctx.await(); } }
protected void setUpAuthUsers()throws Throwable { TestContext testContext = this.host.testCreate(1); // create admin user. if it already exists, skip creation. this.host.setSystemAuthorizationContext(); AuthorizationSetupHelper.create() .setHost(this.host) .setUserEmail(this.adminEmail) .setUserPassword(this.adminPassword) .setUserSelfLink(this.adminEmail) .setIsAdmin(true) .setCompletion(testContext.getCompletion()) .start(); testContext.await(); this.host.resetAuthorizationContext(); }
protected void setUpAuthUsers()throws Throwable { TestContext testContext = this.host.testCreate(1); // create admin user. if it already exists, skip creation. this.host.setSystemAuthorizationContext(); AuthorizationSetupHelper.create() .setHost(this.host) .setUserEmail(this.adminEmail) .setUserPassword(this.adminPassword) .setUserSelfLink(this.adminEmail) .setIsAdmin(true) .setCompletion(testContext.getCompletion()) .start(); testContext.await(); this.host.resetAuthorizationContext(); }