Пример #1
0
    def test_empty_payload_no_metrics_success(self):
        processor = ipmi.TemperatureSensorNotification(None)
        counters = dict([(counter.resource_id, counter)
                         for counter in processor.process_notification(
                             ipmi_test_data.EMPTY_PAYLOAD)])

        self.assertEqual(0, len(counters), 'expected 0 readings')
Пример #2
0
    def test_ipmi_temperature_notification(self):
        """Test IPMI Temperature sensor data.

        Based on the above ipmi_testdata the expected sample for a single
        temperature reading has::

        * a resource_id composed from the node_uuid Sensor ID
        * a name composed from 'hardware.ipmi.' and 'temperature'
        * a volume from the first chunk of the Sensor Reading
        * a unit from the last chunk of the Sensor Reading
        * some readings are skipped if the value is 'Disabled'
        * metatata with the node id
        """
        processor = ipmi.TemperatureSensorNotification(None)
        counters = dict([(counter.resource_id, counter)
                         for counter in processor.process_notification(
                             ipmi_test_data.SENSOR_DATA)])

        self.assertEqual(10, len(counters), 'expected 10 temperature readings')
        resource_id = (
            'f4982fd2-2f2b-4bb5-9aff-48aac801d1ad-dimm_gh_vr_temp_(0x3b)')
        test_counter = counters[resource_id]
        self.assertEqual(26.0, test_counter.volume)
        self.assertEqual('C', test_counter.unit)
        self.assertEqual(sample.TYPE_GAUGE, test_counter.type)
        self.assertEqual('hardware.ipmi.temperature', test_counter.name)
        self.assertEqual('hardware.ipmi.metrics.update',
                         test_counter.resource_metadata['event_type'])
        self.assertEqual('f4982fd2-2f2b-4bb5-9aff-48aac801d1ad',
                         test_counter.resource_metadata['node'])
Пример #3
0
    def test_missing_sensor_id(self, mylog):
        """Test for desired error message when 'Sensor ID' missing."""
        processor = ipmi.TemperatureSensorNotification(None)

        messages = []
        mylog.warn = lambda *args: messages.extend(args)

        list(processor.process_notification(ipmi_test_data.NO_SENSOR_ID))

        self.assertEqual(
            'invalid sensor data for missing id: missing key in payload: '
            "'Sensor ID'", messages[0])
Пример #4
0
    def test_sensor_data_malformed(self, mylog):
        processor = ipmi.TemperatureSensorNotification(None)

        messages = []
        mylog.warn = lambda *args: messages.extend(args)

        list(processor.process_notification(ipmi_test_data.BAD_SENSOR))

        self.assertEqual(
            'invalid sensor data for '
            'f4982fd2-2f2b-4bb5-9aff-48aac801d1ad-pci_riser_1_temp_(0x33): '
            'unable to parse sensor reading: some bad stuff', messages[0])
Пример #5
0
    def test_missing_sensor_data(self, mylog):
        processor = ipmi.TemperatureSensorNotification(None)

        messages = []
        mylog.warn = lambda *args: messages.extend(args)

        list(processor.process_notification(ipmi_test_data.MISSING_SENSOR))

        self.assertEqual(
            'invalid sensor data for '
            'f4982fd2-2f2b-4bb5-9aff-48aac801d1ad-pci_riser_1_temp_(0x33): '
            "missing 'Sensor Reading' in payload", messages[0])
Пример #6
0
    def test_disabed_skips_metric(self):
        """Test that a meter which a disabled volume is skipped."""
        processor = ipmi.TemperatureSensorNotification(None)
        counters = dict([(counter.resource_id, counter)
                         for counter in processor.process_notification(
                             ipmi_test_data.SENSOR_DATA)])

        self.assertEqual(10, len(counters), 'expected 10 temperature readings')

        resource_id = (
            'f4982fd2-2f2b-4bb5-9aff-48aac801d1ad-mezz_card_temp_(0x35)')

        self.assertNotIn(resource_id, counters)
Пример #7
0
    def test_missing_node_uuid(self, mylog):
        """Test for desired error message when 'node_uuid' missing.

        Presumably this will never happen given the way the data
        is created, but better defensive than dead.
        """
        processor = ipmi.TemperatureSensorNotification(None)

        messages = []
        mylog.warn = lambda *args: messages.extend(args)

        list(processor.process_notification(ipmi_test_data.NO_NODE_ID))

        self.assertEqual(
            'invalid sensor data for missing id: missing key in payload: '
            "'node_uuid'", messages[0])