Пример #1
0
        public void IndexerTest()
        {
            using (var store = NewDocumentStore(requestedStorage: "esent", configureStore: s => s.Conventions.AcceptGzipContent = false))
            {
                var index = new RavenDocumentsByEntityName();
                index.Execute(store);

                var tasks = new List <Task>();
                for (var i = 1; i <= 20; i++)
                {
                    var taskNumber = i;
                    tasks.Add(Save(store, taskNumber));
                }

                Task.WaitAll(tasks.ToArray());

                WaitForIndexing(store);

                Assert.Equal(20000, store.DatabaseCommands.GetStatistics().CountOfDocuments);

                using (var session = store.OpenSession())
                {
                    var count = session.Query <Person>(index.IndexName)
                                .Customize(x => x.WaitForNonStaleResults())
                                .Count();

                    Assert.Equal(20000, count);
                }
            }
        }
        public async Task <long> StoreDataAsNew(T[] data)
        {
            var sw = new Stopwatch();

            sw.Start();

            DeleteData();
            await CreateDatabase();

            //using (var instance = ConnectInstance(DatabaseName()))
            {
                using (var bulkInsert = instanceDefault.BulkInsert(DatabaseName()))
                {
                    foreach (var id in data)
                    {
                        bulkInsert.Store(id, id.ID);
                    }
                }

                var dbc      = instanceDefault.DatabaseCommands.ForDatabase(DatabaseName());
                var defIndex = new RavenDocumentsByEntityName();

                defIndex.Execute(dbc, new DocumentConvention()
                {
                    DefaultUseOptimisticConcurrency = true
                });
                instanceDefault.ExecuteIndex(defIndex);
            }
            sw.Stop();

            await Task.Delay(2000);//to can retrieve after

            return(sw.ElapsedMilliseconds);
        }
Пример #3
0
 public void CanResetIndex()
 {
     using (var store = NewDocumentStore())
     {
         var ravenDocumentsByEntityName = new RavenDocumentsByEntityName();
         ravenDocumentsByEntityName.Execute(store);
         store.SystemDatabase.Indexes.ResetIndex(ravenDocumentsByEntityName.IndexName);
     }
 }
Пример #4
0
 public void CanResetIndexInMuninStorage()
 {
     using (var store = NewDocumentStore("munin", false))
     {
         var ravenDocumentsByEntityName = new RavenDocumentsByEntityName();
         ravenDocumentsByEntityName.Execute(store);
         store.DocumentDatabase.ResetIndex(ravenDocumentsByEntityName.IndexName);
     }
 }
Пример #5
0
        public void ReducerTest()
        {
            using (var store = NewDocumentStore(requestedStorage: "esent", configureStore: documentStore => documentStore.Conventions.AcceptGzipContent = false))
            {
                var index1 = new RavenDocumentsByEntityName();
                index1.Execute(store);
                var index2 = new PersonCount();
                index2.Execute(store);

                var tasks = new List <Task>();
                for (var i = 1; i <= 20; i++)
                {
                    var taskNumber = i;
                    tasks.Add(Save(store, taskNumber));
                }

                Task.WaitAll(tasks.ToArray());

                WaitForIndexing(store, timeout: TimeSpan.FromMinutes(1));

                Assert.Equal(20000, store.DatabaseCommands.GetStatistics().CountOfDocuments);

                using (var session = store.OpenSession())
                {
                    var count = session.Query <Person>(index1.IndexName)
                                .Customize(x => x.WaitForNonStaleResults())
                                .Count();

                    Assert.Equal(20000, count);

                    var results = session.Query <PersonCount.ReduceResult, PersonCount>()
                                  .Customize(customization => customization.WaitForNonStaleResults())
                                  .Take(1001)
                                  .ToList();


                    WaitForUserToContinueTheTest(store);

                    Assert.Equal(1000, results.Count);

                    foreach (var result in results)
                    {
                        Assert.Equal(20, result.Count);
                    }
                }
            }
        }
Пример #6
0
        public void Reset_index_in_database_with_replication_should_not_corrupt_etag_indice()
        {
            var sb = new StringBuilder();

            for (int i = 0; i < 1000; i++)
            {
                sb.Append(Guid.NewGuid());
            }
            var aLongString = sb.ToString();

            using (var store = NewDocumentStore())
            {
                var ravenDocumentsByEntityName = new RavenDocumentsByEntityName();
                ravenDocumentsByEntityName.Execute(store);

                using (var operation = store.BulkInsert(options: new BulkInsertOptions
                {
                    BatchSize = 1
                }))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        operation.Store(new { Foo = aLongString }, "Foo/" + i);
                    }
                }
                WaitForIndexing(store);

                using (var session = store.OpenSession())
                {
                    var count = session.Query <dynamic>().Count();
                    Assert.Equal(10, count);
                }

                store.SystemDatabase.Indexes.ResetIndex(ravenDocumentsByEntityName.IndexName);

                WaitForIndexing(store);

                using (var session = store.OpenSession())
                {
                    var count  = session.Query <dynamic>().Count();
                    var errors = store.DatabaseCommands.GetStatistics().Errors;
                    Assert.Empty(errors);
                    Assert.Equal(10, count);
                }
            }
        }