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-22128 : add test to verify that ETL script will filter increm…
…ent time series when using upper cased inc prefix
- Loading branch information
aviv
committed
Mar 7, 2024
1 parent
be2539a
commit 52d85ae
Showing
1 changed file
with
70 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Raven.Client; | ||
using Raven.Client.Documents; | ||
using SlowTests.Core.Utils.Entities; | ||
using SlowTests.Server.Documents.ETL; | ||
using Tests.Infrastructure; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace SlowTests.Issues | ||
{ | ||
public class RavenDB_22128 : EtlTestBase | ||
{ | ||
public RavenDB_22128(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
private const string IncrementalTsName = Constants.Headers.IncrementalTimeSeriesPrefix + "HeartRate"; | ||
private const string TsName = "HeartRate"; | ||
|
||
[RavenFact(RavenTestCategory.TimeSeries | RavenTestCategory.Etl)] | ||
public void TimeSeriesEtlShouldSkipIncrementalTsBasingOnUpperCasedIncPrefix() | ||
{ | ||
var collections = new List<string> { "Users" }; | ||
|
||
const string etlScript = """ | ||
loadToUsers(this); | ||
function loadTimeSeriesOfUsersBehavior(doc, ts) | ||
{ | ||
if (ts.startsWith("INC")){ | ||
return false; | ||
} | ||
return true; | ||
} | ||
"""; | ||
|
||
(DocumentStore src, DocumentStore dest, _) = CreateSrcDestAndAddEtl(collections, script: etlScript); | ||
var baseline = RavenTestHelper.UtcToday; | ||
var etlDone = WaitForEtl(src, (s, statistics) => statistics.LoadSuccesses > 0); | ||
|
||
using (var session = src.OpenSession()) | ||
{ | ||
session.Store(new User { Name = "Oren" }, "users/ayende"); | ||
session.Store(new User { Name = "Gracjan" }, "users/poisson"); | ||
var ts = session.IncrementalTimeSeriesFor("users/ayende", IncrementalTsName); | ||
var ts2 = session.TimeSeriesFor("users/poisson", TsName); | ||
ts.Increment(baseline, 100_000); | ||
ts2.Append(baseline, 100); | ||
session.SaveChanges(); | ||
} | ||
|
||
Assert.True(etlDone.Wait(TimeSpan.FromSeconds(30))); | ||
|
||
using (var session = dest.OpenSession()) | ||
{ | ||
var ts = session.IncrementalTimeSeriesFor("users/ayende", IncrementalTsName); | ||
var ts2 = session.TimeSeriesFor("users/poisson", TsName); | ||
var incTsEntries = ts.Get(); | ||
var tsEntries = ts2.Get(); | ||
|
||
Assert.Equal(1, tsEntries.Length); | ||
|
||
// should be filtered | ||
Assert.Null(incTsEntries); | ||
} | ||
} | ||
|
||
} | ||
} |