Esempio n. 1
0
        public void AddingOverlappingRecordsForTheSameBuild()
        {
            _buildTracker.AddBuild(TestTimestamp, TestBuild); // Same timestamp
            _buildTracker.AddBuild(TestTimestamp.AddSeconds(1), TestBuild);

            _buildTracker.GetBuild(TestTimestamp).Should().Be(TestBuild);
            _buildTracker.GetBuild(TestTimestamp.AddMinutes(2)).Should().Be(null);

            // Subtest 1 - adding a record that is 1 minute later. This should extend window by 1 minute ahead
            _buildTracker.AddBuild(TestTimestamp.AddMinutes(1), TestBuild);

            void AssertSubtest1Results()
            {
                _buildTracker.GetBuild(TestTimestamp.Subtract(TimeSpan.FromMinutes(2))).Should().Be(null);
                _buildTracker.GetBuild(TestTimestamp.Subtract(TimeSpan.FromMinutes(1))).Should().Be(TestBuild);
                _buildTracker.GetBuild(TestTimestamp).Should().Be(TestBuild);
                _buildTracker.GetBuild(TestTimestamp.AddMinutes(1)).Should().Be(TestBuild);
                _buildTracker.GetBuild(TestTimestamp.AddMinutes(2)).Should().Be(TestBuild);
                _buildTracker.GetBuild(TestTimestamp.AddMinutes(3)).Should().Be(null);
            }

            AssertSubtest1Results();

            // Subtest 2 - adding a record that is far from the original record, so we should now have 2 disjoined time frames
            const string build2     = "someOtherBuild";
            var          timestamp2 = TestTimestamp.AddMinutes(10);

            _buildTracker.AddBuild(timestamp2, build2);
            AssertSubtest1Results();
            _buildTracker.GetBuild(timestamp2.AddMinutes(-2)).Should().Be(null);
            _buildTracker.GetBuild(timestamp2.AddMinutes(-1)).Should().Be(build2);
            _buildTracker.GetBuild(timestamp2).Should().Be(build2);
            _buildTracker.GetBuild(timestamp2.AddMinutes(1)).Should().Be(build2);
            _buildTracker.GetBuild(timestamp2.AddMinutes(2)).Should().Be(null);
        }
Esempio n. 2
0
        private TabadminControllerEvent ParseVersionInfo(LogLine logLine, JavaLineMatchResult javaLineMatchResult)
        {
            var match = LoadingTopologyLine.Match(javaLineMatchResult.Message);

            if (!match.Success)
            {
                return(null);
            }

            var rawBuild = match.GetNullableString("build");

            if (string.IsNullOrWhiteSpace(rawBuild))
            {
                _processingNotificationsCollector.ReportError("Line looks like a loading topology settings, but build string cannot be parsed", logLine, nameof(TabadminControllerEventParser));
                return(null);
            }

            var build = rawBuild.StartsWith("0.")
                ? rawBuild.Substring(2)
                : rawBuild;

            _buildTracker.AddBuild(javaLineMatchResult.Timestamp, build);

            return(new TabadminControllerEvent("Loading Topology", logLine, javaLineMatchResult, _buildTracker));
        }
Esempio n. 3
0
 public BuildTrackerTests()
 {
     _processingNotificationsCollectorMock = new Mock <IProcessingNotificationsCollector>();
     _buildTracker = new BuildTracker(_processingNotificationsCollectorMock.Object);
     _buildTracker.AddBuild(TestTimestamp, TestBuild);
 }