示例#1
0
        public void TestNoConfigurationErrorEventsIfConfigIsOk()
        {
            Twin.ChangeConfiguration("maxMessageSizeInBytes", "4096");
            var events = _genertorUnderTest.GetEvents();

            Assert.AreEqual(0, events.Count());
        }
        public void TestMessagePiggybacking()
        {
            int maxMessageSize = 3000;

            Twin.ChangeConfiguration("maxMessageSizeInBytes", maxMessageSize.ToString())
            .ChangeEventPriority(typeof(FakeOperationalEvent).Name, EventPriority.High)
            .ChangeEventPriority(typeof(FakePeriodicEvent).Name, EventPriority.Low)
            .ChangeEventPriority(typeof(FakeTriggeredEvent).Name, EventPriority.Low)
            .UpdateAgentTwinConfiguration();

            var expectedOperationalEvent = FakesEventsFactory.CreateFakeOperationalEvent();
            var expectedPeriodicEvent    = FakesEventsFactory.CreateFakePeriodicEvent(EventPriority.Low);
            var expectedTriggeredEvent   = FakesEventsFactory.CreateFakeTriggeredEvent(EventPriority.Low);

            FakeOperationalEventGenerator.SetEvents(new[] { expectedOperationalEvent });
            FakeSnapshotEventGenerator.SetEvents(new[] { expectedPeriodicEvent });
            FakeTriggeredEventGenerator.SetEvents(new[] { expectedTriggeredEvent });

            _eventProducer.ExecuteTask();
            _messageBuilderConsumer.ExecuteTask();

            //One message should fit for all 3 events
            var sentMessages = ClientMock.GetMessages();

            Assert.AreEqual(1, sentMessages.Count);
            var events = MessageHelper.GetEventsFromMsg(sentMessages.First().GetBytes());

            Assert.AreEqual(1, events.Count(ev => ev.Name == typeof(FakeOperationalEvent).Name));
            Assert.AreEqual(1, events.Count(ev => ev.Name == typeof(FakePeriodicEvent).Name));
            Assert.AreEqual(1, events.Count(ev => ev.Name == typeof(FakeTriggeredEvent).Name));
        }
示例#3
0
        public void TestIsCustomChecksEnabledPositive(string baselineCustomChecksFilePath, string baselineCustomChecksFileHash, bool baselineCustomChecksEnabled)
        {
            Twin.ChangeConfiguration("baselineCustomChecksFilePath", baselineCustomChecksFilePath)
            .ChangeConfiguration("baselineCustomChecksFileHash", baselineCustomChecksFileHash)
            .ChangeConfiguration("baselineCustomChecksEnabled", baselineCustomChecksEnabled.ToString());

            Assert.IsTrue(BaselineEventGenerator.IsCustomChecksEnabled());
        }
示例#4
0
        public void TestIsCustomChecksEnabledPositive()
        {
            Twin.ChangeConfiguration("baselineCustomChecksFilePath", "/file/path")
            .ChangeConfiguration("baselineCustomChecksFileHash", "file_hash#")
            .ChangeConfiguration("baselineCustomChecksEnabled", "true");

            Assert.IsTrue(BaselineEventGenerator.IsCustomChecksEnabled());
        }
示例#5
0
        public override void Init()
        {
            base.Init();
            _genertorUnderTest = new AgentConfigurationErrorEventGenerator();
            Twin.ChangeConfiguration("maxMessageSizeInBytes", "8192")
            .ChangeConfiguration("maxLocalCacheSizeInBytes", "8192")
            .ChangeConfiguration("lowPriorityMessageFrequency", "PT10S")
            .ChangeConfiguration("highPriorityMessageFrequency", "PT10S")
            .UpdateAgentTwinConfiguration();

            _genertorUnderTest.GetEvents();
        }
示例#6
0
        public void TestBaselineCustomChecksPopulation()
        {
            MockBaselineOutput(Resources.baseline_output_nice);

            Twin.ChangeConfiguration("baselineCustomChecksFilePath", "/file/path")
            .ChangeConfiguration("baselineCustomChecksFileHash", "file_hash#")
            .ChangeConfiguration("baselineCustomChecksEnabled", true.ToString());

            var events = _genertorUnderTest.GetEvents().ToList();

            Assert.AreEqual(1, events.Count);
            Assert.AreEqual(16, ((OSBaseline)events.First()).Payload.Count());
        }
