Skip to content

Commit

Permalink
fix: default values for version & always use api-based simulation runs (
Browse files Browse the repository at this point in the history
#83)

* fix: setting default values for version
* Version bump
* Report api-based runs by default in the heartbeat

Co-authored-by: Ivan Polomani <[email protected]>
  • Loading branch information
abdullah-cognite and polomani authored Dec 18, 2023
1 parent 5c06fe1 commit 6e7dd6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Cognite.Simulator.Tests/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ await cdf.Alpha.Simulators.UpdateSimulatorIntegrationAsync(
{
Update = new SimulatorIntegrationUpdate
{
Heartbeat = new Update<long>(DateTime.UtcNow.ToUnixTimeMilliseconds())
Heartbeat = new Update<long>(DateTime.UtcNow.ToUnixTimeMilliseconds()),
RunApiEnabled = new Update<bool>(true),
}
}
}
Expand Down
17 changes: 10 additions & 7 deletions Cognite.Simulator.Utils/ConnectorBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Cognite.Extractor.Common;
using Cognite.Extractor.Common;
using Cognite.Extractor.Utils;
using Cognite.Simulator.Extensions;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -162,7 +162,7 @@ public virtual bool ShouldLicenseCheck()
/// <returns></returns>
public virtual bool ApiEnabled()
{
return _config.UseSimulatorsApi;
return true;
}

/// <summary>
Expand Down Expand Up @@ -192,20 +192,23 @@ protected async Task EnsureSimulatorIntegrationsExists(CancellationToken token)
new SimulatorQuery (),
token).ConfigureAwait(false);
var existingSimulator = existingSimulators.Items.FirstOrDefault(s => s.ExternalId == simulatorName);

if (existingSimulator == null)
{
_logger.LogWarning("Simulator {Simulator} not found in CDF", simulatorName);
throw new ConnectorException($"Simulator {simulatorName} not found in CDF");
}

var integrationToCreate = new SimulatorIntegrationCreate
{
ExternalId = connectorName,
SimulatorExternalId = simulatorName,
DataSetId = simulator.DataSetId,
ConnectorVersion = GetConnectorVersion(),
SimulatorVersion = GetSimulatorVersion(simulatorName),
RunApiEnabled = ApiEnabled(),
ConnectorVersion = GetConnectorVersion() ?? "N/A",
SimulatorVersion = GetSimulatorVersion(simulatorName) ?? "N/A",
RunApiEnabled = ApiEnabled()
};

var res = await simulatorsApi.CreateSimulatorIntegrationAsync(new List<SimulatorIntegrationCreate> {
integrationToCreate
}, token).ConfigureAwait(false);
Expand Down Expand Up @@ -245,8 +248,8 @@ protected async Task UpdateIntegrationRows(
var integrationUpdate = init ? new SimulatorIntegrationUpdate
{
DataSetId = new Update<long> { Set = simulator.DataSetId },
ConnectorVersion = new Update<string> { Set = GetConnectorVersion() },
SimulatorVersion = new Update<string> { Set = GetSimulatorVersion(simulator.Name) },
ConnectorVersion = new Update<string> { Set = GetConnectorVersion() ?? "N/A" },
SimulatorVersion = new Update<string> { Set = GetSimulatorVersion(simulator.Name) ?? "N/A" },
RunApiEnabled = new Update<bool> { Set = ApiEnabled() },
ConnectorStatus = new Update<string> { Set = "IDLE" },
ConnectorStatusUpdatedTime = new Update<long> { Set = DateTime.UtcNow.ToUnixTimeMilliseconds() },
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0-alpha-017
1.0.0-alpha-018

0 comments on commit 6e7dd6d

Please sign in to comment.