/** * Creates a test wait context that can be nested and isolated from other wait contexts */ public TestContext testCreate(long c) { return testCreate((int) c); }
/** * Creates a test wait context that can be nested and isolated from other wait contexts */ public TestContext testCreate(long c) { return testCreate((int) c); }
public TestContext testCreate(int c) { return this.host.testCreate(c); }
public TestContext testCreate(int c) { return this.host.testCreate(c); }
public TestContext testCreate(int c) { return this.host.testCreate(c); }
public TestContext testCreate(int c) { return this.host.testCreate(c); }
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 void startHosts() throws Throwable { for (int i = 0; i < this.nodeCount; i++) { Arguments args = new Arguments(); args.port = 0; args.id = "node-" + i; args.sandbox = this.sandboxRoot.resolve(args.id); VerificationHost h = VerificationHost.create(args); h.start(); startServicesOnHost(h); this.hosts.add(h); } joinNodesAndVerifyConvergence(); for (VerificationHost host : this.hosts) { TestContext ctx = host.testCreate(this.services.size()); host.registerForServiceAvailability(ctx.getCompletion(), true, this.services.toArray(new String[] {})); ctx.await(); } }
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 void waitForReplicatedFactoryServiceAvailable(URI u, String nodeSelectorPath) { waitFor("replicated available check time out for " + u, () -> { boolean[] isReady = new boolean[1]; TestContext ctx = testCreate(1); NodeGroupUtils.checkServiceAvailability((o, e) -> { if (e != null) { isReady[0] = false; ctx.completeIteration(); return; } isReady[0] = true; ctx.completeIteration(); }, this, u, nodeSelectorPath); ctx.await(); return isReady[0]; }); }
public Service startServiceAndWait(Service s, String uriPath, ServiceDocument body) throws Throwable { TestContext ctx = testCreate(1); URI u = null; if (uriPath != null) { u = UriUtils.buildUri(this, uriPath); } Operation post = Operation .createPost(u) .setBody(body) .setCompletion(ctx.getCompletion()); startService(post, s); ctx.await(); return s; }
public Service startServiceAndWait(Service s, String uriPath, ServiceDocument body) throws Throwable { TestContext ctx = testCreate(1); URI u = null; if (uriPath != null) { u = UriUtils.buildUri(this, uriPath); } Operation post = Operation .createPost(u) .setBody(body) .setCompletion(ctx.getCompletion()); startService(post, s); ctx.await(); return s; }
@Test public void testInvalidUri() throws Throwable { TestContext ctx = host.testCreate(1); URI rpPingUri = UriUtils.buildUri(host, "/rp/invalid"); Operation op = Operation.createGet(rpPingUri) .setCompletion(ctx.getExpectedFailureCompletion()); host.send(op); host.testWait(ctx); }
@Test public void testRecover() throws Throwable { TestContext ctx = this.host.testCreate(1); Operation get = Operation .createGet(host, UriUtils.buildUriPath(ExampleService.FACTORY_LINK, "unknown")); DeferredResult<ExampleServiceState> deferredResult = this.host.sendWithDeferredResult(get, ExampleServiceState.class) .exceptionally(ex -> { ExampleServiceState doc = new ExampleServiceState(); doc.name = "?"; return doc; }); ctx.await(deferredResult); ExampleServiceState doc = deferredResult.getNow(() -> null); Assert.assertEquals("?", doc.name); }
@Test public void startServiceSelfLinkWithStar() throws Throwable { setUp(false); MinimalTestServiceState initialState = new MinimalTestServiceState(); initialState.id = this.host.nextUUID(); TestContext ctx = this.host.testCreate(1); Operation startPost = Operation .createPost(UriUtils.buildUri(this.host, this.host.nextUUID() + "*")) .setBody(initialState).setCompletion(ctx.getExpectedFailureCompletion()); this.host.startService(startPost, new MinimalTestService()); this.host.testWait(ctx); }
@Test public void startServiceSelfLinkWithStar() throws Throwable { setUp(false); MinimalTestServiceState initialState = new MinimalTestServiceState(); initialState.id = this.host.nextUUID(); TestContext ctx = this.host.testCreate(1); Operation startPost = Operation .createPost(UriUtils.buildUri(this.host, this.host.nextUUID() + "*")) .setBody(initialState).setCompletion(ctx.getExpectedFailureCompletion()); this.host.startService(startPost, new MinimalTestService()); this.host.testWait(ctx); }
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(); }