Пример #1
0
    def insert_delayed_test_data(self, guid_, testcase_address, expected_result, done=0, expires_at=DEFAULT_EXPIRATION):
        """ This method inserts rows into the delayedTestData table
            in the DB based on the given parameters where
            inserted_at (Date format) is automatically set in this method.
            :param guid_: The guid that is provided by the test case.
            (Format: str(uuid.uuid4()))
            :param testcase_address: The ID (address) of the test case.
            :param expected_result: The result string of persistent data
            that will be stored in the DB.
            :param done: (0 for test not done or 1 for test done)
            :returns: True (when no exceptions or errors occur)
        """
        inserted_at = int(time.time() * 1000)

        db = DatabaseManager()
        query = """INSERT INTO delayedTestData(
                   guid,testcaseAddress,insertedAt,
                   expectedResult,done,expiresAt)
                   VALUES (%(guid)s,%(testcaseAddress)s,%(inserted_at)s,
                           %(expected_result)s,%(done)s,%(expires_at)s)"""

        db.execute_query_and_close(
            query,
            {
                "guid": guid_,
                "testcaseAddress": testcase_address,
                "inserted_at": inserted_at,
                "expected_result": expected_result,
                "done": done,
                "expires_at": inserted_at + expires_at,
            },
        )
        return True
Пример #2
0
 def get_delayed_test_data(self, testcase_address, done=0):
     """ This method queries the delayedTestData table in the DB and
         then returns a list of rows with the matching parameters.
         :param testcase_address: The ID (address) of the test case.
         :param done: (0 for test not done or 1 for test done)
         :returns: A list of rows found with the matching testcase_address.
     """
     db = DatabaseManager()
     query = """SELECT guid,testcaseAddress,insertedAt,expectedResult,done
                FROM delayedTestData
                WHERE testcaseAddress=%(testcase_address)s
                AND done=%(done)s"""
     data = db.fetchall_query_and_close(query, {
         "testcase_address": testcase_address,
         "done": done
     })
     if data:
         return data
     else:
         logging.debug("Could not find any rows in delayedTestData.")
         logging.debug("DB Query = " + query % {
             "testcase_address": testcase_address,
             "done": done
         })
         return []
Пример #3
0
 def set_delayed_test_to_done(self, guid_):
     """ This method updates the delayedTestData table in the DB
         to set the test with the selected guid to done.
         :param guid_: The guid that is provided by the test case.
         (Format: str(uuid.uuid4()))
         :returns: True (when no exceptions or errors occur)
     """
     db = DatabaseManager()
     query = """UPDATE delayedTestData
                SET done=TRUE
                WHERE guid=%(guid)s
                AND done=FALSE"""
     db.execute_query_and_close(query, {"guid": guid_})
     return True
Пример #4
0
 def set_delayed_test_to_done(self, guid_):
     """ This method updates the delayedTestData table in the DB
         to set the test with the selected guid to done.
         :param guid_: The guid that is provided by the test case.
         (Format: str(uuid.uuid4()))
         :returns: True (when no exceptions or errors occur)
     """
     db = DatabaseManager()
     query = """UPDATE delayedTestData
                SET done=TRUE
                WHERE guid=%(guid)s
                AND done=FALSE"""
     db.execute_query_and_close(query, {"guid": guid_})
     return True
Пример #5
0
    def update_testcase_log_url(self, testcase_payload):
        """updates an existing testcase run's logging URL in the database"""

        query = """UPDATE testcaseRunData
                   SET logURL=%(logURL)s
                   WHERE guid=%(guid)s """
        DatabaseManager(self.database_env).execute_query_and_close(
            query, testcase_payload.get_params())
Пример #6
0
 def update_execution_data(self, execution_guid, execution_time):
     """ Updates an existing test execution row in the database. """
     query = """UPDATE test_execution
                SET total_execution_time=%(execution_time)s
                WHERE guid=%(execution_guid)s """
     DatabaseManager(self.database_env).execute_query(
         query,
         {"execution_guid": execution_guid,
          "execution_time": execution_time})
Пример #7
0
 def get_delayed_test_data(self, testcase_address, done=0):
     """ This method queries the delayedTestData table in the DB and
         then returns a list of rows with the matching parameters.
         :param testcase_address: The ID (address) of the test case.
         :param done: (0 for test not done or 1 for test done)
         :returns: A list of rows found with the matching testcase_address.
     """
     db = DatabaseManager()
     query = """SELECT guid,testcaseAddress,insertedAt,expectedResult,done
                FROM delayedTestData
                WHERE testcaseAddress=%(testcase_address)s
                AND done=%(done)s"""
     data = db.fetchall_query_and_close(query, {"testcase_address": testcase_address, "done": done})
     if data:
         return data
     else:
         logging.debug("Could not find any rows in delayedTestData.")
         logging.debug("DB Query = " + query % {"testcase_address": testcase_address, "done": done})
         return []
Пример #8
0
 def update_testcase_data(self, testcase_payload):
     """Updates an existing test run in the database."""
     query = """UPDATE test_run_data SET
                         runtime=%(runtime)s,
                         state=%(state)s,
                         retry_count=%(retry_count)s,
                         stack_trace=%(stack_trace)s,
                         message=%(message)s
                         WHERE guid=%(guid)s """
     DatabaseManager(self.database_env).execute_query(
         query, testcase_payload.get_params())
