Example #1
0
 def test_remote(self):
     ssh = ExecutorFactory().set_host('').set_user('').set_pwd(
         '').get_executor()  # Padding your information.
     self.assertIsNotNone(
         ssh.exec_command_sync(
             "cat /proc/cpuinfo | grep \"processor\" | wc -l"))
     self.assertIsNotNone(
         ssh.exec_command_sync("cat /proc/self/cmdline | xargs -0"))
     self.assertIsNotNone(
         ssh.exec_command_sync("echo -e 'hello \\n world'")[0].count('\n'))
     self.assertIsNotNone(
         ssh.exec_command_sync("echo -e 'hello \\n world'")[0])
     self.assertIsNotNone(ssh.exec_command_sync('echo $SHELL'))
Example #2
0
    def __init__(self,
                 host,
                 host_user,
                 host_user_pwd,
                 db_user,
                 db_user_pwd,
                 db_name,
                 db_port,
                 ssh_port=22):
        """
        This class is used to abstract the database instance and interact with the database.
        All operations such as obtaining database information and setting knobs
        need to be implemented through this class.

        :param host: String type, meaning the same as variable name.
        :param host_user: Same as above.
        :param host_user_pwd: Same as above.
        :param db_user: Same as above.
        :param db_user_pwd: Same as above.
        :param db_name: Same as above.
        :param db_port: Int type, meaning the same as variable name.
        :param ssh_port: Same as above.
        """
        # Set database authorization information:
        self.ssh = ExecutorFactory() \
            .set_host(host) \
            .set_user(host_user) \
            .set_pwd(host_user_pwd) \
            .set_port(ssh_port) \
            .get_executor()

        self.host_user = host_user
        self.db_user = host_user if not db_user else db_user
        self.db_user_pwd = db_user_pwd
        self.db_name = db_name
        self.db_port = db_port
        self.data_path = None
        self.knobs = None
        self.ordered_knob_list = None

        self.check_connection_params()

        # Set a connection session as unlimited.
        self.set_knob_value("statement_timeout", 0)

        # Initialize database metrics.
        self.metric = OpenGaussMetric(self)
Example #3
0
 def test_local(self):
     proc = ExecutorFactory().get_executor()
     self.assertIsNotNone(proc.exec_command_sync("ping -h"))
Example #4
0
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
"""

import importlib
import os
import types

from tuner.exceptions import ConfigureError
from tuner.executor import ExecutorFactory

# Create a local shell with resident memory.
# We must pass a local shell as an API to benchmark instance,
# maybe the shell will be used by benchmark instance sometime.
local_ssh = ExecutorFactory() \
    .set_host('127.0.0.1') \
    .get_executor()


def get_benchmark_instance(script, path, cmd, db_info):
    name = script.rstrip('.py')
    if not os.path.exists(os.path.join(os.path.dirname(__file__),
                                       name + '.py')):
        raise ConfigureError(
            'Incorrect configuration option benchmark_script. '
            'Enter the filename of the script in the benchmark directory '
            'and ensure that the script file exists.')

    bm = importlib.import_module('tuner.benchmark.{}'.format(name))
    # Verify the validity of the benchmark script.
    # An exception will be thrown if benchmark instance does not have specified attributes.