public void ReadLastAbortedProcess() { //Arrange StartLoadProcessTask.Start("Test process 10"); Task.Delay(10).Wait(); //Sql Server datetime is not that exact EndLoadProcessTask.End(); Task.Delay(10).Wait(); StartLoadProcessTask.Start("Test process 11"); Task.Delay(10).Wait(); //Sql Server datetime is not that exact AbortLoadProcessTask.Abort(); StartLoadProcessTask.Start("Test process 12"); Task.Delay(10).Wait(); //Sql Server datetime is not that exact EndLoadProcessTask.End(); //Act var lp = ReadLoadProcessTableTask.ReadWithOption(ReadOptions.ReadLastAborted); //Assert Assert.True(lp.IsFinished); Assert.True(lp.WasAborted); Assert.False(lp.WasSuccessful); Assert.Equal("Test process 11", lp.ProcessName); Assert.Equal(3, new RowCountTask("etl.LoadProcess", "IsFinished=1") { DisableLogging = true }.Count().Rows); Assert.Equal(2, new RowCountTask("etl.LoadProcess", "WasSuccessful=1") { DisableLogging = true }.Count().Rows); Assert.Equal(1, new RowCountTask("etl.LoadProcess", "WasAborted=1") { DisableLogging = true }.Count().Rows); }
public void EndLoadProcess() { //Arrange StartLoadProcessTask.Start("Test process 2"); Assert.True(ControlFlow.CurrentLoadProcess.IsRunning == true); DateTime beforeTask = DateTime.Now; Task.Delay(10).Wait(); //Sql Server datetime is not that exact //Act EndLoadProcessTask.End(); //Assert DateTime afterTask = DateTime.Now; Assert.True(ControlFlow.CurrentLoadProcess.IsRunning == false); Assert.True(ControlFlow.CurrentLoadProcess.WasSuccessful == true); Assert.True(ControlFlow.CurrentLoadProcess.IsFinished == true); Assert.True(ControlFlow.CurrentLoadProcess.EndDate <= afterTask && ControlFlow.CurrentLoadProcess.EndDate >= beforeTask); Assert.False(new SqlTask("Check if logging was disabled for end process task", "select count(*) from etl.Log") { DisableLogging = true }.ExecuteScalarAsBool()); Assert.Equal(1, new RowCountTask("etl.LoadProcess ", "IsRunning=0 and WasSuccessful=1 and WasAborted=0") { DisableLogging = true }.Count().Rows); Assert.Equal(1, new RowCountTask("etl.LoadProcess", "StartMessage is null and EndMessage is null and AbortMessage is null") { DisableLogging = true }.Count().Rows); }
public void EndLoadProcess(IConnectionManager connection) { //Arrange CreateLoadProcessTableTask.Create(connection, "test_lp_end"); StartLoadProcessTask.Start(connection, "Test process 2"); Assert.True(ControlFlow.CurrentLoadProcess.IsRunning == true); //Act EndLoadProcessTask.End(connection, "End process 2"); //Assert Assert.True(ControlFlow.CurrentLoadProcess.IsRunning == false); Assert.True(ControlFlow.CurrentLoadProcess.WasSuccessful == true); Assert.True(ControlFlow.CurrentLoadProcess.IsFinished == true); Assert.True(ControlFlow.CurrentLoadProcess.EndDate >= DateTime.Now.AddSeconds(-1)); Assert.Equal(1, RowCountTask.Count(connection, "test_lp_end", "is_running=0 and was_successful=1 and was_aborted=0")); Assert.Equal(1, RowCountTask.Count(connection, "test_lp_end", "start_message IS NULL AND end_message = 'End process 2' AND abort_message IS NULL")); //Cleanup DropTableTask.Drop(connection, "test_lp_end"); }
public void ReadLastAbortedProcess() { //Arrange ControlFlow.DefaultDbConnection = SqlConnection; CreateLoadProcessTableTask.Create("test_lpkey_lastabort"); StartLoadProcessTask.Start("Test process 10"); Task.Delay(10).Wait(); //Sql Server datetime is not that exact EndLoadProcessTask.End(); Task.Delay(10).Wait(); StartLoadProcessTask.Start("Test process 11"); Task.Delay(10).Wait(); //Sql Server datetime is not that exact AbortLoadProcessTask.Abort(); StartLoadProcessTask.Start("Test process 12"); Task.Delay(10).Wait(); //Sql Server datetime is not that exact EndLoadProcessTask.End(); //Act var lp = ReadLoadProcessTableTask.ReadWithOption(ReadOptions.ReadLastAborted); //Assert Assert.True(lp.IsFinished); Assert.True(lp.WasAborted); Assert.False(lp.WasSuccessful); Assert.Equal("Test process 11", lp.ProcessName); //Cleanup DropTableTask.Drop(SqlConnection, "test_lpkey_lastabort"); }
public void TestEndLoadProcessTask() { StartLoadProcessTask.Start("Test process 2"); Assert.IsTrue(ControlFlow.CurrentLoadProcess.IsRunning == true); DateTime beforeTask = DateTime.Now; Task.Delay(10).Wait(); //Sql Server datetime is not that exact EndLoadProcessTask.End(); DateTime afterTask = DateTime.Now; Assert.IsTrue(ControlFlow.CurrentLoadProcess.IsRunning == false); Assert.IsTrue(ControlFlow.CurrentLoadProcess.WasSuccessful == true); Assert.IsTrue(ControlFlow.CurrentLoadProcess.IsFinished == true); Assert.IsTrue(ControlFlow.CurrentLoadProcess.EndDate <= afterTask && ControlFlow.CurrentLoadProcess.EndDate >= beforeTask); Assert.IsFalse(new SqlTask("Check if logging was disabled for end process task", "select count(*) from etl.Log") { DisableLogging = true }.ExecuteScalarAsBool()); Assert.AreEqual(1, new SqlTask("Check if load process entry is correct", $"select count(*) from etl.LoadProcess where IsRunning=0 and WasSuccessful=1 and WasAborted=0") { DisableLogging = true }.ExecuteScalar <int>()); Assert.AreEqual(1, new SqlTask("Check if load process messages are correct", $"select count(*) from etl.LoadProcess where StartMessage is null and EndMessage is null and AbortMessage is null") { DisableLogging = true }.ExecuteScalar <int>()); }
public void TestReadLastAbortedProcess() { StartLoadProcessTask.Start("Test process 10"); Task.Delay(10).Wait(); //Sql Server datetime is not that exact EndLoadProcessTask.End(); Task.Delay(10).Wait(); StartLoadProcessTask.Start("Test process 11"); Task.Delay(10).Wait(); //Sql Server datetime is not that exact AbortLoadProcessTask.Abort(); StartLoadProcessTask.Start("Test process 12"); Task.Delay(10).Wait(); //Sql Server datetime is not that exact EndLoadProcessTask.End(); var lp = ReadLoadProcessTableTask.ReadWithOption(ReadOptions.ReadLastAborted); Assert.IsTrue(lp.IsFinished); Assert.IsTrue(lp.WasAborted); Assert.IsFalse(lp.WasSuccessful); Assert.AreEqual("Test process 11", lp.ProcessName); Assert.AreEqual(3, new SqlTask("Check if finished processes exists", $"select count(*) from etl.LoadProcess where IsFinished=1") { DisableLogging = true }.ExecuteScalar <int>()); Assert.AreEqual(2, new SqlTask("Check if successful processes exists", $"select count(*) from etl.LoadProcess where WasSuccessful=1") { DisableLogging = true }.ExecuteScalar <int>()); Assert.AreEqual(1, new SqlTask("Check if aborted processes exists", $"select count(*) from etl.LoadProcess where WasAborted=1") { DisableLogging = true }.ExecuteScalar <int>()); }
public void Start() { //Recreate database ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;")); DropDatabaseTask.Drop("DemoDB"); CreateDatabaseTask.Create("DemoDB"); ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;Initial Catalog=DemoDB;")); //Logging (only works with existing configuration nlog config in App.config) CreateLogTablesTask.CreateLog(); StartLoadProcessTask.Start("Process 1"); ControlFlow.STAGE = "Staging"; SqlTask.ExecuteNonQuery("some sql", "Select 1 as test"); TransferCompletedForLoadProcessTask.Complete(); ControlFlow.STAGE = "DataVault"; Sequence.Execute("some custom code", () => { }); LogTask.Warn("Some warning!"); EndLoadProcessTask.End("Everything successful"); string jsonLP = GetLoadProcessAsJSONTask.GetJSON(); string jsonLog = GetLogAsJSONTask.GetJSON(1); }
public void LoggingInSourceAndDestination() { CreateLogTablesTask.CreateLog(); StartLoadProcessTask.Start("Test"); DataFlow.LoggingThresholdRows = 3; DBSource source; DBDestination dest; CreateSourceAndDestination(out source, out dest); source.LinkTo(dest); source.Execute(); dest.Wait(); EndLoadProcessTask.End(); Assert.AreEqual(4, RowCountTask.Count("etl.Log", "TaskType = 'DF_DBSOURCE' AND TaskAction = 'LOG' AND LoadProcessKey IS NOT NULL")); Assert.AreEqual(4, RowCountTask.Count("etl.Log", "TaskType = 'DF_DBDEST' AND TaskAction = 'LOG' AND LoadProcessKey IS NOT NULL")); Assert.AreEqual(1, RowCountTask.Count("etl.LoadProcess")); }
private void RunProcess1() { StartLoadProcessTask.Start("Process 1", "Start"); SqlTask.ExecuteNonQuery($"Just some sql", "Select 1 as test"); EndLoadProcessTask.End("End"); }