Ejemplo n.º 1
0
    def configure(self, config):
        def get_option(config, section, key):
            if not config.has_option(section, key):
                return None
            value = config.get(section, key)
            if value.isdigit():
                value = int(value)
            return value

        self.config = os.path.abspath(config)
        # now read the server config, we need some properties from it
        with open(self.config) as fp:
            dummy_section_name = "tarantool"
            config = ConfigParser.ConfigParser()
            config.readfp(TarantoolConfigFile(fp, dummy_section_name))

            self.pidfile = get_option(config, dummy_section_name, "pid_file")
            self.primary_port = get_option(config, dummy_section_name,
                                           "primary_port")
            self.admin_port = get_option(config, dummy_section_name,
                                         "admin_port")
            self.memcached_port = get_option(config, dummy_section_name,
                                             "memcached_port")

        self.port = self.admin_port
        self.admin = AdminConnection("localhost", self.admin_port)
        self.sql = BoxConnection("localhost", self.primary_port)
        if self.memcached_port != 0:
            # Run memcached client
            self.memcached = MemcachedConnection('localhost',
                                                 self.memcached_port)
Ejemplo n.º 2
0
    def setUpClass(cls):
        # Load configuration yaml
        config_path = os.path.join(os.path.dirname(__file__),
                                   'test_config.yaml')
        with open(config_path, 'r') as ymlfile:
            config = yaml.load(ymlfile)
        cls.config = config
        # Create database mutex for Bank and AdminBackend
        db_mutex = threading.Lock()

        # Run bank and its admin interface
        cls.bank = Process(target=Bank, args=(config, db_mutex))
        cls.admin = Process(target=AdminBackend, args=(config, db_mutex))
        cls.bank.start()
        cls.admin.start()

        # Wait for bank and admin interface to initialize
        time.sleep(3)

        # Connect to bank and admin interfaces
        cls.admin_iface = AdminConnection(config)
Ejemplo n.º 3
0
    def configure(self, config):
        TarantoolServer.configure(self, config)
        with open(self.config) as fp:
            dummy_section_name = "tarantool"
            config = ConfigParser.ConfigParser()
            config.readfp(TarantoolConfigFile(fp, dummy_section_name))

            self.primary_port = self.get_option_int(config, dummy_section_name,
                                                    "primary_port")
            self.admin_port = self.get_option_int(config, dummy_section_name,
                                                  "admin_port")
            self.memcached_port = self.get_option_int(config,
                                                      dummy_section_name,
                                                      "memcached_port")

        self.port = self.admin_port
        self.admin = AdminConnection("localhost", self.admin_port)
        self.sql = BoxConnection("localhost", self.primary_port)
        if self.memcached_port != 0:
            # Run memcached client
            self.memcached = MemcachedConnection('localhost',
                                                 self.memcached_port)
Ejemplo n.º 4
0
    def setUpClass(cls):
        # Load configuration yaml
        config_path = os.path.join(os.path.dirname(__file__),
                                   'test_config.yaml')
        with open(config_path, 'r') as ymlfile:
            config = yaml.load(ymlfile)
        cls.config = config

        # Connect to bank and admin interfaces
        cls.admin_iface = AdminConnection(config)
        cls.atm_iface = ATMConnection(config)

        cls.bills = [
            'Example Bill 000', 'Example Bill 001', 'Example Bill 002',
            'Example Bill 003', 'Example Bill 004', 'Example Bill 005',
            'Example Bill 006', 'Example Bill 007', 'Example Bill 008',
            'Example Bill 009', 'Example Bill 00a', 'Example Bill 00b',
            'Example Bill 00c', 'Example Bill 00d', 'Example Bill 00e',
            'Example Bill 00f'
        ]

        cls.account_name = 'martha'
        cls.amount = 400
        cls.pin = '12345678'