def test_6_all_domains(self): print "" print "get all domains" # Force authentication ... connection = frontend.login("admin", "admin", force=True) assert_true(frontend.authenticated) assert_true(frontend.token) connection = frontend.connect(username="******") assert_true(frontend.authenticated) assert_true(frontend.connected) # Get all pages print "get all elements at once" # Filter the templates ... for object_type in frontend.backend_available_objets: items = frontend.get_objects(object_type["title"], parameters=None, all_elements=False) print "Got %d %ss:" % (len(items), object_type) items = frontend.get_ui_data_model(object_type["title"]) print "Got %d %ss:" % (len(items), object_type) # assert_true('_items' not in items) # Backend connection frontend.disconnect()
def test_9_livesynthesis(self): print "" print "get live synthesis" # Force authentication ... connection = frontend.login("admin", "admin", force=True) assert_true(frontend.authenticated) assert_true(frontend.token) connection = frontend.connect(username="******") assert_true(frontend.authenticated) assert_true(frontend.connected) print "get live synthesis" synthesis = frontend.get_livesynthesis() print synthesis assert_true("hosts_synthesis" in synthesis) assert_true("nb_elts" in synthesis["hosts_synthesis"]) assert_true("business_impact" in synthesis["hosts_synthesis"]) assert_true("nb_up" in synthesis["hosts_synthesis"]) assert_true("nb_down" in synthesis["hosts_synthesis"]) assert_true("nb_unreachable" in synthesis["hosts_synthesis"]) assert_true("nb_acknowledged" in synthesis["hosts_synthesis"]) assert_true("nb_in_downtime" in synthesis["hosts_synthesis"]) assert_true("nb_flapping" in synthesis["hosts_synthesis"]) assert_true("nb_problems" in synthesis["hosts_synthesis"]) assert_true("pct_up" in synthesis["hosts_synthesis"]) assert_true("pct_down" in synthesis["hosts_synthesis"]) assert_true("pct_unreachable" in synthesis["hosts_synthesis"]) assert_true("pct_acknowledged" in synthesis["hosts_synthesis"]) assert_true("pct_in_downtime" in synthesis["hosts_synthesis"]) assert_true("pct_flapping" in synthesis["hosts_synthesis"]) assert_true("pct_problems" in synthesis["hosts_synthesis"]) assert_true("services_synthesis" in synthesis) assert_true("nb_elts" in synthesis["services_synthesis"]) assert_true("business_impact" in synthesis["services_synthesis"]) assert_true("nb_ok" in synthesis["services_synthesis"]) assert_true("nb_warning" in synthesis["services_synthesis"]) assert_true("nb_critical" in synthesis["services_synthesis"]) assert_true("nb_unknown" in synthesis["services_synthesis"]) assert_true("nb_acknowledged" in synthesis["services_synthesis"]) assert_true("nb_in_downtime" in synthesis["services_synthesis"]) assert_true("nb_flapping" in synthesis["services_synthesis"]) assert_true("nb_problems" in synthesis["services_synthesis"]) assert_true("pct_ok" in synthesis["services_synthesis"]) assert_true("pct_warning" in synthesis["services_synthesis"]) assert_true("pct_critical" in synthesis["services_synthesis"]) assert_true("pct_unknown" in synthesis["services_synthesis"]) assert_true("pct_acknowledged" in synthesis["services_synthesis"]) assert_true("pct_in_downtime" in synthesis["services_synthesis"]) assert_true("pct_flapping" in synthesis["services_synthesis"]) assert_true("pct_problems" in synthesis["services_synthesis"]) # Backend disconnection frontend.disconnect()
def test_8_livestate(self): print "" print "get livestate" # Force authentication ... connection = frontend.login("admin", "admin", force=True) assert_true(frontend.authenticated) assert_true(frontend.token) connection = frontend.connect(username="******") assert_true(frontend.authenticated) assert_true(frontend.connected) print "get livetstate elements" items = frontend.get_livestate(parameters=None) print "Got %d elements" % (len(items)) print items print "get livetstate registered elements" parameters = {"where": '{"register":true}'} items = frontend.get_livestate(parameters=parameters) print "Got %d elements" % (len(items)) print items print "get livetstate hosts" items = frontend.get_livestate_hosts(parameters=None) print "Got %d elements" % (len(items)) print items[0] print "get livetstate registered hosts" parameters = {"where": '{"register":true}'} items = frontend.get_livestate_hosts(parameters=parameters) print "Got %d elements" % (len(items)) print items[0] print "get livetstate services" parameters = {"where": '{"register":true}'} items = frontend.get_livestate_services(parameters=parameters) print "Got %d elements" % (len(items)) print items[0] print "get livetstate registered services" items = frontend.get_livestate_services(parameters=None) print "Got %d elements" % (len(items)) print items[0] # Backend connection frontend.disconnect()
def test_10_livesynthesis(self): print "---" # Initialize backend communication ... frontend.configure(alignak_webui.app.config.get('ui.backend', 'http://localhost:5000')) print "Frontend: %s", frontend.url_endpoint_root # Configure users' management backend User.set_backend(frontend) # Force authentication ... connection = frontend.login('admin', 'admin', force=True) assert_true(frontend.authenticated) assert_true(frontend.token) connection = frontend.connect(username='******') assert_true(frontend.authenticated) assert_true(frontend.connected) print "Get live synthesis ..." synthesis = self.helper.get_livesynthesis() print "Result:", synthesis assert_true('hosts_synthesis' in synthesis) assert_true('nb_elts' in synthesis['hosts_synthesis']) assert_true('services_synthesis' in synthesis) assert_true('nb_elts' in synthesis['services_synthesis']) print "Get HTML live synthesis ..." synthesis = self.helper.get_html_livesynthesis() print "Result:", synthesis assert 'hosts_states_popover' in synthesis assert 'host state is UP' in synthesis['hosts_states_popover'] assert 'host state is DOWN' in synthesis['hosts_states_popover'] assert 'host state is UNREACHABLE' in synthesis['hosts_states_popover'] assert 'hosts_state' in synthesis # assert False assert 'services_states_popover' in synthesis assert 'service state is OK' in synthesis['services_states_popover'] assert 'service state is WARNING' in synthesis['services_states_popover'] assert 'service state is CRITICAL' in synthesis['services_states_popover'] assert 'services_state' in synthesis # Backend disconnection frontend.disconnect()
def test_4_connection_username(self): print "" print "test connection with username/password" connection = frontend.login("admin", "admin") assert_true(frontend.authenticated) assert_false(frontend.connected) assert_true(frontend.token) # Already authenticated ... connection = frontend.login("", "") assert_true(frontend.authenticated) assert_false(frontend.connected) assert_true(frontend.token) # Force authentication ... connection = frontend.login("admin", "admin", force=True) assert_true(frontend.authenticated) assert_false(frontend.connected) assert_true(frontend.token) connection = frontend.logout() assert_false(frontend.authenticated) assert_false(frontend.connected) assert_false(frontend.token) print "authenticated:", frontend.authenticated connection = frontend.connect(username="******") print "authenticated:", frontend.authenticated assert_false(frontend.connected) assert_false(frontend.authenticated) connection = frontend.disconnect() assert_false(frontend.authenticated) assert_false(frontend.connected) assert_false(frontend.token)
def test_11_livestate(self): print "---" # Initialize backend communication ... frontend.configure(alignak_webui.app.config.get('ui.backend', 'http://localhost:5000')) print "Frontend: %s", frontend.url_endpoint_root # Configure users' management backend User.set_backend(frontend) # Force authentication ... connection = frontend.login('admin', 'admin', force=True) assert_true(frontend.authenticated) assert_true(frontend.token) connection = frontend.connect(username='******') assert_true(frontend.authenticated) assert_true(frontend.connected) print "Get live state ..." print "Livestate_age: ", self.helper.livestate_age ls = self.helper.get_livestate() print "Livestate_age: ", self.helper.livestate_age print "Livestate: ", self.helper.livestate assert self.helper.livestate_age for item in ls: print "Item:", item assert_true('type' in item) assert_true('id' in item) assert_true('bi' in item) assert_true('name' in item) assert_true('friendly_name' in item) for item in self.helper.livestate: print "Item:", item assert_true('type' in item) assert_true('id' in item) assert_true('bi' in item) assert_true('name' in item) assert_true('friendly_name' in item) assert len(ls) == len(self.helper.livestate) print "Get HTML live state ..." print "Current user: "******"Items:", len(html['rows']) for bi in [0,1,2,3,4,5]: print "Get HTML live state (BI = %d) ..." % bi html = self.helper.get_html_livestate(bi=bi) assert 'bi' in html assert 'rows' in html assert 'panel_bi' in html print "Items:", len(html['rows']) / 2 # for row in html['rows']: # print "Item:", row print "Get HTML live state ... filter" html = self.helper.get_html_livestate(search_filter="type:host") assert 'bi' in html assert 'rows' in html assert 'panel_bi' in html print "Items:", len(html['rows']) for bi in [0,1,2,3,4,5]: print "Get HTML live state (BI = %d) ...and filter" % bi html = self.helper.get_html_livestate(bi=bi, search_filter="type:host") assert 'bi' in html assert 'rows' in html assert 'panel_bi' in html print "Items:", len(html['rows']) # Backend disconnection frontend.disconnect()
def test_09_search(self): print "---" # Initialize backend communication ... frontend.configure(alignak_webui.app.config.get('ui.backend', 'http://localhost:5000')) print "Frontend: %s", frontend.url_endpoint_root # Configure users' management backend User.set_backend(frontend) # Force authentication ... connection = frontend.login('admin', 'admin', force=True) assert_true(frontend.authenticated) assert_true(frontend.token) connection = frontend.connect(username='******') assert_true(frontend.authenticated) assert_true(frontend.connected) ls = self.helper.get_livestate() print "Search on element type ..." search = self.helper.search_livestate(ls, "type:all") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "type:host") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "type:service") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "host") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "service") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "type:unknown") print "Result, found %d elements" % len(search) print "---" print "Search on element name and content ... " print "found in name ..." search = self.helper.search_livestate(ls, "charnay") print "Result, found %d elements" % len(search) # assert len(search) > 0 print "found in output ..." search = self.helper.search_livestate(ls, "time") print "Result, found %d elements" % len(search) # assert len(search) > 0 print "not found ..." search = self.helper.search_livestate(ls, "test") print "Result, found %d elements" % len(search) print "---" print "Search on element business impact ... " search = self.helper.search_livestate(ls, "bi:0") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "bi:=0") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "bi:>0") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "bi:>=0") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "bi:<5") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "bi:<=5") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "bi:>3") print "Result, found %d elements" % len(search) # assert len(search) > 0 print "---" print "Search on element state ... " search = self.helper.search_livestate(ls, "is:ack") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "ack:true") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "ack:yes") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "ack:1") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:ack") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "ack:false") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "ack:no") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "ack:0") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:downtime") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "downtime:yes") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "downtime:true") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "downtime:1") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "downtime:false") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "downtime:no") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "downtime:0") print "Result, found %d elements" % len(search) assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:downtime") print "Result, found %d elements" % len(search) assert len(search) > 0 search = self.helper.search_livestate(ls, "is:0") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:1") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:2") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:3") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:up") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "up") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:down") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "down") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:unreachable") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "unreachable") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:ok") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "OK") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:warning") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "WARNING") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:critical") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "CRITICAL") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:unknown") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "UNKNOWN") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "is:pending") print "Result, found %d elements" % len(search) search = self.helper.search_livestate(ls, "PENDING") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:up") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:down") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:unreachable") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:ok") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:warning") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:critical") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:unknown") print "Result, found %d elements" % len(search) # assert len(search) > 0 search = self.helper.search_livestate(ls, "isnot:pending") print "Result, found %d elements" % len(search) # assert len(search) > 0 # Backend disconnection frontend.disconnect()