Ejemplo n.º 1
0
    def _truncate(self):
        with self.config_manager.context() as config:
            store = crashstorage.PostgreSQLCrashStorage(config.database)

            connection = store.database.connection()
            cursor = connection.cursor()
            cursor.execute("""
                TRUNCATE
                    report_partition_info,
                    plugins
                CASCADE
            """)
            connection.commit()
Ejemplo n.º 2
0
    def tearDown(self):
        with self.config_manager.context() as config:
            store = crashstorage.PostgreSQLCrashStorage(config.database)

        connection = store.database.connection()
        cursor = connection.cursor()
        cursor.execute("""
            TRUNCATE
                report_partition_info,
                plugins
            CASCADE;
        """)
        connection.commit()

        super(TestIntegrationPostgresCrashData, self).tearDown()
Ejemplo n.º 3
0
    def setUp(self):
        super(TestIntegrationPostgresCrashData, self).setUp()
        self.config_manager = self._common_config_setup()
        self._truncate()
        with self.config_manager.context() as config:
            store = crashstorage.PostgreSQLCrashStorage(config.database)

        # First we need to create the partitioned tables.
        connection = store.database.connection()
        cursor = connection.cursor()
        table_data = ([
            'reports', '1', '{id,uuid}',
            '{date_processed,hangid,"product,version",reason,signature,url}',
            '{}', 'date_processed', 'TIMESTAMPTZ'
        ], [
            'raw_crashes', '4', '{uuid}', '{}', '{}', 'date_processed',
            'TIMESTAMPTZ'
        ], [
            'processed_crashes', '6', '{uuid}', '{}', '{}', 'date_processed',
            'TIMESTAMPTZ'
        ])
        query = """
            INSERT INTO report_partition_info
            (table_name, build_order, keys, indexes, fkeys, partition_column,
             timetype)
            VALUES (%s, %s, %s, %s, %s, %s, %s);
        """
        cursor.executemany(query, table_data)
        connection.commit()

        cursor.execute("SELECT weekly_report_partitions(2, '2012-03-14');")
        cursor.execute("SELECT weekly_report_partitions(2, '2012-08-20');")
        connection.commit()

        # A complete crash report (raw, dump and processed)
        fake_raw_dump_1 = 'peter is a swede'
        fake_raw_dump_2 = 'lars is a norseman'
        fake_raw_dump_3 = 'adrian is a frenchman'
        fake_dumps = {
            'upload_file_minidump': fake_raw_dump_1,
            'lars': fake_raw_dump_2,
            'adrian': fake_raw_dump_3
        }
        fake_raw = {
            'name': 'Peter',
            'uuid': '114559a5-d8e6-428c-8b88-1c1f22120314',
            'legacy_processing': 0,
            'submitted_timestamp': '2012-03-15T00:00:00',
        }
        fake_processed = a_processed_crash.copy()
        fake_processed.update({
            'name': 'Peter',
            'uuid': '114559a5-d8e6-428c-8b88-1c1f22120314',
            'completeddatetime': '2012-03-15T00:00:00',
            'date_processed': '2012-03-15T00:00:00',
            'email': '*****@*****.**',
        })

        store.save_raw_crash(fake_raw, fake_dumps,
                             '114559a5-d8e6-428c-8b88-1c1f22120314')
        store.save_processed(fake_processed)

        # A non-processed crash report
        fake_raw = {
            'name': 'Adrian',
            'uuid': '58727744-12f5-454a-bcf5-f688a2120821',
            'legacy_processing': 0,
            'submitted_timestamp': '2012-08-24'
        }

        store.save_raw_crash(fake_raw, fake_dumps,
                             '58727744-12f5-454a-bcf5-f688a2120821')