Esempio n. 1
0
    def setUp(self):
        super(DebuggerPollResult, self).setUp()
        self.schema_data = parent_node_dict['schema'][-1]
        self.server_id = self.schema_data['server_id']
        self.db_id = self.schema_data['db_id']
        self.schema_id = self.schema_data['schema_id']

        local_self = funcs_utils.set_up(self)

        self.test_data['funcowner'] = self.server["username"]

        function_info = debugger_utils.create_function(self, utils)

        self.func_id = json.loads(function_info.data)['node']['_id']

        if self.add_extension:
            debugger_utils.add_extension(self, utils, db_utils=db_utils)

        init_debugger = debugger_utils.init_debugger_function(self)

        self.trans_id = json.loads(init_debugger.data)['data']['trans_id']

        if self.init_target:
            debugger_utils.initialize_target(self, utils)

            debugger_utils.start_listener(self, utils, db_utils)
Esempio n. 2
0
    def setUp(self):
        super(RestartDebugger, self).setUp()
        self.schema_data = parent_node_dict['schema'][-1]
        self.server_id = self.schema_data['server_id']
        self.db_id = self.schema_data['db_id']
        self.schema_id = self.schema_data['schema_id']

        local_self = funcs_utils.set_up(self)

        func_name = "test_function_%s" % str(uuid.uuid4())[1:8]
        function_info = funcs_utils.create_function(local_self.server,
                                                    local_self.db_name,
                                                    local_self.schema_name,
                                                    func_name)

        self.func_id = function_info[0]

        if self.add_extension:
            debugger_utils.add_extension(self, utils, db_utils=db_utils)

        init_debugger = debugger_utils.init_debugger_function(self)

        self.trans_id = json.loads(init_debugger.data)['data']['trans_id']

        if self.init_target:
            debugger_utils.initialize_target(self, utils)
Esempio n. 3
0
    def setUp(self):
        super(DebuggerStartListener, self).setUp()
        self.schema_data = parent_node_dict['schema'][-1]
        self.server_id = self.schema_data['server_id']
        self.db_id = self.schema_data['db_id']
        self.schema_id = self.schema_data['schema_id']

        local_self = funcs_utils.set_up(self)

        # if self.server['type'] == 'pg':
        #     self.skipTest('Skipping test case for pg')

        self.test_data['funcowner'] = self.server["username"]

        function_info = debugger_utils.create_function(self, utils)

        self.func_id = json.loads(function_info.data)['node']['_id']

        if self.add_extension:
            debugger_utils.add_extension(self, utils, db_utils=db_utils)

        init_debugger = debugger_utils.init_debugger_function(self)
        self.trans_id = json.loads(init_debugger.data)['data']['trans_id']

        if self.init_target:
            debugger_utils.initialize_target(self, utils)
Esempio n. 4
0
    def setUp(self):
        super(InitTargetDebugger, self).setUp()
        self.debugger_error = 'The debugger plugin is not enabled. ' \
                              'Please add the plugin to the shared_preload_' \
                              'libraries setting in the postgresql.conf file' \
                              ' and restart the database server for indirect' \
                              ' debugging.'

        self.schema_data = parent_node_dict['schema'][-1]
        self.server_id = self.schema_data['server_id']
        self.db_id = self.schema_data['db_id']
        self.schema_id = self.schema_data['schema_id']

        local_self = funcs_utils.set_up(self)

        func_name = "test_function_%s" % str(uuid.uuid4())[1:8]
        function_info = funcs_utils.create_function(local_self.server,
                                                    local_self.db_name,
                                                    local_self.schema_name,
                                                    func_name)

        self.func_id = function_info[0]

        if self.add_extension:
            debugger_utils.add_extension(self, utils)

        init_debugger = debugger_utils.init_debugger_function(self)

        self.trans_id = json.loads(init_debugger.data)['data']['trans_id']

        if hasattr(self, 'create_trigger_func') and self.create_trigger_func:
            db_con = db_utils.connect_database(self, utils.SERVER_GROUP,
                                               self.server_id, self.db_id)
            if not db_con['data']["connected"]:
                raise Exception(
                    "Could not connect to database to delete trigger.")

            self.table_name = "table_trigger_%s" % (str(uuid.uuid4())[1:8])
            self.table_id = tables_utils.create_table(self.server,
                                                      self.db_name,
                                                      self.schema_name,
                                                      self.table_name)

            self.trigger_func_name = 'test_trigger_function_%s' % str(
                uuid.uuid4())[1:8]

            self.trigger_function_id = \
                trigger_funcs_utils.create_trigger_function_with_trigger(
                    self.server, self.db_name, self.schema_name,
                    self.trigger_func_name)[0]

            self.trigger_name = "trigger_%s" % str(uuid.uuid4())[1:8]
            self.test_data['name'] = self.trigger_name
            self.test_data['tfunction'] = "{0}.{1}".format(
                self.schema_name, self.trigger_func_name)

            self.trigger_id = debugger_utils.create_trigger(self, utils)
Esempio n. 5
0
    def setUp(self):
        super(DebuggerGetArguments, self).setUp()
        self.schema_data = parent_node_dict['schema'][-1]
        self.server_id = self.schema_data['server_id']
        self.db_id = self.schema_data['db_id']
        self.schema_id = self.schema_data['schema_id']

        local_self = funcs_utils.set_up(self)

        self.test_data['funcowner'] = self.server["username"]

        function_info = debugger_utils.create_function(self, utils)

        self.func_id = json.loads(function_info.data)['node']['_id']
    def setUp(self):
        super(InitDebugger, self).setUp()
        self.schema_data = parent_node_dict['schema'][-1]
        self.server_id = self.schema_data['server_id']
        self.db_id = self.schema_data['db_id']
        self.schema_id = self.schema_data['schema_id']

        local_self = funcs_utils.set_up(self)

        if self.invalid_name:
            db_user = self.server["username"]
            self.test_data = {"acl": [
                {
                    "grantee": db_user,
                    "grantor": db_user,
                    "privileges":
                        [
                            {
                                "privilege_type": "X",
                                "privilege": True,
                                "with_grant": True
                            }
                        ]
                }
            ], "arguments": [], "funcowner": db_user, "lanname": "sql",
                "name": "test_function_:_%s" % str(uuid.uuid4())[1:8],
                "options": [], "proleakproof": True, "pronamespace": 2200,
                "prorettypename": "integer", "prosecdef": True,
                "prosrc": "SELECT 1;", "probin": "$libdir/",
                "provolatile": "s", "seclabels": [], "variables": [{
                    "name": "search_path",
                    "value": "public, pg_temp"
                }]
            }

            function_info = debugger_utils.create_function(self, utils)
            self.func_id = json.loads(function_info.data)['node']['_id']
        else:
            func_name = "test_function_%s" % str(uuid.uuid4())[1:8]
            function_info = funcs_utils.create_function(
                local_self.server, local_self.db_name, local_self.schema_name,
                func_name)

            self.func_id = function_info[0]

        if self.add_extension:
            debugger_utils.add_extension(self, utils, db_utils=db_utils)