Ejemplo n.º 1
0
    def __init__(self,
                 name,
                 mongod_bin=None,
                 hostname='localhost',
                 storage_port_base=None,
                 count=0,
                 cleanup=True):
        """
        Base class.

        Configure multiple ``MongoLayer`` into this ``CascadedLayer``.

        :name: (required)
            The first and only positional argument is the layer name

        :mongod_bin:
            The path to ``mongod``, defaults to ``mongod``

        :hostname:
            The hostname to be used for:
                - adding MongoDB nodes to the cluster
                - connecting to a MongoDB node from Python
            Defaults to ``localhost``

        :storage_port_base:
            At which port to start. Will start multiple instances on
            consecutive ports, starting with this value

        :count:
            How many MongoDB nodes to start

        :cleanup:
            Whether to erase the workspace directory on initialization,
            defaults to ``True``
        """
        self.name = name
        self.mongod_bin = mongod_bin
        self.hostname = hostname
        self.storage_port_base = storage_port_base
        self.count = count
        self.cleanup = cleanup
        self.layers = []

        logger.info('Initializing %s with layer_options=%s' %
                    (self.__class__.__name__, list(self.layer_options)))
        self.create_layers()
        CascadedLayer.__init__(self, name, *self.layers)
Ejemplo n.º 2
0
    def __init__(self, name,
            mongod_bin = None,
            hostname = 'localhost', storage_port_base = None,
            count = 0, cleanup = True):
        """
        Base class.

        Configure multiple ``MongoLayer`` into this ``CascadedLayer``.

        :name: (required)
            The first and only positional argument is the layer name

        :mongod_bin:
            The path to ``mongod``, defaults to ``mongod``

        :hostname:
            The hostname to be used for:
                - adding MongoDB nodes to the cluster
                - connecting to a MongoDB node from Python
            Defaults to ``localhost``

        :storage_port_base:
            At which port to start. Will start multiple instances on
            consecutive ports, starting with this value

        :count:
            How many MongoDB nodes to start

        :cleanup:
            Whether to erase the workspace directory on initialization,
            defaults to ``True``
        """
        self.name = name
        self.mongod_bin = mongod_bin
        self.hostname = hostname
        self.storage_port_base = storage_port_base
        self.count = count
        self.cleanup = cleanup
        self.layers = []

        logger.info('Initializing %s with layer_options=%s' %
            (self.__class__.__name__, list(self.layer_options)))
        self.create_layers()
        CascadedLayer.__init__(self, name, *self.layers)
Ejemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     num_servers = kwargs.pop("num_servers", getattr(self, "NUM_SERVERS", self.DEFAULT_NUM_SERVERS))
     super(GracefulStopTest, self).__init__(*args, **kwargs)
     self.crates = []
     self.clients = []
     self.node_names = []
     for i in range(num_servers):
         layer = GracefulStopCrateLayer(self.node_name(i),
                        crate_path(),
                        host=public_ip(),
                        port=random_available_port(),
                        transport_port=random_available_port(),
                        multicast=True,
                        cluster_name=self.__class__.__name__)
         client = Client(layer.crate_servers)
         self.crates.append(layer)
         self.clients.append(client)
         self.node_names.append(self.node_name(i))
     self.layer = CascadedLayer(
         "{0}_{1}_crates".format(self.__class__.__name__, num_servers),
         *self.crates
     )
Ejemplo n.º 4
0
                         transport_port=crate_transport)

tornado_port = get_rnd_port()
tornado_host = 'localhost:{port}'.format(port=tornado_port)
tornado_uri = 'http://{host}'.format(host=tornado_host)

engine = create_engine('crate://localhost:{}'.format(crate_port))
Session = scoped_session(
    sessionmaker(autocommit=False, autoflush=False, bind=engine))
app = StreamMania(dbsession=Session, debug_mode=True)
tornado_layer = TornadoLayer(app, tornado_port, patches=[tvdb_mock])

crate_host = '127.0.0.1:{port}'.format(port=crate_port)
crate_uri = 'http://{0}'.format(crate_host)

layer = CascadedLayer('all', crate_layer, tornado_layer)


class WrappedSession():
    def __init__(self, uri, session, method=None):
        self.uri = uri
        self.session = session
        self.method = method

    def login(self):
        self.session.post('{}/__debug/api/auth/'.format(self.uri))

    def logout(self):
        self.session.delete('{}/__debug/api/auth/'.format(self.uri))

    def authenticate(self):