ConfigSentinelClient extends AbstractComponent { synchronized void updateServiceStatuses(List<VespaService> services) { try { setStatus(services); } catch (Exception e) { log.log(Level.SEVERE, "Unable to update service pids from sentinel", e); } } @Inject  ConfigSentinelClient(); @Override void deconstruct();  }
@Test public void testElastic() { String response = "container state=RUNNING mode=AUTO pid=14338 exitstatus=0 autostart=TRUE autorestart=TRUE id=\"get/container.0\"\n" + "container-clustercontroller state=RUNNING mode=AUTO pid=25020 exitstatus=0 autostart=TRUE autorestart=TRUE id=\"admin/cluster-controllers/0\"\n" + "distributor state=RUNNING mode=AUTO pid=25024 exitstatus=0 autostart=TRUE autorestart=TRUE id=\"search/distributor/0\"\n" + "docprocservice state=RUNNING mode=AUTO pid=11973 exitstatus=0 autostart=TRUE autorestart=TRUE id=\"docproc/cluster.search.indexing/0\"\n" + "logd state=RUNNING mode=AUTO pid=25016 exitstatus=0 autostart=TRUE autorestart=TRUE id=\"hosts/vespa19.dev.gq1.yahoo.com/logd\"\n" + "logserver state=RUNNING mode=AUTO pid=25018 exitstatus=0 autostart=TRUE autorestart=TRUE id=\"admin/logserver\"\n" + "metricsproxy state=RUNNING mode=AUTO pid=13107 exitstatus=0 autostart=TRUE autorestart=TRUE id=\"hosts/vespa19.dev.gq1.yahoo.com/metricsproxy\"\n" + "searchnode state=RUNNING mode=AUTO pid=25023 exitstatus=0 autostart=TRUE autorestart=TRUE id=\"search/search/cluster.search/0\"\n" + "slobrok state=RUNNING mode=AUTO pid=25019 exitstatus=0 autostart=TRUE autorestart=TRUE id=\"admin/slobrok.0\"\n" + "\n"; ConfigSentinelDummy configsentinel = new ConfigSentinelDummy(response); List<VespaService> services = new ArrayList<>(); VespaService container = VespaService.create("container", "get/container.0", -1); VespaService containerClusterController = VespaService.create("container-clustercontroller", "get/container.0", -1); VespaService notPresent = VespaService.create("dummy","fake", -1); services.add(container); services.add(containerClusterController); services.add(notPresent); try (MockConfigSentinelClient client = new MockConfigSentinelClient(configsentinel)) { client.updateServiceStatuses(services); assertThat(container.isAlive(),is(true)); assertThat(container.getPid(),is(14338)); assertThat(container.getState(),is("RUNNING")); assertThat(containerClusterController.isAlive(),is(true)); assertThat(containerClusterController.getPid(),is(25020)); assertThat(containerClusterController.getState(),is("RUNNING")); } }