Пример #9
0
    def update_execution_data(self, execution_guid, execution_time):
        """updates an existing execution in the database"""

        query = """UPDATE execution
                   SET totalExecutionTime=%(execution_time)s
                   WHERE guid=%(execution_guid)s """
        DatabaseManager(self.database_env).execute_query_and_close(
            query, {
                "execution_guid": execution_guid,
                "execution_time": execution_time
            })
Пример #10
0
    def insert_execution_data(self, execution_query_payload):
        """ Inserts an execution into the database.
            Returns the execution guid. """

        query = """INSERT INTO execution
                   (guid, executionStart, totalExecutionTime, username)
                   VALUES (%(guid)s,%(execution_start_time)s,
                           %(total_execution_time)s,%(username)s)"""
        DatabaseManager(self.database_env).execute_query_and_close(
            query, execution_query_payload.get_params())
        return execution_query_payload.guid
Пример #11
0
    def update_testcase_data(self, testcase_payload):
        """updates an existing testcase run in the database"""

        query = """UPDATE testcaseRunData SET
                          runtime=%(runtime)s,
                          state=%(state)s,
                          retryCount=%(retryCount)s,
                          stackTrace=%(stackTrace)s,
                          message=%(message)s
                          WHERE guid=%(guid)s """
        DatabaseManager(self.database_env).execute_query_and_close(
            query, testcase_payload.get_params())
Пример #12
0
    def insert_execution_data(self, execution_query_payload):
        """Inserts a test execution row into the database.
        Returns the execution guid.
        "execution_start_time" is defined by milliseconds since the Epoch.
        (See https://currentmillis.com to convert that to a real date.)"""

        query = """INSERT INTO test_execution
                   (guid, execution_start, total_execution_time, username)
                   VALUES (%(guid)s,%(execution_start_time)s,
                           %(total_execution_time)s,%(username)s)"""
        DatabaseManager(self.database_env).execute_query(
            query, execution_query_payload.get_params())
        return execution_query_payload.guid
Пример #13
0
    def insert_delayed_test_data(self,
                                 guid_,
                                 testcase_address,
                                 expected_result,
                                 done=0,
                                 expires_at=DEFAULT_EXPIRATION):
        """ This method inserts rows into the delayedTestData table
            in the DB based on the given parameters where
            inserted_at (Date format) is automatically set in this method.
            :param guid_: The guid that is provided by the test case.
            (Format: str(uuid.uuid4()))
            :param testcase_address: The ID (address) of the test case.
            :param expected_result: The result string of persistent data
            that will be stored in the DB.
            :param done: (0 for test not done or 1 for test done)
            :returns: True (when no exceptions or errors occur)
        """
        inserted_at = int(time.time() * 1000)

        db = DatabaseManager()
        query = """INSERT INTO delayedTestData(
                   guid,testcaseAddress,insertedAt,
                   expectedResult,done,expiresAt)
                   VALUES (%(guid)s,%(testcaseAddress)s,%(inserted_at)s,
                           %(expected_result)s,%(done)s,%(expires_at)s)"""

        db.execute_query_and_close(
            query, {
                "guid": guid_,
                "testcaseAddress": testcase_address,
                "inserted_at": inserted_at,
                "expected_result": expected_result,
                "done": done,
                "expires_at": inserted_at + expires_at
            })
        return True
Пример #14
0
 def insert_testcase_data(self, testcase_run_payload):
     """Inserts all data for the test in the DB. Returns new row guid."""
     query = """INSERT INTO test_run_data(
                guid, browser, state, execution_guid, env, start_time,
                test_address, runtime, retry_count, message, stack_trace)
                       VALUES (
                           %(guid)s,
                           %(browser)s,
                           %(state)s,
                           %(execution_guid)s,
                           %(env)s,
                           %(start_time)s,
                           %(test_address)s,
                           %(runtime)s,
                           %(retry_count)s,
                           %(message)s,
                           %(stack_trace)s) """
     DatabaseManager(self.database_env).execute_query(
         query, testcase_run_payload.get_params())
Пример #15
0
    def insert_testcase_data(self, testcase_run_payload):
        """inserts all data for the test case, returns the new row guid"""

        query = """INSERT INTO testcaseRunData
                   (guid, browser, state, execution_guid, env, start_time,
                    testcaseAddress, runtime, retryCount, message, stackTrace)
                          VALUES (
                              %(guid)s,
                              %(browser)s,
                              %(state)s,
                              %(execution_guid)s,
                              %(env)s,
                              %(start_time)s,
                              %(testcaseAddress)s,
                              %(runtime)s,
                              %(retryCount)s,
                              %(message)s,
                              %(stackTrace)s) """
        DatabaseManager(self.database_env).execute_query_and_close(
            query, testcase_run_payload.get_params())
Пример #16
0
 def update_testcase_log_url(self, testcase_payload):
     query = """UPDATE test_run_data
                SET log_url=%(log_url)s
                WHERE guid=%(guid)s """
     DatabaseManager(self.database_env).execute_query(
         query, testcase_payload.get_params())