Пример #1
0
        public void UnsupportedLogType()
        {
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new LogShark.Plugins.TabadminController.TabadminControllerPlugin())
            {
                plugin.Configure(testWriterFactory, null, _processingNotificationsCollectorMock.Object, new NullLoggerFactory());

                var someLogLine = new LogLine(
                    new ReadLogLineResult(123, "2020-09-28 17:47:01.730 -0500  pool-20-thread-1 : INFO  com.tableausoftware.tabadmin.webapp.asyncjobs.AsyncJobService - Running job 117 of type StartServerJob"),
                    TestLogFileInfo);
                Action wrongLogTypeAction = () => { plugin.ProcessLogLine(someLogLine, LogType.Apache); };
                wrongLogTypeAction.Should().Throw <LogSharkProgramLogicException>();

                plugin.CompleteProcessing();
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
            _processingNotificationsCollectorMock.VerifyNoOtherCalls();
        }
Пример #2
0
        public void NotAJavaLine()
        {
            var testWriterFactory = new TestWriterFactory();
            var logLine           = new LogLine(new ReadLogLineResult(123, "Not a Java Log Line"), TestLogFileInfo);

            using (var plugin = new LogShark.Plugins.TabadminController.TabadminControllerPlugin())
            {
                plugin.Configure(testWriterFactory, null, _processingNotificationsCollectorMock.Object, new NullLoggerFactory());
                plugin.ProcessLogLine(logLine, LogType.TabadminControllerJava);
                plugin.CompleteProcessing();
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
            _processingNotificationsCollectorMock.Verify(m => m.ReportError(
                                                             It.IsAny <string>(),
                                                             logLine,
                                                             nameof(LogShark.Plugins.TabadminController.TabadminControllerPlugin)),
                                                         Times.Once);
            _processingNotificationsCollectorMock.VerifyNoOtherCalls();
        }
        public void BadInput()
        {
            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new SearchServerPlugin())
            {
                plugin.Configure(testWriterFactory, null, processingNotificationsCollector, new NullLoggerFactory());

                var wrongContentFormat = new LogLine(new ReadLogLineResult(123, 1234), TestLogFileInfo);
                var nullContent        = new LogLine(new ReadLogLineResult(123, null), TestLogFileInfo);
                var incorrectContent   = new LogLine(new ReadLogLineResult(123, "I am not a SearchServer line!"), TestLogFileInfo);

                plugin.ProcessLogLine(wrongContentFormat, LogType.SearchServer);
                plugin.ProcessLogLine(nullContent, LogType.SearchServer);
                plugin.ProcessLogLine(incorrectContent, LogType.SearchServer);
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
            processingNotificationsCollector.TotalErrorsReported.Should().Be(3);
        }
Пример #4
0
        public void BadAndNoOpInput()
        {
            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new TabadminPlugin())
            {
                plugin.Configure(testWriterFactory, null, processingNotificationsCollector, new NullLoggerFactory());

                var wrongContentFormat = new LogLine(new ReadLogLineResult(123, 1234), TestLogFileInfo);
                var nullContent        = new LogLine(new ReadLogLineResult(123, null), TestLogFileInfo);
                var wrongContent       = new LogLine(new ReadLogLineResult(123, "Not a tabadmin line"), TestLogFileInfo);

                plugin.ProcessLogLine(wrongContentFormat, LogType.Apache);
                plugin.ProcessLogLine(nullContent, LogType.Apache);
                plugin.ProcessLogLine(wrongContent, LogType.Apache);
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(3);
            processingNotificationsCollector.TotalErrorsReported.Should().Be(3);
        }
Пример #5
0
        public void BadInput()
        {
            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new NetstatPlugin())
            {
                plugin.Configure(testWriterFactory, null, processingNotificationsCollector, new NullLoggerFactory());
                var logFileInfo = new LogFileInfo("netstat-anp.txt", @"folder1/netstat-anp.txt", "worker1", new DateTime(2019, 04, 12, 13, 33, 31));

                var wrongContentFormat = new LogLine(new ReadLogLineResult(123, 1234), logFileInfo);
                var nullContent        = new LogLine(new ReadLogLineResult(123, null), logFileInfo);

                plugin.ProcessLogLine(wrongContentFormat, LogType.NetstatLinux);
                plugin.ProcessLogLine(nullContent, LogType.NetstatLinux);
                plugin.ProcessLogLine(nullContent, LogType.NetstatWindows);
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
            processingNotificationsCollector.TotalErrorsReported.Should().Be(3);
        }
        public void BadOrNoOpInput()
        {
            var processingNotificationsCollector = new ProcessingNotificationsCollector(10);
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new VizqlDesktopPlugin())
            {
                plugin.Configure(testWriterFactory, null, processingNotificationsCollector, new NullLoggerFactory());

                var wrongContentFormat = new LogLine(new ReadLogLineResult(123, "VizqlDesktop doesn't expect string"), TestLogFileInfo);
                var nullContent        = new LogLine(new ReadLogLineResult(123, null), TestLogFileInfo);
                var noOpContentType    = new LogLine(new ReadLogLineResult(123, new NativeJsonLogsBaseEvent {
                    EventType = "something else"
                }), TestLogFileInfo);

                plugin.ProcessLogLine(wrongContentFormat, LogType.BackgrounderJava);
                plugin.ProcessLogLine(nullContent, LogType.BackgrounderJava);
                plugin.ProcessLogLine(noOpContentType, LogType.BackgrounderJava);
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(4);
            processingNotificationsCollector.TotalErrorsReported.Should().Be(2);
        }
Пример #7
0
        public void RunTestCases(string testName, string logLineText, DateTime timestamp, LogType logType, IDictionary <string, object> nonNullProps)
        {
            var testWriterFactory = new TestWriterFactory();
            var logLine           = new LogLine(new ReadLogLineResult(123, logLineText), TestLogFileInfo);
            SinglePluginExecutionResults processingResults;

            using (var plugin = new LogShark.Plugins.TabadminController.TabadminControllerPlugin())
            {
                plugin.Configure(testWriterFactory, null, _processingNotificationsCollectorMock.Object, new NullLoggerFactory());
                plugin.ProcessLogLine(logLine, logType);
                processingResults = plugin.CompleteProcessing();
            }

            _processingNotificationsCollectorMock.VerifyNoOtherCalls();

            processingResults.AdditionalTags.Should().BeEmpty();
            processingResults.HasAdditionalTags.Should().BeFalse();
            processingResults.WritersStatistics.Count.Should().Be(1);

            if (nonNullProps == null)
            {
                testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
                processingResults.WritersStatistics[0].LinesPersisted.Should().Be(0);
                return;
            }

            processingResults.WritersStatistics[0].LinesPersisted.Should().Be(1);
            var testWriter = testWriterFactory.GetOneWriterAndVerifyOthersAreEmptyAndDisposed <TabadminControllerEvent>("TabadminControllerEvents", 1);

            testWriter.ReceivedObjects.Count.Should().Be(1);
            var result = testWriter.ReceivedObjects.FirstOrDefault() as TabadminControllerEvent;

            result.Should().NotBeNull();
            AssertMethods.AssertThatAllClassOwnPropsAreAtDefaultExpectFor(result, nonNullProps, testName);
            result.VerifyBaseEventProperties(timestamp, logLine);
        }