public void start(String[] args) throws Exception { PropertiesManager pm = new PropertiesManager(new File(propFile)); jrds.JrdsLoggerConfiguration.configure(pm); System.getProperties().setProperty("java.awt.headless", "true"); System.getProperties().putAll(pm); HostsList hl = new HostsList(pm); logger.debug("Scanning dir"); for(Timer t: hl.getTimers()) { t.collectAll(); } }
private Configuration(Properties p) { propertiesManager.join(p); propertiesManager.importSystemProps(); propertiesManager.update(); hostsList = new HostsList(propertiesManager); }
HostsList hl = new HostsList(pm);
System.getProperties().putAll(pm); HostsList hl = new HostsList(pm);
propertiesManager.importSystemProps(); propertiesManager.update(); HostsList hostsList = new HostsList(propertiesManager); GraphTree gt = hostsList.getGraphTreeByHost(); for (GraphNode gn: gt.enumerateChildsGraph()) {
@Test public void testHostList1() { HostsList hl = new HostsList(); StarterNode n2 = new StarterNode(hl) { }; StarterNode n3 = new StarterNode(n2) { }; Assert.assertEquals(hl, n3.getHostList()); }
@Test public void testDefault() throws IOException { PropertiesManager pm = Tools.makePm(testFolder, "tabs=filtertab,customgraph,@,sumstab,servicestab,viewstab,hoststab,tagstab,adminTab"); HostsList hl = new HostsList(pm); Assert.assertEquals("First tab not found", pm.tabsList.get(0), hl.getFirstTab()); Assert.assertEquals("Missing tabs", pm.tabsList.size() - optionalstabs.length, hl.getTabsId().size()); }
@Test(expected = RuntimeException.class) public void emptysum() throws Exception { HostsList hl = new HostsList(); hl.configure(new PropertiesManager()); ArrayList<String> graphlist = new ArrayList<String>(); graphlist.add("badhost/badgraph"); Sum s = new Sum("emptysum", graphlist); s.configure(hl); }
@Test public void testTagsTab() throws IOException { PropertiesManager pm = Tools.makePm(testFolder); pm.setProperty("tabs", "filtertab"); pm.update(); HostsList hl = new HostsList(pm); Set<String> hostsTags = Collections.singleton("tag"); Set<Tab> tabs = new HashSet<Tab>(); hl.doTagsTabs(hostsTags, tabs); Tab tab = (Tab) tabs.toArray()[0]; Assert.assertTrue(tab.isFilters()); }
@Test public void testOther() throws IOException { PropertiesManager pm = Tools.makePm(testFolder); pm.setProperty("tabs", "filtertab"); pm.update(); HostsList hl = new HostsList(pm); Assert.assertEquals("First tab not found", pm.tabsList.get(0), hl.getFirstTab()); Assert.assertEquals("Missing tabs", pm.tabsList.size(), hl.getTabsId().size()); }
@Test public void testHostList2() { StarterNode n2 = new StarterNode() { }; StarterNode n3 = new StarterNode(n2) { }; HostsList hl = new HostsList(); n2.setParent(hl); Assert.assertEquals(hl, n3.getHostList()); }
@Test public void testLoad() throws Exception { JrdsDocument d = Tools.parseString(goodSumSXml); JrdsElement je = d.getRootElement(); je.addElement("element", "name=DummyHost/DummyProbe"); HostsList hl = new HostsList(); Sum s = doSum(d, hl); Document sumDocument = s.getGraphDesc().dumpAsXml(); logger.trace(sumDocument); }
@Test public void testCustomGraph() throws IOException { PropertiesManager pm = Tools.makePm(testFolder); pm.setProperty("tabs", "filtertab"); pm.update(); HostsList hl = new HostsList(pm); GraphDesc gd = new GraphDesc(); gd.setName("truc"); gd.setGraphTitle("title"); Map<String, GraphDesc> gdmap = new HashMap<String, GraphDesc>(); gdmap.put(gd.getName(), gd); Set<Tab> tabs = new HashSet<Tab>(); Map<Integer, GraphNode> graphMap = new HashMap<Integer, GraphNode>(); Map<String, GraphTree> graphTrees = new HashMap<String, GraphTree>(); hl.doCustomGraphs(gdmap, graphMap, graphTrees, tabs); hl.addGraphs(graphMap.values()); boolean found = false; GraphNode node = null; for(Tab t: tabs) { if(PropertiesManager.CUSTOMGRAPHTAB.equals(t.id)) { found = true; t.setHostlist(hl); node = t.getGraphTree().enumerateChildsGraph().get(0); } } Assert.assertNotNull(graphMap.get(node.hashCode())); Assert.assertTrue(found); Assert.assertNotEquals(graphTrees.size(), 0); } }
@Test public void testRoles() throws Exception { JrdsDocument d = Tools.parseString(goodSumSXml); JrdsElement je = d.getRootElement(); je.addElement("element", "name=DummyHost/DummyProbe"); je.addElement("role").setTextContent("role1"); HostsList hl = new HostsList(); Sum s = doSum(d, hl); ACL acl = s.getACL(); Assert.assertEquals("Not an role ACL", RolesACL.class, acl.getClass()); }
@SuppressWarnings("unchecked") @Before public void prepare() throws Exception { pm = Tools.makePm(testFolder); hl = new HostsList(pm); GenerateProbe.ChainedMap<Object> args = GenerateProbe.ChainedMap.start().set(PropertiesManager.class, pm); p = GenerateProbe.quickProbe(testFolder, args); p.getPd().add("data", DsType.GAUGE); Assert.assertTrue("Failed to create probe " + p.getMainStore().getPath(), p.checkStore()); }
@Test public void testLoad() throws Exception { PropertiesManager pm = Tools.makePm(testFolder, "security=true"); HostsList hl = new HostsList(); hl.configure(pm); JrdsDocument d = Tools.parseRessource("goodtab.xml"); TabBuilder tb = new TabBuilder(); tb.setPm(pm); Tab tab = tb.build(d); tab.setHostlist(hl); Assert.assertEquals("goodtab", tab.getName()); Assert.assertNotNull("No graph tree generated", tab.getGraphTree()); }
@Test public void getSum() throws Exception { PropertiesManager pm = Tools.makePm(testFolder); HostsList hl = new HostsList(pm);