diff --git a/configuration.json b/configuration.json index 02975fca6..b7b5dd9f9 100644 --- a/configuration.json +++ b/configuration.json @@ -74,7 +74,7 @@ "Processors": [ { "$type": "WorkItemMigrationConfig", - "Enabled": false, + "Enabled": true, "UpdateCreatedDate": true, "UpdateCreatedBy": true, "WIQLQuery": "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc", @@ -96,7 +96,7 @@ "SkipRevisionWithInvalidAreaPath": false } ], - "Version": "14.2", + "Version": "15.0", "workaroundForQuerySOAPBugEnabled": false, "WorkItemTypeDefinition": { "sourceWorkItemTypeName": "targetWorkItemTypeName" diff --git a/src/MigrationTools.ConsoleFull/Properties/launchSettings.json b/src/MigrationTools.ConsoleFull/Properties/launchSettings.json index 6efaef226..1e63b28b4 100644 --- a/src/MigrationTools.ConsoleFull/Properties/launchSettings.json +++ b/src/MigrationTools.ConsoleFull/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "execute": { "commandName": "Project", - "commandLineArgs": "execute -c \"C:\\temp\\configuration.json\"" + "commandLineArgs": "execute -c \"configuration.json\"" }, "executepipe": { "commandName": "Project", diff --git a/src/MigrationTools.Host/MigrationToolHost.cs b/src/MigrationTools.Host/MigrationToolHost.cs index 3842c7dd2..514527ac9 100644 --- a/src/MigrationTools.Host/MigrationToolHost.cs +++ b/src/MigrationTools.Host/MigrationToolHost.cs @@ -49,7 +49,7 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) .Enrich.WithProcessId() .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug, theme: AnsiConsoleTheme.Code, outputTemplate: outputTemplate) .WriteTo.ApplicationInsights(services.GetService(), new CustomConverter(), LogEventLevel.Error) - .WriteTo.File(logPath, LogEventLevel.Verbose); + .WriteTo.File(logPath, LogEventLevel.Verbose, outputTemplate: outputTemplate); }) .ConfigureLogging((context, logBuilder) => { @@ -94,7 +94,13 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) }); // Application Insights - services.AddApplicationInsightsTelemetryWorkerService(new ApplicationInsightsServiceOptions { ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(), ConnectionString = "InstrumentationKey=2d666f84-b3fb-4dcf-9aad-65de038d2772" }); + ApplicationInsightsServiceOptions aiso = new ApplicationInsightsServiceOptions(); + aiso.ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + aiso.ConnectionString = "InstrumentationKey=2d666f84-b3fb-4dcf-9aad-65de038d2772"; + //# if DEBUG + //aiso.DeveloperMode = true; + //#endif + services.AddApplicationInsightsTelemetryWorkerService(aiso); // Services services.AddTransient(); diff --git a/src/MigrationTools/Services/TelemetryClientAdapter.cs b/src/MigrationTools/Services/TelemetryClientAdapter.cs index a6207770f..d656af26c 100644 --- a/src/MigrationTools/Services/TelemetryClientAdapter.cs +++ b/src/MigrationTools/Services/TelemetryClientAdapter.cs @@ -11,6 +11,7 @@ public class TelemetryClientAdapter : ITelemetryLogger public TelemetryClientAdapter(TelemetryClient telemetryClient) { + telemetryClient.InstrumentationKey = "2d666f84-b3fb-4dcf-9aad-65de038d2772"; telemetryClient.Context.Session.Id = Guid.NewGuid().ToString(); telemetryClient.Context.Device.OperatingSystem = Environment.OSVersion.ToString(); if (!(System.Reflection.Assembly.GetEntryAssembly() is null)) diff --git a/src/MigrationTools/_EngineV1/Configuration/EngineConfiguration.cs b/src/MigrationTools/_EngineV1/Configuration/EngineConfiguration.cs index 9fbf032a7..7d6ff45e9 100644 --- a/src/MigrationTools/_EngineV1/Configuration/EngineConfiguration.cs +++ b/src/MigrationTools/_EngineV1/Configuration/EngineConfiguration.cs @@ -13,14 +13,14 @@ public EngineConfiguration() public IMigrationClientConfig Source { get; set; } public IMigrationClientConfig Target { get; set; } - public List FieldMaps { get; set; } - public Dictionary GitRepoMapping { get; set; } + public List FieldMaps { get; set; } = new List(); + public Dictionary GitRepoMapping { get; set; } = new Dictionary(); public string LogLevel { get; private set; } - public List CommonEnrichersConfig { get; set; } + public List CommonEnrichersConfig { get; set; } = new List(); public List Processors { get; set; } public string Version { get; set; } public bool workaroundForQuerySOAPBugEnabled { get; set; } - public Dictionary WorkItemTypeDefinition { get; set; } + public Dictionary WorkItemTypeDefinition { get; set; } = new Dictionary(); } } diff --git a/src/MigrationTools/_EngineV1/Processors/MigrationProcessorBase.cs b/src/MigrationTools/_EngineV1/Processors/MigrationProcessorBase.cs index 43a830df2..7598dc224 100644 --- a/src/MigrationTools/_EngineV1/Processors/MigrationProcessorBase.cs +++ b/src/MigrationTools/_EngineV1/Processors/MigrationProcessorBase.cs @@ -90,7 +90,11 @@ protected void PullCommonEnrichersConfig (List().FirstOrDefault(); + TEnricherOptions config = default(TEnricherOptions); + if (commonEnrichersStore != null) + { + config = commonEnrichersStore.OfType().FirstOrDefault(); + } if (config == null) { var result = new TEnricherOptions(); diff --git a/src/VstsSyncMigrator.Core.Tests/WorkItemMigrationTests.cs b/src/VstsSyncMigrator.Core.Tests/WorkItemMigrationTests.cs index 2dcc92e09..89b48a7d1 100644 --- a/src/VstsSyncMigrator.Core.Tests/WorkItemMigrationTests.cs +++ b/src/VstsSyncMigrator.Core.Tests/WorkItemMigrationTests.cs @@ -43,6 +43,10 @@ public void Setup() }, }); + //IMigrationEngine xx = _services.GetRequiredService(); + // IOptions < EngineConfiguration> engine = _services.GetRequiredService>(); + + _underTest = new WorkItemMigrationContext(_services.GetRequiredService(), _services, _services.GetRequiredService(), @@ -54,13 +58,15 @@ public void Setup() _services.GetRequiredService(), _services.GetRequiredService(), _services.GetRequiredService>()); + _underTest.Configure(new WorkItemMigrationConfig { }); + } - [TestMethod] + [TestMethod, TestCategory("L0")] public void TestFixAreaPath_WhenNoAreaPathOrIterationPath_DoesntChangeQuery() { string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')"; @@ -71,7 +77,7 @@ public void TestFixAreaPath_WhenNoAreaPathOrIterationPath_DoesntChangeQuery() } - [TestMethod] + [TestMethod, TestCategory("L0")] public void TestFixAreaPath_WhenAreaPathInQuery_ChangesQuery() { string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [System.AreaPath] = 'SourceServer\Area\Path1' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')"; @@ -82,7 +88,7 @@ public void TestFixAreaPath_WhenAreaPathInQuery_ChangesQuery() Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit); } - [TestMethod] + [TestMethod, TestCategory("L1")] public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesEnabled_ChangesQuery() { var nodeStructure = _services.GetRequiredService(); @@ -102,7 +108,7 @@ public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesEnabled_ Assert.AreEqual(expectTargetQueryBit, targetWIQLQuery); } - [TestMethod] + [TestMethod, TestCategory("L1")] public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesDisabled_SupportsWhitespaces() { var nodeStructure = _services.GetRequiredService(); @@ -129,7 +135,7 @@ public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesDisabled Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit); } - [TestMethod] + [TestMethod, TestCategory("L1")] public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesEnabled_SupportsWhitespaces() { var nodeStructure = _services.GetRequiredService(); @@ -156,7 +162,7 @@ public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesEnabled_ Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit); } - [TestMethod] + [TestMethod, TestCategory("L0")] public void TestFixAreaPath_WhenMultipleAreaPathInQuery_ChangesQuery() { string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [System.AreaPath] = 'SourceServer\Area\Path1' OR [System.AreaPath] = 'SourceServer\Area\Path2' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')"; @@ -167,7 +173,7 @@ public void TestFixAreaPath_WhenMultipleAreaPathInQuery_ChangesQuery() Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit); } - [TestMethod] + [TestMethod, TestCategory("L0")] public void TestFixAreaPath_WhenAreaPathAtEndOfQuery_ChangesQuery() { string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan') AND [System.AreaPath] = 'SourceServer\Area\Path1'"; @@ -178,7 +184,7 @@ public void TestFixAreaPath_WhenAreaPathAtEndOfQuery_ChangesQuery() Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit); } - [TestMethod] + [TestMethod, TestCategory("L0")] public void TestFixIterationPath_WhenInQuery_ChangesQuery() { string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [System.IterationPath] = 'SourceServer\Iteration\Path1' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')"; @@ -189,7 +195,7 @@ public void TestFixIterationPath_WhenInQuery_ChangesQuery() Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit); } - [TestMethod] + [TestMethod, TestCategory("L0")] public void TestFixAreaPathAndIteration_WhenMultipleOccuranceInQuery_ChangesQuery() { string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND ([System.AreaPath] = 'SourceServer\Area\Path1' OR [System.AreaPath] = 'SourceServer\Area\Path2') AND ([System.IterationPath] = 'SourceServer\Iteration\Path1' OR [System.IterationPath] = 'SourceServer\Iteration\Path2') AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')"; @@ -200,7 +206,7 @@ public void TestFixAreaPathAndIteration_WhenMultipleOccuranceInQuery_ChangesQuer Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit); } - [TestMethod] + [TestMethod, TestCategory("L0")] public void TestFixAreaPathAndIteration_WhenMultipleOccuranceWithMixtureOrEqualAndUnderOperatorsInQuery_ChangesQuery() { string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND ([System.AreaPath] = 'SourceServer\Area\Path1' OR [System.AreaPath] UNDER 'SourceServer\Area\Path2') AND ([System.IterationPath] UNDER 'SourceServer\Iteration\Path1' OR [System.IterationPath] = 'SourceServer\Iteration\Path2') AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";