Skip to content

Commit

Permalink
test: fix last failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
toondaey committed Jun 29, 2023
1 parent b450ec5 commit fa3bd31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 39 deletions.
52 changes: 13 additions & 39 deletions Extractor/Pushers/CDFPusher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,28 +379,20 @@ await fdmDestination.PushNodes(

if (isTimeseriesPushed && fdmDestination != null)
{
tasks.Add(Task.Run(() => PushFdm(objects, variables, references, result, token)));
tasks.Add(PushFdm(objects, variables, references, result, token));
}

if (!pushCleanAssets && assetsMap.Any())
{
tasks.Add(
Task.Run(
() => PushRawAssets(assetsMap, update.Objects, report, result, token)
)
);
tasks.Add(PushRawAssets(assetsMap, update.Objects, report, result, token));
}

if (!pushCleanTimeseries)
{
tasks.Add(
Task.Run(
() => PushRawTimeseries(timeseriesMap, update.Variables, report, result, token)
)
);
tasks.Add(PushRawTimeseries(timeseriesMap, update.Variables, report, result, token));
}

tasks.Add(Task.Run(() => PushReferences(references, report, result, token)));
tasks.Add(PushReferences(references, report, result, token));

await Task.WhenAll(tasks);

Expand Down Expand Up @@ -531,15 +523,15 @@ CancellationToken token
var timeseries = await CreateTimeseries(
timeseriesMap,
report,
config.SkipMetadata,
!pushCleanTimeseries || config.SkipMetadata,
token
);

var toPushMeta = timeseriesMap
.Where(kvp => kvp.Value.Source != NodeSource.CDF)
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

if (update.AnyUpdate && toPushMeta.Any())
if (update.AnyUpdate && toPushMeta.Any() && pushCleanTimeseries)
{
await UpdateTimeseries(toPushMeta, timeseries, update, report, token);
}
Expand Down Expand Up @@ -1292,31 +1284,18 @@ private async Task UpdateTimeseries(
IEnumerable<TimeSeries> timeseries,
TypeUpdateConfig update,
BrowseReport report,
CancellationToken token
)
CancellationToken token)
{
var updates = new List<TimeSeriesUpdateItem>();
var existing = timeseries.ToDictionary(asset => asset.ExternalId);
foreach (var kvp in tsMap)
{
if (existing.TryGetValue(kvp.Key, out var ts))
{
var tsUpdate = PusherUtils.GetTSUpdate(
fullConfig,
Extractor,
ts,
kvp.Value,
update,
nodeToAssetIds
);
if (tsUpdate == null)
continue;
if (
tsUpdate.AssetId != null
|| tsUpdate.Description != null
|| tsUpdate.Name != null
|| tsUpdate.Metadata != null
)
var tsUpdate = PusherUtils.GetTSUpdate(fullConfig, Extractor, ts, kvp.Value, update, nodeToAssetIds);
if (tsUpdate == null) continue;
if (tsUpdate.AssetId != null || tsUpdate.Description != null
|| tsUpdate.Name != null || tsUpdate.Metadata != null)
{
updates.Add(new TimeSeriesUpdateItem(ts.ExternalId) { Update = tsUpdate });
}
Expand All @@ -1325,12 +1304,7 @@ CancellationToken token

if (updates.Any())
{
var res = await destination.UpdateTimeSeriesAsync(
updates,
RetryMode.OnError,
SanitationMode.Clean,
token
);
var res = await destination.UpdateTimeSeriesAsync(updates, RetryMode.OnError, SanitationMode.Clean, token);

log.LogResult(res, RequestType.UpdateTimeSeries, false);
res.ThrowOnFatal();
Expand Down Expand Up @@ -1373,7 +1347,7 @@ CancellationToken token
.Where(kvp => kvp.Value.Source != NodeSource.CDF)
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

if (update.AnyUpdate)
if (update.AnyUpdate && !config.SkipMetadata)
{
await UpdateRawTimeseries(toPushMeta, report, token);
}
Expand Down
2 changes: 2 additions & 0 deletions Test/Unit/CDFPusherTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public CDFPusherTestFixture() : base()
public sealed class CDFPusherTest : IClassFixture<CDFPusherTestFixture>, IDisposable
{
private readonly CDFPusherTestFixture tester;
private readonly ITestOutputHelper _output;
private CDFMockHandler handler;
private CDFPusher pusher;
public CDFPusherTest(ITestOutputHelper output, CDFPusherTestFixture tester)
Expand All @@ -43,6 +44,7 @@ public CDFPusherTest(ITestOutputHelper output, CDFPusherTestFixture tester)
tester.ResetConfig();
(handler, pusher) = tester.GetCDFPusher();
tester.Client.TypeManager.Reset();
_output = output;
}

public void Dispose()
Expand Down

0 comments on commit fa3bd31

Please sign in to comment.