public void IsLoadProcessKeySetIfRestarted()
        {
            //Arrange
            ControlFlow.DefaultDbConnection = SqlConnection;
            CreateLoadProcessTableTask.Create("test_lp_restart");
            CreateLogTableTask.Create("test_log_restart");
            ControlFlow.AddLoggingDatabaseToConfig(SqlConnection, NLog.LogLevel.Info, "test_log_restart");

            //Act
            StartLoadProcessTask.Start("Test process 13");
            long?processId1 = ControlFlow.CurrentLoadProcess.Id;

            SqlTask.ExecuteNonQuery("Test Task", "Select 1 as test");
            Assert.Equal(2, new RowCountTask("test_log_restart", $"message='Test Task' AND load_process_id = {processId1}")
            {
                DisableLogging = true
            }.Count().Rows);

            StartLoadProcessTask.Start("Test process 14");
            long?processId2 = ControlFlow.CurrentLoadProcess.Id;

            //Assert
            Assert.NotEqual(processId1, processId2);
            SqlTask.ExecuteNonQuery("Test Task", "Select 1 as test");
            Assert.Equal(2, new RowCountTask("test_log_restart", $"message='Test Task' AND load_process_id = {processId2}")
            {
                DisableLogging = true
            }.Count().Rows);

            //Cleanup
            DropTableTask.Drop(ControlFlow.LogTable);
            DropTableTask.Drop(ControlFlow.LoadProcessTable);
        }
Esempio n. 2
0
        public void TestErrorLogging(IConnectionManager conn)
        {
            //Arrange
            CreateLogTableTask.Create(conn, "test_log");
            ControlFlow.AddLoggingDatabaseToConfig(conn, NLog.LogLevel.Trace, "test_log");
            //Act
            LogTask.Error(conn, "Error!");
            LogTask.Warn(conn, "Warn!");
            LogTask.Info(conn, "Info!");
            LogTask.Debug(conn, "Debug!");
            LogTask.Trace(conn, "Trace!");
            LogTask.Fatal(conn, "Fatal!");
            //Assert
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Error!' AND {conn.QB}level{conn.QE} = 'Error' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Warn!' AND {conn.QB}level{conn.QE} = 'Warn' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Info!' AND {conn.QB}level{conn.QE} = 'Info' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Debug!' AND {conn.QB}level{conn.QE} = 'Debug' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Trace!' AND {conn.QB}level{conn.QE} = 'Trace' AND {conn.QB}task_action{conn.QE} = 'LOG'"));
            Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable,
                                               $"{conn.QB}message{conn.QE} = 'Fatal!' AND {conn.QB}level{conn.QE} = 'Fatal' AND {conn.QB}task_action{conn.QE} = 'LOG'"));

            //Cleanup
            DropTableTask.Drop(conn, ControlFlow.LogTable);
        }
        public void IsLoadProcessKeySetForLogTask()
        {
            //Arrange
            ControlFlow.DefaultDbConnection = SqlConnection;
            CreateLoadProcessTableTask.Create("test_lp_logtask");
            CreateLogTableTask.Create("test_log_logtask");
            ControlFlow.AddLoggingDatabaseToConfig(SqlConnection, NLog.LogLevel.Info, "test_log_logtask");

            //Act
            StartLoadProcessTask.Start("Test process 15");
            long?processId1 = ControlFlow.CurrentLoadProcess.Id;

            LogTask.Error("Test1");
            LogTask.Warn("Test2");
            LogTask.Info("Test3");
            //Assert
            Assert.Equal(3, new RowCountTask("test_log_logtask",
                                             $"message like 'Test%' AND load_process_id = {processId1}")
            {
                DisableLogging = true
            }.Count().Rows);

            //Cleanup
            DropTableTask.Drop(ControlFlow.LogTable);
            DropTableTask.Drop(ControlFlow.LoadProcessTable);
        }
Esempio n. 4
0
        public void IsLoadProcessKeyInLog(IConnectionManager conn)
        {
            //Arrange
            CreateLoadProcessTableTask.Create(conn, "test_lpkey_inlog");
            CreateLogTableTask.Create(conn, "test_lpkey_log");
            ControlFlow.AddLoggingDatabaseToConfig(conn, NLog.LogLevel.Info, "test_lpkey_log");
            StartLoadProcessTask.Start(conn, "Test process 5");

            //Act
            string fromdual = conn.GetType() == typeof(OracleConnectionManager) ? "FROM DUAL" : "";

            SqlTask.ExecuteNonQuery(conn, "Test Task", $"Select 1 AS test {fromdual}");

            //Assert
            Assert.Equal(2, new RowCountTask("test_lpkey_log",
                                             $"{conn.QB}message{conn.QE}='Test Task' AND {conn.QB}load_process_id{conn.QE} = {ControlFlow.CurrentLoadProcess.Id}")
            {
                DisableLogging    = true,
                ConnectionManager = conn
            }.Count().Rows);;

            //Cleanup
            DropTableTask.Drop(conn, ControlFlow.LogTable);
            DropTableTask.Drop(conn, ControlFlow.LoadProcessTable);
        }
