grr/server/grr_response_server/db_utils_test.py
def testStatsEntryId_IgnoreMetricValues(self):
    """Ensures metric values have no influence id generation."""
    int_entry = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.INT, int_value=42),
        timestamp=_one_second_timestamp)
    float_entry = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.FLOAT,
            float_value=4.2),
        timestamp=_one_second_timestamp)
    # TODO: String gauges are deprecated.
    str_entry = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.DEPRECATED_STR,
            str_value="foo"),
        timestamp=_one_second_timestamp)
    distribution_entry = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.DISTRIBUTION,
            distribution_value=rdf_stats.Distribution()),
        timestamp=_one_second_timestamp)

    expected_id = (
        b"\x8e\xf4\xe7\xdb\x03\x01}sB\x97\x98\x957\x18\x02U\xb0\xe6x\x9f"
        b"\x97Xfs/C\xedT\xd3\x89N\xe5")
    self.assertEqual(db_utils.GenerateStatsEntryId(int_entry), expected_id)
    self.assertEqual(db_utils.GenerateStatsEntryId(float_entry), expected_id)
    self.assertEqual(db_utils.GenerateStatsEntryId(str_entry), expected_id)
    self.assertEqual(
        db_utils.GenerateStatsEntryId(distribution_entry), expected_id)
Ensures metric values have no influence id generation.
Ensures metric values have no influence id generation.
Ensures metric values have no influence id generation .
def testStatsEntryId_IgnoreMetricValues(self):
    int_entry = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.INT, int_value=42),
        timestamp=_one_second_timestamp)
    float_entry = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.FLOAT,
            float_value=4.2),
        timestamp=_one_second_timestamp)
    str_entry = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.DEPRECATED_STR,
            str_value="foo"),
        timestamp=_one_second_timestamp)
    distribution_entry = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.DISTRIBUTION,
            distribution_value=rdf_stats.Distribution()),
        timestamp=_one_second_timestamp)
    expected_id = (
        b"\x8e\xf4\xe7\xdb\x03\x01}sB\x97\x98\x957\x18\x02U\xb0\xe6x\x9f"
        b"\x97Xfs/C\xedT\xd3\x89N\xe5")
    self.assertEqual(db_utils.GenerateStatsEntryId(int_entry), expected_id)
    self.assertEqual(db_utils.GenerateStatsEntryId(float_entry), expected_id)
    self.assertEqual(db_utils.GenerateStatsEntryId(str_entry), expected_id)
    self.assertEqual(
        db_utils.GenerateStatsEntryId(distribution_entry), expected_id)
def testStatsEntryId_IgnoreMetricValues ( self ) : int_entry = stats_values . StatsStoreEntry ( process_id = "test_process" , metric_name = "test_metric" , metric_value = stats_values . StatsStoreValue ( value_type = rdf_stats . MetricMetadata . ValueType . INT , int_value = 42 ) , timestamp = _one_second_timestamp ) float_entry = stats_values . StatsStoreEntry ( process_id = "test_process" , metric_name = "test_metric" , metric_value = stats_values . StatsStoreValue ( value_type = rdf_stats . MetricMetadata . ValueType . FLOAT , float_value = 4.2 ) , timestamp = _one_second_timestamp ) str_entry = stats_values . StatsStoreEntry ( process_id = "test_process" , metric_name = "test_metric" , metric_value = stats_values . StatsStoreValue ( value_type = rdf_stats . MetricMetadata . ValueType . DEPRECATED_STR , str_value = "foo" ) , timestamp = _one_second_timestamp ) distribution_entry = stats_values . StatsStoreEntry ( process_id = "test_process" , metric_name = "test_metric" , metric_value = stats_values . StatsStoreValue ( value_type = rdf_stats . MetricMetadata . ValueType . DISTRIBUTION , distribution_value = rdf_stats . Distribution ( ) ) , timestamp = _one_second_timestamp ) expected_id = ( b"\x8e\xf4\xe7\xdb\x03\x01}sB\x97\x98\x957\x18\x02U\xb0\xe6x\x9f" b"\x97Xfs/C\xedT\xd3\x89N\xe5" ) self . assertEqual ( db_utils . GenerateStatsEntryId ( int_entry ) , expected_id ) self . assertEqual ( db_utils . GenerateStatsEntryId ( float_entry ) , expected_id ) self . assertEqual ( db_utils . GenerateStatsEntryId ( str_entry ) , expected_id ) self . assertEqual ( db_utils . GenerateStatsEntryId ( distribution_entry ) , expected_id )
Ensures metric values have no influence id generation.
Ensures metric values have no influence id generation .
"""Ensures metric values have no influence id generation.""" # TODO: String gauges are deprecated.
self