def test_018_read_min_max_by_name(self): """ Test reading an RS485 device. Read min/max values out from the second airflow sensor by name. """ r = http.get(PREFIX + '/read/airflow/rack_1/50000004/cec airflow 2 - min max') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertIsInstance(response, dict) self.assertIsInstance(response[_S.AIRFLOW_MILLIMETERS_PER_SECOND], int) self.assertEqual(response[_S.AIRFLOW_MILLIMETERS_PER_SECOND], 399) r = http.get(PREFIX + '/read/airflow/rack_1/50000004/cec airflow 2 - min max') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertIsInstance(response, dict) self.assertIn(_S.AIRFLOW_MILLIMETERS_PER_SECOND, response) self.assertIsInstance(response[_S.AIRFLOW_MILLIMETERS_PER_SECOND], int) self.assertEqual(response[_S.AIRFLOW_MILLIMETERS_PER_SECOND], 0) r = http.get(PREFIX + '/read/airflow/rack_1/50000004/cec airflow 2 - min max') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertIsInstance(response, dict) self.assertIsInstance(response[_S.AIRFLOW_MILLIMETERS_PER_SECOND], int) self.assertEqual(response[_S.AIRFLOW_MILLIMETERS_PER_SECOND], 399)
def test_007_board_id_representation(self): """ Test reading while specifying different representations (same value) for the board id """ r = http.get(PREFIX + '/read/thermistor/rack_1/14/04FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 32768) self.assertEqual(response['temperature_c'], -4173.97) r = http.get(PREFIX + '/read/thermistor/rack_1/014/04FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 32768) self.assertEqual(response['temperature_c'], -4173.97) r = http.get(PREFIX + '/read/thermistor/rack_1/00014/04FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 32768) self.assertEqual(response['temperature_c'], -4173.97) r = http.get(PREFIX + '/read/thermistor/rack_1/000014/04FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 32768) self.assertEqual(response['temperature_c'], -4173.97) r = http.get(PREFIX + '/read/thermistor/rack_1/00000014/04FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 32768) self.assertEqual(response['temperature_c'], -4173.97)
def test_002_device_reads(self): for x in range(100): r = http.get(PREFIX + '/read/thermistor/rack_1/00000001/01FF') self.assertTrue(http.request_ok(r.status_code)) r = http.get(PREFIX + '/read/humidity/rack_1/00000001/0CFF') self.assertTrue(http.request_ok(r.status_code))
def test_010_device_id_representation(self): """ Test version while specifying different representations (same value) for the device id """ r = http.get(PREFIX + '/version/rack_1/A') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['firmware_version'], 'Version Response 1') r = http.get(PREFIX + '/version/rack_1/00A') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['firmware_version'], 'Version Response 1') r = http.get(PREFIX + '/version/rack_1/00000A') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['firmware_version'], 'Version Response 1') r = http.get(PREFIX + '/version/rack_1/000000000A') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['firmware_version'], 'Version Response 1') r = http.get(PREFIX + '/version/rack_1/00000000000000000A') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['firmware_version'], 'Version Response 1')
def test_003_read_8byte_max(self): """ Get a max value for each supported conversion method """ with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + '/read/thermistor/rack_1/00000014/07FF') self.assertEqual(ctx.exception.status, 500) # 65535 was the value r = http.get(PREFIX + '/read/thermistor/rack_1/00000014/08FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 65534) self.assertAlmostEqual(response['temperature_c'], -8466.32, 1) r = http.get(PREFIX + '/read/humidity/rack_1/00000014/09FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 4294967295) self.assertAlmostEqual(response['temperature_c'], 125, 1) self.assertAlmostEqual(response['humidity'], 100, 1) with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + '/read/rack_1/none/00000014/0AFF') self.assertEqual(ctx.exception.status, 500)
def test_002_read_mid(self): """ Get a midpoint value for each supported conversion method """ r = http.get(PREFIX + '/read/thermistor/rack_1/00000014/04FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 32768) self.assertEqual(response['temperature_c'], -4173.97) r = http.get(PREFIX + '/read/humidity/rack_1/00000014/05FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 65535) # 0x0000FFFF self.assertAlmostEqual(response['temperature_c'], 125, 1) # max self.assertEqual(response['humidity'], 0) # zero r = http.get(PREFIX + '/read/humidity/rack_1/00000014/05FF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 4294901760) # 0xFFFF0000 self.assertEqual(response['temperature_c'], -40) # zero self.assertAlmostEqual(response['humidity'], 100, 1) # max with self.assertRaises(VaporHTTPError) as ctx: http.get(PREFIX + '/read/rack_1/none/00000014/06FF') self.assertEqual(ctx.exception.status, 500)
def test_002_valid_board_device_location(self): """ Test simple location (valid board, valid device) """ r = http.get(PREFIX + '/location/rack_1/00000000/0000') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['physical_location']['horizontal'], 'unknown') self.assertEqual(response['physical_location']['vertical'], 'unknown') self.assertEqual(response['physical_location']['depth'], 'unknown') self.assertEqual(response['chassis_location']['horiz_pos'], 'unknown') self.assertEqual(response['chassis_location']['vert_pos'], 'unknown') self.assertEqual(response['chassis_location']['depth'], 'unknown') r = http.get(PREFIX + '/location/rack_1/00000000/72DF') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['physical_location']['horizontal'], 'unknown') self.assertEqual(response['physical_location']['vertical'], 'unknown') self.assertEqual(response['physical_location']['depth'], 'unknown') self.assertEqual(response['chassis_location']['horiz_pos'], 'left') self.assertEqual(response['chassis_location']['vert_pos'], 'bottom') self.assertEqual(response['chassis_location']['depth'], 'middle') self.assertEqual(response['chassis_location']['server_node'], 'unknown') r = http.get(PREFIX + '/location/rack_1/00000000/8302') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['physical_location']['horizontal'], 'unknown') self.assertEqual(response['physical_location']['vertical'], 'unknown') self.assertEqual(response['physical_location']['depth'], 'unknown') self.assertEqual(response['chassis_location']['horiz_pos'], 'unknown') self.assertEqual(response['chassis_location']['vert_pos'], 'unknown') self.assertEqual(response['chassis_location']['depth'], 'unknown') self.assertEqual(response['chassis_location']['server_node'], 3) r = http.get(PREFIX + '/location/rack_1/00000000/5555') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['physical_location']['horizontal'], 'unknown') self.assertEqual(response['physical_location']['vertical'], 'unknown') self.assertEqual(response['physical_location']['depth'], 'unknown') self.assertEqual(response['chassis_location']['horiz_pos'], 'left') self.assertEqual(response['chassis_location']['vert_pos'], 'top') self.assertEqual(response['chassis_location']['depth'], 'front') self.assertEqual(response['chassis_location']['server_node'], 'unknown') r = http.get(PREFIX + '/location/rack_1/00000000/9F00') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['physical_location']['horizontal'], 'unknown') self.assertEqual(response['physical_location']['vertical'], 'unknown') self.assertEqual(response['physical_location']['depth'], 'unknown') self.assertEqual(response['chassis_location']['horiz_pos'], 'unknown') self.assertEqual(response['chassis_location']['vert_pos'], 'unknown') self.assertEqual(response['chassis_location']['depth'], 'unknown') self.assertEqual(response['chassis_location']['server_node'], 31)
def test_11_read(self): """ Test reading a Redfish device. This will turn the power off to test reads when the BMC in unpowered. In these cases, we expect that the reads should not return data. """ # turn the power off r = http.get(PREFIX + '/power/rack_1/70000000/0100/off') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertIsInstance(response, dict) self.assertEqual(len(response), 6) self.assertIn('power_status', response) self.assertIn('power_ok', response) self.assertIn('over_current', response) self.assertIn('input_power', response) self.assertIn('request_received', response) self.assertIn('timestamp', response) self.assertEqual(response['power_status'], 'off') self.assertEqual(response['power_ok'], True) self.assertEqual(response['over_current'], False) #TODO - self.assertEqual(response['input_power'], 0) when emulator changes this value # TODO - check the read values for devices that have already been tested above when emulator # TODO (con't) - changes these values # with self.assertRaises(VaporHTTPError): # http.get(PREFIX + '/read/voltage/rack_1/70000000/0005') # with self.assertRaises(VaporHTTPError): # http.get(PREFIX + '/read/voltage/rack_1/70000000/0001') # with self.assertRaises(VaporHTTPError): # http.get(PREFIX + '/read/voltage/rack_1/70000000/0004') # with self.assertRaises(VaporHTTPError): # http.get(PREFIX + '/read/voltage/rack_1/70000000/0007') # turn the power back on r = http.get(PREFIX + '/power/rack_1/70000000/0100/on') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertIsInstance(response, dict) self.assertEqual(len(response), 6) self.assertIn('power_status', response) self.assertIn('power_ok', response) self.assertIn('over_current', response) self.assertIn('input_power', response) self.assertIn('request_received', response) self.assertIn('timestamp', response) self.assertEqual(response['power_status'], 'on') self.assertEqual(response['power_ok'], True) self.assertEqual(response['over_current'], False) self.assertEqual(response['input_power'], 344.0)
def test_002_scan_boards_individually(self): """ Test scanning each board individually """ r = http.get(PREFIX + '/scan/rack_1/00000001') self.assertTrue(http.request_ok(r.status_code)) r = http.get(PREFIX + '/scan/rack_1/00000003') self.assertTrue(http.request_ok(r.status_code)) r = http.get(PREFIX + '/scan/rack_1/00000010') self.assertTrue(http.request_ok(r.status_code))
def test_012_scan_board_id_representation(self): """ Test scanning while specifying different representations (same value) for the board id """ r = http.get(PREFIX + '/scan/rack_1/3') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1) r = http.get(PREFIX + '/scan/rack_1/03') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1) r = http.get(PREFIX + '/scan/rack_1/003') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1) r = http.get(PREFIX + '/scan/rack_1/0003') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1) r = http.get(PREFIX + '/scan/rack_1/00003') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1) r = http.get(PREFIX + '/scan/rack_1/000003') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1) r = http.get(PREFIX + '/scan/rack_1/0000003') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1) r = http.get(PREFIX + '/scan/rack_1/00000003') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1) r = http.get(PREFIX + '/scan/rack_1/000000003') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1) r = http.get(PREFIX + '/scan/rack_1/0000000003') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards'][0]['devices']), 1)
def test_011_power_device_id_representation(self): """ Test power status while specifying different representations (same value) for the board id """ r = http.get(PREFIX + '/power/rack_1/0000001E/1FF') self.assertTrue(http.request_ok(r.status_code)) r = http.get(PREFIX + '/power/rack_1/0000001E/01FF') self.assertTrue(http.request_ok(r.status_code)) r = http.get(PREFIX + '/power/rack_1/0000001E/00001FF') self.assertTrue(http.request_ok(r.status_code))
def test_006_device_id_representation(self): """ Test reading while specifying different representations (same value) for the device id """ r = http.get(PREFIX + '/boot_target/rack_1/00000040/000000002') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['target'], 'hdd') r = http.get(PREFIX + '/boot_target/rack_1/00000040/000000002') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['target'], 'hdd')
def test_004_empty_version(self): """ Test empty version (valid board, empty version) """ r = http.get(PREFIX + '/version/rack_1/0000000C') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['firmware_version'], '')
def test_002_simple_version(self): """ Test simple version (valid board, valid version) """ r = http.get(PREFIX + '/version/rack_1/0000000A') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['firmware_version'], 'Version Response 1')
def test_020_read_pressure_int_valid(self): """ Read a valid pressure value (-1) """ r = http.get(PREFIX + '/read/pressure/rack_1/00000016/0005') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response[_S.PRESSURE_PA], -1)
def test_008_triple_power_retry_valid(self): """ Single retry, valid retry response """ r = http.get(PREFIX + '/power/status/12/02ff') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['pmbus_raw'], '0,0,0,0')
def test_006_double_version_retry_valid(self): """ Single retry, valid retry response """ r = http.get(PREFIX + '/version/rack_1/11') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['firmware_version'], '12345')
def test_002_one_boards(self): """ Test for one board. """ r = http.get(PREFIX + '/scan/rack_1/00000000') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(len(response['boards']), 1)
def test_015_read_temperature_int_valid(self): """ Read a valid temperature value (30.03) """ r = http.get(PREFIX + '/read/temperature/rack_1/00000015/0005') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['temperature_c'], 30)
def test_version(): r = http.get(PREFIX + '/version/rack_1/0000000A', timeout=self.timeout) self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response['firmware_version'], 'Version Response 1')
def test_read_thermistor(): r = http.get(PREFIX + '/read/thermistor/rack_1/0000000A/01FF', timeout=self.timeout) self.assertTrue(http.request_ok(r.status_code)) response = r.json() # self.assertEqual(response['device_raw'], 656) self.assertAlmostEqual(response['temperature_c'], 28.7, delta=0.1)
def test_018_read_pressure_float_string_valid(self): """ Read a valid pressure value (-0.12) """ r = http.get(PREFIX + '/read/pressure/rack_1/00000016/0003') self.assertTrue(http.request_ok(r.status_code)) response = r.json() self.assertEqual(response[_S.PRESSURE_PA], -0.12)