grr/server/grr_response_server/db_utils_test.py
def testStatsEntryId_VaryStringDimensions(self):
    """Ensures StatsEntries with different str dimensions get different ids."""
    entry1 = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.INT,
            fields_values=[
                stats_values.StatsStoreFieldValue(
                    field_type=rdf_stats.MetricFieldDefinition.FieldType.STR,
                    str_value="dim1"),
                stats_values.StatsStoreFieldValue(
                    field_type=rdf_stats.MetricFieldDefinition.FieldType.STR,
                    str_value="dim2")
            ],
            int_value=42),
        timestamp=_one_second_timestamp)

    # Clone entry1 and change a single dimension value.
    entry2 = stats_values.StatsStoreEntry()
    entry2.FromDict(entry1.ToPrimitiveDict())
    entry2.metric_value.fields_values[0].str_value = "dim3"

    self.assertEqual(
        db_utils.GenerateStatsEntryId(entry1),
        b"\xb8'\x1cv\xf9`\x90\xd1\x9d#{\x8a'y\xd8E\x0bx\x1b6f\xe6\x8d\x16\xb95"
        b"\x0011uy\xf9")
    self.assertEqual(
        db_utils.GenerateStatsEntryId(entry2),
        b"\xa4\xcb\x95*\xe4\x8aclM&@\xde\xba\x17\xec\x02\xc6i\xea\xc0\x1a{bQ"
        b"\xabr~w}Z\xb9\x99")
Ensures StatsEntries with different str dimensions get different ids.
Ensures StatsEntries with different str dimensions get different ids.
Ensures StatsEntries with different str dimensions get different ids .
def testStatsEntryId_VaryStringDimensions(self):
    entry1 = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.INT,
            fields_values=[
                stats_values.StatsStoreFieldValue(
                    field_type=rdf_stats.MetricFieldDefinition.FieldType.STR,
                    str_value="dim1"),
                stats_values.StatsStoreFieldValue(
                    field_type=rdf_stats.MetricFieldDefinition.FieldType.STR,
                    str_value="dim2")
            ],
            int_value=42),
        timestamp=_one_second_timestamp)
    entry2 = stats_values.StatsStoreEntry()
    entry2.FromDict(entry1.ToPrimitiveDict())
    entry2.metric_value.fields_values[0].str_value = "dim3"
    self.assertEqual(
        db_utils.GenerateStatsEntryId(entry1),
        b"\xb8'\x1cv\xf9`\x90\xd1\x9d#{\x8a'y\xd8E\x0bx\x1b6f\xe6\x8d\x16\xb95"
        b"\x0011uy\xf9")
    self.assertEqual(
        db_utils.GenerateStatsEntryId(entry2),
        b"\xa4\xcb\x95*\xe4\x8aclM&@\xde\xba\x17\xec\x02\xc6i\xea\xc0\x1a{bQ"
        b"\xabr~w}Z\xb9\x99")
def testStatsEntryId_VaryStringDimensions ( self ) : entry1 = stats_values . StatsStoreEntry ( process_id = "test_process" , metric_name = "test_metric" , metric_value = stats_values . StatsStoreValue ( value_type = rdf_stats . MetricMetadata . ValueType . INT , fields_values = [ stats_values . StatsStoreFieldValue ( field_type = rdf_stats . MetricFieldDefinition . FieldType . STR , str_value = "dim1" ) , stats_values . StatsStoreFieldValue ( field_type = rdf_stats . MetricFieldDefinition . FieldType . STR , str_value = "dim2" ) ] , int_value = 42 ) , timestamp = _one_second_timestamp ) entry2 = stats_values . StatsStoreEntry ( ) entry2 . FromDict ( entry1 . ToPrimitiveDict ( ) ) entry2 . metric_value . fields_values [ 0 ] . str_value = "dim3" self . assertEqual ( db_utils . GenerateStatsEntryId ( entry1 ) , b"\xb8'\x1cv\xf9`\x90\xd1\x9d#{\x8a'y\xd8E\x0bx\x1b6f\xe6\x8d\x16\xb95" b"\x0011uy\xf9" ) self . assertEqual ( db_utils . GenerateStatsEntryId ( entry2 ) , b"\xa4\xcb\x95*\xe4\x8aclM&@\xde\xba\x17\xec\x02\xc6i\xea\xc0\x1a{bQ" b"\xabr~w}Z\xb9\x99" )
Ensures StatsEntries with different str dimensions get different ids.
Ensures StatsEntries with different str dimensions get different ids .
"""Ensures StatsEntries with different str dimensions get different ids.""" # Clone entry1 and change a single dimension value.
self