From 5b8b99a773e61b16be73452e1ef8fd12f306a529 Mon Sep 17 00:00:00 2001 From: Bill Al Date: Tue, 30 Dec 2025 11:16:14 -0800 Subject: [PATCH 1/3] applied fallback validation --- .../Services/Client/Classes/RedisClient.cs | 3 ++- .../Services/Client/Classes/JSONFileClient.cs | 4 +-- .../Client/Classes/LocalhostClient.cs | 3 ++- .../Client/Classes/SelfRefreshingClient.cs | 3 ++- .../Services/Client/Classes/SplitClient.cs | 12 ++++++--- .../Classes/FallbackTreatmentsValidator.cs | 24 ++++++++++-------- .../IFallbackTreatmentsValidator.cs | 2 +- .../Client/SplitClientForTesting.cs | 3 ++- .../FallbackTreatmentsValidatorTests.cs | 16 ++++++------ .../Splitio.TestSupport/SplitClientForTest.cs | 5 ++-- .../BaseIntegrationTests.cs | 25 +++++++++++++++++++ 11 files changed, 69 insertions(+), 31 deletions(-) diff --git a/Splitio.Redis/Services/Client/Classes/RedisClient.cs b/Splitio.Redis/Services/Client/Classes/RedisClient.cs index f8027320..35274832 100644 --- a/Splitio.Redis/Services/Client/Classes/RedisClient.cs +++ b/Splitio.Redis/Services/Client/Classes/RedisClient.cs @@ -29,12 +29,13 @@ public class RedisClient : SplitClient private ConnectionPoolManager _connectionPoolManager; private IFeatureFlagCacheConsumer _featureFlagCacheConsumer; - public RedisClient(ConfigurationOptions config, string apiKey) : base(apiKey, config) + public RedisClient(ConfigurationOptions config, string apiKey) : base(apiKey) { _config = new RedisConfig(); ReadConfig(config); + BuildFallbackCalculator(config.FallbackTreatments); BuildRedisCache(); BuildTreatmentLog(config.ImpressionListener); diff --git a/src/Splitio/Services/Client/Classes/JSONFileClient.cs b/src/Splitio/Services/Client/Classes/JSONFileClient.cs index 5c2faeba..0c330e56 100644 --- a/src/Splitio/Services/Client/Classes/JSONFileClient.cs +++ b/src/Splitio/Services/Client/Classes/JSONFileClient.cs @@ -1,7 +1,6 @@ using Splitio.Domain; using Splitio.Services.Cache.Classes; using Splitio.Services.Cache.Interfaces; -using Splitio.Services.Common; using Splitio.Services.EngineEvaluator; using Splitio.Services.Events.Interfaces; using Splitio.Services.Impressions.Classes; @@ -33,7 +32,7 @@ public JSONFileClient(string splitsFilePath, ITrafficTypeValidator trafficTypeValidator = null, IImpressionsManager impressionsManager = null, IRuleBasedSegmentCache ruleBasedSegmentCache = null - ) : base("localhost", config) + ) : base("localhost") { _segmentCache = segmentCacheInstance ?? new InMemorySegmentCache(new ConcurrentDictionary(), _eventsManager); var rbsCache = ruleBasedSegmentCache ?? new InMemoryRuleBasedSegmentCache(new ConcurrentDictionary(), _eventsManager); @@ -53,6 +52,7 @@ public JSONFileClient(string splitsFilePath, parsedSplits.TryAdd(split.name, _splitParser.Parse(split, rbsCache)); } + BuildFallbackCalculator(config.FallbackTreatments); BuildFlagSetsFilter(new HashSet()); _featureFlagCache = featureFlagCacheInstance ?? new InMemorySplitCache(new ConcurrentDictionary(parsedSplits), _flagSetsFilter, _eventsManager); _impressionsLog = impressionsLog; diff --git a/src/Splitio/Services/Client/Classes/LocalhostClient.cs b/src/Splitio/Services/Client/Classes/LocalhostClient.cs index 96495a1a..adabe05c 100644 --- a/src/Splitio/Services/Client/Classes/LocalhostClient.cs +++ b/src/Splitio/Services/Client/Classes/LocalhostClient.cs @@ -27,7 +27,7 @@ public class LocalhostClient : SplitClient private readonly object _lock = new object(); - public LocalhostClient(ConfigurationOptions configurationOptions) : base("localhost", configurationOptions) + public LocalhostClient(ConfigurationOptions configurationOptions) : base("localhost") { var configs = (LocalhostClientConfigurations)_configService.ReadConfig(configurationOptions, ConfigTypes.Localhost, _statusManager); @@ -44,6 +44,7 @@ public LocalhostClient(ConfigurationOptions configurationOptions) : base("localh _localhostFileService = new LocalhostFileService(); } + BuildFallbackCalculator(configurationOptions.FallbackTreatments); BuildFlagSetsFilter(new HashSet()); var splits = _localhostFileService.ParseSplitFile(_fullPath); diff --git a/src/Splitio/Services/Client/Classes/SelfRefreshingClient.cs b/src/Splitio/Services/Client/Classes/SelfRefreshingClient.cs index 14fae995..e88f758f 100644 --- a/src/Splitio/Services/Client/Classes/SelfRefreshingClient.cs +++ b/src/Splitio/Services/Client/Classes/SelfRefreshingClient.cs @@ -52,10 +52,11 @@ public class SelfRefreshingClient : SplitClient private IRuleBasedSegmentCache _ruleBasedSegmentCache; private IUpdater _ruleBasedSegmentUpdater; - public SelfRefreshingClient(string apiKey, ConfigurationOptions config) : base(apiKey, config) + public SelfRefreshingClient(string apiKey, ConfigurationOptions config) : base(apiKey) { _config = (SelfRefreshingConfig)_configService.ReadConfig(config, ConfigTypes.InMemory); + BuildFallbackCalculator(config.FallbackTreatments); BuildFlagSetsFilter(_config.FlagSetsFilter); BuildSplitCache(); BuildSegmentCache(); diff --git a/src/Splitio/Services/Client/Classes/SplitClient.cs b/src/Splitio/Services/Client/Classes/SplitClient.cs index 1d00ef41..6e04a324 100644 --- a/src/Splitio/Services/Client/Classes/SplitClient.cs +++ b/src/Splitio/Services/Client/Classes/SplitClient.cs @@ -39,7 +39,6 @@ public abstract class SplitClient : ISplitClient protected readonly IConfigService _configService; protected readonly IFlagSetsValidator _flagSetsValidator; protected readonly string ApiKey; - protected readonly FallbackTreatmentCalculator _fallbackTreatmentCalculator; protected ISplitManager _manager; protected IEventsLog _eventsLog; @@ -63,6 +62,8 @@ public abstract class SplitClient : ISplitClient protected IImpressionsObserver _impressionsObserver; protected IClientExtensionService _clientExtensionService; protected IFlagSetsFilter _flagSetsFilter; + protected FallbackTreatmentCalculator _fallbackTreatmentCalculator; + public IEventsManager _eventsManager; private EventHandler SdkReadyEvent; public event EventHandler SdkReady @@ -84,10 +85,9 @@ public event EventHandler SdkReady public event EventHandler SdkUpdate; public event EventHandler SdkTimedOut; - protected SplitClient(string apikey, ConfigurationOptions options) + protected SplitClient(string apikey) { ApiKey = apikey; - _fallbackTreatmentCalculator = new FallbackTreatmentCalculator(options.FallbackTreatments); _eventsManager = new EventsManager(new EventsManagerConfig(), new EventDelivery()); RegisterEvents(); @@ -445,6 +445,12 @@ protected void BuildFlagSetsFilter(HashSet sets) { _flagSetsFilter = new FlagSetsFilter(sets); } + + protected void BuildFallbackCalculator(FallbackTreatmentsConfiguration fallbackTreatmentsConfiguration) + { + FallbackTreatmentsValidator fallbackTreatmentsValidator = new FallbackTreatmentsValidator(); + _fallbackTreatmentCalculator = new FallbackTreatmentCalculator(fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration)); + } #endregion #region Private Async Methods diff --git a/src/Splitio/Services/InputValidation/Classes/FallbackTreatmentsValidator.cs b/src/Splitio/Services/InputValidation/Classes/FallbackTreatmentsValidator.cs index 0e88c9fe..b48675c5 100644 --- a/src/Splitio/Services/InputValidation/Classes/FallbackTreatmentsValidator.cs +++ b/src/Splitio/Services/InputValidation/Classes/FallbackTreatmentsValidator.cs @@ -15,7 +15,7 @@ public class FallbackTreatmentsValidator : IFallbackTreatmentsValidator private readonly ISplitLogger _log = WrapperAdapter.Instance().GetLogger(typeof(FallbackTreatmentsValidator)); - public FallbackTreatmentsConfiguration validate(FallbackTreatmentsConfiguration fallbackTreatmentsConfiguration, Enums.API method) + public FallbackTreatmentsConfiguration validate(FallbackTreatmentsConfiguration fallbackTreatmentsConfiguration) { FallbackTreatmentsConfiguration processedFallback = new FallbackTreatmentsConfiguration(); if (fallbackTreatmentsConfiguration == null) @@ -27,29 +27,33 @@ public FallbackTreatmentsConfiguration validate(FallbackTreatmentsConfiguration if (fallbackTreatmentsConfiguration.GlobalFallbackTreatment != null) { processedGlobalFallbackTreatment = new FallbackTreatment( - IsValidTreatment(fallbackTreatmentsConfiguration.GlobalFallbackTreatment.Treatment, method), + IsValidTreatment(fallbackTreatmentsConfiguration.GlobalFallbackTreatment.Treatment), fallbackTreatmentsConfiguration.GlobalFallbackTreatment.Config); + if (processedGlobalFallbackTreatment.Treatment == null) + { + processedGlobalFallbackTreatment = null; + } } if (fallbackTreatmentsConfiguration.ByFlagFallbackTreatment != null) { - processedByFlagFallbackTreatment = IsValidByFlagTreatment(fallbackTreatmentsConfiguration.ByFlagFallbackTreatment, method); + processedByFlagFallbackTreatment = IsValidByFlagTreatment(fallbackTreatmentsConfiguration.ByFlagFallbackTreatment); } return new FallbackTreatmentsConfiguration(processedGlobalFallbackTreatment, processedByFlagFallbackTreatment); } - public string IsValidTreatment(string name, Enums.API method) + public string IsValidTreatment(string name) { if (string.IsNullOrEmpty(name)) { - _log.Error($"{method}: you passed a null or empty treatment, fallback treatment must be a non-empty string"); + _log.Error($"FallbackTreatments: you passed a null or empty treatment, fallback treatment must be a non-empty string"); return null; } string trimmed = name.Trim(); if (!trimmed.Equals(name)) { - _log.Warn($"{method}: fallback treatment %s has extra whitespace, trimming"); + _log.Warn($"FallbackTreatments: fallback treatment %s has extra whitespace, trimming"); name = trimmed; } @@ -60,26 +64,26 @@ public string IsValidTreatment(string name, Enums.API method) if (!Regex.IsMatch(name, TreatmentMatcher, RegexOptions.None, TimeSpan.FromMilliseconds(100))) { - _log.Error($"{method}: you passed {name}, treatment must adhere to the regular expression {TreatmentMatcher}"); + _log.Error($"FallbackTreatments: you passed {name}, treatment must adhere to the regular expression {TreatmentMatcher}"); return null; } return name; } - public Dictionary IsValidByFlagTreatment(Dictionary byFlagTreatment, Enums.API method) + public Dictionary IsValidByFlagTreatment(Dictionary byFlagTreatment) { Dictionary result = new Dictionary(); foreach (var entry in byFlagTreatment) { - string featureName = new SplitNameValidator(_log).SplitNameIsValid(entry.Key, method).Value; + string featureName = new SplitNameValidator(_log).SplitNameIsValid(entry.Key, Enums.API.Split).Value; if (string.IsNullOrEmpty(featureName)) { continue; } FallbackTreatment fallbackTreatment = entry.Value; - string treatment = IsValidTreatment(fallbackTreatment.Treatment, method); + string treatment = IsValidTreatment(fallbackTreatment.Treatment); if (treatment != null) { result.Add(featureName, new FallbackTreatment(treatment, fallbackTreatment.Config)); diff --git a/src/Splitio/Services/InputValidation/Interfaces/IFallbackTreatmentsValidator.cs b/src/Splitio/Services/InputValidation/Interfaces/IFallbackTreatmentsValidator.cs index 498f6681..0fb71877 100644 --- a/src/Splitio/Services/InputValidation/Interfaces/IFallbackTreatmentsValidator.cs +++ b/src/Splitio/Services/InputValidation/Interfaces/IFallbackTreatmentsValidator.cs @@ -5,6 +5,6 @@ namespace Splitio.Services.InputValidation.Interfaces { public interface IFallbackTreatmentsValidator { - FallbackTreatmentsConfiguration validate(FallbackTreatmentsConfiguration fallbackTreatmentsConfiguration, Enums.API method); + FallbackTreatmentsConfiguration validate(FallbackTreatmentsConfiguration fallbackTreatmentsConfiguration); } } \ No newline at end of file diff --git a/tests/Splitio-tests/Unit Tests/Client/SplitClientForTesting.cs b/tests/Splitio-tests/Unit Tests/Client/SplitClientForTesting.cs index 2cc6936b..b63ea971 100644 --- a/tests/Splitio-tests/Unit Tests/Client/SplitClientForTesting.cs +++ b/tests/Splitio-tests/Unit Tests/Client/SplitClientForTesting.cs @@ -21,8 +21,9 @@ public SplitClientForTesting(IFeatureFlagCacheConsumer featureFlagCacheConsumer, ISyncManager syncManager, ITelemetryEvaluationProducer telemetryEvaluationProducer, ConfigurationOptions config) - : base("SplitClientForTesting", config) + : base("SplitClientForTesting") { + BuildFallbackCalculator(config.FallbackTreatments); _eventsLog = eventsLog; _impressionsLog = impressionsLog; _blockUntilReadyService = blockUntilReadyService; diff --git a/tests/Splitio-tests/Unit Tests/InputValidation/FallbackTreatmentsValidatorTests.cs b/tests/Splitio-tests/Unit Tests/InputValidation/FallbackTreatmentsValidatorTests.cs index 0273d65d..98042b38 100644 --- a/tests/Splitio-tests/Unit Tests/InputValidation/FallbackTreatmentsValidatorTests.cs +++ b/tests/Splitio-tests/Unit Tests/InputValidation/FallbackTreatmentsValidatorTests.cs @@ -15,30 +15,30 @@ public void Works() FallbackTreatmentsValidator fallbackTreatmentsValidator = new FallbackTreatmentsValidator(); FallbackTreatmentsConfiguration fallbackTreatmentsConfiguration = new FallbackTreatmentsConfiguration(new FallbackTreatment("12#2")); - Assert.AreEqual(null, fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration, Splitio.Enums.API.GetTreatment).GlobalFallbackTreatment.Treatment); + Assert.AreEqual(null, fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration).GlobalFallbackTreatment); fallbackTreatmentsConfiguration = new FallbackTreatmentsConfiguration("12#2"); - Assert.AreEqual(null, fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration, Splitio.Enums.API.GetTreatment).GlobalFallbackTreatment.Treatment); + Assert.AreEqual(null, fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration).GlobalFallbackTreatment); fallbackTreatmentsConfiguration = new FallbackTreatmentsConfiguration( new Dictionary() { { "flag", new FallbackTreatment("12#2") } }); - Assert.AreEqual(0, fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration, Splitio.Enums.API.GetTreatment).ByFlagFallbackTreatment.Count); + Assert.AreEqual(0, fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration).ByFlagFallbackTreatment.Count); fallbackTreatmentsConfiguration = new FallbackTreatmentsConfiguration( new Dictionary() { { "flag", "12#2" } }); - Assert.AreEqual(0, fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration, Splitio.Enums.API.GetTreatment).ByFlagFallbackTreatment.Count); + Assert.AreEqual(0, fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration).ByFlagFallbackTreatment.Count); fallbackTreatmentsConfiguration = new FallbackTreatmentsConfiguration( new FallbackTreatment("on"), new Dictionary() { { "flag", new FallbackTreatment("off") } }); - var processed = fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration, Splitio.Enums.API.GetTreatment); + var processed = fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration); Assert.AreEqual("on", processed.GlobalFallbackTreatment.Treatment); processed.ByFlagFallbackTreatment.TryGetValue("flag", out FallbackTreatment fallbackTreatment); Assert.AreEqual("off", fallbackTreatment.Treatment); fallbackTreatmentsConfiguration = new FallbackTreatmentsConfiguration("on", new Dictionary() { { "flag", new FallbackTreatment("off") } }); - processed = fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration, Splitio.Enums.API.GetTreatment); + processed = fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration); Assert.AreEqual("on", processed.GlobalFallbackTreatment.Treatment); processed.ByFlagFallbackTreatment.TryGetValue("flag", out FallbackTreatment fallbackTreatment2); Assert.AreEqual("off", fallbackTreatment2.Treatment); @@ -46,7 +46,7 @@ public void Works() fallbackTreatmentsConfiguration = new FallbackTreatmentsConfiguration( new FallbackTreatment("on"), new Dictionary() { { "flag", "off" } }); - processed = fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration, Splitio.Enums.API.GetTreatment); + processed = fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration); Assert.AreEqual("on", processed.GlobalFallbackTreatment.Treatment); processed.ByFlagFallbackTreatment.TryGetValue("flag", out fallbackTreatment); Assert.AreEqual("off", fallbackTreatment.Treatment); @@ -54,7 +54,7 @@ public void Works() fallbackTreatmentsConfiguration = new FallbackTreatmentsConfiguration( new FallbackTreatment("on"), new Dictionary() { { "flag", "off" } }); - processed = fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration, Splitio.Enums.API.GetTreatment); + processed = fallbackTreatmentsValidator.validate(fallbackTreatmentsConfiguration); Assert.AreEqual("on", processed.GlobalFallbackTreatment.Treatment); processed.ByFlagFallbackTreatment.TryGetValue("flag", out fallbackTreatment); Assert.AreEqual("off", fallbackTreatment.Treatment); diff --git a/tests/Splitio.TestSupport/SplitClientForTest.cs b/tests/Splitio.TestSupport/SplitClientForTest.cs index 101d5210..9f453fc1 100644 --- a/tests/Splitio.TestSupport/SplitClientForTest.cs +++ b/tests/Splitio.TestSupport/SplitClientForTest.cs @@ -1,6 +1,4 @@ using Splitio.Domain; -using Splitio.Services.Common; -using Splitio.Services.Impressions.Classes; using System.Collections.Generic; using System.Threading.Tasks; @@ -10,8 +8,9 @@ public class SplitClientForTest : SplitClient { private readonly Dictionary _tests; - public SplitClientForTest(ConfigurationOptions config) : base("SplitClientForTest", config) + public SplitClientForTest(ConfigurationOptions config) : base("SplitClientForTest") { + BuildFallbackCalculator(config.FallbackTreatments); _tests = new Dictionary(); } diff --git a/tests/Splitio.Tests.Common/BaseIntegrationTests.cs b/tests/Splitio.Tests.Common/BaseIntegrationTests.cs index 4bfa02db..0efa18c0 100644 --- a/tests/Splitio.Tests.Common/BaseIntegrationTests.cs +++ b/tests/Splitio.Tests.Common/BaseIntegrationTests.cs @@ -1155,6 +1155,31 @@ public void GetTreatmentsByFlagSet_WithWrongFlagSets() #region FallbackTreatments [TestMethod] + public void FallbackTreatmentsIgnored_WithInvalidConfig() + { + var features = new List { "feature2", "feature" }; + FallbackTreatmentsConfiguration fallbackTreatmentsConfiguration = new FallbackTreatmentsConfiguration(new FallbackTreatment("on-gl^^obal", "\"prop\":\"global\""), new Dictionary() { { "feature", new FallbackTreatment("off-l###ocal", "\"prop\":\"local\"") } }); + var impressionListener = new IntegrationTestsImpressionListener(50); + var configurations = GetConfigurationOptions(impressionListener: impressionListener); + configurations.FallbackTreatments = fallbackTreatmentsConfiguration; + + var apikey = "base-apikey10"; + + var splitFactory = new SplitFactory(apikey, configurations); + var client = splitFactory.Client(); + + client.BlockUntilReady(10000); + + // Act. + var result = client.GetTreatment("nico_test", "feature"); + var result2 = client.GetTreatment("nico_test", "feature2"); + client.Destroy(); + + // Assert. + Assert.AreEqual("control", result); + Assert.AreEqual("control", result2); + } + [TestMethod] public void FallbackTreatments_WhenFeatureDoesNotExist() { var features = new List { "feature2", "feature" }; From c70e9d8d706d5e714148be3b0cbb45d11800b0f9 Mon Sep 17 00:00:00 2001 From: Bill Al Date: Tue, 30 Dec 2025 11:37:13 -0800 Subject: [PATCH 2/3] polish --- src/Splitio/Services/Client/Classes/SplitClient.cs | 6 +++--- .../Unit Tests/Impressions/UniqueKeysTrackerTests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Splitio/Services/Client/Classes/SplitClient.cs b/src/Splitio/Services/Client/Classes/SplitClient.cs index 6e04a324..8d536d36 100644 --- a/src/Splitio/Services/Client/Classes/SplitClient.cs +++ b/src/Splitio/Services/Client/Classes/SplitClient.cs @@ -63,9 +63,9 @@ public abstract class SplitClient : ISplitClient protected IClientExtensionService _clientExtensionService; protected IFlagSetsFilter _flagSetsFilter; protected FallbackTreatmentCalculator _fallbackTreatmentCalculator; - - public IEventsManager _eventsManager; + protected IEventsManager _eventsManager; private EventHandler SdkReadyEvent; + public event EventHandler SdkReady { add @@ -73,7 +73,7 @@ public event EventHandler SdkReady SdkReadyEvent = (EventHandler)Delegate.Combine(SdkReadyEvent, value); if (_eventsManager.EventAlreadyTriggered(SdkEvent.SdkReady)) { - SdkReadyEvent.Invoke(this, null); + SdkReadyEvent.Invoke(this, new EventMetadata(new Dictionary())); } } diff --git a/tests/Splitio-tests/Unit Tests/Impressions/UniqueKeysTrackerTests.cs b/tests/Splitio-tests/Unit Tests/Impressions/UniqueKeysTrackerTests.cs index 6292b5d5..de2c485c 100644 --- a/tests/Splitio-tests/Unit Tests/Impressions/UniqueKeysTrackerTests.cs +++ b/tests/Splitio-tests/Unit Tests/Impressions/UniqueKeysTrackerTests.cs @@ -52,7 +52,7 @@ public async Task PeriodicTask_ShouldSendBulk() // Assert. Assert.IsTrue(_uniqueKeysTracker.Track("key-test", "feature-name-test")); - System.Threading.SpinWait.SpinUntil(() => _cache.Count == 0, TimeSpan.FromMilliseconds(2000)); + System.Threading.SpinWait.SpinUntil(() => _cache.IsEmpty, TimeSpan.FromMilliseconds(2000)); _senderAdapter.Verify(mock => mock.RecordUniqueKeysAsync(It.IsAny>()), Times.Once); Assert.IsTrue(_uniqueKeysTracker.Track("key-test", "feature-name-test")); @@ -104,7 +104,7 @@ public void Track_WithFullSize_ShouldSendTwoBulk() Thread.Sleep(1000); Assert.IsTrue(_uniqueKeysTracker.Track("key-test-2", "feature-name-test-6")); - System.Threading.SpinWait.SpinUntil(() => _cache.Count==0, TimeSpan.FromMilliseconds(3000)); + System.Threading.SpinWait.SpinUntil(() => _cache.IsEmpty, TimeSpan.FromMilliseconds(3000)); _senderAdapter.Verify(mock => mock.RecordUniqueKeysAsync(It.IsAny>()), Times.Exactly(2)); _cache.Clear(); @@ -144,7 +144,7 @@ public void Track_WithFullSize_ShouldSplitBulks() Assert.IsTrue(_uniqueKeysTracker2.Track("key-test-5", "feature-name-test-2")); Assert.IsTrue(_uniqueKeysTracker2.Track("key-test-6", "feature-name-test-2")); - System.Threading.SpinWait.SpinUntil(() => _cache2.Count == 0, TimeSpan.FromMilliseconds(3000)); + System.Threading.SpinWait.SpinUntil(() => _cache2.IsEmpty, TimeSpan.FromMilliseconds(3000)); _senderAdapter2.Verify(mock => mock.RecordUniqueKeysAsync(It.IsAny>()), Times.Exactly(4)); _cache2.Clear(); From 70fb6afe63ad5edc5628412d784cf1769abc8b98 Mon Sep 17 00:00:00 2001 From: Bill Al Date: Tue, 30 Dec 2025 20:48:17 -0800 Subject: [PATCH 3/3] reduce logging for events --- src/Splitio/Services/Common/EventDelivery.cs | 1 - src/Splitio/Services/Common/EventsManager.cs | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/Splitio/Services/Common/EventDelivery.cs b/src/Splitio/Services/Common/EventDelivery.cs index 38b04ffe..cc562399 100644 --- a/src/Splitio/Services/Common/EventDelivery.cs +++ b/src/Splitio/Services/Common/EventDelivery.cs @@ -13,7 +13,6 @@ public virtual void Deliver(E sdkEvent, M eventMetadata, Action handler) { if (handler != null) { - _logger.Debug($"EventDelivery: Triggering handle for Sdk Event {sdkEvent}"); try { handler.Invoke(eventMetadata); diff --git a/src/Splitio/Services/Common/EventsManager.cs b/src/Splitio/Services/Common/EventsManager.cs index 20be55e4..68cdb526 100644 --- a/src/Splitio/Services/Common/EventsManager.cs +++ b/src/Splitio/Services/Common/EventsManager.cs @@ -64,7 +64,6 @@ public void NotifyInternalEvent(I sdkInternalEvent, M eventMetadata) { lock (_lock) { - _logger.Debug($"EventsManager: Handling internal event {sdkInternalEvent}"); foreach (E sortedEvent in _managerConfig.EvaluationOrder.Where(x => GetSdkEventIfApplicable(sdkInternalEvent).Contains(x))) { _logger.Debug($"EventsManager: Firing Sdk event {sortedEvent}"); @@ -93,7 +92,6 @@ public void UpdateSdkInternalEventStatus(I sdkInternalEvent, bool status) { _internalEventsStatus.AddOrUpdate(sdkInternalEvent, status, (_, oldValue) => status); - _logger.Debug($"EventsManager: Internal Event {sdkInternalEvent} status is updated to {status}"); } #endregion