Skip to content
Browse files

Merge commit '6407f40e65450b44776e6f50c06ccdb15085d6b6'

Conflicts:
	Raven.Tests/Bugs/Indexing/DynamicFields.cs
  • Loading branch information...
2 parents 8ad9a81 + 6407f40 commit f402e4c0853e646e3a59e6d5d5693ae0501b68e8 @ayende ayende committed Feb 9, 2011
View
73 Modules/Munin/Raven.Munin.Tests/Bugs/MultiThreadedWrites.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Linq;
+using System.Diagnostics;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+using Newtonsoft.Json.Linq;
+using Xunit;
+
+namespace Raven.Munin.Tests.Bugs
+{
+ public class MultiThreadedWrites
+ {
+ [Fact]
+ public void MultipleThreadsCanSafelyWriteandCommit()
+ {
+ var tempPath = Path.GetTempPath();
+ var dbPath = Path.Combine(tempPath, "test" + ".ravendb");
+ Log("Saving db in: " + dbPath);
+ File.Delete(dbPath);
+ var persistentSource = new FileBasedPersistentSource(tempPath, "test", writeThrough: true);
+ var database = new Database(persistentSource);
+ var tableOne = database.Add(new Table("Test1"));
+ var tableTwo = database.Add(new Table("Test2"));
+ database.Initialze();
+
+ try
+ {
+ Parallel.For(0, 10, counter =>
+ {
+ Table table = counter % 2 == 0 ? tableOne : tableTwo;
+ ProcessTask(counter, database, table);
+ });
+ }
+ catch (AggregateException aggEx)
+ {
+ Assert.False(true, aggEx.Message + " : " + aggEx.InnerException.Message);
+ }
+ finally
+ {
+ persistentSource.Dispose();
+ }
+ }
+
+ private static void ProcessTask(int counter, Database database, Table table)
+ {
+ var localData = new byte[] { 1, 2, 4, 5 }.Select(x => (byte)(x * counter)).ToArray();
+ var localKey = "key" + counter.ToString();
+ var thrId = Thread.CurrentThread.ManagedThreadId;
+ Log("Thread {0,2}, counter = {1}, localKey = {2}, localData = {3}",
+ thrId, counter, localKey, String.Join(", ", localData));
+
+ using (database.BeginTransaction())
+ {
+ Assert.True(table.Put(JToken.FromObject(localKey), localData));
+
+ for (int i = 0; i < 50; i++)
+ {
+ Assert.True(table.Put(JToken.FromObject(localKey + "_" + i), localData));
+ }
+
+ database.Commit();
+ }
+
+ database.Compact();
+ }
+
+ private static void Log(string format, params object[] args)
+ {
+ Trace.WriteLine(String.Format(format, args));
+ }
+ }
+}
View
1 Modules/Munin/Raven.Munin.Tests/Raven.Munin.Tests.csproj
@@ -47,6 +47,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Bugs\Compaction.cs" />
+ <Compile Include="Bugs\MultiThreadedWrites.cs" />
<Compile Include="CanWorkWithTwoDicsInSameFile.cs" />
<Compile Include="Conflicts.cs" />
<Compile Include="MultiDicInSingleFile.cs" />
View
30 Raven.Client.Lightweight/Indexes/AbstractIndexCreationTask.cs
@@ -10,6 +10,9 @@
#if !NET_3_5
using System.Threading.Tasks;
#endif
+using Raven.Client.Client;
+using Raven.Client.Client.Async;
+using Raven.Client.Document;
using Raven.Database.Indexing;
namespace Raven.Client.Indexes
@@ -43,7 +46,7 @@ public abstract class AbstractIndexCreationTask
/// Gets or sets the document store.
/// </summary>
/// <value>The document store.</value>
- public IDocumentStore DocumentStore { get; private set; }
+ public DocumentConvention Conventions { get; private set; }
#if !NET_3_5
/// <summary>
@@ -56,34 +59,41 @@ protected IEnumerable<dynamic> Project<T>(IEnumerable<T> self, Func<T, object> p
#endif
#if !SILVERLIGHT
+
/// <summary>
/// Executes the index creation against the specified document store.
/// </summary>
- /// <param name="documentStore">The document store.</param>
- public virtual void Execute(IDocumentStore documentStore)
+ public void Execute(IDocumentStore store)
+ {
+ Execute(store.DatabaseCommands, store.Conventions);
+ }
+
+ /// <summary>
+ /// Executes the index creation against the specified document database using the specified conventions
+ /// </summary>
+ public virtual void Execute(IDatabaseCommands databaseCommands, DocumentConvention documentConvention)
{
- DocumentStore = documentStore;
+ Conventions = documentConvention;
var indexDefinition = CreateIndexDefinition();
// This code take advantage on the fact that RavenDB will turn an index PUT
// to a noop of the index already exists and the stored definition matches
// the new defintion.
- documentStore.DatabaseCommands.PutIndex(IndexName, indexDefinition, true);
+ databaseCommands.PutIndex(IndexName, indexDefinition, true);
}
#endif
#if !NET_3_5
/// <summary>
/// Executes the index creation against the specified document store.
/// </summary>
- /// <param name="documentStore">The document store.</param>
- public virtual Task ExecuteAsync(IDocumentStore documentStore)
+ public virtual Task ExecuteAsync(IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention documentConvention)
{
- DocumentStore = documentStore;
+ Conventions = documentConvention;
var indexDefinition = CreateIndexDefinition();
// This code take advantage on the fact that RavenDB will turn an index PUT
// to a noop of the index already exists and the stored definition matches
// the new defintion.
- return documentStore.AsyncDatabaseCommands.PutIndexAsync(IndexName, indexDefinition, true);
+ return asyncDatabaseCommands.PutIndexAsync(IndexName, indexDefinition, true);
}
#endif
}
@@ -125,7 +135,7 @@ public override IndexDefinition CreateIndexDefinition()
Reduce = Reduce,
TransformResults = TransformResults,
Stores = Stores
- }.ToIndexDefinition(DocumentStore.Conventions);
+ }.ToIndexDefinition(Conventions);
}
/// <summary>
View
33 Raven.Client.Lightweight/Indexes/IndexCreation.cs
@@ -9,6 +9,9 @@
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
+using Raven.Client.Client;
+using Raven.Client.Client.Async;
+using Raven.Client.Document;
namespace Raven.Client.Indexes
{
@@ -28,19 +31,29 @@ public static void CreateIndexes(Assembly assemblyToScanForIndexingTasks, IDocum
var catalog = new CompositionContainer(new AssemblyCatalog(assemblyToScanForIndexingTasks));
CreateIndexes(catalog, documentStore);
}
+
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
- /// <param name="catalogToGetnIndexingTasksFrom">The catalog to getn indexing tasks from.</param>
- /// <param name="documentStore">The document store.</param>
- public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore)
+ /// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param>
+ public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions)
{
var tasks = catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>();
foreach (var task in tasks)
{
- task.Execute(documentStore);
+ task.Execute(databaseCommands, conventions);
}
}
+
+ /// <summary>
+ /// Creates the indexes found in the specified catalog
+ /// </summary>
+ /// <param name="catalogToGetnIndexingTasksFrom">The catalog to getn indexing tasks from.</param>
+ /// <param name="documentStore">The document store.</param>
+ public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore)
+ {
+ CreateIndexes(catalogToGetnIndexingTasksFrom, documentStore.DatabaseCommands, documentStore.Conventions);
+ }
#endif
/// <summary>
@@ -61,9 +74,19 @@ public static Task CreateIndexesAsync(Assembly assemblyToScanForIndexingTasks, I
/// <param name="documentStore">The document store.</param>
public static Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore)
{
+ return CreateIndexesAsync(catalogToGetnIndexingTasksFrom, documentStore.AsyncDatabaseCommands,
+ documentStore.Conventions);
+ }
+
+ /// <summary>
+ /// Creates the indexes found in the specified catalog
+ /// </summary>
+ /// <param name="catalogToGetnIndexingTasksFrom">The catalog to getn indexing tasks from.</param>
+ public static Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention conventions)
+ {
var tasks = catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>();
- Task[] array = tasks.Select(task => task.ExecuteAsync(documentStore)).ToArray();
+ Task[] array = tasks.Select(task => task.ExecuteAsync(asyncDatabaseCommands, conventions)).ToArray();
var indexesAsync = new Task(() => Task.WaitAll(array));
indexesAsync.Start();
return indexesAsync;
View
8 Raven.Client.VisualBasic.Tests/Data_NewIndex.vb
@@ -12,9 +12,9 @@ Public Class Data_NewIndex
Inherits AbstractIndexCreationTask
Public Overrides Function CreateIndexDefinition() As Raven.Database.Indexing.IndexDefinition
- Return (New IndexDefinition(Of TestClass)() With { _
- .Map = Function(items) From item In items.WhereEntityIs(Of TestClass)("TestClass", "TestClass2") _
- Select New With {item.ResourceKey}
- }.ToIndexDefinition(DocumentStore.Conventions))
+ Return (New IndexDefinition(Of TestClass)() With { _
+ .Map = Function(items) From item In items.WhereEntityIs(Of TestClass)("TestClass", "TestClass2") _
+ Select New With {item.ResourceKey}
+ }.ToIndexDefinition(Conventions))
End Function
End Class
View
2 Raven.Client.VisualBasic.Tests/LinqQueriesUsingVB.vb
@@ -11,7 +11,7 @@ Public Class LinqQueriesUsingVB
Public Sub CanUseWhereEntityIs()
Using store As EmbeddableDocumentStore = NewDocumentStore()
Dim x = New Data_NewIndex()
- x.Execute(store)
+ x.Execute(store.DatabaseCommands, store.Conventions)
End Using
End Sub
View
2 Raven.Storage.Esent/RemoteEsentStorage.cs
@@ -26,7 +26,7 @@ public class RemoteEsentStorage : IRemoteStorage, IDocumentCacher
{
var cachedDocument = (Tuple<JObject, JObject>)cachedSerializedDocuments.Get("Doc/" + key + "/" + etag);
if (cachedDocument != null)
- return Tuple.Create(new JObject(cachedDocument.Item1), new JObject(cachedDocument.Item2));
+ return Tuple.Create((JObject)cachedDocument.Item1.DeepClone(), (JObject)cachedDocument.Item2.DeepClone());
return null;
}
View
2 Raven.Storage.Esent/TransactionalStorage.cs
@@ -47,7 +47,7 @@ public class TransactionalStorage : CriticalFinalizerObject, ITransactionalStora
{
var cachedDocument = (Tuple<JObject, JObject>)cachedSerializedDocuments.Get("Doc/" + key + "/" + etag);
if (cachedDocument != null)
- return Tuple.Create(new JObject(cachedDocument.Item1), new JObject(cachedDocument.Item2));
+ return Tuple.Create((JObject)cachedDocument.Item1.DeepClone(), (JObject)cachedDocument.Item2.DeepClone());
return null;
}
View
2 Raven.Storage.Managed/Impl/TableStorage.cs
@@ -18,7 +18,7 @@ public class TableStorage : Munin.Database
{
var cachedDocument = (Tuple<JObject, JObject>)cachedSerializedDocuments.Get("Doc/" + key + "/" + etag);
if (cachedDocument != null)
- return Tuple.Create(new JObject(cachedDocument.Item1), new JObject(cachedDocument.Item2));
+ return Tuple.Create((JObject)cachedDocument.Item1.DeepClone(), (JObject)cachedDocument.Item1.DeepClone());
return null;
}
View
37 Raven.Tests/Bugs/Indexing/DynamicFields.cs
@@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Linq;
using Lucene.Net.Documents;
+using Raven.Client;
using Raven.Client.Indexes;
using Xunit;
@@ -73,7 +74,7 @@ public void CanCreateCompletelyDynamicFields()
{
using (var store = NewDocumentStore())
{
- new Product_ByAttribute().Execute(store);
+ new Product_ByAttribute().Execute(((IDocumentStore) store).DatabaseCommands, ((IDocumentStore) store).Conventions);
using (var session = store.OpenSession())
{
@@ -105,7 +106,7 @@ public void CanCreateCompletelyDynamicNumericFields()
{
using (var store = NewDocumentStore())
{
- new Product_ByNumericAttribute().Execute(store);
+ new Product_ByNumericAttribute().Execute(((IDocumentStore) store).DatabaseCommands, ((IDocumentStore) store).Conventions);
using (var session = store.OpenSession())
{
@@ -163,6 +164,38 @@ public void CanQueryCompletelyDynamicNumericFieldsWithNegativeRangeUsingInt()
}
}
}
+
+ [Fact]
+ public void CanQueryCompletelyDynamicNumericFieldsWithNegativeRange()
+ {
+ using (var store = NewDocumentStore())
+ {
+ new Product_ByNumericAttribute().Execute(store);
+
+ using (var session = store.OpenSession())
+ {
+ session.Store(new Product
+ {
+ Attributes = new List<Attribute>
+ {
+ new Attribute{Name = "Color", Value = "Red", NumericValue = 30}
+ }
+ });
+
+ session.SaveChanges();
+ }
+
+ using (var session = store.OpenSession())
+ {
+ var products = session.Advanced.LuceneQuery<Product, Product_ByNumericAttribute>()
+ .WhereGreaterThan("Color", -1d)
+ .WaitForNonStaleResults(TimeSpan.FromMinutes(3))
+ .ToList();
+
+ Assert.NotEmpty(products);
+ }
+ }
+ }
}
View
5 Raven.Tests/Bugs/LiveProjection.cs
@@ -22,7 +22,8 @@ public LiveProjection()
{
Store = NewDocumentStore();
var purchaseHistoryIndex = new PurchaseHistoryIndex();
- purchaseHistoryIndex.Execute(Store);
+ IDocumentStore documentStore = Store;
+ purchaseHistoryIndex.Execute(documentStore.DatabaseCommands, documentStore.Conventions);
}
public EmbeddableDocumentStore Store { get; set; }
@@ -121,7 +122,7 @@ select new
ProductId = item.ProductId,
ProductName = product.Name
}
- }.ToIndexDefinition(DocumentStore.Conventions);
+ }.ToIndexDefinition(Conventions);
}
}
View
3 Raven.Tests/Bugs/LiveProjections/CanLoadMultipleItems.cs
@@ -1,4 +1,5 @@
using System.Linq;
+using Raven.Client;
using Raven.Client.Indexes;
using Xunit;
@@ -11,7 +12,7 @@ public void CanLoadMultipleItemsInTransformResults()
{
using (var store = NewDocumentStore())
{
- new ParentAndChildrenNames().Execute(store);
+ new ParentAndChildrenNames().Execute(((IDocumentStore) store).DatabaseCommands, ((IDocumentStore) store).Conventions);
using(var s = store.OpenSession())
{
View
5 Raven.Tests/Bugs/LiveProjections/LiveProjectionOnProducts.cs
@@ -1,4 +1,5 @@
using System.Diagnostics;
+using Raven.Client;
namespace Raven.Tests.Bugs.LiveProjections
{
@@ -19,7 +20,7 @@ public void SimpleLiveProjection()
{
using (var documentStore = NewDocumentStore())
{
- new ProductSkuListViewModelReport_ByArticleNumberAndName().Execute(documentStore);
+ new ProductSkuListViewModelReport_ByArticleNumberAndName().Execute(((IDocumentStore) documentStore).DatabaseCommands, ((IDocumentStore) documentStore).Conventions);
using (var session = documentStore.OpenSession())
{
@@ -60,7 +61,7 @@ public void ComplexLiveProjection()
{
using (var documentStore = NewDocumentStore())
{
- new ProductDetailsReport_ByProductId().Execute(documentStore);
+ new ProductDetailsReport_ByProductId().Execute(((IDocumentStore) documentStore).DatabaseCommands, ((IDocumentStore) documentStore).Conventions);
using (var session = documentStore.OpenSession())
{
View
2 Raven.Tests/Bugs/MapReduceThrowsNRE.cs
@@ -130,7 +130,7 @@ select new
Melancholic = g.Count(x => x.Temperament == Temperaments.Melancholic),
Phlegmatic = g.Count(x => x.Temperament == Temperaments.Phlegmatic)
}
- }.ToIndexDefinition(DocumentStore.Conventions);
+ }.ToIndexDefinition(Conventions);
}
}
View
3 Raven.Tests/Bugs/TransformResults/WithGuidId.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using Raven.Client;
using Raven.Client.Indexes;
using Raven.Database.Indexing;
using Xunit;
@@ -13,7 +14,7 @@ public void CanBeUsedForTransformResultsWithDocumentId()
{
using(var store = NewDocumentStore())
{
- new ThorIndex().Execute(store);
+ new ThorIndex().Execute(((IDocumentStore) store).DatabaseCommands, ((IDocumentStore) store).Conventions);
using(var s = store.OpenSession())
{
View
3 Raven.Tests/Bugs/Vlko/Relations.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using Raven.Client;
using Raven.Client.Indexes;
using Xunit;
@@ -12,7 +13,7 @@ public void CanBeUsedForTransformResultsWithDocumentId()
{
using (var store = NewDocumentStore())
{
- new ThorIndex().Execute(store);
+ new ThorIndex().Execute(((IDocumentStore) store).DatabaseCommands, ((IDocumentStore) store).Conventions);
var relId = Guid.NewGuid();
using (var s = store.OpenSession())
View
13 Raven.Tryouts/Program.cs
@@ -1,15 +1,26 @@
using System;
+using System.Diagnostics;
+using System.IO;
+using Newtonsoft.Json.Bson;
+using Newtonsoft.Json.Linq;
using Raven.Client.Document;
using Raven.Tests.Bugs.DTC;
using Raven.Tests.Stress;
+using Xunit;
namespace Raven.Tryouts
{
class Program
{
static void Main()
{
- new StressTester().esent_stress_testing_ravendb_100kb_in_filesystem_with_indexing_case2();
+ for (int i = 0; i < 15; i++)
+ {
+ var memoryStream = new MemoryStream(File.ReadAllBytes(@"c:\work\test2.data"));
+ var sp = Stopwatch.StartNew();
+ JToken.ReadFrom(new BsonReader(memoryStream));
+ Console.WriteLine(sp.ElapsedMilliseconds);
+ }
}
}
}
View
2 Raven.Tryouts/Raven.Tryouts.csproj
@@ -42,7 +42,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- <PlatformTarget>x86</PlatformTarget>
+ <PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
View
533 Raven.Tryouts/Stress/StressTester.cs
@@ -9,260 +9,281 @@
namespace Raven.Tests.Stress
{
- public class StressTester : LocalClientTest
- {
- const string FilePath5MB = "Stress\\Data\\data_5MB.txt";
- const string FilePath500KB = "Stress\\Data\\data_500KB.txt";
- const string FilePath100KB = "Stress\\Data\\data_100KB.txt";
-
- public void munin_stress_testing_ravendb_5mb_in_single_session_in_memory()
- {
- var text = File.ReadAllText(FilePath5MB);
-
- var documentStore = NewDocumentStore("munin",true, text.Length * 102);
- JObject dummy = null;
-
- using (var session = documentStore.OpenSession())
- {
- for (int i = 0; i < 100; i++)
- {
- dummy = new JObject();
- var property = new JProperty("Content", text);
- dummy.Add(property);
- dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
- // Create
- session.Store(dummy);
- }
- session.SaveChanges();
- }
- Assert.True(true);
- }
-
- public void munin_stress_testing_ravendb_5mb_in_single_session_in_filesystem()
- {
- var text = File.ReadAllText(FilePath5MB);
-
- var documentStore = NewDocumentStore("munin", false);
- JObject dummy = null;
-
- using (var session = documentStore.OpenSession())
- {
- for (int i = 0; i < 100; i++)
- {
- dummy = new JObject();
- var property = new JProperty("Content", text);
- dummy.Add(property);
- dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
- // Create
- session.Store(dummy);
- }
- session.SaveChanges();
- }
- Assert.True(true);
- }
-
- public void munin_stress_testing_ravendb_100kb_in_filesystem()
- {
- var text = File.ReadAllText(FilePath100KB);
-
- var documentStore = NewDocumentStore("munin", false);
- JObject dummy = null;
-
- for (int i = 0; i < 100; i++)
- {
- using (var session = documentStore.OpenSession())
- {
- for (int j = 0; j < 100; j++)
- {
- var id = Guid.NewGuid().ToString();
- dummy = new JObject();
- var property = new JProperty("Content", text);
- dummy.Add(property);
- dummy.Add("Id", id);
- // Create
- session.Store(dummy);
- }
- session.SaveChanges();
- }
- }
-
- Assert.True(true);
- }
-
-
- public void munin_stress_testing_ravendb_500kb_in_filesystem()
- {
-
- var text = File.ReadAllText(FilePath500KB);
-
- var documentStore = NewDocumentStore("munin", false);
- JObject dummy = null;
-
- for (int j = 0; j < 100; j++)
- {
- using (var session = documentStore.OpenSession())
- {
- for (int i = 0; i < 100; i++)
- {
- dummy = new JObject();
- var property = new JProperty("Content", text);
- dummy.Add(property);
- dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
- // Create
- session.Store(dummy);
- }
- session.SaveChanges();
- }
- }
- Assert.True(true);
- }
-
- public void esent_stress_testing_ravendb_500kb_in_filesystem()
- {
- var text = File.ReadAllText(FilePath500KB);
-
- var documentStore = NewDocumentStore("esent", false);
-
- JObject dummy = null;
-
- for (int j = 0; j < 100; j++)
- {
- using (var session = documentStore.OpenSession())
- {
- for (int i = 0; i < 100; i++)
- {
- dummy = new JObject();
- var property = new JProperty("Content", text);
- dummy.Add(property);
- dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
- // Create
- session.Store(dummy);
- }
- session.SaveChanges();
- }
- }
- Assert.True(true);
- }
-
- public void esent_stress_testing_ravendb_500kb_in_filesystem_case2()
- {
- var text = File.ReadAllText(FilePath500KB);
-
- var documentStore = NewDocumentStore("esent", false);
-
- JObject dummy = null;
-
- for (int j = 0; j < 1000; j++)
- {
- using (var session = documentStore.OpenSession())
- {
- for (int i = 0; i < 10; i++)
- {
- dummy = new JObject();
- var property = new JProperty("Content", text);
- dummy.Add(property);
- dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
- // Create
- session.Store(dummy);
- }
- session.SaveChanges();
- }
- }
- Assert.True(true);
- }
-
- public void esent_stress_testing_ravendb_100kb_in_filesystem()
- {
- var text = File.ReadAllText(FilePath100KB);
-
- var documentStore = NewDocumentStore("esent", false);
-
- JObject dummy = null;
-
- for (int j = 0; j < 100; j++)
- {
- using (var session = documentStore.OpenSession())
- {
- for (int i = 0; i < 100; i++)
- {
- dummy = new JObject();
- var property = new JProperty("Content", text);
- dummy.Add(property);
- dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
- // Create
- session.Store(dummy);
- }
- session.SaveChanges();
- }
- }
- Assert.True(true);
- }
-
- public void esent_stress_testing_ravendb_100kb_in_filesystem_with_indexing()
- {
- var text = File.ReadAllText(FilePath100KB);
-
- var documentStore = NewDocumentStore("esent", false);
-
- JObject dummy = null;
-
- for (int j = 0; j < 100; j++)
- {
- using (var session = documentStore.OpenSession())
- {
- for (int i = 0; i < 100; i++)
- {
- dummy = new JObject();
- var property = new JProperty("Content", text);
- dummy.Add(property);
- dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
- // Create
- session.Store(dummy);
- }
- session.SaveChanges();
- // Force indexing
- var stored = session.Query<JObject>().Customize(x => x.WaitForNonStaleResults()).ToArray();
- Assert.NotNull(stored);
- Assert.NotEmpty(stored);
- }
-
- }
- Assert.True(true);
- }
-
- public void esent_stress_testing_ravendb_100kb_in_filesystem_with_indexing_case2()
- {
- var text = File.ReadAllText(FilePath100KB);
-
- var documentStore = NewDocumentStore("esent", false);
-
- JObject dummy = null;
-
- for (int j = 0; j < 100; j++)
- {
- using (var session = documentStore.OpenSession())
- {
- for (int i = 0; i < 100; i++)
- {
- dummy = new JObject();
- var property = new JProperty("Content", text);
- dummy.Add(property);
- dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
- // Create
- session.Store(dummy);
- }
- session.SaveChanges();
- }
- // Force indexing
- using (var session = documentStore.OpenSession())
- {
- var stored = session.Query<JObject>().Customize(x => x.WaitForNonStaleResults()).ToArray();
- Assert.NotNull(stored);
- Assert.NotEmpty(stored);
- }
- }
- Assert.True(true);
- }
-
- }
+ public class StressTester : LocalClientTest
+ {
+ const string FilePath5MB = "Stress\\Data\\data_5MB.txt";
+ const string FilePath500KB = "Stress\\Data\\data_500KB.txt";
+ const string FilePath100KB = "Stress\\Data\\data_100KB.txt";
+
+ public void munin_stress_testing_ravendb_5mb_in_single_session_in_memory()
+ {
+ var text = File.ReadAllText(FilePath5MB);
+
+ using (var documentStore = NewDocumentStore("munin", true, text.Length * 102))
+ {
+ JObject dummy = null;
+
+ using (var session = documentStore.OpenSession())
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ dummy = new JObject();
+ var property = new JProperty("Content", text);
+ dummy.Add(property);
+ dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
+ // Create
+ session.Store(dummy);
+ }
+ session.SaveChanges();
+ }
+ Assert.True(true);
+ }
+ }
+
+ public void munin_stress_testing_ravendb_5mb_in_single_session_in_filesystem()
+ {
+ var text = File.ReadAllText(FilePath5MB);
+
+ using (var documentStore = NewDocumentStore("munin", false))
+ {
+ JObject dummy = null;
+
+ using (var session = documentStore.OpenSession())
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ dummy = new JObject();
+ var property = new JProperty("Content", text);
+ dummy.Add(property);
+ dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
+ // Create
+ session.Store(dummy);
+ }
+ session.SaveChanges();
+ }
+ Assert.True(true);
+ }
+ }
+
+ public void munin_stress_testing_ravendb_100kb_in_filesystem()
+ {
+ var text = File.ReadAllText(FilePath100KB);
+
+ using (var documentStore = NewDocumentStore("munin", false))
+ {
+ JObject dummy = null;
+
+ for (int i = 0; i < 100; i++)
+ {
+ using (var session = documentStore.OpenSession())
+ {
+ for (int j = 0; j < 100; j++)
+ {
+ var id = Guid.NewGuid().ToString();
+ dummy = new JObject();
+ var property = new JProperty("Content", text);
+ dummy.Add(property);
+ dummy.Add("Id", id);
+ // Create
+ session.Store(dummy);
+ }
+ session.SaveChanges();
+ }
+ }
+ Console.WriteLine(GC.GetTotalMemory(false));
+ Debugger.Launch();
+
+ Assert.True(true);
+ }
+ }
+
+
+ public void munin_stress_testing_ravendb_500kb_in_filesystem()
+ {
+
+ var text = File.ReadAllText(FilePath500KB);
+
+ using (var documentStore = NewDocumentStore("munin", false))
+ {
+ JObject dummy = null;
+
+ for (int j = 0; j < 100; j++)
+ {
+ using (var session = documentStore.OpenSession())
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ dummy = new JObject();
+ var property = new JProperty("Content", text);
+ dummy.Add(property);
+ dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
+ // Create
+ session.Store(dummy);
+ }
+ session.SaveChanges();
+ }
+ }
+ Assert.True(true);
+ }
+ }
+
+ public void esent_stress_testing_ravendb_500kb_in_filesystem()
+ {
+ var text = File.ReadAllText(FilePath500KB);
+
+ using (var documentStore = NewDocumentStore("esent", false))
+ {
+
+ JObject dummy = null;
+
+ for (int j = 0; j < 100; j++)
+ {
+ using (var session = documentStore.OpenSession())
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ dummy = new JObject();
+ var property = new JProperty("Content", text);
+ dummy.Add(property);
+ dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
+ // Create
+ session.Store(dummy);
+ }
+ session.SaveChanges();
+ }
+ }
+ Assert.True(true);
+ }
+ }
+
+ public void esent_stress_testing_ravendb_500kb_in_filesystem_case2()
+ {
+ var text = File.ReadAllText(FilePath500KB);
+
+ using (var documentStore = NewDocumentStore("esent", false))
+ {
+
+ JObject dummy = null;
+
+ for (int j = 0; j < 1000; j++)
+ {
+ using (var session = documentStore.OpenSession())
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ dummy = new JObject();
+ var property = new JProperty("Content", text);
+ dummy.Add(property);
+ dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
+ // Create
+ session.Store(dummy);
+ }
+ session.SaveChanges();
+ }
+ }
+ Assert.True(true);
+ }
+ }
+
+ public void esent_stress_testing_ravendb_100kb_in_filesystem()
+ {
+ var text = File.ReadAllText(FilePath100KB);
+
+ using (var documentStore = NewDocumentStore("esent", false))
+ {
+
+ JObject dummy = null;
+
+ for (int j = 0; j < 100; j++)
+ {
+ using (var session = documentStore.OpenSession())
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ dummy = new JObject();
+ var property = new JProperty("Content", text);
+ dummy.Add(property);
+ dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
+ // Create
+ session.Store(dummy);
+ }
+ session.SaveChanges();
+ }
+ }
+ Assert.True(true);
+ }
+ }
+
+ public void esent_stress_testing_ravendb_100kb_in_filesystem_with_indexing()
+ {
+ var text = File.ReadAllText(FilePath100KB);
+
+ using (var documentStore = NewDocumentStore("esent", false))
+ {
+
+ JObject dummy = null;
+
+ for (int j = 0; j < 100; j++)
+ {
+ using (var session = documentStore.OpenSession())
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ dummy = new JObject();
+ var property = new JProperty("Content", text);
+ dummy.Add(property);
+ dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
+ // Create
+ session.Store(dummy);
+ }
+ session.SaveChanges();
+ // Force indexing
+ var stored = session.Query<JObject>().Customize(x => x.WaitForNonStaleResults()).ToArray();
+ Assert.NotNull(stored);
+ Assert.NotEmpty(stored);
+ }
+
+ }
+ Assert.True(true);
+ }
+ }
+
+
+ public void esent_stress_testing_ravendb_100kb_in_filesystem_with_indexing_case2()
+ {
+ var text = File.ReadAllText(FilePath100KB);
+
+ using (var documentStore = NewDocumentStore("esent", false))
+ {
+
+ JObject dummy = null;
+
+ for (int j = 0; j < 100; j++)
+ {
+ using (var session = documentStore.OpenSession())
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ dummy = new JObject();
+ var property = new JProperty("Content", text);
+ dummy.Add(property);
+ dummy.Add("Id", JToken.FromObject(Guid.NewGuid()));
+ // Create
+ session.Store(dummy);
+ }
+ session.SaveChanges();
+ }
+ // Force indexing
+ using (var session = documentStore.OpenSession())
+ {
+ var stored = session.Query<JObject>().Customize(x => x.WaitForNonStaleResults()).ToArray();
+ Assert.NotNull(stored);
+ Assert.NotEmpty(stored);
+ }
+ }
+ Assert.True(true);
+ }
+
+ }
+ }
}

0 comments on commit f402e4c

Please sign in to comment.
Something went wrong with that request. Please try again.