def test_2_pollers_by_id(self): msg = "Description: Display the poller data per node." if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] poller_list = ['driveHealth', 'sel', 'chassis', 'selInformation', 'sdr'] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "Node: {} Type: {}".format(node, nodetype) mondata = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertIn(mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}".format(mondata['status'])) # check required fields for item in mondata['json']: if item['pollInterval'] == 0: errorlist.append("Node: {} pollInterval field error: {}".format(node, item['pollInterval'])) for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'config']: if subitem not in item: errorlist.append("Node: {} field error: {}".format(node, subitem)) # display poller data for the node poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) poll_data = fit_common.rackhdapi("/api/2.0/pollers/" + poller_id) if fit_common.VERBOSITY >= 3: print fit_common.json.dumps(poll_data.get('json', ""), indent=4) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_7_poller_error_counter(self): msg = "Description: Check for Poller Errors" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "Node: {} Type: {}".format(node, nodetype) mondata = fit_common.rackhdapi("/api/1.1/nodes/" + node + "/pollers") self.assertIn(mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}".format(mondata['status'])) for item in mondata['json']: # check required fields if item['pollInterval'] == 0: errorlist.append("Node: {} pollInterval field error: {}".format(node, item['pollInterval'])) for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'config', 'updatedAt']: if subitem not in item: errorlist.append("Node: {} field error: {}".format(node, subitem)) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poll_data = fit_common.rackhdapi("/api/1.1/pollers/" + poller_id) poll_fails = poll_data['json'].get('failureCount', 0) if poll_fails != 0: errorlist.append("Node: {} Poller: {} {} reported {} failureCount".format(node, poller, poller_id, poll_fails)) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error counters are non-zero in Pollers counters") else: if fit_common.VERBOSITY >= 2: print "No Poller errors found"
def test_7_poller_error_counter(self): msg = "Description: Check for Poller Errors" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "\nNode: {} Type: {}".format(node, nodetype) mondata = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertIn(mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}".format(mondata['status'])) for item in mondata['json']: # check required fields if item['pollInterval'] == 0: errorlist.append("Node: {} pollInterval field error: {}".format(node, item['pollInterval'])) for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'config', 'updatedAt']: if subitem not in item: errorlist.append("Node: {} field error: {}".format(node, subitem)) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poll_data = fit_common.rackhdapi("/api/2.0/pollers/" + poller_id) poll_fails = poll_data['json'].get('failureCount', 0) if poll_fails != 0: errorlist.append("Node: {} Poller: {} {} reported {} failureCount".format(node, poller, poller_id, poll_fails)) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported in Pollers counters") else: if fit_common.VERBOSITY >= 2: print "No Poller errors found"
def test_2_pollers_by_id(self): msg = "Description: Display the poller data per node." if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] poller_list = ['driveHealth', 'sel', 'chassis', 'selInformation', 'sdr'] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "Node: {} Type: {}".format(node, nodetype) mondata = fit_common.rackhdapi("/api/1.1/nodes/" + node + "/pollers") self.assertIn(mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}".format(mondata['status'])) # check required fields for item in mondata['json']: if item['pollInterval'] == 0: errorlist.append("Node: {} pollInterval field error: {}".format(node, item['pollInterval'])) for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'config']: if subitem not in item: errorlist.append("Node: {} field error: {}".format(node, subitem)) # display poller data for the node poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) poll_data = fit_common.rackhdapi("/api/1.1/pollers/" + poller_id) if fit_common.VERBOSITY >= 3: print fit_common.json.dumps(poll_data.get('json', ""), indent=4) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_get_nodes_id_pollers(self): msg = "Description: Display the poller updated-at per node." print "\t{0}".format(msg) node = 0 for node in NODELIST: print "\nNode: ", node mon_data = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertIn(mon_data['status'], [200], "Incorrect HTTP return code") for item in mon_data['json']: # check required fields self.assertGreater(item['pollInterval'], 0, 'pollInterval field error') for subitem in [ 'node', 'config', 'createdAt', 'id', 'name', 'config', 'updatedAt' ]: self.assertIn(subitem, item, subitem + ' field error') poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] print "\nPoller: " + poller + " ID: " + str(poller_id) poll_data = fit_common.rackhdapi("/api/2.0/pollers/" + poller_id) pprint.pprint("Created At: {}".format( poll_data['json']['createdAt'])) pprint.pprint("Updated At: {}".format( poll_data['json']['updatedAt']))
def test_nodes_id_pollers(self): msg = "Description: Display the poller updated-at per node." print "\t{0}".format(msg) node = 0 errorlist = [] for node in NODELIST: if fit_common.VERBOSITY >= 2: print "Node: {}".format(node) mondata = fit_common.rackhdapi("/api/1.1/nodes/" + node + "/pollers") self.assertIn(mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}".format(mondata['status'])) for item in mondata['json']: # check required fields if item['pollInterval'] == 0: errorlist.append("Node: {} pollInterval field error: {}".format(node, item['pollInterval'])) for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'config', 'updatedAt']: if subitem not in item: errorlist.append("Node: {} field error: {}".format(node, subitem)) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poll_data = fit_common.rackhdapi("/api/1.1/pollers/" + poller_id) if fit_common.VERBOSITY >= 2: print "\nPoller: {} ID: {} ".format(poller, str(poller_id)) print "Created At: {}".format(fit_common.json.dumps(poll_data['json']['createdAt'])) print "Updated At: {}".format(fit_common.json.dumps(poll_data['json']['updatedAt'])) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reporterd.")
def test_verify_poller_data(self): if fit_common.VERBOSITY >= 2: msg = "Description: Check number of polls being kept for poller ID" print "\t{0}".format(msg) for node in NODELIST: if fit_common.VERBOSITY >= 2: print "\nNode: ", node nodetype = get_rackhd_nodetype(node) # Run test against managed nodes only if nodetype != "unknown" and nodetype != "Unmanaged": poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poller_data = test_api_utils.get_poller_data_by_id( poller_id) poll_len = len(poller_data) if fit_common.VERBOSITY >= 2: print "\nPoller: " + poller + " ID: " + str(poller_id) print "Number of polls for " + str( poller_id) + ": " + str(len(poller_data)) self.assertLessEqual( poll_len, 10, 'Number of cached polls should not exceed 10')
def test_verify_poller_error_counter(self): if fit_common.VERBOSITY >= 2: msg = "Description: Check for Poller Errors" print "\t{0}".format(msg) errorlist = [] for node in NODELIST: mon_data = fit_common.rackhdapi("/api/1.1/nodes/" + node + "/pollers") self.assertIn(mon_data['status'], [200], "Incorrect HTTP return code") for item in mon_data['json']: # check required fields self.assertGreater(item['pollInterval'], 0, 'pollInterval field error') for subitem in [ 'node', 'config', 'createdAt', 'id', 'name', 'config', 'updatedAt' ]: self.assertIn(subitem, item, subitem + ' field error') poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poll_data = fit_common.rackhdapi("/api/1.1/pollers/" + poller_id) poll_fails = poll_data['json'].get('failureCount', 0) if poll_fails != 0: errorlist.append( "Node: {} Poller: {} {} reported {} failureCount". format(node, poller, poller_id, poll_fails)) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported in Pollers") else: if fit_common.VERBOSITY >= 2: print("No Poller errors found")
def test_6_poller_status_timestamp(self): msg = "Description: Display status and timestamp from current poll" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "Node: {} Type: {}".format(node, nodetype) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) monurl = "/api/1.1/pollers/" + str(poller_id) + "/data/current" mondata = fit_common.rackhdapi(url_cmd=monurl) if mondata['status'] == 200: if fit_common.VERBOSITY >= 2: print "Timestamp: {}".format( mondata['json'][0]['timestamp']) else: errorlist.append( "Error: Node {} Poller_ID {} Failed to get current poller data, status {}" .format(node, poller_id, mondata['status'])) if errorlist != []: if fit_common.VERBOSITY >= 2: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_3_poller_headers(self): msg = "Description: Verify header data reported on the poller" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: mondata = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertIn(mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}".format(mondata['status'])) if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "\nNode: {} Type: {}".format(node, nodetype) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) poller_data = test_api_utils.get_poller_data_by_id(poller_id) if poller_data == []: errorlist.append("Error: Node {} Poller ID {}, {} failed to return any data".format(node, poller_id, poller)) if fit_common.VERBOSITY >= 3: print fit_common.json.dumps(poller_data, indent=4) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_3_poller_headers(self): msg = "Description: Verify header data reported on the poller" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "Node: {} Type: {}".format(node, nodetype) mondata = fit_common.rackhdapi("/api/1.1/nodes/" + node + "/pollers") self.assertIn( mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}". format(mondata['status'])) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) poller_data = test_api_utils.get_poller_data_by_id(poller_id) if poller_data == []: errorlist.append( "Error: Node {} Poller ID {}, {} failed to return any data" .format(node, poller_id, poller)) if fit_common.VERBOSITY >= 3: print fit_common.json.dumps(poller_data, indent=4) if errorlist != []: if fit_common.VERBOSITY >= 2: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_4_poller_default_cache(self): msg = "Description: Check number of polls being kept for poller ID" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "Node: {} Type: {}".format(node, nodetype) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poller_data = test_api_utils.get_poller_data_by_id(poller_id) poll_len = len(poller_data) if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) print "Number of polls for " + str(poller_id) + ": " + str( len(poller_data)) if poll_len > 10: errorlist.append( 'Error: Poller {} ID: {} - Number of cached polls should not exceed 10' .format(poller_id, poller)) elif poll_len == 0: errorlist.append( 'Error: Poller {} ID: {} - Pollers not running'.format( poller_id, poller)) if errorlist != []: if fit_common.VERBOSITY >= 2: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_5_poller_current_data(self): msg = "Description: Display most current data from poller" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "\nNode: {} Type: {}".format(node, nodetype) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) monurl = "/api/2.0/pollers/" + str(poller_id) + "/data/current" mondata = fit_common.rackhdapi(url_cmd=monurl) if mondata['status'] not in [200, 201, 202, 204]: errorlist.append( "Error: Node {} Poller_ID {} Failed to get current poller data, status {}" .format(node, poller_id, mondata['status'])) else: if fit_common.VERBOSITY >= 2: print fit_common.json.dumps(mondata['json'], indent=4) if errorlist != []: if fit_common.VERBOSITY >= 2: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_5_poller_current_data(self): msg = "Description: Display most current data from poller" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "\nNode: {} Type: {}".format(node, nodetype) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) monurl = "/api/2.0/pollers/" + str(poller_id) + "/data/current" mondata = fit_common.rackhdapi(url_cmd=monurl) if mondata['status'] not in [200, 201, 202, 204]: errorlist.append("Error: Node {} Poller_ID {} Failed to get current poller data, status {}".format(node, poller_id, mondata['status'])) else: if fit_common.VERBOSITY >= 2: print fit_common.json.dumps(mondata, indent=4) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_1_verify_pollers(self): msg = "Description: Check pollers created for node" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] poller_list = ['driveHealth', 'sel', 'chassis', 'selInformation', 'sdr', 'selEntries'] if fit_common.VERBOSITY >= 2: print "Expected Pollers for a Node: {}".format(poller_list) for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "\nNode: {} Type: {}".format(node, nodetype) mondata = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertIn(mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}".format(mondata['status'])) poller_dict = test_api_utils.get_supported_pollers(node) if set(poller_list) == set(poller_dict): if fit_common.VERBOSITY >= 2: print "Expected pollers instantiated on node" if fit_common.VERBOSITY >= 3: print "Poller list retreived", poller_dict else: if list(set(poller_list) - set(poller_dict)): errorlist.append("Error: Node {} Pollers not running {}".format(node, list(set(poller_list) - set(poller_dict)))) if list(set(poller_dict) - set(poller_list)): errorlist.append("Error: Node {} Unexpected Pollers running {}".format(node, list(set(poller_dict) - set(poller_list)))) if errorlist != []: if fit_common.VERBOSITY >= 2: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_7_nodes_id_pollers(self): msg = "Description: Display the poller last-finished per node." if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "\nNode: {} Type: {}".format(node, nodetype) mondata = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertIn(mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}".format(mondata['status'])) for item in mondata['json']: # check required fields if item['pollInterval'] == 0: errorlist.append("Node: {} pollInterval field error: {}".format(node, item['pollInterval'])) for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'config', 'updatedAt']: if subitem not in item: errorlist.append("Node: {} field error: {}".format(node, subitem)) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poll_data = fit_common.rackhdapi("/api/2.0/pollers/" + poller_id) if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) print "Last Started: {}".format(fit_common.json.dumps(poll_data['json'].get('lastStarted'))) print "Last Finished: {}".format(fit_common.json.dumps(poll_data['json'].get('lastFinished'))) print "Paused: {}".format(fit_common.json.dumps(poll_data['json'].get('paused'))) if errorlist != []: if fit_common.VERBOSITY >= 2: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reporterd.")
def test_api_20_get_pollers_by_id(self): msg = "Description: Display the poller data per node." logs.info_2("\t{0}".format(msg)) for node in self.NODELIST: api_data = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertEqual( api_data['status'], 200, "Incorrect HTTP return code, expected 200, got:{0}".format( str(api_data['status']))) for item in api_data['json']: # check required fields self.assertGreater(item['pollInterval'], 0, 'pollInterval field error') for subitem in [ 'node', 'config', 'createdAt', 'id', 'name', 'failureCount', 'leaseExpires', 'leaseToken', 'updatedAt' ]: self.assertIn(subitem, item, subitem + ' field error') logs.info_2("\nNode: ") poller_dict = test_api_utils.get_supported_pollers(node) self.POLLERS[node] = poller_dict for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] logs.info_2("\nPoller: " + poller + " ID: " + str(poller_id)) poll_data = fit_common.rackhdapi("/api/2.0/pollers/" + poller_id) logs.info_5(fit_common.json.dumps(poll_data['json'], indent=4))
def test_verify_poller_error_counter(self): msg = "Description: Check for Poller Errors" print "\t{0}".format(msg) errorlist = [] for node in NODELIST: mon_data = fit_common.rackhdapi("/api/1.1/nodes/" + node + "/pollers") self.assertIn(mon_data['status'], [200], "Incorrect HTTP return code") for item in mon_data['json']: # check required fields self.assertGreater(item['pollInterval'], 0, 'pollInterval field error') for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'config', 'updatedAt']: self.assertIn(subitem, item, subitem + ' field error') poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poll_data = fit_common.rackhdapi("/api/1.1/pollers/" + poller_id) poll_fails = poll_data['json'].get('failureCount', 0) if poll_fails != 0: errorlist.append("Node: {} Poller: {} {} reported {} failureCount".format(node, poller, poller_id, poll_fails)) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported in Pollers") else: if fit_common.VERBOSITY >- 2: print ("No Poller errors found")
def test_1_verify_pollers(self): msg = "Description: Check pollers created for node" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] poller_list = ['driveHealth', 'sel', 'chassis', 'selInformation', 'sdr'] if fit_common.VERBOSITY >= 2: print "Expected Pollers for a Node: ".format(poller_list) for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "\nNode: {} Type: {}".format(node, nodetype) mondata = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertIn(mondata['status'], [200], "Incorrect HTTP return code, expecting 200, received {}".format(mondata['status'])) poller_dict = test_api_utils.get_supported_pollers(node) if set(poller_list) == set(poller_dict): if fit_common.VERBOSITY >= 2: print "Expected pollers instantiated on node" if fit_common.VERBOSITY >= 3: print "Poller list retreived", poller_dict else: errorlist.append("Error: Node {0} Pollers not running {1}".format(node, list(set(poller_list) - set(poller_dict)))) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_get_id_pollers(self): if fit_common.VERBOSITY >= 2: msg = "Description: Display the poller data per node." print "\t{0}".format(msg) for node in NODELIST: mon_data = fit_common.rackhdapi("/api/1.1/nodes/" + node + "/pollers") self.assertIn(mon_data['status'], [200], "Incorrect HTTP return code") for item in mon_data['json']: # check required fields self.assertGreater(item['pollInterval'], 0, 'pollInterval field error') for subitem in [ 'node', 'config', 'createdAt', 'id', 'name', 'config' ]: self.assertIn(subitem, item, subitem + ' field error') if fit_common.VERBOSITY >= 2: print "\nNode: ", node poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poll_data = fit_common.rackhdapi("/api/1.1/pollers/" + poller_id) if fit_common.VERBOSITY >= 2: print "\nPoller: " + poller + " ID: " + str(poller_id) print fit_common.json.dumps(poll_data['json'], indent=4)
def test_4_poller_default_cache(self): msg = "Description: Check number of polls being kept for poller ID" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) for node in NODELIST: if fit_common.VERBOSITY >= 2: nodetype = get_rackhd_nodetype(node) print "Node: {} Type: {}".format(node, nodetype) errorlist = [] for node in NODELIST: nodetype = get_rackhd_nodetype(node) if fit_common.VERBOSITY >= 2: print "\nNode: {} Type: {}".format(node, nodetype) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] poller_data = test_api_utils.get_poller_data_by_id(poller_id) poll_len = len(poller_data) if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) print "Number of polls for "+ str(poller_id) + ": " + str(len(poller_data)) if poll_len > 10: errorlist.append('Error: Poller {} ID: {} - Number of cached polls should not exceed 10'.format(poller_id, poller)) elif poll_len == 0: errorlist.append('Error: Poller {} ID: {} - Pollers not running'.format(poller_id, poller)) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_get_poller_status_timestamp(self): if fit_common.VERBOSITY >= 2: msg = "Description: Display status and timestamp from current poll" print "\t{0}".format(msg) for node in NODELIST: if fit_common.VERBOSITY >= 2: print "\nNode: ", node nodetype = get_rackhd_nodetype(node) # Run test against managed nodes only if nodetype != "unknown" and nodetype != "Unmanaged": poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] if fit_common.VERBOSITY >= 2: print "\nPoller: " + poller + " ID: " + str(poller_id) monurl = "/api/1.1/pollers/" + str( poller_id) + "/data/current" mondata = fit_common.rackhdapi(url_cmd=monurl) print "Return status", mondata['status'] if mondata['status'] == 200: if fit_common.VERBOSITY >= 2: print "Timestamp:", mondata['json'][0]['timestamp'] print fit_common.json.dumps(mondata['json'][0], indent=4)
def test_6_poller_status_timestamp(self): msg = "Description: Display status and timestamp from current poll" if fit_common.VERBOSITY >= 2: print "\t{0}".format(msg) errorlist = [] for node in NODELIST: nodetype = get_rackhd_nodetype(node) if fit_common.VERBOSITY >= 2: print "\nNode: {} Type: {}".format(node, nodetype) poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] if fit_common.VERBOSITY >= 2: print "Poller: {} ID: {} ".format(poller, str(poller_id)) monurl = "/api/2.0/pollers/" + str(poller_id) + "/data/current" mondata = fit_common.rackhdapi(url_cmd=monurl) if mondata['status'] == 200: if fit_common.VERBOSITY >= 2: print "Timestamp: {}".format(mondata['json'][0]['timestamp']) else: errorlist.append("Error: Node {} Poller_ID {} Failed to get current poller data, status {}".format(node, poller_id, mondata['status'])) if errorlist != []: print "{}".format(fit_common.json.dumps(errorlist, indent=4)) self.assertEqual(errorlist, [], "Error reported.")
def test_verify_poller_data(self): msg = "Description: Check number of polls being kept for poller ID" print "\t{0}".format(msg) for node in NODELIST: print "\nNode: ", node nodetype = get_rackhd_nodetype(node) # Run test against managed nodes only if nodetype != "unknown" and nodetype != "Unmanaged": poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] print "\nPoller: " + poller + " ID: " + str(poller_id) poller_data = test_api_utils.get_poller_data_by_id(poller_id) poll_len = len(poller_data) print "Number of polls for "+ str(poller_id) + ": " + str(len(poller_data)) self.assertLessEqual(poll_len, 10, 'Number of cached polls should not exceed 10')
def test_get_current_poller_data(self): msg = "Description: Display most current data from poller" print "\t{0}".format(msg) for node in NODELIST: print "\nNode: ", node nodetype = get_rackhd_nodetype(node) # Run test against managed nodes only if nodetype != "unknown" and nodetype != "Unmanaged": poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] print "\nPoller: " + poller + " ID: " + str(poller_id) monurl = "/api/1.1/pollers/" + str(poller_id) + "/data/current" mondata = fit_common.rackhdapi(url_cmd=monurl) if fit_common.VERBOSITY >= 2: print fit_common.json.dumps(mondata, indent=4)
def test_get_current_poller_data(self): msg = "Description: Display most current data from poller" print "\t{0}".format(msg) for node in NODELIST: print "\nNode: ", node nodetype = get_rackhd_nodetype(node) # Run test against managed nodes only if nodetype != "unknown" and nodetype != "Unmanaged": poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] print "\nPoller: " + poller + " ID: " + str(poller_id) monurl = "/api/2.0/pollers/" + str( poller_id) + "/data/current" mondata = fit_common.rackhdapi(url_cmd=monurl) if fit_common.VERBOSITY >= 2: print fit_common.json.dumps(mondata, indent=4)
def test_verify_poller_headers(self): msg = "Description: Verify header data reported on the poller" print "\t{0}".format(msg) for node in NODELIST: mon_data = fit_common.rackhdapi("/api/1.1/nodes/" + node + "/pollers") self.assertIn(mon_data['status'], [200], "Incorrect HTTP return code") nodetype = get_rackhd_nodetype(node) print "\nNode: {} Type: {}".format(node, nodetype) # Run test against managed nodes only if nodetype != "unknown" and nodetype != "Unmanaged": poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] print "\nPoller: " + poller + " ID: " + str(poller_id) poller_data = test_api_utils.get_poller_data_by_id(poller_id) if fit_common.VERBOSITY >= 3: print fit_common.json.dumps(poller_data, indent=4)
def test_get_nodes_id_pollers(self): msg = "Description: Display the poller updated-at per node." print "\t{0}".format(msg) node = 0 for node in NODELIST: print "\nNode: ", node mon_data = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertIn(mon_data['status'], [200], "Incorrect HTTP return code") for item in mon_data['json']: # check required fields self.assertGreater(item['pollInterval'], 0, 'pollInterval field error') for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'config', 'updatedAt']: self.assertIn(subitem, item, subitem + ' field error') poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] print "\nPoller: " + poller + " ID: " + str(poller_id) poll_data = fit_common.rackhdapi("/api/2.0/pollers/" + poller_id) pprint.pprint("Created At: {}".format(poll_data['json']['createdAt'])) pprint.pprint("Updated At: {}".format(poll_data['json']['updatedAt']))
def test_get_id_pollers(self): msg = "Description: Display the poller data per node." print "\t{0}".format(msg) for node in NODELIST: mon_data = fit_common.rackhdapi("/api/1.1/nodes/" + node + "/pollers") self.assertIn(mon_data['status'], [200], "Incorrect HTTP return code") for item in mon_data['json']: # check required fields self.assertGreater(item['pollInterval'], 0, 'pollInterval field error') for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'config']: self.assertIn(subitem, item, subitem + ' field error') print "\nNode: ", node poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] print "\nPoller: " + poller + " ID: " + str(poller_id) poll_data = fit_common.rackhdapi("/api/1.1/pollers/" + poller_id) if fit_common.VERBOSITY >= 2: print fit_common.json.dumps(poll_data['json'], indent=4)
def test_get_poller_status_timestamp(self): msg = "Description: Display status and timestamp from current poll" print "\t{0}".format(msg) for node in NODELIST: print "\nNode: ", node nodetype = get_rackhd_nodetype(node) # Run test against managed nodes only if nodetype != "unknown" and nodetype != "Unmanaged": poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] print "\nPoller: " + poller + " ID: " + str(poller_id) monurl = "/api/1.1/pollers/" + str(poller_id) + "/data/current" mondata = fit_common.rackhdapi(url_cmd=monurl) print "Return status", mondata['status'] if mondata['status'] == 200: print "Timestamp:", mondata['json'][0]['timestamp'] if fit_common.VERBOSITY >= 2: print fit_common.json.dumps(mondata['json'][0], indent=4)
def test_verify_poller_headers(self): msg = "Description: Verify header data reported on the poller" print "\t{0}".format(msg) for node in NODELIST: mon_data = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertIn(mon_data['status'], [200], "Incorrect HTTP return code") nodetype = get_rackhd_nodetype(node) print "\nNode: {} Type: {}".format(node, nodetype) # Run test against managed nodes only if nodetype != "unknown" and nodetype != "Unmanaged": poller_dict = test_api_utils.get_supported_pollers(node) for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] print "\nPoller: " + poller + " ID: " + str(poller_id) poller_data = test_api_utils.get_poller_data_by_id( poller_id) if fit_common.VERBOSITY >= 3: print fit_common.json.dumps(poller_data, indent=4)
def test_api_20_get_pollers_by_id(self): msg = "Description: Display the poller data per node." logs.info_2("\t{0}".format(msg)) for node in self.NODELIST: api_data = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers") self.assertEqual(api_data['status'], 200, "Incorrect HTTP return code, expected 200, got:{0}" .format(str(api_data['status']))) for item in api_data['json']: # check required fields self.assertGreater(item['pollInterval'], 0, 'pollInterval field error') for subitem in ['node', 'config', 'createdAt', 'id', 'name', 'failureCount', 'leaseExpires', 'leaseToken', 'updatedAt']: self.assertIn(subitem, item, subitem + ' field error') logs.info_2("\nNode: ") poller_dict = test_api_utils.get_supported_pollers(node) self.POLLERS[node] = poller_dict for poller in poller_dict: poller_id = poller_dict[poller]["poller_id"] logs.info_2("\nPoller: " + poller + " ID: " + str(poller_id)) poll_data = fit_common.rackhdapi("/api/2.0/pollers/" + poller_id) logs.info_5(fit_common.json.dumps(poll_data['json'], indent=4))