Esempio n. 1
0
    def setUp(self):
        super(IndirectProfilingTest, self).setUp()
        self.config_data = utils.get_config_data()[0]
        self.conn = utils.get_db_connection(
            db=self.config_data['db'],
            username=self.config_data['username'],
            password=self.config_data['db_password'],
            host=self.config_data['host'],
            port=self.config_data['port'],
            sslmode=self.config_data['sslmode'])

        self.cursor = self.conn.cursor()
        self.cursor.execute("""
                        SELECT N.nspname
                        FROM pg_catalog.pg_extension E
                        JOIN pg_catalog.pg_namespace N
                            ON N.oid = E.extnamespace
                        WHERE E.extname = 'plprofiler'
                    """)
        res = self.cursor.fetchone()[0]
        self.schema_name = res

        self.db_name = self.config_data['db']
        self.cursor.execute("SELECT db.oid from pg_database db WHERE"
                            " db.datname='%s'" % self.db_name)
        self.db_id = self.cursor.fetchone()[0]
Esempio n. 2
0
    logger.addHandler(fh)

    # Create logger to write log in the logger file as well as on console
    stderr_logger = logging.getLogger('STDERR')
    sys.stderr = StreamToLogger(stderr_logger, logging.ERROR)
    args = vars(add_arguments())
    # Get test module list
    try:
        test_module_list = get_test_modules(args)
    except Exception as e:
        print(str(e))
        sys.exit(1)
    # Login the test client
    test_utils.login_tester_account(test_client)

    servers_info = test_utils.get_config_data()
    node_name = "all"
    if args['pkg'] is not None:
        node_name = args['pkg'].split('.')[-1]
    try:
        for server in servers_info:
            print(
                "\n=============Running the test cases for '%s'=============" %
                server['name'],
                file=sys.stderr)
            # Create test server
            server_information = test_utils.create_parent_server_node(server)

            # Create test database with random number to avoid conflict in
            # parallel execution on different platforms. This database will be
            # used across all feature tests.
Esempio n. 3
0
    def setUp(self):
        super(DirectProfilingTestCase, self).setUp()
        self.config_data = utils.get_config_data()[0]
        self.conn = utils.get_db_connection(
            db=self.config_data['db'],
            username=self.config_data['username'],
            password=self.config_data['db_password'],
            host=self.config_data['host'],
            port=self.config_data['port'],
            sslmode=self.config_data['sslmode'])

        self.cursor = self.conn.cursor()
        self.cursor.execute(
                        "SELECT N.nspname "
                        "FROM pg_catalog.pg_extension E "
                        "JOIN pg_catalog.pg_namespace N "
                        "   ON N.oid = E.extnamespace "
                        "WHERE E.extname = \'plprofiler\'")
        self.schema_name = self.cursor.fetchone()[0]

        self.db_name = self.config_data['db']
        self.cursor.execute("SELECT db.oid from pg_database db "
                            "WHERE db.datname='%s'" % self.db_name)
        self.db_id = self.cursor.fetchone()[0]

        self.cursor.execute("SELECT N.oid "
                            "FROM pg_catalog.pg_namespace N "
                            "JOIN pg_catalog.pg_extension E "
                            "   ON N.oid = E.extnamespace "
                            "WHERE E.extname = 'plprofiler'")
        try:
            self.schema_id = self.cursor.fetchone()[0]
        except Exception as e:
            self.skipTest('Could not find schema with plprofiler '
                          'extension installed '
                          '(Please verify config settings are correct)')
        schid = str(self.schema_id)

        try:
            self.cursor.execute(
                "CREATE OR REPLACE FUNCTION {0} RETURNS integer AS $$"
                "   BEGIN "
                "       {1}; "
                "   END; "
                "$$   LANGUAGE plpgsql; ".format(
                    TEST_FUNC_SIGN, TEST_FUNC_BODY)
            )
        except Exception as e:
            self.skipTest('Could not create test function')

        self.cursor.execute("SELECT p.oid "
                            "FROM pg_catalog.pg_proc P "
                            "LEFT JOIN pg_catalog.pg_namespace N "
                            "   ON p.pronamespace = N.oid "
                            "WHERE p.proname = '{0}' AND N.oid = {1}".format(
                                TEST_FUNC_NAME, schid))
        try:
            self.fid = self.cursor.fetchone()[0]
        except Exception as e:
            self.skipTest('Specified test function not found')

        self.conn.commit()
Esempio n. 4
0
    )

    # Create logger to write log in the logger file as well as on console
    stderr_logger = logging.getLogger('STDERR')
    sys.stderr = StreamToLogger(stderr_logger, logging.ERROR)
    args = vars(add_arguments())
    # Get test module list
    try:
        test_module_list = get_test_modules(args)
    except Exception as e:
        print(str(e))
        sys.exit(1)
    # Login the test client
    test_utils.login_tester_account(test_client)

    servers_info = test_utils.get_config_data()
    node_name = "all"
    if args['pkg'] is not None:
        node_name = args['pkg'].split('.')[-1]
    try:
        for server in servers_info:
            print("\n=============Running the test cases for '%s'============="
                  % server['name'], file=sys.stderr)
            # Create test server
            server_information = test_utils.create_parent_server_node(server)

            # Create test database with random number to avoid conflict in
            # parallel execution on different platforms. This database will be
            # used across all feature tests.
            test_db_name = "acceptance_test_db" + \
                           str(random.randint(10000, 65535))