From aaaa8cc5a6ce948813094b41128bcde18737d7d6 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 06:43:14 -0400 Subject: [PATCH 01/14] Fixed really small number test --- .../DataAccess/LeadTimeForChangesDA.cs | 2 +- .../Service/DORASummaryControllerTests.cs | 62 ++++++++++++++++++- .../LeadTimeForChangesControllerTests.cs | 13 ++-- 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/DevOpsMetrics.Core/DataAccess/LeadTimeForChangesDA.cs b/src/DevOpsMetrics.Core/DataAccess/LeadTimeForChangesDA.cs index d7082a8a..5134a370 100644 --- a/src/DevOpsMetrics.Core/DataAccess/LeadTimeForChangesDA.cs +++ b/src/DevOpsMetrics.Core/DataAccess/LeadTimeForChangesDA.cs @@ -323,7 +323,7 @@ public static async Task GetGitHubLeadTimesForChanges(b AverageBuildHours = averageBuildHours, AveragePullRequestHours = leadTime, LeadTimeForChangesMetric = leadTime + averageBuildHours, - LeadTimeForChangesMetricDescription = LeadTimeForChanges.GetLeadTimeForChangesRating(leadTime), + LeadTimeForChangesMetricDescription = LeadTimeForChanges.GetLeadTimeForChangesRating(leadTime + averageBuildHours), PullRequests = utility.GetLastNItems(pullRequests, maxNumberOfItems), NumberOfDays = numberOfDays, MaxNumberOfItems = uiPullRequests.Count, diff --git a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs index abaf3396..b5b13953 100644 --- a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs @@ -1,5 +1,11 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Diagnostics; +using System.Reflection; +using System.Threading.Tasks; +using DevOpsMetrics.Core.DataAccess.TableStorage; +using DevOpsMetrics.Core.Models.AzureDevOps; using DevOpsMetrics.Core.Models.Common; +using DevOpsMetrics.Core.Models.GitHub; using DevOpsMetrics.Service.Controllers; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -49,5 +55,59 @@ public async Task DORASummaryControllerUpdateIntegrationTest() //Assert.IsTrue(model.TotalResults > 0); } + [TestMethod] + public async Task DORASummaryControllerUpdateALLIntegrationTest() + { + //Arrange + int numberOfDays = 30; + int maxNumberOfItems = 20; + int totalResults = 0; + DORASummaryController controller = new(base.Configuration); + SettingsController settingsController = new(base.Configuration, new AzureTableStorageDA()); + + //Act + List azSettings = settingsController.GetAzureDevOpsSettings(); + List ghSettings = settingsController.GetGitHubSettings(); + + foreach (AzureDevOpsSettings item in azSettings) + { + // (int, string) buildsUpdated = (0, null); + // (int, string) prsUpdated = (0, null); + // try + // { + //log.LogInformation($"Processing Azure DevOps organization {item.Organization}, project {item.Project}"); + // buildsUpdated = await api.UpdateAzureDevOpsBuilds(item.Organization, item.Project, item.Repository, item.Branch, item.BuildName, item.BuildId, numberOfDays, maxNumberOfItems); + // prsUpdated = await api.UpdateAzureDevOpsPullRequests(item.Organization, item.Project, item.Repository, numberOfDays, maxNumberOfItems); + // log.LogInformation($"Processed Azure DevOps organization {item.Organization}, project {item.Project}. {buildsUpdated.Item1} builds and {prsUpdated.Item1} prs/commits updated"); + // totalResults += buildsUpdated.Item1 + prsUpdated.Item1; + // await api.UpdateAzureDevOpsProjectLog(item.Organization, item.Project, item.Repository, buildsUpdated.Item1, prsUpdated.Item1, buildsUpdated.Item2, prsUpdated.Item2, null, null); + // } + // catch (Exception ex) + // { + // string error = $"Exception while processing Azure DevOps organization {item.Organization}, project {item.Project}. {buildsUpdated.Item1} builds and {prsUpdated.Item1} prs/commits updated"; + // log.LogInformation(error); + // await api.UpdateAzureDevOpsProjectLog(item.Organization, item.Project, item.Repository, buildsUpdated.Item1, prsUpdated.Item1, buildsUpdated.Item2, prsUpdated.Item2, ex.Message, error); + // } + } + + foreach (GitHubSettings ghSetting in ghSettings) + { + Debug.WriteLine($"Owner {ghSetting.Owner}, Repo {ghSetting.Repo}"); + ProcessingResult ghResult = await controller.UpdateDORASummaryItem( + ghSetting.Owner, ghSetting.Repo, ghSetting.Branch, + ghSetting.WorkflowName, ghSetting.WorkflowId, + ghSetting.ProductionResourceGroup, + numberOfDays, maxNumberOfItems); + totalResults += ghResult.TotalResults; + Assert.IsNotNull(ghResult); + } + + //ProcessingResult model = await controller.UpdateDORASummaryItem(organization, repository, + // branch, workflowName, workflowId, resourceGroup, numberOfDays, maxNumberOfItems); + + //Assert + Assert.IsTrue(totalResults > 0); + } + } } diff --git a/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs b/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs index eb233d2f..7469dad3 100644 --- a/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs @@ -247,11 +247,16 @@ public async Task GHLeadTimeControllerAPILiveIntegrationTest() { //Arrange bool getSampleData = false; - string owner = "DeveloperMetrics"; - string repo = "devopsmetrics"; + //string owner = "DeveloperMetrics"; + //string repo = "devopsmetrics"; + //string branch = "main"; + //string workflowName = "DevOpsMetrics.CICD"; + //string workflowId = "1162561"; + string owner = "samsmithnz"; + string repo = "AzurePipelinesToGitHubActionsConverter"; string branch = "main"; - string workflowName = "DevOpsMetrics.CICD"; - string workflowId = "1162561"; + string workflowName = "CI/ CD"; + string workflowId = "38158"; int numberOfDays = 20; int maxNumberOfItems = 60; bool useCache = true; From fc6055c130575876d25ad4cf3661d787130ad181 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 06:49:08 -0400 Subject: [PATCH 02/14] Updated test --- .../Service/ChangeFailureRateTests.cs | 8 ++++++-- .../Service/LeadTimeForChangesControllerTests.cs | 13 ++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs index 17eb0e88..9f905ede 100644 --- a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs +++ b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs @@ -75,10 +75,14 @@ public void GHChangeFailureRateSampleControllerIntegrationTest() { //Arrange bool getSampleData = true; + //string owner = "samsmithnz"; + //string repo = "SamsFeatureFlags"; + //string branch = "main"; + //string workflowName = "SamsFeatureFlags.CI/CD"; string owner = "samsmithnz"; - string repo = "SamsFeatureFlags"; + string repo = "AzurePipelinesToGitHubActionsConverter"; string branch = "main"; - string workflowName = "SamsFeatureFlags.CI/CD"; + string workflowName = "CI/ CD"; DevOpsPlatform targetDevOpsPlatform = DevOpsPlatform.GitHub; int numberOfDays = 7; int maxNumberOfItems = 20; diff --git a/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs b/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs index 7469dad3..eb233d2f 100644 --- a/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs @@ -247,16 +247,11 @@ public async Task GHLeadTimeControllerAPILiveIntegrationTest() { //Arrange bool getSampleData = false; - //string owner = "DeveloperMetrics"; - //string repo = "devopsmetrics"; - //string branch = "main"; - //string workflowName = "DevOpsMetrics.CICD"; - //string workflowId = "1162561"; - string owner = "samsmithnz"; - string repo = "AzurePipelinesToGitHubActionsConverter"; + string owner = "DeveloperMetrics"; + string repo = "devopsmetrics"; string branch = "main"; - string workflowName = "CI/ CD"; - string workflowId = "38158"; + string workflowName = "DevOpsMetrics.CICD"; + string workflowId = "1162561"; int numberOfDays = 20; int maxNumberOfItems = 60; bool useCache = true; From 284f0588fb77092144e8fac27134e3a8fc7a751c Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 06:49:48 -0400 Subject: [PATCH 03/14] commented out massive test --- .../Service/DORASummaryControllerTests.cs | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs index b5b13953..a5199667 100644 --- a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs @@ -55,59 +55,59 @@ public async Task DORASummaryControllerUpdateIntegrationTest() //Assert.IsTrue(model.TotalResults > 0); } - [TestMethod] - public async Task DORASummaryControllerUpdateALLIntegrationTest() - { - //Arrange - int numberOfDays = 30; - int maxNumberOfItems = 20; - int totalResults = 0; - DORASummaryController controller = new(base.Configuration); - SettingsController settingsController = new(base.Configuration, new AzureTableStorageDA()); + //[TestMethod] + //public async Task DORASummaryControllerUpdateALLIntegrationTest() + //{ + // //Arrange + // int numberOfDays = 30; + // int maxNumberOfItems = 20; + // int totalResults = 0; + // DORASummaryController controller = new(base.Configuration); + // SettingsController settingsController = new(base.Configuration, new AzureTableStorageDA()); - //Act - List azSettings = settingsController.GetAzureDevOpsSettings(); - List ghSettings = settingsController.GetGitHubSettings(); + // //Act + // List azSettings = settingsController.GetAzureDevOpsSettings(); + // List ghSettings = settingsController.GetGitHubSettings(); - foreach (AzureDevOpsSettings item in azSettings) - { - // (int, string) buildsUpdated = (0, null); - // (int, string) prsUpdated = (0, null); - // try - // { - //log.LogInformation($"Processing Azure DevOps organization {item.Organization}, project {item.Project}"); - // buildsUpdated = await api.UpdateAzureDevOpsBuilds(item.Organization, item.Project, item.Repository, item.Branch, item.BuildName, item.BuildId, numberOfDays, maxNumberOfItems); - // prsUpdated = await api.UpdateAzureDevOpsPullRequests(item.Organization, item.Project, item.Repository, numberOfDays, maxNumberOfItems); - // log.LogInformation($"Processed Azure DevOps organization {item.Organization}, project {item.Project}. {buildsUpdated.Item1} builds and {prsUpdated.Item1} prs/commits updated"); - // totalResults += buildsUpdated.Item1 + prsUpdated.Item1; - // await api.UpdateAzureDevOpsProjectLog(item.Organization, item.Project, item.Repository, buildsUpdated.Item1, prsUpdated.Item1, buildsUpdated.Item2, prsUpdated.Item2, null, null); - // } - // catch (Exception ex) - // { - // string error = $"Exception while processing Azure DevOps organization {item.Organization}, project {item.Project}. {buildsUpdated.Item1} builds and {prsUpdated.Item1} prs/commits updated"; - // log.LogInformation(error); - // await api.UpdateAzureDevOpsProjectLog(item.Organization, item.Project, item.Repository, buildsUpdated.Item1, prsUpdated.Item1, buildsUpdated.Item2, prsUpdated.Item2, ex.Message, error); - // } - } + // foreach (AzureDevOpsSettings item in azSettings) + // { + // // (int, string) buildsUpdated = (0, null); + // // (int, string) prsUpdated = (0, null); + // // try + // // { + // //log.LogInformation($"Processing Azure DevOps organization {item.Organization}, project {item.Project}"); + // // buildsUpdated = await api.UpdateAzureDevOpsBuilds(item.Organization, item.Project, item.Repository, item.Branch, item.BuildName, item.BuildId, numberOfDays, maxNumberOfItems); + // // prsUpdated = await api.UpdateAzureDevOpsPullRequests(item.Organization, item.Project, item.Repository, numberOfDays, maxNumberOfItems); + // // log.LogInformation($"Processed Azure DevOps organization {item.Organization}, project {item.Project}. {buildsUpdated.Item1} builds and {prsUpdated.Item1} prs/commits updated"); + // // totalResults += buildsUpdated.Item1 + prsUpdated.Item1; + // // await api.UpdateAzureDevOpsProjectLog(item.Organization, item.Project, item.Repository, buildsUpdated.Item1, prsUpdated.Item1, buildsUpdated.Item2, prsUpdated.Item2, null, null); + // // } + // // catch (Exception ex) + // // { + // // string error = $"Exception while processing Azure DevOps organization {item.Organization}, project {item.Project}. {buildsUpdated.Item1} builds and {prsUpdated.Item1} prs/commits updated"; + // // log.LogInformation(error); + // // await api.UpdateAzureDevOpsProjectLog(item.Organization, item.Project, item.Repository, buildsUpdated.Item1, prsUpdated.Item1, buildsUpdated.Item2, prsUpdated.Item2, ex.Message, error); + // // } + // } - foreach (GitHubSettings ghSetting in ghSettings) - { - Debug.WriteLine($"Owner {ghSetting.Owner}, Repo {ghSetting.Repo}"); - ProcessingResult ghResult = await controller.UpdateDORASummaryItem( - ghSetting.Owner, ghSetting.Repo, ghSetting.Branch, - ghSetting.WorkflowName, ghSetting.WorkflowId, - ghSetting.ProductionResourceGroup, - numberOfDays, maxNumberOfItems); - totalResults += ghResult.TotalResults; - Assert.IsNotNull(ghResult); - } + // foreach (GitHubSettings ghSetting in ghSettings) + // { + // Debug.WriteLine($"Owner {ghSetting.Owner}, Repo {ghSetting.Repo}"); + // ProcessingResult ghResult = await controller.UpdateDORASummaryItem( + // ghSetting.Owner, ghSetting.Repo, ghSetting.Branch, + // ghSetting.WorkflowName, ghSetting.WorkflowId, + // ghSetting.ProductionResourceGroup, + // numberOfDays, maxNumberOfItems); + // totalResults += ghResult.TotalResults; + // Assert.IsNotNull(ghResult); + // } - //ProcessingResult model = await controller.UpdateDORASummaryItem(organization, repository, - // branch, workflowName, workflowId, resourceGroup, numberOfDays, maxNumberOfItems); + // //ProcessingResult model = await controller.UpdateDORASummaryItem(organization, repository, + // // branch, workflowName, workflowId, resourceGroup, numberOfDays, maxNumberOfItems); - //Assert - Assert.IsTrue(totalResults > 0); - } + // //Assert + // Assert.IsTrue(totalResults > 0); + //} } } From 2f88d4c0dd81aeec84c2f32114609d69a0850e61 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 07:00:14 -0400 Subject: [PATCH 04/14] Updating tests --- .../Service/ChangeFailureRateTests.cs | 54 +++++++++---------- .../Service/DORASummaryControllerTests.cs | 16 ++++-- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs index 9f905ede..48f4fc20 100644 --- a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs +++ b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs @@ -104,36 +104,36 @@ public void GHChangeFailureRateSampleControllerIntegrationTest() Assert.IsTrue(model.TotalItems > 0); } - //[TestCategory("L1Test")] - //[TestMethod] - //public void GHChangeFailureRateLiveControllerIntegrationTest() - //{ - // //Arrange - // bool getSampleData = false; - // string owner = "samsmithnz"; - // string repo = "SamsFeatureFlags"; - // string branch = "main"; - // string workflowName = "SamsFeatureFlags.CI/CD"; - // DevOpsPlatform targetDevOpsPlatform = DevOpsPlatform.GitHub; - // int numberOfDays = 7; - // int maxNumberOfItems = 20; - // ChangeFailureRateController controller = new(base.Configuration); + [TestCategory("L1Test")] + [TestMethod] + public void GHChangeFailureRateLiveControllerIntegrationTest() + { + //Arrange + bool getSampleData = false; + string owner = "samsmithnz"; + string repo = "AzurePipelinesToGitHubActionsConverter"; + string branch = "main"; + string workflowName = "CI/ CD"; + DevOpsPlatform targetDevOpsPlatform = DevOpsPlatform.GitHub; + int numberOfDays = 7; + int maxNumberOfItems = 20; + ChangeFailureRateController controller = new(base.Configuration); - // //Act - // ChangeFailureRateModel model = controller.GetChangeFailureRate(getSampleData, - // targetDevOpsPlatform, owner, repo, branch, workflowName, numberOfDays, maxNumberOfItems); + //Act + ChangeFailureRateModel model = controller.GetChangeFailureRate(getSampleData, + targetDevOpsPlatform, owner, repo, branch, workflowName, numberOfDays, maxNumberOfItems); - // //Assert - // Assert.IsTrue(model != null); - // Assert.IsTrue(model.TargetDevOpsPlatform == targetDevOpsPlatform); - // Assert.IsTrue(model.DeploymentName == workflowName); - // Assert.IsTrue(model.ChangeFailureRateMetric >= 0f); - // Assert.AreEqual(false, string.IsNullOrEmpty(model.ChangeFailureRateMetricDescription)); - // Assert.AreEqual(numberOfDays, model.NumberOfDays); - // Assert.IsTrue(model.MaxNumberOfItems > 0); - // Assert.IsTrue(model.TotalItems > 0); + //Assert + Assert.IsTrue(model != null); + Assert.IsTrue(model.TargetDevOpsPlatform == targetDevOpsPlatform); + Assert.IsTrue(model.DeploymentName == workflowName); + Assert.IsTrue(model.ChangeFailureRateMetric >= 0f); + Assert.AreEqual(false, string.IsNullOrEmpty(model.ChangeFailureRateMetricDescription)); + Assert.AreEqual(numberOfDays, model.NumberOfDays); + Assert.IsTrue(model.MaxNumberOfItems > 0); + Assert.IsTrue(model.TotalItems > 0); - //} + } } diff --git a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs index a5199667..5aa6c49e 100644 --- a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs @@ -36,12 +36,18 @@ public void DORASummaryControllerGetIntegrationTest() public async Task DORASummaryControllerUpdateIntegrationTest() { //Arrange - string organization = "DeveloperMetrics"; - string repository = "DevOpsMetrics"; + //string organization = "DeveloperMetrics"; + //string repository = "DevOpsMetrics"; + //string branch = "main"; + //string workflowName = "CI/CD"; + //string workflowId = "1162561"; + //string resourceGroup = "DevOpsMetrics"; + string organization = "samsmithnz"; + string repository = "AzurePipelinesToGitHubActionsConverter"; string branch = "main"; - string workflowName = "1162561"; - string workflowId = "1162561"; - string resourceGroup = "DevOpsMetrics"; + string workflowName = "CI/ CD"; + string workflowId = "38158"; + string resourceGroup = null; int numberOfDays = 30; int maxNumberOfItems = 20; DORASummaryController controller = new(base.Configuration); From 8c567f197eda791ecd90320a4872a8c04dd8e99c Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 11:30:22 -0400 Subject: [PATCH 05/14] Updated tests --- .../Core/AzureMonitorTests.cs | 2 +- .../Core/ChangeFailureRateDATests.cs | 4 +++- .../Core/ChangeFailureRateTests.cs | 2 +- .../Core/DeploymentFrequencyDATests.cs | 4 +++- .../Core/DeploymentFrequencyTests.cs | 2 +- .../Core/FractionConverterTests.cs | 2 +- .../Core/LeadTimeForChangesDATests.cs | 4 +++- .../Core/LeadTimeForChangesTests.cs | 2 +- .../Core/MeanTimeToRestoreDATests.cs | 3 ++- .../Core/MeanTimeToRestoreTests.cs | 2 +- ...DATests.cs => PostiveNegativeListTests.cs} | 4 ++-- src/DevOpsMetrics.Tests/Core/SLATests.cs | 2 +- .../Core/SettingsDATests.cs | 2 +- src/DevOpsMetrics.Tests/Service/BadgeTests.cs | 21 +------------------ ...cs => ChangeFailureRateControllerTests.cs} | 9 ++++---- .../Service/DORASummaryControllerTests.cs | 2 +- .../DeploymentFrequencyControllerTests.cs | 7 +++++-- .../LeadTimeForChangesControllerTests.cs | 14 ++++++------- .../MeanTimeToRestoreControllerTests.cs | 8 +++---- .../Service/NightlyProcessTests.cs | 2 +- .../Service/SecretsProcessingTests.cs | 2 +- .../Service/TableStorageControllerDATests.cs | 2 +- .../Service/TableStorageDATests.cs | 2 +- 23 files changed, 45 insertions(+), 59 deletions(-) rename src/DevOpsMetrics.Tests/Core/{PostiveNegativeListDATests.cs => PostiveNegativeListTests.cs} (98%) rename src/DevOpsMetrics.Tests/Service/{ChangeFailureRateTests.cs => ChangeFailureRateControllerTests.cs} (96%) diff --git a/src/DevOpsMetrics.Tests/Core/AzureMonitorTests.cs b/src/DevOpsMetrics.Tests/Core/AzureMonitorTests.cs index db195805..0bc241c9 100644 --- a/src/DevOpsMetrics.Tests/Core/AzureMonitorTests.cs +++ b/src/DevOpsMetrics.Tests/Core/AzureMonitorTests.cs @@ -7,7 +7,7 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestClass] public class AzureMonitorTests : BaseConfiguration { diff --git a/src/DevOpsMetrics.Tests/Core/ChangeFailureRateDATests.cs b/src/DevOpsMetrics.Tests/Core/ChangeFailureRateDATests.cs index 4fe3a4c6..a9f6abd9 100644 --- a/src/DevOpsMetrics.Tests/Core/ChangeFailureRateDATests.cs +++ b/src/DevOpsMetrics.Tests/Core/ChangeFailureRateDATests.cs @@ -7,11 +7,12 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestClass] public class ChangeFailureRateDATests : BaseConfiguration { + [TestCategory("UnitTest")] [TestMethod] public void AzChangeFailureRateDAIntegrationTest() { @@ -74,6 +75,7 @@ public void AzChangeFailureRateDAIntegrationTest() // Assert.AreNotEqual("Elite", model.ChangeFailureRateMetricDescription); //} + [TestCategory("UnitTest")] [TestMethod] public void GHChangeFailureRateDAIntegrationTest() { diff --git a/src/DevOpsMetrics.Tests/Core/ChangeFailureRateTests.cs b/src/DevOpsMetrics.Tests/Core/ChangeFailureRateTests.cs index e2aa5577..d436a32c 100644 --- a/src/DevOpsMetrics.Tests/Core/ChangeFailureRateTests.cs +++ b/src/DevOpsMetrics.Tests/Core/ChangeFailureRateTests.cs @@ -7,7 +7,7 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] public class ChangeFailureRateTests { diff --git a/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyDATests.cs b/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyDATests.cs index d3828ea4..fc8722d5 100644 --- a/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyDATests.cs +++ b/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyDATests.cs @@ -7,10 +7,11 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestClass] public class DeploymentFrequencyDATests : BaseConfiguration { + [TestCategory("UnitTest")] [TestMethod] public async Task AzDeploymentFrequencyDAIntegrationTest() { @@ -42,6 +43,7 @@ public async Task AzDeploymentFrequencyDAIntegrationTest() Assert.IsTrue(model.ItemOrder == 0); } + [TestCategory("UnitTest")] [TestMethod] public async Task GHDeploymentFrequencyDAIntegrationTest() { diff --git a/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyTests.cs b/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyTests.cs index e59a37d0..62cf7089 100644 --- a/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyTests.cs +++ b/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyTests.cs @@ -7,7 +7,7 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] public class DeploymentFrequencyTests { diff --git a/src/DevOpsMetrics.Tests/Core/FractionConverterTests.cs b/src/DevOpsMetrics.Tests/Core/FractionConverterTests.cs index bda6d09d..93d59968 100644 --- a/src/DevOpsMetrics.Tests/Core/FractionConverterTests.cs +++ b/src/DevOpsMetrics.Tests/Core/FractionConverterTests.cs @@ -4,7 +4,7 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] public class FractionConverterTests { diff --git a/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesDATests.cs b/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesDATests.cs index 5770a2c5..e01c2d92 100644 --- a/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesDATests.cs +++ b/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesDATests.cs @@ -8,10 +8,11 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestClass] public class LeadTimeForChangesDATests : BaseConfiguration { + [TestCategory("UnitTest")] [TestMethod] public async Task AzLeadTimeForChangesDAIntegrationTest() { @@ -58,6 +59,7 @@ public async Task AzLeadTimeForChangesDAIntegrationTest() Assert.IsTrue(model.TotalItems > 0); } + [TestCategory("UnitTest")] [TestMethod] public async Task GHLeadTimeForChangesDAIntegrationTest() { diff --git a/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesTests.cs b/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesTests.cs index 6e4c97fb..6cf623e2 100644 --- a/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesTests.cs +++ b/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesTests.cs @@ -7,7 +7,7 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] public class LeadTimeForChangesTests { diff --git a/src/DevOpsMetrics.Tests/Core/MeanTimeToRestoreDATests.cs b/src/DevOpsMetrics.Tests/Core/MeanTimeToRestoreDATests.cs index 5ec8e158..3938977b 100644 --- a/src/DevOpsMetrics.Tests/Core/MeanTimeToRestoreDATests.cs +++ b/src/DevOpsMetrics.Tests/Core/MeanTimeToRestoreDATests.cs @@ -6,10 +6,11 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestClass] public class MeanTimeToRestoreDATests : BaseConfiguration { + [TestCategory("UnitTest")] [TestMethod] public void MeanTimeToRestoreDAIntegrationTest() { diff --git a/src/DevOpsMetrics.Tests/Core/MeanTimeToRestoreTests.cs b/src/DevOpsMetrics.Tests/Core/MeanTimeToRestoreTests.cs index 77221545..dad82f8f 100644 --- a/src/DevOpsMetrics.Tests/Core/MeanTimeToRestoreTests.cs +++ b/src/DevOpsMetrics.Tests/Core/MeanTimeToRestoreTests.cs @@ -7,7 +7,7 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] public class MeanTimeToRestoreTests { diff --git a/src/DevOpsMetrics.Tests/Core/PostiveNegativeListDATests.cs b/src/DevOpsMetrics.Tests/Core/PostiveNegativeListTests.cs similarity index 98% rename from src/DevOpsMetrics.Tests/Core/PostiveNegativeListDATests.cs rename to src/DevOpsMetrics.Tests/Core/PostiveNegativeListTests.cs index 6ad323b9..a1dd999d 100644 --- a/src/DevOpsMetrics.Tests/Core/PostiveNegativeListDATests.cs +++ b/src/DevOpsMetrics.Tests/Core/PostiveNegativeListTests.cs @@ -7,9 +7,9 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] - public class PostiveNegativeListDATests + public class PostiveNegativeListTests { [TestMethod] diff --git a/src/DevOpsMetrics.Tests/Core/SLATests.cs b/src/DevOpsMetrics.Tests/Core/SLATests.cs index a7ff3316..dc8bf694 100644 --- a/src/DevOpsMetrics.Tests/Core/SLATests.cs +++ b/src/DevOpsMetrics.Tests/Core/SLATests.cs @@ -6,7 +6,7 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] public class SLATests { diff --git a/src/DevOpsMetrics.Tests/Core/SettingsDATests.cs b/src/DevOpsMetrics.Tests/Core/SettingsDATests.cs index cfe68747..ad4442cd 100644 --- a/src/DevOpsMetrics.Tests/Core/SettingsDATests.cs +++ b/src/DevOpsMetrics.Tests/Core/SettingsDATests.cs @@ -10,7 +10,7 @@ namespace DevOpsMetrics.Tests.Core { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestClass] public class SettingsDATests : BaseConfiguration { diff --git a/src/DevOpsMetrics.Tests/Service/BadgeTests.cs b/src/DevOpsMetrics.Tests/Service/BadgeTests.cs index a1658dfc..4e94b99b 100644 --- a/src/DevOpsMetrics.Tests/Service/BadgeTests.cs +++ b/src/DevOpsMetrics.Tests/Service/BadgeTests.cs @@ -4,12 +4,11 @@ namespace DevOpsMetrics.Tests.Service { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] public class BadgeTests { - [TestCategory("L0Test")] [TestMethod] public void DeploymentFrequencyEliteBadgeTest() { @@ -29,7 +28,6 @@ public void DeploymentFrequencyEliteBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void DeploymentFrequencyHighBadgeTest() { @@ -47,7 +45,6 @@ public void DeploymentFrequencyHighBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void DeploymentFrequencyMediumBadgeTest() { @@ -65,7 +62,6 @@ public void DeploymentFrequencyMediumBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void DeploymentFrequencyLowBadgeTest() { @@ -83,7 +79,6 @@ public void DeploymentFrequencyLowBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void DeploymentFrequencyNoneBadgeTest() { @@ -100,7 +95,6 @@ public void DeploymentFrequencyNoneBadgeTest() Assert.AreEqual("https://img.shields.io/badge/Deployment%20frequency-None-lightgrey", model.BadgeURL); } - [TestCategory("L0Test")] [TestMethod] public void ChangeFailureRateControllerHighBadgeTest() { @@ -118,7 +112,6 @@ public void ChangeFailureRateControllerHighBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void ChangeFailureRateControllerMediumBadgeTest() { @@ -136,7 +129,6 @@ public void ChangeFailureRateControllerMediumBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void ChangeFailureRateControllerLowBadgeTest() { @@ -154,7 +146,6 @@ public void ChangeFailureRateControllerLowBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void ChangeFailureRateControllerNoneBadgeTest() { @@ -171,7 +162,6 @@ public void ChangeFailureRateControllerNoneBadgeTest() Assert.AreEqual("https://img.shields.io/badge/Change%20failure%20rate-None-lightgrey", model.BadgeURL); } - [TestCategory("L0Test")] [TestMethod] public void LeadTimeForChangesEliteBadgeTest() { @@ -191,7 +181,6 @@ public void LeadTimeForChangesEliteBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void LeadTimeForChangesHighBadgeTest() { @@ -209,7 +198,6 @@ public void LeadTimeForChangesHighBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void LeadTimeForChangesMediumBadgeTest() { @@ -227,7 +215,6 @@ public void LeadTimeForChangesMediumBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void LeadTimeForChangesLowBadgeTest() { @@ -245,7 +232,6 @@ public void LeadTimeForChangesLowBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void LeadTimeForChangesNoneBadgeTest() { @@ -263,7 +249,6 @@ public void LeadTimeForChangesNoneBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void MeanTimeToRestoreEliteBadgeTest() { @@ -283,7 +268,6 @@ public void MeanTimeToRestoreEliteBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void MeanTimeToRestoreHighBadgeTest() { @@ -301,7 +285,6 @@ public void MeanTimeToRestoreHighBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void MeanTimeToRestoreMediumBadgeTest() { @@ -319,7 +302,6 @@ public void MeanTimeToRestoreMediumBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void MeanTimeToRestoreLowBadgeTest() { @@ -337,7 +319,6 @@ public void MeanTimeToRestoreLowBadgeTest() } - [TestCategory("L0Test")] [TestMethod] public void MeanTimeToRestoreNoneBadgeTest() { diff --git a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs similarity index 96% rename from src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs rename to src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs index 48f4fc20..b276929d 100644 --- a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateTests.cs +++ b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs @@ -5,9 +5,9 @@ namespace DevOpsMetrics.Tests.Service { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("UnitTest")] [TestClass] - public class ChangeFailureRateTests : BaseConfiguration + public class ChangeFailureRateControllerTests : BaseConfiguration { [TestMethod] public void AzChangeFailureRateSampleControllerIntegrationTest() @@ -39,7 +39,7 @@ public void AzChangeFailureRateSampleControllerIntegrationTest() Assert.IsTrue(model.TotalItems > 0); } - //[TestCategory("L1Test")] + //[TestCategory("IntegrationTest")] //[TestMethod] //public void AzChangeFailureRateLiveControllerIntegrationTest() //{ @@ -69,7 +69,6 @@ public void AzChangeFailureRateSampleControllerIntegrationTest() // Assert.IsTrue(model.TotalItems > 0); //} - [TestCategory("L1Test")] [TestMethod] public void GHChangeFailureRateSampleControllerIntegrationTest() { @@ -104,7 +103,7 @@ public void GHChangeFailureRateSampleControllerIntegrationTest() Assert.IsTrue(model.TotalItems > 0); } - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestMethod] public void GHChangeFailureRateLiveControllerIntegrationTest() { diff --git a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs index 5aa6c49e..a42c667a 100644 --- a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs @@ -12,7 +12,7 @@ namespace DevOpsMetrics.Tests.Service { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestClass] public class DORASummaryControllerTests : BaseConfiguration { diff --git a/src/DevOpsMetrics.Tests/Service/DeploymentFrequencyControllerTests.cs b/src/DevOpsMetrics.Tests/Service/DeploymentFrequencyControllerTests.cs index 4ba95b91..a119fa67 100644 --- a/src/DevOpsMetrics.Tests/Service/DeploymentFrequencyControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/DeploymentFrequencyControllerTests.cs @@ -7,10 +7,11 @@ namespace DevOpsMetrics.Tests.Service { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestClass] - public class DeploymentFrequencyL1s : BaseConfiguration + public class DeploymentFrequencyControllerTests : BaseConfiguration { + [TestCategory("UnitTest")] [TestMethod] public async Task AzDeploymentsSampleControllerIntegrationTest() { @@ -135,6 +136,7 @@ public async Task AzDeploymentsCacheControllerIntegrationTest() } + [TestCategory("UnitTest")] [TestMethod] public async Task GHDeploymentsSampleControllerIntegrationTest() { @@ -306,6 +308,7 @@ public async Task AzDeploymentsControllerAPILiveWithCacheIntegrationTest() + [TestCategory("UnitTest")] [TestMethod] public async Task GHDeploymentsControllerAPILiveWithCacheIntegrationTest() { diff --git a/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs b/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs index eb233d2f..e88e1bc5 100644 --- a/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs @@ -7,10 +7,11 @@ namespace DevOpsMetrics.Tests.Service { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [TestCategory("IntegrationTest")] [TestClass] - public class LeadTimeForChangesL1s : BaseConfiguration + public class LeadTimeForChangesControllerTests : BaseConfiguration { - [TestCategory("L1Test")] + [TestCategory("UnitTest")] [TestMethod] public async Task AzLeadTimeControllerIntegrationTest() { @@ -53,7 +54,7 @@ public async Task AzLeadTimeControllerIntegrationTest() Assert.IsTrue(model.TotalItems > 0); } - [TestCategory("L1Test")] + [TestCategory("UnitTest")] [TestMethod] public async Task GHLeadTimeControllerIntegrationTest() { @@ -100,7 +101,7 @@ public async Task GHLeadTimeControllerIntegrationTest() } - [TestCategory("L1Test")] + [TestCategory("UnitTest")] [TestMethod] public async Task AzLeadTimeControllerAPIIntegrationTest() { @@ -144,7 +145,7 @@ public async Task AzLeadTimeControllerAPIIntegrationTest() } - [TestCategory("L1Test")] + [TestCategory("UnitTest")] [TestMethod] public async Task GHLeadTimeControllerAPIIntegrationTest() { @@ -188,7 +189,6 @@ public async Task GHLeadTimeControllerAPIIntegrationTest() } - [TestCategory("L1Test")] [TestMethod] public async Task AzLeadTimeControllerAPILiveIntegrationTest() { @@ -241,7 +241,6 @@ public async Task AzLeadTimeControllerAPILiveIntegrationTest() } - [TestCategory("L1Test")] [TestMethod] public async Task GHLeadTimeControllerAPILiveIntegrationTest() { @@ -294,7 +293,6 @@ public async Task GHLeadTimeControllerAPILiveIntegrationTest() } - //[TestCategory("L1Test")] //[TestMethod] //public async Task GHFeatureFlagsLeadTimeControllerAPILiveIntegrationTest() //{ diff --git a/src/DevOpsMetrics.Tests/Service/MeanTimeToRestoreControllerTests.cs b/src/DevOpsMetrics.Tests/Service/MeanTimeToRestoreControllerTests.cs index 4b7bebc3..eb23a65c 100644 --- a/src/DevOpsMetrics.Tests/Service/MeanTimeToRestoreControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/MeanTimeToRestoreControllerTests.cs @@ -6,10 +6,11 @@ namespace DevOpsMetrics.Tests.Service { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [TestCategory("IntegrationTest")] [TestClass] - public class MeanTimeToRestoreL1s : BaseConfiguration + public class MeanTimeToRestoreControllerTests : BaseConfiguration { - [TestCategory("L1Test")] + [TestCategory("UnitTest")] [TestMethod] public void AzureMTTRSampleControllerIntegrationTest() { @@ -44,7 +45,6 @@ public void AzureMTTRSampleControllerIntegrationTest() Assert.IsTrue(model.TotalItems > 0); } - [TestCategory("L1Test")] [TestMethod] public void AzureMTTRsAPIControllerIntegrationTest() { @@ -82,7 +82,6 @@ public void AzureMTTRsAPIControllerIntegrationTest() Assert.IsTrue(model.TotalItems >= 0); } - [TestCategory("L1Test")] [TestMethod] public void AzureMTTRsAPINullIntegrationTest() { @@ -120,7 +119,6 @@ public void AzureMTTRsAPINullIntegrationTest() Assert.IsTrue(model.TotalItems >= 0); } - [TestCategory("L1Test")] [TestMethod] public void AzureMTTRsAPIEmptyIntegrationTest() { diff --git a/src/DevOpsMetrics.Tests/Service/NightlyProcessTests.cs b/src/DevOpsMetrics.Tests/Service/NightlyProcessTests.cs index 2949d019..87d5144d 100644 --- a/src/DevOpsMetrics.Tests/Service/NightlyProcessTests.cs +++ b/src/DevOpsMetrics.Tests/Service/NightlyProcessTests.cs @@ -11,7 +11,7 @@ //namespace DevOpsMetrics.Tests.Service //{ // [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -// [TestCategory("L1Test")] +// [TestCategory("IntegrationTest")] // [TestClass] // public class NightlyProcessTests : BaseConfiguration // { diff --git a/src/DevOpsMetrics.Tests/Service/SecretsProcessingTests.cs b/src/DevOpsMetrics.Tests/Service/SecretsProcessingTests.cs index 0bce6aea..2de03226 100644 --- a/src/DevOpsMetrics.Tests/Service/SecretsProcessingTests.cs +++ b/src/DevOpsMetrics.Tests/Service/SecretsProcessingTests.cs @@ -4,7 +4,7 @@ namespace DevOpsMetrics.Tests.Service { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] public class SecretsProcessingTests { diff --git a/src/DevOpsMetrics.Tests/Service/TableStorageControllerDATests.cs b/src/DevOpsMetrics.Tests/Service/TableStorageControllerDATests.cs index 5d7d9ae6..b172913c 100644 --- a/src/DevOpsMetrics.Tests/Service/TableStorageControllerDATests.cs +++ b/src/DevOpsMetrics.Tests/Service/TableStorageControllerDATests.cs @@ -12,7 +12,7 @@ namespace DevOpsMetrics.Tests.Service { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L0Test")] + [TestCategory("UnitTest")] [TestClass] public class TableStorageControllerDATests { diff --git a/src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs b/src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs index 564f3f68..1403af94 100644 --- a/src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs +++ b/src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs @@ -11,7 +11,7 @@ namespace DevOpsMetrics.Tests.Service { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - [TestCategory("L1Test")] + [TestCategory("IntegrationTest")] [TestClass] public class TableStorageDATests : BaseConfiguration { From d29784135e8df2ebf09846c1b710c25bb8575b2e Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 14:09:03 -0400 Subject: [PATCH 06/14] added branch for Azure DevOps --- .../Controllers/DORASummaryController.cs | 106 +++++++++++------- 1 file changed, 68 insertions(+), 38 deletions(-) diff --git a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs index 45f21a45..f41edea2 100644 --- a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs +++ b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs @@ -51,7 +51,8 @@ public async Task UpdateDORASummaryItem( int numberOfDays, int maxNumberOfItems, ILogger log = null, - bool useCache = true) + bool useCache = true, + bool isGitHub = true) { AzureTableStorageDA azureTableStorageDA = new(); TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration); @@ -69,7 +70,11 @@ public async Task UpdateDORASummaryItem( try { //TODO: fix this - should be using a common interface, not this null hack - string message = $"Processing GitHub owner {owner}, repo {repo}"; + string message = ""; + if (isGitHub == true) + { + message = $"Processing GitHub owner {owner}, repo {repo}"; + } if (log == null) { Console.WriteLine(message); @@ -78,13 +83,16 @@ public async Task UpdateDORASummaryItem( { log.LogInformation(message); } - result.BuildsUpdated = await azureTableStorageDA.UpdateGitHubActionRunsInStorage(clientId, clientSecret, tableStorageConfig, - owner, repo, branch, workflowName, workflowId, numberOfDays, maxNumberOfItems); - //log.LogInformation($"Processing GitHub owner {item.Owner}, repo {item.Repo}: {buildsUpdated} builds updated"); - result.PRsUpdated = await azureTableStorageDA.UpdateGitHubActionPullRequestsInStorage(clientId, clientSecret, tableStorageConfig, - owner, repo, branch, numberOfDays, maxNumberOfItems); - //log.LogInformation($"Processing GitHub owner {item.Owner}, repo {item.Repo}: {prsUpdated} pull requests updated"); - message = $"Processed GitHub owner {owner}, repo {repo}. {result.BuildsUpdated} builds and {result.PRsUpdated} prs/commits updated"; + if (isGitHub == true) + { + result.BuildsUpdated = await azureTableStorageDA.UpdateGitHubActionRunsInStorage(clientId, clientSecret, tableStorageConfig, + owner, repo, branch, workflowName, workflowId, numberOfDays, maxNumberOfItems); + //log.LogInformation($"Processing GitHub owner {item.Owner}, repo {item.Repo}: {buildsUpdated} builds updated"); + result.PRsUpdated = await azureTableStorageDA.UpdateGitHubActionPullRequestsInStorage(clientId, clientSecret, tableStorageConfig, + owner, repo, branch, numberOfDays, maxNumberOfItems); + //log.LogInformation($"Processing GitHub owner {item.Owner}, repo {item.Repo}: {prsUpdated} pull requests updated"); + message = $"Processed GitHub owner {owner}, repo {repo}. {result.BuildsUpdated} builds and {result.PRsUpdated} prs/commits updated"; + } if (log == null) { Console.WriteLine(message); @@ -97,32 +105,39 @@ public async Task UpdateDORASummaryItem( //Process summary results for last 90 days, creating badges for the four metrics //Get the DORA metrics for the last 90 days - DeploymentFrequencyModel deploymentFrequencyModel = await DeploymentFrequencyDA.GetGitHubDeploymentFrequency(false, clientId, clientSecret, tableStorageConfig, - owner, repo, branch, workflowName, workflowId, - numberOfDays, maxNumberOfItems, useCache); - - LeadTimeForChangesModel leadTimeForChangesModel = await LeadTimeForChangesDA.GetGitHubLeadTimesForChanges(false, clientId, clientSecret, tableStorageConfig, - owner, repo, branch, workflowName, workflowId, - numberOfDays, maxNumberOfItems, useCache); - + DeploymentFrequencyModel deploymentFrequencyModel = new(); + LeadTimeForChangesModel leadTimeForChangesModel = new(); MeanTimeToRestoreModel meanTimeToRestoreModel = new(); - if (resourceGroup != null) + ChangeFailureRateModel changeFailureRateModel = new(); + if (isGitHub == true) { - meanTimeToRestoreModel = MeanTimeToRestoreDA.GetAzureMeanTimeToRestore(false, tableStorageConfig, - DevOpsPlatform.GitHub, - resourceGroup, - numberOfDays, maxNumberOfItems); - } - else - { - meanTimeToRestoreModel.MTTRAverageDurationInHours = 0; - meanTimeToRestoreModel.MTTRAverageDurationDescription = MeanTimeToRestore.GetMeanTimeToRestoreRating(0); - } + deploymentFrequencyModel = await DeploymentFrequencyDA.GetGitHubDeploymentFrequency(false, clientId, clientSecret, tableStorageConfig, + owner, repo, branch, workflowName, workflowId, + numberOfDays, maxNumberOfItems, useCache); + + leadTimeForChangesModel = await LeadTimeForChangesDA.GetGitHubLeadTimesForChanges(false, clientId, clientSecret, tableStorageConfig, + owner, repo, branch, workflowName, workflowId, + numberOfDays, maxNumberOfItems, useCache); - ChangeFailureRateModel changeFailureRateModel = ChangeFailureRateDA.GetChangeFailureRate(false, tableStorageConfig, - DevOpsPlatform.GitHub, - owner, repo, branch, workflowName, - numberOfDays, maxNumberOfItems); + meanTimeToRestoreModel = new(); + if (resourceGroup != null) + { + meanTimeToRestoreModel = MeanTimeToRestoreDA.GetAzureMeanTimeToRestore(false, tableStorageConfig, + DevOpsPlatform.GitHub, + resourceGroup, + numberOfDays, maxNumberOfItems); + } + else + { + meanTimeToRestoreModel.MTTRAverageDurationInHours = 0; + meanTimeToRestoreModel.MTTRAverageDurationDescription = MeanTimeToRestore.GetMeanTimeToRestoreRating(0); + } + + changeFailureRateModel = ChangeFailureRateDA.GetChangeFailureRate(false, tableStorageConfig, + DevOpsPlatform.GitHub, + owner, repo, branch, workflowName, + numberOfDays, maxNumberOfItems); + } //Summarize the results into a new object DORASummaryItem DORASummary = new() @@ -143,10 +158,18 @@ public async Task UpdateDORASummaryItem( await AzureTableStorageDA.UpdateDORASummaryItem(tableStorageConfig, owner, repo, DORASummary); //await settingsController.UpdateGitHubProjectLog(ghSetting.Owner, ghSetting.Repo, result.BuildsUpdated, result.PRsUpdated, "", "", null, null); - ProjectLog projectLog = new( - PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo), - result.BuildsUpdated, result.PRsUpdated, "", "", null, null); - await azureTableStorageDA.UpdateProjectLogInStorage(tableStorageConfig, projectLog); + ProjectLog projectLog = null; + if (isGitHub == true) + { + projectLog = new( + PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo), + result.BuildsUpdated, result.PRsUpdated, + "", "", null, null); + } + if (projectLog != null) + { + await azureTableStorageDA.UpdateProjectLogInStorage(tableStorageConfig, projectLog); + } } catch (Exception ex) { @@ -163,13 +186,20 @@ public async Task UpdateDORASummaryItem( // ghSetting.Owner + "_" + ghSetting.Repo + "_" + ghSetting.Branch + "_" + ghSetting.WorkflowName + "_" + ghSetting.WorkflowId + "_" + numberOfDays + "_" + maxNumberOfItems, // ghSetting.Owner + "_" + ghSetting.Repo + "_" + ghSetting.Branch + "_" + numberOfDays + "_" + maxNumberOfItems, // ex.ToString(), error); - ProjectLog projectLog = new( + ProjectLog projectLog = null; + if (isGitHub == true) + { + projectLog = new( PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo), result.BuildsUpdated, result.PRsUpdated, owner + "_" + repo + "_" + branch + "_" + workflowName + "_" + workflowId + "_" + numberOfDays + "_" + maxNumberOfItems, owner + "_" + repo + "_" + branch + "_" + numberOfDays + "_" + maxNumberOfItems, ex.ToString(), error); - await azureTableStorageDA.UpdateProjectLogInStorage(tableStorageConfig, projectLog); + } + if (projectLog != null) + { + await azureTableStorageDA.UpdateProjectLogInStorage(tableStorageConfig, projectLog); + } } return result; From becd6d23a3bad235658028e226ff1467a5af2763 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 14:09:11 -0400 Subject: [PATCH 07/14] increased minor version --- GitVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitVersion.yml b/GitVersion.yml index 7993277d..67dd9aed 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1 +1 @@ -next-version: 1.7.0 +next-version: 1.8.0 From d6f2ed6057cec74543c81c680b54fd5ad506cbb5 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 14:26:37 -0400 Subject: [PATCH 08/14] Updated function to include Azure DevOps updates --- .../NightlyProcessor.cs | 37 ++++--------- .../ServiceApiClient.cs | 9 ++- .../Controllers/DORASummaryController.cs | 55 +++++++++++++------ .../LeadTimeForChangesController.cs | 1 - .../Service/DORASummaryControllerTests.cs | 5 +- 5 files changed, 58 insertions(+), 49 deletions(-) diff --git a/src/DevOpsMetrics.Function/NightlyProcessor.cs b/src/DevOpsMetrics.Function/NightlyProcessor.cs index 30ef0803..07c55e8e 100644 --- a/src/DevOpsMetrics.Function/NightlyProcessor.cs +++ b/src/DevOpsMetrics.Function/NightlyProcessor.cs @@ -6,8 +6,6 @@ using DevOpsMetrics.Core.Models.AzureDevOps; using DevOpsMetrics.Core.Models.Common; using DevOpsMetrics.Core.Models.GitHub; -//using DevOpsMetrics.Service; -//using DevOpsMetrics.Service.Controllers; using Microsoft.Azure.KeyVault; using Microsoft.Azure.Services.AppAuthentication; using Microsoft.Azure.WebJobs; @@ -48,45 +46,32 @@ public static async Task Run( string clientId = Configuration["AppSettings:GitHubClientId"]; string clientSecret = Configuration["AppSettings:GitHubClientSecret"]; AzureTableStorageDA azureTableStorageDA = new(); - //SettingsController settingsController = new(Configuration, azureTableStorageDA); - //DORASummaryController doraSummaryController = new(Configuration); List azSettings = await serviceApiClient.GetAzureDevOpsSettings(); List ghSettings = await serviceApiClient.GetGitHubSettings(); - //TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration); //Loop through each setting to update the runs, pull requests and pull request commits int numberOfDays = 30; int maxNumberOfItems = 20; int totalResults = 0; - foreach (AzureDevOpsSettings item in azSettings) + foreach (AzureDevOpsSettings azSetting in azSettings) { - // (int, string) buildsUpdated = (0, null); - // (int, string) prsUpdated = (0, null); - // try - // { - log.LogInformation($"Processing Azure DevOps organization {item.Organization}, project {item.Project}"); - // buildsUpdated = await api.UpdateAzureDevOpsBuilds(item.Organization, item.Project, item.Repository, item.Branch, item.BuildName, item.BuildId, numberOfDays, maxNumberOfItems); - // prsUpdated = await api.UpdateAzureDevOpsPullRequests(item.Organization, item.Project, item.Repository, numberOfDays, maxNumberOfItems); - // log.LogInformation($"Processed Azure DevOps organization {item.Organization}, project {item.Project}. {buildsUpdated.Item1} builds and {prsUpdated.Item1} prs/commits updated"); - // totalResults += buildsUpdated.Item1 + prsUpdated.Item1; - // await api.UpdateAzureDevOpsProjectLog(item.Organization, item.Project, item.Repository, buildsUpdated.Item1, prsUpdated.Item1, buildsUpdated.Item2, prsUpdated.Item2, null, null); - // } - // catch (Exception ex) - // { - // string error = $"Exception while processing Azure DevOps organization {item.Organization}, project {item.Project}. {buildsUpdated.Item1} builds and {prsUpdated.Item1} prs/commits updated"; - // log.LogInformation(error); - // await api.UpdateAzureDevOpsProjectLog(item.Organization, item.Project, item.Repository, buildsUpdated.Item1, prsUpdated.Item1, buildsUpdated.Item2, prsUpdated.Item2, ex.Message, error); - // } + log.LogInformation($"Processing Azure DevOps organization {azSetting.Organization}, project {azSetting.Project}"); + ProcessingResult ghResult = await serviceApiClient.UpdateDORASummaryItem( + azSetting.Organization, azSetting.Project, azSetting.Repository, + azSetting.Branch, azSetting.BuildName, azSetting.BuildId, + azSetting.ProductionResourceGroup, + numberOfDays, maxNumberOfItems, false); + totalResults = ghResult.TotalResults; } foreach (GitHubSettings ghSetting in ghSettings) { - + log.LogInformation($"Processing GitHub owner {ghSetting.Owner}, repo {ghSetting.Repo}"); ProcessingResult ghResult = await serviceApiClient.UpdateDORASummaryItem( - ghSetting.Owner, ghSetting.Repo, ghSetting.Branch, + ghSetting.Owner, "", ghSetting.Repo, ghSetting.Branch, ghSetting.WorkflowName, ghSetting.WorkflowId, ghSetting.ProductionResourceGroup, - numberOfDays, maxNumberOfItems); + numberOfDays, maxNumberOfItems, true); totalResults = ghResult.TotalResults; } log.LogInformation($"C# Timer trigger function complete at: {DateTime.Now} after updating {totalResults} records"); diff --git a/src/DevOpsMetrics.Function/ServiceApiClient.cs b/src/DevOpsMetrics.Function/ServiceApiClient.cs index 2497dafb..2bea3472 100644 --- a/src/DevOpsMetrics.Function/ServiceApiClient.cs +++ b/src/DevOpsMetrics.Function/ServiceApiClient.cs @@ -8,6 +8,7 @@ using DevOpsMetrics.Core.Models.Common; using DevOpsMetrics.Core.Models.GitHub; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace DevOpsMetrics.Function @@ -38,9 +39,13 @@ public async Task> GetGitHubSettings() return await GetResponse>(Client, url); } - public async Task UpdateDORASummaryItem(string owner, string repository, string branch, string workflowName, string workflowId, string resourceGroup, int numberOfDays, int maxNumberOfItems) + public async Task UpdateDORASummaryItem( + string owner, string project, string repository, + string branch, string workflowName, string workflowId, + string resourceGroup, int numberOfDays, int maxNumberOfItems, + bool isGitHub = true) { - string url = $"/api/DORASummary/UpdateDORASummaryItem?owner={owner}&repository={repository}&branch={branch}&workflowName={workflowName}&workflowId={workflowId}&resourceGroup={resourceGroup}&numberOfDays={numberOfDays}&maxNumberOfItems={maxNumberOfItems}"; + string url = $"/api/DORASummary/UpdateDORASummaryItem?owner={owner}&project={project}&repository={repository}&branch={branch}&workflowName={workflowName}&workflowId={workflowId}&resourceGroup={resourceGroup}&numberOfDays={numberOfDays}&maxNumberOfItems={maxNumberOfItems}&log=&useCache=true&isGitHub={isGitHub}"; return await GetResponse(Client, url); } diff --git a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs index f41edea2..e2221ca4 100644 --- a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs +++ b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs @@ -42,28 +42,43 @@ public DORASummaryItem GetDORASummaryItem(string owner, string repository) [HttpGet("UpdateDORASummaryItem")] public async Task UpdateDORASummaryItem( - string owner, - string repo, - string branch, - string workflowName, - string workflowId, - string resourceGroup, - int numberOfDays, - int maxNumberOfItems, - ILogger log = null, - bool useCache = true, - bool isGitHub = true) + string owner, + string project, + string repo, + string branch, + string workflowName, + string workflowId, + string resourceGroup, + int numberOfDays, + int maxNumberOfItems, + ILogger log = null, + bool useCache = true, + bool isGitHub = true) { AzureTableStorageDA azureTableStorageDA = new(); TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration); - //Get the client id and secret from the settings - string clientIdName = PartitionKeys.CreateGitHubSettingsPartitionKeyClientId(owner, repo); - string clientSecretName = PartitionKeys.CreateGitHubSettingsPartitionKeyClientSecret(owner, repo); - string clientId = Configuration[clientIdName]; - string clientSecret = Configuration[clientSecretName]; - if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(clientSecret)) + string clientId = null; + string clientSecret = null; + string patToken = null; + if (isGitHub == true) + { //Get the client id and secret from the settings + string clientIdName = PartitionKeys.CreateGitHubSettingsPartitionKeyClientId(owner, repo); + string clientSecretName = PartitionKeys.CreateGitHubSettingsPartitionKeyClientSecret(owner, repo); + clientId = Configuration[clientIdName]; + clientSecret = Configuration[clientSecretName]; + if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(clientSecret)) + { + throw new Exception($"clientId '{clientId}' or clientSecret '{clientSecret}' not found in key vault"); + } + } + else { - throw new Exception($"clientId '{clientId}' or clientSecret '{clientSecret}' not found in key vault"); + string patTokenName = PartitionKeys.CreateAzureDevOpsSettingsPartitionKeyPatToken(owner, project, repo); + patToken = Configuration[patTokenName]; + if (string.IsNullOrEmpty(patToken)) + { + throw new Exception($"patToken '{patTokenName}' not found in key vault"); + } } ProcessingResult result = new(); @@ -75,6 +90,10 @@ public async Task UpdateDORASummaryItem( { message = $"Processing GitHub owner {owner}, repo {repo}"; } + else + { + message = $"Processing Azure DevOps organization {owner}, project {project}"; + } if (log == null) { Console.WriteLine(message); diff --git a/src/DevOpsMetrics.Service/Controllers/LeadTimeForChangesController.cs b/src/DevOpsMetrics.Service/Controllers/LeadTimeForChangesController.cs index 02027b30..7babbb05 100644 --- a/src/DevOpsMetrics.Service/Controllers/LeadTimeForChangesController.cs +++ b/src/DevOpsMetrics.Service/Controllers/LeadTimeForChangesController.cs @@ -33,7 +33,6 @@ public async Task GetAzureDevOpsLeadTimeForChanges(bool //Get the PAT token from the key vault string patTokenName = PartitionKeys.CreateAzureDevOpsSettingsPartitionKeyPatToken(organization, project, repository); - patTokenName = SecretsProcessing.CleanKey(patTokenName); string patToken = Configuration[patTokenName]; if (string.IsNullOrEmpty(patToken)) { diff --git a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs index a42c667a..04214460 100644 --- a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs @@ -53,8 +53,9 @@ public async Task DORASummaryControllerUpdateIntegrationTest() DORASummaryController controller = new(base.Configuration); //Act - ProcessingResult model = await controller.UpdateDORASummaryItem(organization, repository, - branch, workflowName, workflowId, resourceGroup, numberOfDays, maxNumberOfItems); + ProcessingResult model = await controller.UpdateDORASummaryItem(organization, "", repository, + branch, workflowName, workflowId, resourceGroup, numberOfDays, maxNumberOfItems, + null, true, true); //Assert Assert.IsNotNull(model); From daad52cbec071215a237cc99df56061f19738d49 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 14:48:39 -0400 Subject: [PATCH 09/14] Updated processing --- .../Controllers/DORASummaryController.cs | 61 +++++++++++-------- .../Service/DORASummaryControllerTests.cs | 35 ++++++++--- 2 files changed, 63 insertions(+), 33 deletions(-) diff --git a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs index e2221ca4..c515a0ff 100644 --- a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs +++ b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs @@ -92,7 +92,7 @@ public async Task UpdateDORASummaryItem( } else { - message = $"Processing Azure DevOps organization {owner}, project {project}"; + message = $"Processing Azure DevOps organization {owner}, project {project}, repo {repo}"; } if (log == null) { @@ -106,12 +106,18 @@ public async Task UpdateDORASummaryItem( { result.BuildsUpdated = await azureTableStorageDA.UpdateGitHubActionRunsInStorage(clientId, clientSecret, tableStorageConfig, owner, repo, branch, workflowName, workflowId, numberOfDays, maxNumberOfItems); - //log.LogInformation($"Processing GitHub owner {item.Owner}, repo {item.Repo}: {buildsUpdated} builds updated"); result.PRsUpdated = await azureTableStorageDA.UpdateGitHubActionPullRequestsInStorage(clientId, clientSecret, tableStorageConfig, - owner, repo, branch, numberOfDays, maxNumberOfItems); - //log.LogInformation($"Processing GitHub owner {item.Owner}, repo {item.Repo}: {prsUpdated} pull requests updated"); + owner, repo, branch, numberOfDays, maxNumberOfItems); message = $"Processed GitHub owner {owner}, repo {repo}. {result.BuildsUpdated} builds and {result.PRsUpdated} prs/commits updated"; } + else + { + result.BuildsUpdated = await azureTableStorageDA.UpdateAzureDevOpsBuildsInStorage(patToken, tableStorageConfig, + owner, repo, branch, workflowName, workflowId, numberOfDays, maxNumberOfItems); + result.PRsUpdated = await azureTableStorageDA.UpdateAzureDevOpsPullRequestsInStorage(patToken, tableStorageConfig, + owner, repo, branch, numberOfDays, maxNumberOfItems); + message = $"Processed Azure DevOps organization {owner}, project {project}, repo {repo}. {result.BuildsUpdated} builds and {result.PRsUpdated} prs/commits updated"; + } if (log == null) { Console.WriteLine(message); @@ -126,8 +132,6 @@ public async Task UpdateDORASummaryItem( //Get the DORA metrics for the last 90 days DeploymentFrequencyModel deploymentFrequencyModel = new(); LeadTimeForChangesModel leadTimeForChangesModel = new(); - MeanTimeToRestoreModel meanTimeToRestoreModel = new(); - ChangeFailureRateModel changeFailureRateModel = new(); if (isGitHub == true) { deploymentFrequencyModel = await DeploymentFrequencyDA.GetGitHubDeploymentFrequency(false, clientId, clientSecret, tableStorageConfig, @@ -137,26 +141,35 @@ public async Task UpdateDORASummaryItem( leadTimeForChangesModel = await LeadTimeForChangesDA.GetGitHubLeadTimesForChanges(false, clientId, clientSecret, tableStorageConfig, owner, repo, branch, workflowName, workflowId, numberOfDays, maxNumberOfItems, useCache); + } + else + { + deploymentFrequencyModel = await DeploymentFrequencyDA.GetAzureDevOpsDeploymentFrequency(false, patToken, tableStorageConfig, + owner, project, branch, workflowName, + numberOfDays, maxNumberOfItems, useCache); - meanTimeToRestoreModel = new(); - if (resourceGroup != null) - { - meanTimeToRestoreModel = MeanTimeToRestoreDA.GetAzureMeanTimeToRestore(false, tableStorageConfig, - DevOpsPlatform.GitHub, - resourceGroup, - numberOfDays, maxNumberOfItems); - } - else - { - meanTimeToRestoreModel.MTTRAverageDurationInHours = 0; - meanTimeToRestoreModel.MTTRAverageDurationDescription = MeanTimeToRestore.GetMeanTimeToRestoreRating(0); - } - - changeFailureRateModel = ChangeFailureRateDA.GetChangeFailureRate(false, tableStorageConfig, - DevOpsPlatform.GitHub, - owner, repo, branch, workflowName, - numberOfDays, maxNumberOfItems); + leadTimeForChangesModel = await LeadTimeForChangesDA.GetAzureDevOpsLeadTimesForChanges(false, patToken, tableStorageConfig, + owner, project, repo, branch, workflowName, + numberOfDays, maxNumberOfItems, useCache); + } + MeanTimeToRestoreModel meanTimeToRestoreModel = new(); + if (resourceGroup != null) + { + meanTimeToRestoreModel = MeanTimeToRestoreDA.GetAzureMeanTimeToRestore(false, tableStorageConfig, + DevOpsPlatform.GitHub, + resourceGroup, + numberOfDays, maxNumberOfItems); } + else + { + meanTimeToRestoreModel.MTTRAverageDurationInHours = 0; + meanTimeToRestoreModel.MTTRAverageDurationDescription = MeanTimeToRestore.GetMeanTimeToRestoreRating(0); + } + + ChangeFailureRateModel changeFailureRateModel = ChangeFailureRateDA.GetChangeFailureRate(false, tableStorageConfig, + DevOpsPlatform.GitHub, + owner, repo, branch, workflowName, + numberOfDays, maxNumberOfItems); //Summarize the results into a new object DORASummaryItem DORASummary = new() diff --git a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs index 04214460..a0eaaf6a 100644 --- a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs @@ -1,11 +1,5 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Reflection; -using System.Threading.Tasks; -using DevOpsMetrics.Core.DataAccess.TableStorage; -using DevOpsMetrics.Core.Models.AzureDevOps; +using System.Threading.Tasks; using DevOpsMetrics.Core.Models.Common; -using DevOpsMetrics.Core.Models.GitHub; using DevOpsMetrics.Service.Controllers; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -33,7 +27,7 @@ public void DORASummaryControllerGetIntegrationTest() } [TestMethod] - public async Task DORASummaryControllerUpdateIntegrationTest() + public async Task DORASummaryControllerGitHubUpdateIntegrationTest() { //Arrange //string organization = "DeveloperMetrics"; @@ -59,7 +53,30 @@ public async Task DORASummaryControllerUpdateIntegrationTest() //Assert Assert.IsNotNull(model); - //Assert.IsTrue(model.TotalResults > 0); + } + + [TestMethod] + public async Task DORASummaryControllerAzureDevOpsUpdateIntegrationTest() + { + //Arrange + string organization = "samsmithnz"; + string project = "AzDoDevOpsMetrics"; + string repository = "AzDoDevOpsMetrics"; + string branch = "refs/heads/main"; + string buildName = "azure-pipelines.yml"; + string buildId = "3673"; + string resourceGroup = null; + int numberOfDays = 30; + int maxNumberOfItems = 20; + DORASummaryController controller = new(base.Configuration); + + //Act + ProcessingResult model = await controller.UpdateDORASummaryItem(organization, project, repository, + branch, buildName, buildId, resourceGroup, numberOfDays, maxNumberOfItems, + null, true, false); + + //Assert + Assert.IsNotNull(model); } //[TestMethod] From 647be087d9fa6f147a63e0d1b89756ab76b2a439 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 14:53:15 -0400 Subject: [PATCH 10/14] updated partition updates --- .../TableStorage/AzureTableStorageDA.cs | 13 +++++-- .../Controllers/DORASummaryController.cs | 36 ++++++++++++------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/DevOpsMetrics.Core/DataAccess/TableStorage/AzureTableStorageDA.cs b/src/DevOpsMetrics.Core/DataAccess/TableStorage/AzureTableStorageDA.cs index cf02f20b..bf9d15b5 100644 --- a/src/DevOpsMetrics.Core/DataAccess/TableStorage/AzureTableStorageDA.cs +++ b/src/DevOpsMetrics.Core/DataAccess/TableStorage/AzureTableStorageDA.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.ComponentModel.Design; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; @@ -397,10 +398,18 @@ public async Task UpdateProjectLogInStorage(TableStorageConfiguration tabl } public static async Task UpdateDORASummaryItem(TableStorageConfiguration tableStorageConfig, - string owner, string repo, DORASummaryItem DORASummaryItem) + string owner, string project, string repo, DORASummaryItem DORASummaryItem) { string partitionKey = owner; - string rowKey = repo; + string rowKey = ""; + if (project != null) + { + rowKey = project; + } + else + { + rowKey = repo; + } string json = JsonConvert.SerializeObject(DORASummaryItem); AzureStorageTableModel newItem = new(partitionKey, rowKey, json); TableStorageCommonDA tableDA = new(tableStorageConfig.StorageAccountConnectionString, tableStorageConfig.TableDORASummaryItem); diff --git a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs index c515a0ff..96991d73 100644 --- a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs +++ b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs @@ -145,11 +145,11 @@ public async Task UpdateDORASummaryItem( else { deploymentFrequencyModel = await DeploymentFrequencyDA.GetAzureDevOpsDeploymentFrequency(false, patToken, tableStorageConfig, - owner, project, branch, workflowName, + owner, project, branch, workflowName, numberOfDays, maxNumberOfItems, useCache); leadTimeForChangesModel = await LeadTimeForChangesDA.GetAzureDevOpsLeadTimesForChanges(false, patToken, tableStorageConfig, - owner, project, repo, branch, workflowName, + owner, project, repo, branch, workflowName, numberOfDays, maxNumberOfItems, useCache); } MeanTimeToRestoreModel meanTimeToRestoreModel = new(); @@ -187,7 +187,7 @@ public async Task UpdateDORASummaryItem( }; //Serialize the summary into an Azure storage table - await AzureTableStorageDA.UpdateDORASummaryItem(tableStorageConfig, owner, repo, DORASummary); + await AzureTableStorageDA.UpdateDORASummaryItem(tableStorageConfig, owner, project, repo, DORASummary); //await settingsController.UpdateGitHubProjectLog(ghSetting.Owner, ghSetting.Repo, result.BuildsUpdated, result.PRsUpdated, "", "", null, null); ProjectLog projectLog = null; @@ -198,6 +198,13 @@ public async Task UpdateDORASummaryItem( result.BuildsUpdated, result.PRsUpdated, "", "", null, null); } + else + { + projectLog = new( + PartitionKeys.CreateAzureDevOpsSettingsPartitionKey(owner, project, repo), + result.BuildsUpdated, result.PRsUpdated, + "", "", null, null); + } if (projectLog != null) { await azureTableStorageDA.UpdateProjectLogInStorage(tableStorageConfig, projectLog); @@ -214,19 +221,24 @@ public async Task UpdateDORASummaryItem( { log.LogInformation(error); } - //await settingsController.UpdateGitHubProjectLog(ghSetting.Owner, ghSetting.Repo, result.BuildsUpdated, result.PRsUpdated, - // ghSetting.Owner + "_" + ghSetting.Repo + "_" + ghSetting.Branch + "_" + ghSetting.WorkflowName + "_" + ghSetting.WorkflowId + "_" + numberOfDays + "_" + maxNumberOfItems, - // ghSetting.Owner + "_" + ghSetting.Repo + "_" + ghSetting.Branch + "_" + numberOfDays + "_" + maxNumberOfItems, - // ex.ToString(), error); ProjectLog projectLog = null; if (isGitHub == true) { projectLog = new( - PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo), - result.BuildsUpdated, result.PRsUpdated, - owner + "_" + repo + "_" + branch + "_" + workflowName + "_" + workflowId + "_" + numberOfDays + "_" + maxNumberOfItems, - owner + "_" + repo + "_" + branch + "_" + numberOfDays + "_" + maxNumberOfItems, - ex.ToString(), error); + PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo), + result.BuildsUpdated, result.PRsUpdated, + owner + "_" + repo + "_" + branch + "_" + workflowName + "_" + workflowId + "_" + numberOfDays + "_" + maxNumberOfItems, + owner + "_" + repo + "_" + branch + "_" + numberOfDays + "_" + maxNumberOfItems, + ex.ToString(), error); + } + else + { + projectLog = new( + PartitionKeys.CreateAzureDevOpsSettingsPartitionKey(owner, project, repo), + result.BuildsUpdated, result.PRsUpdated, + owner + "_" + project + "_" + repo + "_" + branch + "_" + workflowName + "_" + workflowId + "_" + numberOfDays + "_" + maxNumberOfItems, + owner + "_" + project + "_" + repo + "_" + branch + "_" + numberOfDays + "_" + maxNumberOfItems, + ex.ToString(), error); } if (projectLog != null) { From 597f99f3b02e756ef743d5a5689a29ab8e8fe7b2 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 14:55:36 -0400 Subject: [PATCH 11/14] code gardening --- .../Controllers/DORASummaryController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs index 96991d73..4ec67697 100644 --- a/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs +++ b/src/DevOpsMetrics.Service/Controllers/DORASummaryController.cs @@ -84,7 +84,6 @@ public async Task UpdateDORASummaryItem( ProcessingResult result = new(); try { - //TODO: fix this - should be using a common interface, not this null hack string message = ""; if (isGitHub == true) { @@ -94,6 +93,7 @@ public async Task UpdateDORASummaryItem( { message = $"Processing Azure DevOps organization {owner}, project {project}, repo {repo}"; } + //TODO: fix this - should be using a common interface, not this null hack if (log == null) { Console.WriteLine(message); @@ -221,7 +221,7 @@ public async Task UpdateDORASummaryItem( { log.LogInformation(error); } - ProjectLog projectLog = null; + ProjectLog projectLog; if (isGitHub == true) { projectLog = new( From fe9714f638a7c8ea33ec60365d4084853b11c79f Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 15:38:49 -0400 Subject: [PATCH 12/14] Updated lead source test --- src/DevOpsMetrics.Tests/Core/ChangeFailureRateDATests.cs | 2 +- src/DevOpsMetrics.Tests/Core/DeploymentFrequencyDATests.cs | 2 +- src/DevOpsMetrics.Tests/Core/LeadTimeForChangesDATests.cs | 2 +- .../Service/LeadTimeForChangesControllerTests.cs | 6 +++--- src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/DevOpsMetrics.Tests/Core/ChangeFailureRateDATests.cs b/src/DevOpsMetrics.Tests/Core/ChangeFailureRateDATests.cs index a9f6abd9..ab9f8e16 100644 --- a/src/DevOpsMetrics.Tests/Core/ChangeFailureRateDATests.cs +++ b/src/DevOpsMetrics.Tests/Core/ChangeFailureRateDATests.cs @@ -85,7 +85,7 @@ public void GHChangeFailureRateDAIntegrationTest() string owner = "DeveloperMetrics"; string repo = "DevOpsMetrics"; string branch = "main"; - string workflowName = "DevOpsMetrics CI/CD"; + string workflowName = "CI/CD"; DevOpsPlatform targetDevOpsPlatform = DevOpsPlatform.GitHub; int numberOfDays = 30; int maxNumberOfItems = 20; diff --git a/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyDATests.cs b/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyDATests.cs index fc8722d5..fd4c97e7 100644 --- a/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyDATests.cs +++ b/src/DevOpsMetrics.Tests/Core/DeploymentFrequencyDATests.cs @@ -55,7 +55,7 @@ public async Task GHDeploymentFrequencyDAIntegrationTest() string owner = "DeveloperMetrics"; string repo = "DevOpsMetrics"; string branch = "main"; - string workflowName = "DevOpsMetrics CI/CD"; + string workflowName = "CI/CD"; string workflowId = "1162561"; int numberOfDays = 30; int maxNumberOfItems = 20; diff --git a/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesDATests.cs b/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesDATests.cs index e01c2d92..6694a702 100644 --- a/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesDATests.cs +++ b/src/DevOpsMetrics.Tests/Core/LeadTimeForChangesDATests.cs @@ -71,7 +71,7 @@ public async Task GHLeadTimeForChangesDAIntegrationTest() string owner = "DeveloperMetrics"; string repo = "devopsmetrics"; string mainBranch = "main"; - string workflowName = "DevOpsMetrics.CI"; + string workflowName = "CI/CD"; string workflowId = "1162561"; int numberOfDays = 7; int maxNumberOfItems = 20; diff --git a/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs b/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs index e88e1bc5..c43d2c06 100644 --- a/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/LeadTimeForChangesControllerTests.cs @@ -66,7 +66,7 @@ public async Task GHLeadTimeControllerIntegrationTest() string owner = "DeveloperMetrics"; string repo = "devopsmetrics"; string branch = "main"; - string workflowName = "DevOpsMetrics.CICD"; + string workflowName = "CI/CD"; string workflowId = "1162561"; int numberOfDays = 30; int maxNumberOfItems = 20; @@ -154,7 +154,7 @@ public async Task GHLeadTimeControllerAPIIntegrationTest() string owner = "DeveloperMetrics"; string repo = "devopsmetrics"; string branch = "main"; - string workflowName = "DevOpsMetrics.CICD"; + string workflowName = "CI/CD"; string workflowId = "1162561"; int numberOfDays = 7; int maxNumberOfItems = 20; @@ -249,7 +249,7 @@ public async Task GHLeadTimeControllerAPILiveIntegrationTest() string owner = "DeveloperMetrics"; string repo = "devopsmetrics"; string branch = "main"; - string workflowName = "DevOpsMetrics.CICD"; + string workflowName = "CI/CD"; string workflowId = "1162561"; int numberOfDays = 20; int maxNumberOfItems = 60; diff --git a/src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs b/src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs index 1403af94..5a63f352 100644 --- a/src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs +++ b/src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs @@ -144,7 +144,7 @@ public void GHGetBuildsDAIntegrationTest() TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(base.Configuration); string owner = "DeveloperMetrics"; string repo = "DevOpsMetrics"; - string workflowName = "DevOpsMetrics CI/CD"; + string workflowName = "CI/CD"; //Act AzureTableStorageDA da = new(); @@ -164,7 +164,7 @@ public async Task GHUpdateDevOpsMetricsBuildsDAIntegrationTest() string owner = "DeveloperMetrics"; string repo = "DevOpsMetrics"; string branch = "main"; - string workflowName = "DevOpsMetrics CI/CD"; + string workflowName = "CI/CD"; string workflowId = "1162561"; int numberOfDays = 30; int maxNumberOfItems = 20; From 3d6622b49be7e3f82e6fb9ad9ef968f92f9f53a9 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 15:54:28 -0400 Subject: [PATCH 13/14] Fix to project page --- src/DevOpsMetrics.Web/Controllers/HomeController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DevOpsMetrics.Web/Controllers/HomeController.cs b/src/DevOpsMetrics.Web/Controllers/HomeController.cs index 85d85a7b..56836f12 100644 --- a/src/DevOpsMetrics.Web/Controllers/HomeController.cs +++ b/src/DevOpsMetrics.Web/Controllers/HomeController.cs @@ -38,7 +38,7 @@ public async Task Index() [HttpPost] public IActionResult ProjectUpdate(string RowKey, int NumberOfDaysSelected = 30) { - return RedirectToAction("Project", "Home", new { rowKey = RowKey, numberOfDays = NumberOfDaysSelected }); + return RedirectToAction("Project", "Home", new { projectId = RowKey, numberOfDays = NumberOfDaysSelected }); } [HttpGet] From 361d7b2356e1eab12b5bc319a6495e774e3724b6 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Tue, 23 May 2023 15:56:46 -0400 Subject: [PATCH 14/14] Fixed test --- .../Service/ChangeFailureRateControllerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs index b276929d..4c795dd0 100644 --- a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs @@ -114,7 +114,7 @@ public void GHChangeFailureRateLiveControllerIntegrationTest() string branch = "main"; string workflowName = "CI/ CD"; DevOpsPlatform targetDevOpsPlatform = DevOpsPlatform.GitHub; - int numberOfDays = 7; + int numberOfDays = 30; int maxNumberOfItems = 20; ChangeFailureRateController controller = new(base.Configuration);