Esempio n. 5
0
 public GetLogAsJsonTests(LoggingDatabaseFixture dbFixture)
 {
     CreateLoadProcessTableTask.Create(SqlConnection);
     CreateLogTableTask.Create(SqlConnection);
     ControlFlow.AddLoggingDatabaseToConfig(SqlConnection);
     ControlFlow.DefaultDbConnection = SqlConnection;
 }
Esempio n. 6
0
        public void TestReadLogTask(IConnectionManager connection)
        {
            //Arrange
            CreateLogTableTask.Create(connection, "test_readlog");
            ControlFlow.AddLoggingDatabaseToConfig(connection, NLog.LogLevel.Info, "test_readlog");
            SqlTask.ExecuteNonQuery(connection, "Test Task", "Select 1 as test");

            //Act
            List <LogEntry> entries = ReadLogTableTask.Read(connection);

            //Assert
            Assert.Collection <LogEntry>(entries,
                                         l => Assert.True(l.Message == "Test Task" && l.TaskAction == "START" && l.TaskType == "SqlTask"),
                                         l => Assert.True(l.Message == "Test Task" && l.TaskAction == "END" && l.TaskType == "SqlTask")
                                         );

            //Cleanup
            DropTableTask.Drop(connection, ControlFlow.LogTable);
        }
Esempio n. 7
0
        public void IsControlFlowStageLogged()
        {
            //Arrange
            CreateLogTableTask.Create(SqlConnection, "test_log_stage");
            ControlFlow.AddLoggingDatabaseToConfig(SqlConnection, NLog.LogLevel.Debug, "test_log_stage");

            //Act
            ControlFlow.STAGE = "SETUP";
            SqlTask.ExecuteNonQuery(SqlConnection, "Test Task", "Select 1 as test");

            //Assert
            Assert.Equal(2, new RowCountTask("test_log_stage",
                                             $"message='Test Task' AND stage = 'SETUP'")
            {
                DisableLogging    = true,
                ConnectionManager = SqlConnection
            }.Count().Rows);

            //Cleanup
            DropTableTask.Drop(SqlConnection, ControlFlow.LogTable);
        }
        public void IsLoadProcessKeyInLog(IConnectionManager connection)
        {
            //Arrange
            CreateLoadProcessTableTask.Create(connection, "test_lpkey_inlog");
            CreateLogTableTask.Create(connection, "test_lpkey_log");
            ControlFlow.AddLoggingDatabaseToConfig(connection, NLog.LogLevel.Info, "test_lpkey_log");
            StartLoadProcessTask.Start(connection, "Test process 5");

            //Act
            SqlTask.ExecuteNonQuery(connection, "Test Task", "Select 1 as test");

            //Assert
            Assert.Equal(2, new RowCountTask("test_lpkey_log",
                                             $"message='Test Task' and load_process_id = {ControlFlow.CurrentLoadProcess.Id}")
            {
                DisableLogging    = true,
                ConnectionManager = connection
            }.Count().Rows);;

            //Cleanup
            DropTableTask.Drop(connection, ControlFlow.LogTable);
            DropTableTask.Drop(connection, ControlFlow.LoadProcessTable);
        }
 public GetLoadProcessAsJSONTaskTests(LoggingDatabaseFixture dbFixture)
 {
     CreateLogTableTask.Create(SqlConnection);
     CreateLoadProcessTableTask.Create(SqlConnection);
     ControlFlow.AddLoggingDatabaseToConfig(SqlConnection);
 }
 public DataFlowLoggingTests(LoggingDatabaseFixture dbFixture)
 {
     CreateLogTableTask.Create(SqlConnection);
     ControlFlow.AddLoggingDatabaseToConfig(SqlConnection);
 }
Esempio n. 11
0
 public DifferentLoggingDBTests(LoggingDatabaseFixture dbFixture, OtherDBFixture odbFixture)
 {
     CreateLogTableTask.Create(LoggingConnection);
     ControlFlow.AddLoggingDatabaseToConfig(LoggingConnection);
 }