コード例 #1
0
        public TransactionTests(SharedFileSystem fileSystem)
        {
            var path = fileSystem.CreateNewDirectoryForTest();

            _env = new LightningEnvironment(path);
            _env.Open();
        }
コード例 #2
0
        public void DatabaseDeleteShouldRemoveAllDuplicateDataItems()
        {
            var fs = new SharedFileSystem();

            using (var env = new LightningEnvironment(fs.CreateNewDirectoryForTest(), configuration: new EnvironmentConfiguration {
                MapSize = 1024 * 1024, MaxDatabases = 1
            }))
            {
                env.Open();
                using (var tx = env.BeginTransaction())
                    using (var db = tx.OpenDatabase(configuration: new DatabaseConfiguration()
                    {
                        Flags = DatabaseOpenFlags.DuplicatesSort
                    }))
                    {
                        var key    = "key";
                        var value1 = "value1";
                        var value2 = "value2";

                        tx.Put(db, key, value1);
                        tx.Put(db, key, value2);

                        tx.Delete(db, key);
                        Assert.False(tx.ContainsKey(db, key));
                    }
            }
        }
コード例 #3
0
        public MultiProcessTests(SharedFileSystem fileSystem)
        {
            var path = fileSystem.CreateNewDirectoryForTest();

            _env = new LightningEnvironment(path);
            _env.Open();
        }
コード例 #4
0
        public FinalizeTests(SharedFileSystem fileSystem)
        {
            var env = new LightningEnvironment(fileSystem.CreateNewDirectoryForTest());

            env.Open();
            var tx = env.BeginTransaction();
            var db = tx.OpenDatabase();

            tx.CreateCursor(db);
        }
コード例 #5
0
        public DatabaseIOTests(SharedFileSystem fileSystem)
        {
            var path = fileSystem.CreateNewDirectoryForTest();

            _env = new LightningEnvironment(path);
            _env.MaxDatabases = 2;
            _env.Open();

            _txn = _env.BeginTransaction();
            _db  = _txn.OpenDatabase(configuration: new DatabaseConfiguration {
                Flags = DatabaseOpenFlags.Create
            });
        }
コード例 #6
0
        public void can_load_environment_from_multiple_processes()
        {
            var name = _fileSystem.CreateNewDirectoryForTest();

            using var env = new LightningEnvironment(name);
            env.Open();
            var otherProcessPath = Path.GetFullPath("../../../../SecondProcess/bin/Debug/netcoreapp3.0/SecondProcess.dll");

            using var process = new Process
                  {
                      StartInfo = new ProcessStartInfo
                      {
                          FileName               = "dotnet",
                          Arguments              = $"{otherProcessPath} {name}",
                          RedirectStandardError  = true,
                          RedirectStandardInput  = true,
                          RedirectStandardOutput = true,
                          UseShellExecute        = false,
                          CreateNoWindow         = true,
                          WorkingDirectory       = Directory.GetCurrentDirectory()
                      }
                  };

            var expected = "world";

            using var tx = env.BeginTransaction();
            using var db = tx.OpenDatabase();
            tx.Put(db, Encoding.UTF8.GetBytes("hello"), Encoding.UTF8.GetBytes(expected));
            tx.Commit();

            var current = Process.GetCurrentProcess();

            process.Start();
            Assert.NotEqual(current.Id, process.Id);

            var result = process.StandardOutput.ReadLine();

            process.WaitForExit();
            Assert.Equal(expected, result);
        }
コード例 #7
0
 public EnvironmentTests(SharedFileSystem fileSystem)
 {
     _path     = fileSystem.CreateNewDirectoryForTest();
     _pathCopy = fileSystem.CreateNewDirectoryForTest();
 }
コード例 #8
0
        public DatabaseTests(SharedFileSystem fileSystem)
        {
            var path = fileSystem.CreateNewDirectoryForTest();

            _env = new LightningEnvironment(path);
        }
コード例 #9
0
 public ProfilingTests(SharedFileSystem fileSystem)
 {
     _env = new LightningEnvironment(fileSystem.CreateNewDirectoryForTest());
     _env.MaxDatabases = 2;
     _env.Open();
 }