Ejemplo n.º 1
0
# Software, or a work derivative of such a combination, even if such
# copying, modification, propagation, or distribution would otherwise
# violate the terms of the GPL. You must comply with the GPL in all
# respects for all of the code used other than OpenSSL.
# "OpenSSL" means OpenSSL toolkit software distributed by the OpenSSL
# Project and licensed under the OpenSSL Licenses, or a work based on such
# software and licensed under the OpenSSL Licenses.
# "OpenSSL Licenses" means the OpenSSL License and Original SSLeay License
# under which the OpenSSL Project distributes the OpenSSL toolkit software,
# as those licenses appear in the file LICENSE-OPENSSL.

from shutil import rmtree
from .etcdserver import EtcdServer
from metaswitch.common.logging_config import configure_test_logging

configure_test_logging()


class EtcdCluster(object):
    def __init__(self, n=1):
        self.datadir = "./etcd_test_data"
        self.servers = {}
        self.pool = [
            "127.0.0.{}".format(last_byte) for last_byte in range(100, 150)
        ]
        self.initialise_servers(n)

    def get_live_server(self):
        for ip, server in self.servers.iteritems():
            if server.isAlive():
                return server
Ejemplo n.º 2
0
 def tearDown(self):
     # Once these tests are finished, we want to reset to using standard
     # test logging.
     configure_test_logging()
Ejemplo n.º 3
0
# Copyright (C) Metaswitch Networks 2017
# If license terms are provided to you in a COPYING file in the root directory
# of the source code repository by which you are accessing this code, then
# the license outlined in that COPYING file applies to your use.
# Otherwise no rights are granted except for those provided to you by
# Metaswitch Networks in a separate written agreement.

from shutil import rmtree
from .etcdserver import EtcdServer
from metaswitch.common.logging_config import configure_test_logging
configure_test_logging()


class EtcdCluster(object):
    def __init__(self, n=1):
        self.datadir = "./etcd_test_data"
        self.servers = {}
        self.pool = ["127.0.0.{}".format(last_byte) for last_byte in range(100, 150)]
        self.initialise_servers(n)

    def get_live_server(self):
        for ip, server in self.servers.iteritems():
            if server.isAlive():
                return server

    def add_server(self, **kwargs):
        ip = self.pool.pop()
        existing_ip = None
        live_server = self.get_live_server()
        if live_server is not None:
            existing_ip = live_server._ip
Ejemplo n.º 4
0
 def tearDown(self):
     # Once these tests are finished, we want to reset to using standard
     # test logging.
     configure_test_logging()