forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RavenDB-21866 : 'timeSeriesName' argument that is passed to timeserie…
…s load behaviour functions should be in its original casing
- Loading branch information
Showing
2 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using SlowTests.Server.Documents.ETL; | ||
using Tests.Infrastructure; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace SlowTests.Issues | ||
{ | ||
public class RavenDB_21866 : EtlTestBase | ||
{ | ||
public RavenDB_21866(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[RavenFact(RavenTestCategory.Etl | RavenTestCategory.TimeSeries)] | ||
public async Task EtlCanLoadTimeSeriesByComparingTheNameInItsOriginalCasing() | ||
{ | ||
const string collection = "EventDocuments"; | ||
const string id = $"{collection}/1"; | ||
const string tsName = "AppOpen"; | ||
const string script = @" | ||
loadToEventDocuments(this); | ||
function loadCountersOfEventDocumentsBehavior(documentId, counterName) { | ||
return true; | ||
} | ||
function loadTimeSeriesOfEventDocumentsBehavior(docId, timeSeriesName) { | ||
if (timeSeriesName =='AppOpen'){ | ||
return true; | ||
} | ||
return false | ||
}"; | ||
|
||
var (src, dest, _) = CreateSrcDestAndAddEtl(new[] { collection }, script); | ||
|
||
var etlDone = WaitForEtl(src, (s, statistics) => statistics.LoadSuccesses > 0); | ||
|
||
using (var session = src.OpenAsyncSession()) | ||
{ | ||
var date = DateTime.Today.ToUniversalTime(); | ||
var doc = new EventDocument { Name = "event", Date = date }; | ||
await session.StoreAsync(doc, id); | ||
|
||
var tsFor = session.TimeSeriesFor(doc, tsName); | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
tsFor.Append(date.AddMinutes(i), i); | ||
} | ||
|
||
await session.SaveChangesAsync(); | ||
} | ||
|
||
Assert.True(etlDone.Wait(TimeSpan.FromSeconds(15))); | ||
|
||
using (var session = dest.OpenAsyncSession()) | ||
{ | ||
var doc = await session.LoadAsync<EventDocument>(id); | ||
Assert.NotNull(doc); | ||
|
||
var entries = await session.TimeSeriesFor(id, tsName).GetAsync(); | ||
Assert.Equal(10, entries?.Length); | ||
} | ||
|
||
} | ||
|
||
private class EventDocument | ||
{ | ||
public DateTime Date { get; set; } | ||
|
||
public string Name { get; set; } | ||
|
||
} | ||
} | ||
} |