public static VerificationHost create() { if (!enablePostgres) { return VerificationHost.create(); } return new PostgresVerificationHost(); }
public static VerificationHost create(Integer port) throws Exception { if (!enablePostgres) { return VerificationHost.create(port); } return create(port, null); }
@BeforeClass public static void before() throws Throwable { // create a host just to setup logging HOST = VerificationHost.create(0); HOST.start(); Logger rootLogger = Logger.getLogger(""); rootLogger.setLevel(Level.FINE); for (Handler h : rootLogger.getHandlers()) { h.setLevel(Level.FINE); } }
@BeforeClass public static void before() throws Throwable { // create a host just to setup logging HOST = VerificationHost.create(0); HOST.start(); Logger rootLogger = Logger.getLogger(""); rootLogger.setLevel(Level.FINE); for (Handler h : rootLogger.getHandlers()) { h.setLevel(Level.FINE); } }
private VerificationHost createAndStartHost(boolean enableAuth) throws Throwable { VerificationHost host = VerificationHost.create(0); host.setAuthorizationEnabled(enableAuth); // to speed up tests, set short maintenance interval. // it needs to "explicitly" set for VerificationHost instance host.setMaintenanceIntervalMicros( TimeUnit.MILLISECONDS.toMicros(VerificationHost.FAST_MAINT_INTERVAL_MILLIS)); host.start(); // add to the list for cleanup after each test run this.hostsToCleanup.add(host); return host; }
private VerificationHost createAndStartHost(boolean enableAuth) throws Throwable { VerificationHost host = VerificationHost.create(0); host.setAuthorizationEnabled(enableAuth); // to speed up tests, set short maintenance interval. // it needs to "explicitly" set for VerificationHost instance host.setMaintenanceIntervalMicros( TimeUnit.MILLISECONDS.toMicros(VerificationHost.FAST_MAINT_INTERVAL_MILLIS)); host.start(); // add to the list for cleanup after each test run this.hostsToCleanup.add(host); return host; }
public static VerificationHost create(Arguments args) throws Exception { if (!enablePostgres) { return VerificationHost.create(args); } VerificationHost h = new PostgresVerificationHost(); initialize(h, args); return h; }
@Test public void zipkinGetsZipkin() throws Exception { this.environment.setEnv((env) -> { env.put("XENON_TRACER_FACTORY_PROVIDER", "zipkin"); env.put("ZIPKIN_URL", "http://host/api/v1/spans/"); env.put("ZIPKIN_SERVICE_NAME", "test"); }); ServiceHost h = VerificationHost.create(0); Tracer tracer = TracerFactory.factory.create(h); assertTrue(tracer instanceof BraveTracer); assertTrue(TracerFactory.factory.enabled()); }
@Test(expected = RuntimeException.class) public void invalidTracer() throws Exception { TestXenonConfiguration.override(TracerFactory.class, "provider", "random junk"); ServiceHost h = VerificationHost.create(0); TracerFactory.factory.create(h); }
public void jaegerInvalidHost() throws Exception { // VRXEN-80 - a bad hostname throws RuntimeException TestXenonConfiguration.override(TracerFactory.class, "provider", TracerFactory.IMPL_JAEGER); System.setProperty("JAEGER_SERVICE_NAME", "test"); System.setProperty("JAEGER_AGENT_HOST", "badhostname.local."); ServiceHost h = VerificationHost.create(0); Tracer tracer = TracerFactory.factory.create(h); assertTrue(tracer instanceof NoopTracer); assertTrue(TracerFactory.factory.enabled()); }
private VerificationHost setupMetricHost() throws Throwable { // Start a metric Host separately. VerificationHost metricHost = VerificationHost.create(0); metricHost.start(); ServiceTypeCluster.METRIC_SERVICE.setUri(metricHost.getUri().toString()); PhotonModelMetricServices.startServices(metricHost); return metricHost; }
@Test public void jaegerGetsJaeger() throws Exception { this.environment.setEnv((env) -> { env.put("XENON_TRACER_FACTORY_PROVIDER", "jaeger"); env.put("JAEGER_SERVICE_NAME", "test"); }); ServiceHost h = VerificationHost.create(0); Tracer tracer = TracerFactory.factory.create(h); assertTrue(tracer instanceof com.uber.jaeger.Tracer); assertTrue(TracerFactory.factory.enabled()); }
@Test public void zipkinGetsZipkin() throws Exception { TestXenonConfiguration.override(TracerFactory.class, "provider", TracerFactory.IMPL_ZIPKIN); System.setProperty("ZIPKIN_URL", "http://host/api/v1/spans/"); System.setProperty("ZIPKIN_SERVICE_NAME", "test"); ServiceHost h = VerificationHost.create(0); Tracer tracer = TracerFactory.factory.create(h); assertTrue(tracer instanceof BraveTracer); assertTrue(TracerFactory.factory.enabled()); }
@Test public void jaegerGetsJaeger() throws Exception { TestXenonConfiguration.override(TracerFactory.class, "provider", TracerFactory.IMPL_JAEGER); System.setProperty("JAEGER_SERVICE_NAME", "test"); ServiceHost h = VerificationHost.create(0); Tracer tracer = TracerFactory.factory.create(h); assertTrue(tracer instanceof com.uber.jaeger.Tracer); assertTrue(TracerFactory.factory.enabled()); }
@Before public void setup() throws Throwable { this.host = VerificationHost.create(0); this.host.start(); this.host.startServiceAndWait(new NsOwner(), NsOwner.SELF_LINK, new ServiceDocument()); }
@Test public void testRedirect() { UiNgResourceForwarding service = new UiNgResourceForwarding("/sample", "/sample-new", true); service.setHost(VerificationHost.create()); AtomicBoolean completionCalled = new AtomicBoolean(); service.handleGet(new Operation().setUri(UriUtils.buildUri("http://localhost/sample")) .setCompletion((o, e) -> { assertEquals("/sample-new", o.getResponseHeader(Operation.LOCATION_HEADER)); completionCalled.set(true); })); assertTrue(completionCalled.get()); }
@Before public void setup() throws Throwable { this.host = VerificationHost.create(0); this.host.start(); this.host.startServiceAndWait(new NsOwner(), NsOwner.SELF_LINK, new ServiceDocument()); }
@Test public void defaultIsNoop() throws Exception { TestXenonConfiguration.override(TracerFactory.class, "provider", null); ServiceHost h = VerificationHost.create(0); Tracer tracer = TracerFactory.factory.create(h); assertTrue(tracer instanceof NoopTracer); assertFalse(TracerFactory.factory.enabled()); }
@Test public void testDiscoverFileResourcesOnStart() throws Throwable { UiService service = new UiService(); service.setSelfLink("/"); Arguments args = new Arguments(); args.resourceSandbox = Paths.get("src/main/resources/"); VerificationHost vh = VerificationHost.create(args); service.setHost(vh); Operation start = new Operation().setUri(UriUtils.buildUri("/")); service.handleStart(start); assertEquals(Operation.STATUS_CODE_OK, start.getStatusCode()); }
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; }