Esempio n. 1
0
    def test_017_read_pressure_invalid(self):
        """ Read invalid pressure value (invalid)
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/read/rack_1/pressure/00000016/0002')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 2
0
 def test_009_no_data(self):
     """ Get no packet in return.
     """
     # TIMEOUT
     with self.assertRaises(VaporHTTPError) as ctx:
         http.get(PREFIX + '/scan/rack_1/0000C800')
     self.assert_scan_registration_failure(ctx)
Esempio n. 3
0
 def test_006_many_http(self):
     """ Test for one board many times.  Too many cooks.
     """
     for x in range(5):
         with self.assertRaises(VaporHTTPError) as ctx:
             http.get(PREFIX + '/scan/rack_1/00000000')
         self.assert_scan_registration_failure(ctx)
Esempio n. 4
0
    def test_08_led(self):
        """ Test the led endpoint in Redfish mode.

        Test passing in an invalid LED command option.
        """
        with self.assertRaises(VaporHTTPError):
            http.get(PREFIX + '/led/rack_1/70000000/0300/non-option')
Esempio n. 5
0
 def test_scan_by_rack1(self):
     """ Test scan rack_1 expecting sad results. Emulator is down."""
     try:
         http.get(Uri.create(_S.URI_SCAN, RACK_1))
         self.fail(EXPECTED_VAPOR_HTTP_ERROR)
     except VaporHTTPError as e:
         self._verify_vapor_http_error(e, 500, _S.ERROR_NO_RACK_FOUND_WITH_ID.format(RACK_1))
    def test_024_read_min_max_by_name(self):
        """ Test reading an RS485 device.  Read min/max values out from the chamber fan by name.
        """
        r = http.get(PREFIX + '/fan/rack_1/50000007/chamber fan')
        self.assertTrue(http.request_ok(r.status_code))

        response = r.json()
        self.assertIsInstance(response, dict)
        self.assertIn('speed_rpm', response)
        self.assertIsInstance(response['speed_rpm'], int)
        self.assertEqual(response['speed_rpm'], 0xffff)

        r = http.get(PREFIX + '/fan/rack_1/50000007/chamber fan')
        self.assertTrue(http.request_ok(r.status_code))

        response = r.json()
        self.assertIsInstance(response, dict)
        self.assertIn('speed_rpm', response)
        self.assertIsInstance(response['speed_rpm'], int)
        self.assertEqual(response['speed_rpm'], 0)

        r = http.get(PREFIX + '/fan/rack_1/50000007/chamber fan')
        self.assertTrue(http.request_ok(r.status_code))

        response = r.json()
        self.assertIsInstance(response, dict)
        self.assertIn('speed_rpm', response)
        self.assertIsInstance(response['speed_rpm'], int)
        self.assertEqual(response['speed_rpm'], 0xffff)
Esempio n. 7
0
    def test_014_write_with_bad_response(self):
        """ Test write with bad response.
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/fan/rack_1/00000080/0002/4100')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 8
0
    def test_013_triple_read_retry_fail(self):
        """ Single retry, valid retry response
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/read/thermistor/rack_1/14/01ff')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 9
0
    def test_014_triple_power_retry_fail(self):
        """ Single retry, valid retry response
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/power/status/14/02ff')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 10
0
    def test_003_no_boards(self):
        """ Test for no boards.
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/scan/rack_1/000000D2')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 11
0
    def test_005_many_devices(self):
        """ Test for one board many devices.
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/scan/rack_1/00000002')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 12
0
    def test_08_asset(self):
        """ Test the asset endpoint in Redfish mode.

        Tests getting asset info of a device that does not exist
        """
        with self.assertRaises(VaporHTTPError):
            http.get(PREFIX + '/asset/rack_1/70000000/0056')
Esempio n. 13
0
    def test_011_write_with_bad_response(self):
        """ Test write with bad response.
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/boot_target/rack_1/00000040/0003/hdd')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 14
0
    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)
Esempio n. 15
0
    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))
Esempio n. 16
0
    def test_015_triple_version_retry_fail(self):
        """ Single retry, valid retry response
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/version/rack_1/14')

        self.assertEqual(ctx.exception.status, 500)
    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)
Esempio n. 18
0
    def test_003_invalid_board_location(self):
        """ Test simple location (invalid board)
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/location/rack_1/800000000')

        self.assertEqual(ctx.exception.status, 500)

        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/location/rack_1/8000000000')

        self.assertEqual(ctx.exception.status, 500)

        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/location/rack_1/hot_dog')

        self.assertEqual(ctx.exception.status, 500)

        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/location/rack_1/AAAAAAAAA')

        self.assertEqual(ctx.exception.status, 500)

        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/location/rack_1/-1')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 19
0
    def test_011_write_string(self):
        """ Test write with string.
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/fan/rack_1/00000080/0001/faster')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 20
0
    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')
