public void DeleteOldBackupDataBase() { int backupCount = DataBaseHelper.GetTotalBackupDataBaseCount(); //Last 5 backups will be preserved by the task. Hence if the current backupcount is less than five create more backup to trigger a delete. if (backupCount < 5) { int toCreateCount = 6 - backupCount; for (int i = 0; i < toCreateCount; i++) { string backupName = TaskInvocationHelper.InvokeBackUpDataBaseTask(false); Assert.IsTrue(DataBaseHelper.VerifyDataBaseCreation(backupName), " The back up with name {0} didnt get created properly. See logs for details", "backupName"); } } //Check that the expected count of backups (6) is being present now. backupCount = DataBaseHelper.GetTotalBackupDataBaseCount(); Assert.IsTrue((backupCount == 6), " The number of backups are not as expected after creating new backups. Actual : {0}, Expected : {1}", backupCount, 6); //Invoke the delete task. TaskInvocationHelper.InvokeDeleteOldDatabseBackupsTask(); int newbackupCount = DataBaseHelper.GetTotalBackupDataBaseCount(); //Actual count of backups should be 5 after invoking the task. Assert.IsTrue((5 == newbackupCount), "Backups not deleted properly through DeleteOldBackupDatabase task."); }
public void BackUpDataBaseTaskIfOlderThanTest() { string backupName = TaskInvocationHelper.InvokeBackUpDataBaseTask(false); Assert.IsTrue(DataBaseHelper.VerifyDataBaseCreation(backupName), " The back up with name {0} didnt get created properly. See logs for details", "backupName"); //Try to create a second one with if string secondbackupName = TaskInvocationHelper.InvokeBackUpDataBaseTask(false, 4 * 60 * 60 * 1000); }
public void BackUpDataBaseTaskReturnsIfBackUpInProgressTest() { string backupName = TaskInvocationHelper.InvokeBackUpDataBaseTask(false); Assert.IsNotNull(backupName, " The backup with name {0} didnt get created properly.", backupName); Assert.IsTrue(DataBaseHelper.GetDataBaseState(backupName) == DataBaseState.Copying); string secondBackupName = TaskInvocationHelper.InvokeBackUpDataBaseTask(false); Assert.IsNull(secondBackupName, " BackUp task didnt skip when a backup is already in progress"); //Verify the completion if first db. So that consecutive tests will not get affected. Assert.IsTrue(DataBaseHelper.VerifyDataBaseCreation("Backup_20130412232156"), " The back up with name {0} didnt get created properly. See logs for details", "backupName"); }
public void AggregateStatsTest() { int PrevCount = DataBaseHelper.GetTotalDownCount(); string packageId = DateTime.Now.Ticks.ToString(); PackageHelper.UploadNewPackage(packageId); PackageHelper.DownloadPackage(packageId); TaskInvocationHelper.InvokeAggregateStatsTask(); int currentCount = DataBaseHelper.GetTotalDownCount(); //Instead of increasing by 1, we need to get the count of new rows in package statistics. Assert.IsTrue((currentCount == PrevCount + 1), "The total download count did not increase by one after executing the aggregate stats task"); }
public void CreateAndVerifyNewWareHouseDb(string warehouseDbName) { //Create a new database. DataBaseHelper.CreateDataBase(warehouseDbName); //The initial table count would be 0. int count = DataBaseHelper.GetTableCount(warehouseDbName); Assert.IsTrue((count == 0), "Initial count of tables is not 0 right after creating warehouse DB. Actual : {0}", count); //Invoke the task. TaskInvocationHelper.InvokeCreateWarehouseArtifactTask(DataBaseHelper.GetConnectionStringForDataBase(warehouseDbName), false); //The task should be have created 8 tables in the database. count = DataBaseHelper.GetTableCount(warehouseDbName); Assert.IsTrue((count == 8), "Count of tables is not 8 in the warehouse DB after executing the CreateWarehouseArtifactTask. Actual : {0}", count); //To do : Add more validations around the data that has to be present in the tables. }
public void ReplicatePackageStatisticsTaskBasicTest() { //Create a new DB and create artifacts in it. string warehouseDbName = "Warehouse" + DateTime.Now.Ticks.ToString(); base.CreateAndVerifyNewWareHouseDb(warehouseDbName); //Invoke the replicate task initially. int count = TaskInvocationHelper.InvokeReplicatePackageStatisticsTask(DataBaseHelper.GetConnectionStringForDataBase(warehouseDbName)); //upload a new package and download it. string packageId = DateTime.Now.Ticks.ToString(); PackageHelper.UploadNewPackage(packageId); PackageHelper.DownloadPackage(packageId); //invoke the task again. count = TaskInvocationHelper.InvokeReplicatePackageStatisticsTask(DataBaseHelper.GetConnectionStringForDataBase(warehouseDbName)); //Check that the count of rows replicated is one now. //TDB : This might not be one always ( in case if there is some additional download. The test assumes that no one else is using the BVT environment). Assert.IsTrue((count == 1), "The count of packages being replicated after downloading one package is not one. Actual count : {1}", count); }
public void DeleteOldBackupSkipsIfNumberofBackupsLessThan5() { int backupCount = DataBaseHelper.GetTotalBackupDataBaseCount(); //TDB: Update the test after the bug https://github.com/NuGet/NuGetOperations/issues/32 is fixed. if (backupCount > 5) { //If count > 5, delete all of the, except 2 backups. List <Database> dbs = DataBaseHelper.GetAllDatabaseBackups(); int toDeleteCount = backupCount - 2; for (int i = 0; i < toDeleteCount; i++) { DataBaseHelper.DeleteDataBase(dbs[i].Name); } } backupCount = DataBaseHelper.GetTotalBackupDataBaseCount(); //Invoke the task. The count of backups should remain the same (2) before and after invoking the task. TaskInvocationHelper.InvokeDeleteOldDatabseBackupsTask(); int newbackupCount = DataBaseHelper.GetTotalBackupDataBaseCount(); Assert.IsTrue((backupCount == newbackupCount), "The count of the backup database is not as expected after executing the DeleteOldDatabaseBackupsTask. Actual : {0}, expected : {1}", newbackupCount, backupCount); }
public void BackUpDataBaseTaskWhatIfTest() { string backupName = TaskInvocationHelper.InvokeBackUpDataBaseTask(true); Assert.IsNull(backupName, " The backup with name {0} got created when run in WhatIfMode.", backupName); }
public void BackUpDataBaseTaskTest() { string backupName = TaskInvocationHelper.InvokeBackUpDataBaseTask(false); Assert.IsTrue(DataBaseHelper.VerifyDataBaseCreation(backupName), " The back up with name {0} didnt get created properly. See logs for details", "backupName"); }