Esempio n. 1
0
        /// <summary>
        /// usage: local debugging
        /// </summary>
        private MongoDbRunner(IProcessWatcher processWatcher, IPortWatcher portWatcher, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, string dataDirectory)
        {
            _fileSystem = fileSystem;
            _port       = MongoDbDefaults.DefaultPort;
            _mongoBin   = mongoBin;

            MakeMongoBinarysExecutable();

            ConnectionString = "mongodb://*****:*****@"{0}{1}{2}".Formatted(dataDirectory, System.IO.Path.DirectorySeparatorChar.ToString(), MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(_mongoBin.Directory, dataDirectory, _port, true);

            State = State.Running;
        }
Esempio n. 2
0
        /// <summary>
        /// usage: local debugging
        /// </summary>
        private MongoDbRunner(IProcessWatcher processWatcher, IPortWatcher portWatcher, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, int port, string dataDirectory = null, bool singleNodeReplSet = false, string additionalMongodArguments = null)
        {
            _fileSystem = fileSystem;
            _mongoBin   = mongoBin;
            _port       = port;

            MakeMongoBinarysExecutable();

            ConnectionString = singleNodeReplSet? "mongodb://127.0.0.1:{0}/?connect=direct&replicaSet=singleNodeReplSet&readPreference=primary".Formatted(_port) :
                               "mongodb://127.0.0.1:{0}/".Formatted(_port);

            if (processWatcher.IsProcessRunning(MongoDbDefaults.ProcessName) && !portWatcher.IsPortAvailable(_port))
            {
                State = State.AlreadyRunning;
                return;
            }

            if (!portWatcher.IsPortAvailable(_port))
            {
                throw new MongoDbPortAlreadyTakenException("MongoDB can't be started. The TCP port {0} is already taken.".Formatted(_port));
            }

            if (dataDirectory == null)
            {
                dataDirectory = CreateTemporaryDataDirectory();
            }

            _fileSystem.CreateFolder(dataDirectory);
            _fileSystem.DeleteFile("{0}{1}{2}".Formatted(dataDirectory, Path.DirectorySeparatorChar.ToString(), MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(_mongoBin.Directory, dataDirectory, _port, true, singleNodeReplSet, additionalMongodArguments);

            State = State.Running;
        }
Esempio n. 3
0
        /// <summary>
        /// usage: local debugging
        /// </summary>
        private MongoDbRunner(IProcessWatcher processWatcher, IPortWatcher portWatcher, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, string dataDirectory)
        {
            _fileSystem = fileSystem;
            _port = MongoDbDefaults.DefaultPort;
            _mongoBin = mongoBin;

            MakeMongoBinarysExecutable();

            ConnectionString = "mongodb://*****:*****@"{0}{1}{2}".Formatted(dataDirectory, System.IO.Path.DirectorySeparatorChar.ToString(), MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(_mongoBin.Directory, dataDirectory, _port, true);

            State = State.Running;
        }
Esempio n. 4
0
        /// <summary>
        /// usage: integration tests
        /// </summary>
        private MongoDbRunner(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, string dataDirectory = null, bool singleNodeReplSet = false, string additionalMongodArguments = null,
                              ushort singleNodeReplSetWaitTimeout = MongoDbDefaults.SingleNodeReplicaSetWaitTimeout)
        {
            _fileSystem = fileSystem;
            _port       = portPool.GetNextOpenPort();
            _mongoBin   = mongoBin;

            if (dataDirectory == null)
            {
                dataDirectory = CreateTemporaryDataDirectory();
            }

            MakeMongoBinarysExecutable();

            ConnectionString = singleNodeReplSet
                ? "mongodb://127.0.0.1:{0}/?connect=direct&replicaSet=singleNodeReplSet&readPreference=primary".Formatted(_port)
                : "mongodb://127.0.0.1:{0}/".Formatted(_port);

            _dataDirectoryWithPort = "{0}_{1}".Formatted(dataDirectory, _port);
            _fileSystem.CreateFolder(_dataDirectoryWithPort);
            _fileSystem.DeleteFile("{0}{1}{2}".Formatted(_dataDirectoryWithPort, Path.DirectorySeparatorChar.ToString(), MongoDbDefaults.Lockfile));

            _mongoDbProcess = processStarter.Start(_mongoBin.Directory, _dataDirectoryWithPort, _port, singleNodeReplSet, additionalMongodArguments, singleNodeReplSetWaitTimeout);

            State = State.Running;
        }
Esempio n. 5
0
        /// <summary>
        /// usage: integration tests
        /// </summary>
        private MongoDbRunner(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter)
        {
            _fileSystem = fileSystem;
            _port       = portPool.GetNextOpenPort();

            ConnectionString = "mongodb://*****:*****@"{0}\{1}".Formatted(_dataDirectoryWithPort, MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(BinariesDirectory, _dataDirectoryWithPort, _port);

            State = State.Running;
        }
Esempio n. 6
0
        /// <summary>
        /// usage: integration tests
        /// </summary>
        private MongoDbRunner(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, string dataDirectory)
        {
            _fileSystem = fileSystem;
            _port = portPool.GetNextOpenPort();

            ConnectionString = "mongodb://*****:*****@"{0}\{1}".Formatted(_dataDirectoryWithPort, MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(BinariesDirectory, _dataDirectoryWithPort, _port);

            State = State.Running;
        }
Esempio n. 7
0
        /// <summary>
        /// usage: integration tests
        /// </summary>
        private MongoDbRunner(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, string dataDirectory)
        {
            _fileSystem = fileSystem;
            _port       = portPool.GetNextOpenPort();
            _mongoBin   = mongoBin;

            MakeMongoBinarysExecutable();

            ConnectionString = "mongodb://*****:*****@"{0}{1}{2}".Formatted(_dataDirectoryWithPort, System.IO.Path.DirectorySeparatorChar.ToString(), MongoDbDefaults.Lockfile));

            _mongoDbProcess = processStarter.Start(_mongoBin.Directory, _dataDirectoryWithPort, _port);

            State = State.Running;
        }
Esempio n. 8
0
        /// <summary>
        /// usage: integration tests
        /// </summary>
        private MongoDbRunner(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, string dataDirectory)
        {
            _fileSystem = fileSystem;
            _port = portPool.GetNextOpenPort();
            _mongoBin = mongoBin;

            MakeMongoBinarysExecutable();

            ConnectionString = "mongodb://*****:*****@"{0}{1}{2}".Formatted(_dataDirectoryWithPort, System.IO.Path.DirectorySeparatorChar.ToString(), MongoDbDefaults.Lockfile));

            _mongoDbProcess = processStarter.Start(_mongoBin.Directory, _dataDirectoryWithPort, _port);

            State = State.Running;
        }
Esempio n. 9
0
        /// <summary>
        /// usage: local debugging
        /// </summary>
        private MongoDbRunner(IProcessWatcher processWatcher, IPortWatcher portWatcher, IFileSystem fileSystem, IMongoDbProcessStarter processStarter)
        {
            _fileSystem = fileSystem;
            _port       = MongoDbDefaults.DefaultPort;

            ConnectionString = "mongodb://*****:*****@"{0}\{1}".Formatted(MongoDbDefaults.DataDirectory, MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(BinariesDirectory, MongoDbDefaults.DataDirectory, _port, true);

            State = State.Running;
        }
Esempio n. 10
0
        /// <summary>
        /// usage: local debugging
        /// </summary>
        private MongoDbRunner(IProcessWatcher processWatcher, IPortWatcher portWatcher, IFileSystem fileSystem, IMongoDbProcessStarter processStarter)
        {
            _fileSystem = fileSystem;
            _port = MongoDbDefaults.DefaultPort;

            ConnectionString = "mongodb://*****:*****@"{0}\{1}".Formatted(MongoDbDefaults.DataDirectory, MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(BinariesDirectory, MongoDbDefaults.DataDirectory, _port, true);

            State = State.Running;
        }