示例#7
0
        public void TestIsCustomChecksEnabledNegative()
        {
            Twin.ChangeConfiguration("baselineCustomChecksFilePath", null)
            .ChangeConfiguration("baselineCustomChecksFileHash", null)
            .ChangeConfiguration("baselineCustomChecksEnabled", "false");
            Assert.IsFalse(BaselineEventGenerator.IsCustomChecksEnabled());

            Twin.ChangeConfiguration("baselineCustomChecksEnabled", "true");
            Assert.IsFalse(BaselineEventGenerator.IsCustomChecksEnabled());

            Twin.ChangeConfiguration("baselineCustomChecksEnabled", "false");
            Twin.ChangeConfiguration("baselineCustomChecksFilePath", "not-null-or-empty");
            Assert.IsFalse(BaselineEventGenerator.IsCustomChecksEnabled());
        }
示例#8
0
        public void TestCacheSizeIsSmallerThanMessageSize()
        {
            Twin.ChangeConfiguration("maxLocalCacheSizeInBytes", "8000");

            var events = _genertorUnderTest.GetEvents();

            Assert.AreEqual(1, events.Count());

            var ev = events.Cast <ConfigurationError>().First();

            Assert.AreEqual(1, ev.Payload.Count());

            var payload = ev.Payload.First();

            Assert.AreEqual("maxLocalCacheSizeInBytes", payload.ConfigurationName);
            Assert.AreEqual(ConfigurationErrorType.Conflict, payload.ErrorType);
            Assert.AreEqual("8000", payload.UsedConfiguration);
        }
示例#9
0
        public void TestBadTypeConfiguration()
        {
            var oldTwin = AgentConfiguration.RemoteConfiguration;

            Twin.ChangeConfiguration("highPriorityMessageFrequency", "I'm a string, not a TimeSpan");

            var events = _genertorUnderTest.GetEvents();

            Assert.AreEqual(1, events.Count());

            var ev = events.Cast <ConfigurationError>().First();

            Assert.AreEqual(1, ev.Payload.Count());

            var payload = ev.Payload.First();

            Assert.AreEqual(nameof(RemoteConfiguration), payload.ConfigurationName);
            Assert.AreEqual(ConfigurationErrorType.TypeMismatch, payload.ErrorType);
            Assert.AreEqual(oldTwin, AgentConfiguration.RemoteConfiguration);
        }
示例#10
0
        public void TestHighPrioIntervalGreaterThanLowPrioInterval()
        {
            var oldTwin = AgentConfiguration.RemoteConfiguration;

            Twin.ChangeConfiguration("highPriorityMessageFrequency", "PT11H11M11S");

            var events = _genertorUnderTest.GetEvents();

            Assert.AreEqual(1, events.Count());

            var ev = events.Cast <ConfigurationError>().First();

            Assert.AreEqual(1, ev.Payload.Count());

            var payload = ev.Payload.First();

            Assert.AreEqual("highPriorityMessageFrequency", payload.ConfigurationName);
            Assert.AreEqual(ConfigurationErrorType.Conflict, payload.ErrorType);
            Assert.AreEqual("11:11:11", payload.UsedConfiguration);
        }
 /// <inheritdoc />
 protected override void ToggleAggregation(bool swith)
 {
     Twin.ChangeConfiguration("aggregationEnabledProcessTerminate", swith.ToString());
 }
 /// <inheritdoc />
 protected override void SetAggregationIntervalTime(string ISO8601Interval)
 {
     Twin.ChangeConfiguration("aggregationIntervalProcessTerminate", ISO8601Interval);
 }
示例#13
0
 /// <inheritdoc />
 protected override void ToggleAggregation(bool swith)
 {
     Twin.ChangeConfiguration("aggregationEnabledConnectionCreate", swith.ToString());
 }
示例#14
0
 /// <inheritdoc />
 protected override void SetAggregationIntervalTime(string ISO8601Interval)
 {
     Twin.ChangeConfiguration("aggregationIntervalConnectionCreate", ISO8601Interval);
 }
示例#15
0
 /// <inheritdoc />
 protected override void SetAggregationIntervalTime(string iso8601Interval)
 {
     Twin.ChangeConfiguration("aggregationIntervalProcessCreate", iso8601Interval);
 }