Skip to content

Commit

Permalink
RavenDB-21866 : 'timeSeriesName' argument that is passed to timeserie…
Browse files Browse the repository at this point in the history
…s load behaviour functions should be in its original casing
  • Loading branch information
aviv86 committed Dec 24, 2023
1 parent 3fb0c92 commit 0bd4df9
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ private bool FilterSingleTimeSeriesSegmentByLoadBehaviorScript(
TimeSeriesSegmentEntry segmentEntry,
string loadBehaviorFunction)
{
if (ShouldFilterByScriptAndGetParams(docId, segmentEntry.Name, loadBehaviorFunction, out (DateTime begin, DateTime end)? toLoad))
var tsNameOriginalCasing = Database.DocumentsStorage.TimeSeriesStorage.Stats.GetTimeSeriesNameOriginalCasing(Context, segmentEntry.DocId, segmentEntry.Name);
if (ShouldFilterByScriptAndGetParams(docId, tsNameOriginalCasing, loadBehaviorFunction, out (DateTime begin, DateTime end)? toLoad))
return true;

if (toLoad == null)
Expand Down
76 changes: 76 additions & 0 deletions test/SlowTests/Issues/RavenDB_21866.cs
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; }

}
}
}

0 comments on commit 0bd4df9

Please sign in to comment.