Esempio n. 21
0
    def test_002_read_empty(self):
        """ Read an empty data value back.
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/asset/rack_1/00000050/0002')

        self.assertEqual(ctx.exception.status, 500)
Esempio n. 22
0
    def test_011_invalid_board_id(self):
        """ Test version while specifying invalid board_id representation.
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/version/rack_1/-1')

        self.assertEqual(ctx.exception.status, 500)
 def test_power_read_rack2_not_supported(self):
     """Sad case power read on the second rack. Power command on a fan."""
     try:
         http.get(Uri.create(_S.URI_POWER, RACK_2, BOARD_60000001, '0002'))
         self.fail(EXPECTED_VAPOR_HTTP_ERROR)
     except VaporHTTPError as e:
         self._verify_vapor_http_error(e, 500, _S.ERROR_POWER_COMMAND_NOT_SUPPORTED)
Esempio n. 24
0
    def test_05_read(self):
        """ Test reading a Redfish device.

        This should fail since the fan device is not 'present' in the emulator.
        """
        with self.assertRaises(VaporHTTPError):
            http.get(PREFIX + '/read/fan_speed/rack_1/70000000/0041')
Esempio n. 25
0
    def test_read_write_fan_speed_rack2_board1(self):
        """SNMP read of fan speed. Happy case. Read, write, set back to the original.
        This is a lot like test_read_write_fan_speed_rack1_board0, but verifies that
        command routing is going to the correct emulator.
        NOTE: If a write fails or the write back to original fails, this test may be
        non-reentrant. To avoid reentrancy issues, no other tests should run against
        this device at /rack_2/60000001/0004.
        """
        logger.debug('test_read_write_fan_speed_rack2_board1')
        base_uri = Uri.create(_S.URI_FAN, RACK_2, BOARD_60000001, '0004')
        response = http.get(base_uri).json()
        logger.debug(json.dumps(response, sort_keys=True, indent=4, separators=(',', ': ')))
        self._verify_read_fan_response(response, _S.OK, [], 21)

        response = http.get(Uri.append(base_uri, '300')).json()
        logger.debug(json.dumps(response, sort_keys=True, indent=4, separators=(',', ': ')))
        self._verify_read_fan_response(response, _S.OK, [], 300)

        logger.debug('second read')
        response = http.get(base_uri).json()
        self._verify_read_fan_response(response, _S.OK, [], 300)

        logger.debug('second write (to initial)')
        response = http.get(Uri.append(base_uri, '21')).json()
        self._verify_read_fan_response(response, _S.OK, [], 21)

        logger.debug('third read')
        response = http.get(base_uri).json()
        self._verify_read_fan_response(response, _S.OK, [], 21)
Esempio n. 26
0
    def test_06_read(self):
        """ Test reading a Redfish device.

        This should fail since 'power' is unsupported for Redfish reads.
        """
        with self.assertRaises(VaporHTTPError):
            http.get(PREFIX + '/read/rack_1/power/70000000/0100')
Esempio n. 27
0
    def test_013_scan_board_id_invalid(self):
        """ Test scan while specifying different invalid representations for
        the board id to ensure out-of-range values are not handled (e.g. set bits
        on packet that should not be set)
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/scan/rack_1/FFFFFFFF')
        self.assert_scan_registration_failure(ctx)

        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/scan/rack_1/FFFFFFFFFFFFFFFF')
        self.assertEqual(ctx.exception.status, 500)
        self.assertIn('out of range', ctx.exception.json['message'])

        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/scan/rack_1/20000000')
        self.assert_scan_registration_failure(ctx)

        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/scan/rack_1/10000000')
        self.assert_scan_registration_failure(ctx)

        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/scan/rack_1/-10000000')
        self.assertEqual(ctx.exception.status, 500)
        self.assertIn('out of range', ctx.exception.json['message'])
Esempio n. 28
0
    def test_02_power(self):
        """ Test power control with Redfish.

        This should fail since the specified action is invalid.
        """
        with self.assertRaises(VaporHTTPError):
            http.get(PREFIX + '/power/rack_1/70000000/0100/not-action')
Esempio n. 29
0
 def test_007_extraneous_data(self):
     """ Get a valid packet but with a boxload of data.
     We should be happy and drop the extra data on the floor.
     """
     with self.assertRaises(VaporHTTPError) as ctx:
         http.get(PREFIX + '/scan/rack_1/00000003')
     self.assert_scan_registration_failure(ctx)
Esempio n. 30
0
    def test_012_read_temperature_invalid(self):
        """ Read invalid temperature value (invalid)
        """
        with self.assertRaises(VaporHTTPError) as ctx:
            http.get(PREFIX + '/read/temperature/rack_1/00000015/0002')

        self.assertEqual(ctx.exception.status, 500)