Beispiel #1
0
 def _import_test_run(self, c_test_run, s_bundle):
     s_test_run = super(BundleFormatImporter_1_4, self)._import_test_run(c_test_run, s_bundle)
     test_duration = c_test_run.get('test_duration')
     if test_duration is not None:
         test_duration = timedelta_extension.from_json(test_duration)
         s_test_run.test_duration = test_duration
         s_test_run.save()
     return s_test_run
 def _import_test_run(self, c_test_run, s_bundle):
     s_test_run = super(BundleFormatImporter_1_4,
                        self)._import_test_run(c_test_run, s_bundle)
     test_duration = c_test_run.get('test_duration')
     if test_duration is not None:
         test_duration = timedelta_extension.from_json(test_duration)
         s_test_run.test_duration = test_duration
         s_test_run.save()
     return s_test_run
    def _import_test_results_pgsql(self, c_test_results, s_test_run):
        cursor = connection.cursor()

        # XXX I don't understand how the _order column that Django adds is
        # supposed to work.  I just let it default to 0 here.

        data = []

        for i in range(0, len(c_test_results), 1000):

            cursor.execute("""
                CREATE TEMPORARY TABLE newtestresults (
                    relative_index INTEGER,
                    timestamp      TIMESTAMP WITH TIME ZONE,
                    microseconds   BIGINT,
                    filename       TEXT,
                    result         SMALLINT,
                    measurement    NUMERIC(20,10),
                    message        TEXT,
                    test_case_id   TEXT,
                    lineno         INTEGER
                    )
                """)

            data = []

            for index, c_test_result in enumerate(c_test_results[i:i + 1000],
                                                  i + 1):

                timestamp = c_test_result.get("timestamp")
                if timestamp:
                    timestamp = datetime_extension.from_json(timestamp)
                duration = c_test_result.get("duration", None)
                if duration:
                    duration = timedelta_extension.from_json(duration)
                    duration = (duration.microseconds +
                                (duration.seconds * 10**6) +
                                (duration.days * 24 * 60 * 60 * 10**6))
                result = self._translate_result_string(c_test_result["result"])

                data.extend([
                    index,
                    timestamp,
                    duration,
                    c_test_result.get("log_filename", None),
                    result,
                    c_test_result.get("measurement", None),
                    c_test_result.get("message", None),
                    c_test_result.get("test_case_id", None),
                    c_test_result.get("log_lineno", None),
                ])

            sequel = ',\n'.join(["(" + "%s" %
                                 (', '.join(['%s'] * 9), ) + ")"] *
                                (len(data) // 9))

            cursor.execute(
                """
                INSERT INTO newtestresults (
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    test_case_id,
                    lineno
                ) VALUES """ + sequel, data)

            cursor.execute("""
                INSERT INTO dashboard_app_testresult (
                    test_run_id,
                    _order,
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    test_case_id,
                    lineno
                ) SELECT
                    %s,
                    %s,
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    dashboard_app_testcase.id,
                    lineno
                    FROM newtestresults, dashboard_app_testcase
                      WHERE dashboard_app_testcase.test_id = %s
                        AND dashboard_app_testcase.test_case_id
                          = newtestresults.test_case_id
                """ % (s_test_run.id, 0, s_test_run.test.id))

            cursor.execute("""
                DROP TABLE newtestresults
                """)

        cursor.close()
    def _import_test_results_sqlite(self, c_test_results, s_test_run):
        cursor = connection.cursor()

        # XXX I don't understand how the _order column that Django adds is
        # supposed to work.  I just set it to 0 here.

        data = []

        for index, c_test_result in enumerate(c_test_results, 1):

            timestamp = c_test_result.get("timestamp")
            if timestamp:
                timestamp = datetime_extension.from_json(timestamp)
            duration = c_test_result.get("duration", None)
            if duration:
                duration = timedelta_extension.from_json(duration)
                duration = (duration.microseconds +
                            (duration.seconds * 10**6) +
                            (duration.days * 24 * 60 * 60 * 10**6))
            result = self._translate_result_string(c_test_result["result"])

            data.append((
                s_test_run.id,
                index,
                timestamp,
                duration,
                c_test_result.get("log_filename", None),
                result,
                c_test_result.get("measurement", None),
                c_test_result.get("message", None),
                c_test_result.get("log_lineno", None),
                s_test_run.test.id,
                c_test_result.get("test_case_id", None),
            ))

        cursor.executemany(
            """
            INSERT INTO dashboard_app_testresult (
                test_run_id,
                relative_index,
                timestamp,
                microseconds,
                filename,
                result,
                measurement,
                message,
                lineno,
                _order,
                test_case_id
            ) select
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                0,
                dashboard_app_testcase.id
                FROM dashboard_app_testcase
                  WHERE dashboard_app_testcase.test_id = %s
                    AND dashboard_app_testcase.test_case_id
                      = %s
            """, data)

        cursor.close()
Beispiel #5
0
    def _import_test_results_pgsql(self, c_test_results, s_test_run):
        cursor = connection.cursor()

        # _order has been removed as order_with_respect_to and ordering
        # where never compatible for the same Meta object in Django and
        # django1.9 blocks use of the two elements together.

        data = []

        for i in range(0, len(c_test_results), 1000):

            cursor.execute("""
                CREATE TEMPORARY TABLE newtestresults (
                    relative_index INTEGER,
                    timestamp      TIMESTAMP WITH TIME ZONE,
                    microseconds   BIGINT,
                    filename       TEXT,
                    result         SMALLINT,
                    measurement    CHARACTER VARYING(512),
                    message        TEXT,
                    test_case_id   TEXT,
                    lineno         INTEGER
                    )
                """)

            data = []

            for index, c_test_result in enumerate(c_test_results[i:i + 1000],
                                                  i + 1):

                timestamp = c_test_result.get("timestamp")
                if timestamp:
                    timestamp = datetime_extension.from_json(timestamp)
                duration = c_test_result.get("duration", None)
                if duration:
                    duration = timedelta_extension.from_json(duration)
                    duration = (duration.microseconds +
                                (duration.seconds * 10**6) +
                                (duration.days * 24 * 60 * 60 * 10**6))
                result = self._translate_result_string(c_test_result["result"])

                data.extend([
                    index,
                    timestamp,
                    duration,
                    c_test_result.get("log_filename", None),
                    result,
                    c_test_result.get("measurement", None),
                    c_test_result.get("message", None),
                    c_test_result.get("test_case_id", None),
                    c_test_result.get("log_lineno", None),
                ])

            sequel = ',\n'.join(["(" + "%s" %
                                 (', '.join(['%s'] * 9), ) + ")"] *
                                (len(data) // 9))

            cursor.execute(
                """
                INSERT INTO newtestresults (
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    test_case_id,
                    lineno
                ) VALUES """ + sequel, data)

            cursor.execute("""
                INSERT INTO dashboard_app_testresult (
                    test_run_id,
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    test_case_id,
                    lineno
                ) SELECT
                    %s,
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    dashboard_app_testcase.id,
                    lineno
                    FROM newtestresults, dashboard_app_testcase
                      WHERE dashboard_app_testcase.test_id = %s
                        AND dashboard_app_testcase.test_case_id
                          = newtestresults.test_case_id
                """ % (s_test_run.id, s_test_run.test.id))

            cursor.execute("""
                DROP TABLE newtestresults
                """)

        cursor.close()
Beispiel #6
0
    def _import_test_results_sqlite(self, c_test_results, s_test_run):
        cursor = connection.cursor()

        # _order has been removed as order_with_respect_to and ordering
        # where never compatible for the same Meta object in Django and
        # django1.9 blocks use of the two elements together.

        data = []

        for index, c_test_result in enumerate(c_test_results, 1):

            timestamp = c_test_result.get("timestamp")
            if timestamp:
                timestamp = datetime_extension.from_json(timestamp)
            duration = c_test_result.get("duration", None)
            if duration:
                duration = timedelta_extension.from_json(duration)
                duration = (duration.microseconds +
                            (duration.seconds * 10**6) +
                            (duration.days * 24 * 60 * 60 * 10**6))
            result = self._translate_result_string(c_test_result["result"])

            data.append((
                s_test_run.id,
                index,
                timestamp,
                duration,
                c_test_result.get("log_filename", None),
                result,
                c_test_result.get("measurement", None),
                c_test_result.get("message", None),
                c_test_result.get("log_lineno", None),
                s_test_run.test.id,
                c_test_result.get("test_case_id", None),
            ))

        cursor.executemany(
            """
            INSERT INTO dashboard_app_testresult (
                test_run_id,
                relative_index,
                timestamp,
                microseconds,
                filename,
                result,
                measurement,
                message,
                lineno,
                test_case_id
            ) select
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                dashboard_app_testcase.id
                FROM dashboard_app_testcase
                  WHERE dashboard_app_testcase.test_id = %s
                    AND dashboard_app_testcase.test_case_id
                      = %s
            """, data)

        cursor.close()
Beispiel #7
0
    def _import_test_results_pgsql(self, c_test_results, s_test_run):
        cursor = connection.cursor()

        # XXX I don't understand how the _order column that Django adds is
        # supposed to work.  I just let it default to 0 here.

        data = []

        for i in range(0, len(c_test_results), 1000):

            cursor.execute(
                """
                CREATE TEMPORARY TABLE newtestresults (
                    relative_index INTEGER,
                    timestamp      TIMESTAMP WITH TIME ZONE,
                    microseconds   BIGINT,
                    filename       TEXT,
                    result         SMALLINT,
                    measurement    CHARACTER VARYING(512),
                    message        TEXT,
                    test_case_id   TEXT,
                    lineno         INTEGER
                    )
                """)

            data = []

            for index, c_test_result in enumerate(c_test_results[i:i + 1000], i + 1):

                timestamp = c_test_result.get("timestamp")
                if timestamp:
                    timestamp = datetime_extension.from_json(timestamp)
                duration = c_test_result.get("duration", None)
                if duration:
                    duration = timedelta_extension.from_json(duration)
                    duration = (duration.microseconds +
                                (duration.seconds * 10 ** 6) +
                                (duration.days * 24 * 60 * 60 * 10 ** 6))
                result = self._translate_result_string(c_test_result["result"])

                data.extend([
                    index,
                    timestamp,
                    duration,
                    c_test_result.get("log_filename", None),
                    result,
                    c_test_result.get("measurement", None),
                    c_test_result.get("message", None),
                    c_test_result.get("test_case_id", None),
                    c_test_result.get("log_lineno", None),
                ])

            sequel = ',\n'.join(
                ["(" + "%s" % (', '.join(['%s'] * 9),) + ")"] * (len(data) // 9))

            cursor.execute(
                """
                INSERT INTO newtestresults (
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    test_case_id,
                    lineno
                ) VALUES """ + sequel, data)

            cursor.execute(
                """
                INSERT INTO dashboard_app_testresult (
                    test_run_id,
                    _order,
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    test_case_id,
                    lineno
                ) SELECT
                    %s,
                    %s,
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    dashboard_app_testcase.id,
                    lineno
                    FROM newtestresults, dashboard_app_testcase
                      WHERE dashboard_app_testcase.test_id = %s
                        AND dashboard_app_testcase.test_case_id
                          = newtestresults.test_case_id
                """ % (s_test_run.id, 0, s_test_run.test.id))

            cursor.execute(
                """
                DROP TABLE newtestresults
                """)

        cursor.close()
Beispiel #8
0
    def _import_test_results_sqlite(self, c_test_results, s_test_run):
        cursor = connection.cursor()

        # XXX I don't understand how the _order column that Django adds is
        # supposed to work.  I just set it to 0 here.

        data = []

        for index, c_test_result in enumerate(c_test_results, 1):

            timestamp = c_test_result.get("timestamp")
            if timestamp:
                timestamp = datetime_extension.from_json(timestamp)
            duration = c_test_result.get("duration", None)
            if duration:
                duration = timedelta_extension.from_json(duration)
                duration = (duration.microseconds +
                            (duration.seconds * 10 ** 6) +
                            (duration.days * 24 * 60 * 60 * 10 ** 6))
            result = self._translate_result_string(c_test_result["result"])

            data.append((
                s_test_run.id,
                index,
                timestamp,
                duration,
                c_test_result.get("log_filename", None),
                result,
                c_test_result.get("measurement", None),
                c_test_result.get("message", None),
                c_test_result.get("log_lineno", None),
                s_test_run.test.id,
                c_test_result.get("test_case_id", None),
            ))

        cursor.executemany(
            """
            INSERT INTO dashboard_app_testresult (
                test_run_id,
                relative_index,
                timestamp,
                microseconds,
                filename,
                result,
                measurement,
                message,
                lineno,
                _order,
                test_case_id
            ) select
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                0,
                dashboard_app_testcase.id
                FROM dashboard_app_testcase
                  WHERE dashboard_app_testcase.test_id = %s
                    AND dashboard_app_testcase.test_case_id
                      = %s
            """, data)

        cursor.close()
Beispiel #9
0
    def _import_test_results_pgsql(self, c_test_results, s_test_run):
        cursor = connection.cursor()

        # _order has been removed as order_with_respect_to and ordering
        # where never compatible for the same Meta object in Django and
        # django1.9 blocks use of the two elements together.

        data = []

        for i in range(0, len(c_test_results), 1000):

            cursor.execute(
                """
                CREATE TEMPORARY TABLE newtestresults (
                    relative_index INTEGER,
                    timestamp      TIMESTAMP WITH TIME ZONE,
                    microseconds   BIGINT,
                    filename       TEXT,
                    result         SMALLINT,
                    measurement    CHARACTER VARYING(512),
                    message        TEXT,
                    test_case_id   TEXT,
                    lineno         INTEGER
                    )
                """)

            data = []

            for index, c_test_result in enumerate(c_test_results[i:i + 1000], i + 1):

                timestamp = c_test_result.get("timestamp")
                if timestamp:
                    timestamp = datetime_extension.from_json(timestamp)
                duration = c_test_result.get("duration", None)
                if duration:
                    duration = timedelta_extension.from_json(duration)
                    duration = (duration.microseconds +
                                (duration.seconds * 10 ** 6) +
                                (duration.days * 24 * 60 * 60 * 10 ** 6))
                result = self._translate_result_string(c_test_result["result"])

                data.extend([
                    index,
                    timestamp,
                    duration,
                    c_test_result.get("log_filename", None),
                    result,
                    c_test_result.get("measurement", None),
                    c_test_result.get("message", None),
                    c_test_result.get("test_case_id", None),
                    c_test_result.get("log_lineno", None),
                ])

            sequel = ',\n'.join(
                ["(" + "%s" % (', '.join(['%s'] * 9),) + ")"] * (len(data) // 9))

            cursor.execute(
                """
                INSERT INTO newtestresults (
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    test_case_id,
                    lineno
                ) VALUES """ + sequel, data)

            cursor.execute(
                """
                INSERT INTO dashboard_app_testresult (
                    test_run_id,
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    test_case_id,
                    lineno
                ) SELECT
                    %s,
                    relative_index,
                    timestamp,
                    microseconds,
                    filename,
                    result,
                    measurement,
                    message,
                    dashboard_app_testcase.id,
                    lineno
                    FROM newtestresults, dashboard_app_testcase
                      WHERE dashboard_app_testcase.test_id = %s
                        AND dashboard_app_testcase.test_case_id
                          = newtestresults.test_case_id
                """ % (s_test_run.id, s_test_run.test.id))

            cursor.execute(
                """
                DROP TABLE newtestresults
                """)

        cursor.close()
Beispiel #10
0
    def _import_test_results_sqlite(self, c_test_results, s_test_run):
        cursor = connection.cursor()

        # _order has been removed as order_with_respect_to and ordering
        # where never compatible for the same Meta object in Django and
        # django1.9 blocks use of the two elements together.

        data = []

        for index, c_test_result in enumerate(c_test_results, 1):

            timestamp = c_test_result.get("timestamp")
            if timestamp:
                timestamp = datetime_extension.from_json(timestamp)
            duration = c_test_result.get("duration", None)
            if duration:
                duration = timedelta_extension.from_json(duration)
                duration = (duration.microseconds +
                            (duration.seconds * 10 ** 6) +
                            (duration.days * 24 * 60 * 60 * 10 ** 6))
            result = self._translate_result_string(c_test_result["result"])

            data.append((
                s_test_run.id,
                index,
                timestamp,
                duration,
                c_test_result.get("log_filename", None),
                result,
                c_test_result.get("measurement", None),
                c_test_result.get("message", None),
                c_test_result.get("log_lineno", None),
                s_test_run.test.id,
                c_test_result.get("test_case_id", None),
            ))

        cursor.executemany(
            """
            INSERT INTO dashboard_app_testresult (
                test_run_id,
                relative_index,
                timestamp,
                microseconds,
                filename,
                result,
                measurement,
                message,
                lineno,
                test_case_id
            ) select
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                %s,
                dashboard_app_testcase.id
                FROM dashboard_app_testcase
                  WHERE dashboard_app_testcase.test_id = %s
                    AND dashboard_app_testcase.test_case_id
                      = %s
            """, data)

        cursor.close()