Skip to content

Commit 4420ba1

Browse files
committed
PR 44: Updated to load test migration tools properly +semver:patch
- Updated to load test migration tools properly +semver:patch
1 parent 5bd6a9e commit 4420ba1

File tree

5 files changed

+43
-39
lines changed

5 files changed

+43
-39
lines changed

TfsWitMigrator.Console/Program.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,33 @@ static int Main(string[] args)
4848
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
4949
Trace.Listeners.Add(new TextWriterTraceListener(string.Format(@"{0}-{1}.log", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), "MigrationRun"), "myListener"));
5050
//////////////////////////////////////////////////
51-
Trace.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
52-
Trace.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
53-
Trace.WriteLine(string.Format("Telemitery Enabled: {0}", Telemetry.Current.IsEnabled().ToString()));
54-
Trace.WriteLine(string.Format("SessionID: {0}", Telemetry.Current.Context.Session.Id));
55-
Trace.WriteLine(string.Format("User: {0}", Telemetry.Current.Context.User.Id));
56-
Trace.WriteLine(string.Format("Start Time: {0}", startTime.ToUniversalTime()));
57-
Trace.WriteLine("----------------------------------------------------------------");
58-
Trace.WriteLine("------------------------------START-----------------------------");
59-
Trace.WriteLine("----------------------------------------------------------------");
51+
Trace.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, "vstsbulkeditor");
52+
Trace.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), "vstsbulkeditor");
53+
Trace.WriteLine(string.Format("Telemitery Enabled: {0}", Telemetry.Current.IsEnabled().ToString()), "vstsbulkeditor");
54+
Trace.WriteLine(string.Format("SessionID: {0}", Telemetry.Current.Context.Session.Id), "vstsbulkeditor");
55+
Trace.WriteLine(string.Format("User: {0}", Telemetry.Current.Context.User.Id), "vstsbulkeditor");
56+
Trace.WriteLine(string.Format("Start Time: {0}", startTime.ToUniversalTime()), "vstsbulkeditor");
57+
Trace.WriteLine("----------------------------------------------------------------", "vstsbulkeditor");
58+
Trace.WriteLine("------------------------------START-----------------------------", "vstsbulkeditor");
59+
Trace.WriteLine("----------------------------------------------------------------", "vstsbulkeditor");
6060
//////////////////////////////////////////////////
6161
int result = (int)Parser.Default.ParseArguments<InitOptions, RunOptions>(args).MapResult(
6262
(InitOptions opts) => RunInitAndReturnExitCode(opts),
6363
(RunOptions opts) => RunExecuteAndReturnExitCode(opts),
6464
errs => 1);
6565
//////////////////////////////////////////////////
66-
Trace.WriteLine("----------------------------------------------------------------");
67-
Trace.WriteLine("-------------------------------END------------------------------");
68-
Trace.WriteLine("----------------------------------------------------------------");
66+
Trace.WriteLine("----------------------------------------------------------------", "vstsbulkeditor");
67+
Trace.WriteLine("-------------------------------END------------------------------", "vstsbulkeditor");
68+
Trace.WriteLine("----------------------------------------------------------------", "vstsbulkeditor");
6969
mainTimer.Stop();
7070
Telemetry.Current.TrackEvent("ApplicationEnd", null,
7171
new Dictionary<string, double> {
7272
{ "ApplicationDuration", mainTimer.ElapsedMilliseconds }
7373
});
7474
Telemetry.Current.Flush();
7575

76-
Trace.WriteLine(string.Format("Duration: {0}", mainTimer.Elapsed.ToString("c")));
77-
Trace.WriteLine(string.Format("End Time: {0}", startTime.ToUniversalTime()));
76+
Trace.WriteLine(string.Format("Duration: {0}", mainTimer.Elapsed.ToString("c")), "vstsbulkeditor");
77+
Trace.WriteLine(string.Format("End Time: {0}", startTime.ToUniversalTime()), "vstsbulkeditor");
7878
return result;
7979
}
8080

@@ -89,7 +89,7 @@ private static object RunExecuteAndReturnExitCode(RunOptions opts)
8989

9090
if (!File.Exists(opts.ConfigFile))
9191
{
92-
Trace.WriteLine("The config file does not exist, nor doe the default 'vstsbulkeditor.json'. Use 'init' to create a configuration file first");
92+
Trace.WriteLine("The config file does not exist, nor doe the default 'vstsbulkeditor.json'. Use 'init' to create a configuration file first", "vstsbulkeditor");
9393
return 1;
9494
}
9595
else
@@ -102,11 +102,11 @@ private static object RunExecuteAndReturnExitCode(RunOptions opts)
102102
new FieldMapConfigJsonConverter(),
103103
new ProcessorConfigJsonConverter());
104104
}
105-
Trace.WriteLine("Config Loaded, creating engine");
105+
Trace.WriteLine("Config Loaded, creating engine", "vstsbulkeditor");
106106
MigrationEngine me = new MigrationEngine(ec);
107-
Trace.WriteLine("Engine created, running...");
107+
Trace.WriteLine("Engine created, running...", "vstsbulkeditor");
108108
me.Run();
109-
Trace.WriteLine("Run complete...");
109+
Trace.WriteLine("Run complete...", "vstsbulkeditor");
110110
return 0;
111111
}
112112

@@ -121,7 +121,7 @@ private static object RunInitAndReturnExitCode(InitOptions opts)
121121
StreamWriter sw = new StreamWriter("vstsbulkeditor.json");
122122
sw.WriteLine(json);
123123
sw.Close();
124-
Trace.WriteLine("New vstsbulkeditor.json file has been created");
124+
Trace.WriteLine("New vstsbulkeditor.json file has been created", "vstsbulkeditor");
125125
}
126126
return 0;
127127
}

TfsWitMigrator.Core/Configuration/Processing/TestPlansAndSuitsMigrationConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace VSTS.DataBulkEditor.Engine.Configuration.Processing
99
public class TestPlansAndSuitsMigrationConfig : ITfsProcessingConfig
1010
{
1111
public bool Enabled { get; set; }
12+
public string AreaIterationPath { get; set; }
1213

1314
public Type Processor
1415
{

TfsWitMigrator.Core/Execution/MigrationContext/TestPlansAndSuitsMigrationContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class TestPlansAndSuitsMigrationContext : MigrationContextBase
2020
WorkItemStoreContext targetWitStore;
2121
TestManagementContext targetTestStore;
2222

23-
WorkItemUpdateAreasAsTagsConfig config;
23+
TestPlansAndSuitsMigrationConfig config;
2424

2525
public override string Name
2626
{
@@ -30,7 +30,7 @@ public override string Name
3030
}
3131
}
3232

33-
public TestPlansAndSuitsMigrationContext(MigrationEngine me, WorkItemUpdateAreasAsTagsConfig config) : base(me, config)
33+
public TestPlansAndSuitsMigrationContext(MigrationEngine me, TestPlansAndSuitsMigrationConfig config) : base(me, config)
3434
{
3535
sourceWitStore = new WorkItemStoreContext(me.Source, WorkItemStoreFlags.None);
3636
sourceTestStore = new TestManagementContext(me.Source);

TfsWitMigrator.Core/Execution/MigrationContext/WorkItemMigrationContext.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ internal override void InternalExecute()
4141
tfsqc.AddParameter("TeamProject", me.Source.Name);
4242
tfsqc.Query = string.Format(@"SELECT [System.Id], [System.Tags] FROM WorkItems WHERE [System.TeamProject] = @TeamProject {0} ORDER BY [System.ChangedDate] desc", _config.QueryBit);
4343
WorkItemCollection sourceWIS = tfsqc.Execute();
44-
Trace.WriteLine(string.Format("Migrate {0} work items?", sourceWIS.Count));
44+
Trace.WriteLine(string.Format("Migrate {0} work items?", sourceWIS.Count),this.Name);
4545
//////////////////////////////////////////////////
4646
WorkItemStoreContext targetStore = new WorkItemStoreContext(me.Target, WorkItemStoreFlags.BypassRules);
4747
Project destProject = targetStore.GetProject();
48-
Trace.WriteLine(string.Format("Found target project as {0}", destProject.Name));
48+
Trace.WriteLine(string.Format("Found target project as {0}", destProject.Name), this.Name);
4949

5050
int current = sourceWIS.Count;
5151
int count = 0;
@@ -56,7 +56,7 @@ internal override void InternalExecute()
5656
witstopwatch.Start();
5757
WorkItem targetFound;
5858
targetFound = targetStore.FindReflectedWorkItem(sourceWI, me.ReflectedWorkItemIdFieldName);
59-
Trace.WriteLine(string.Format("{0} - Migrating: {1}-{2}", current, sourceWI.Id, sourceWI.Type.Name));
59+
Trace.WriteLine(string.Format("{0} - Migrating: {1}-{2}", current, sourceWI.Id, sourceWI.Type.Name), this.Name);
6060
if (targetFound == null)
6161
{
6262
WorkItem newwit = null;
@@ -72,12 +72,12 @@ internal override void InternalExecute()
7272
ArrayList fails = newwit.Validate();
7373
foreach (Field f in fails)
7474
{
75-
Trace.WriteLine(string.Format("{0} - Invalid: {1}-{2}-{3}", current, sourceWI.Id, sourceWI.Type.Name, f.ReferenceName));
75+
Trace.WriteLine(string.Format("{0} - Invalid: {1}-{2}-{3}", current, sourceWI.Id, sourceWI.Type.Name, f.ReferenceName), this.Name);
7676
}
7777
}
7878
else
7979
{
80-
Trace.WriteLine("...not supported");
80+
Trace.WriteLine("...not supported", this.Name);
8181
}
8282

8383
if (newwit != null)
@@ -88,22 +88,22 @@ internal override void InternalExecute()
8888
if (_config.UpdateCreatedDate) { newwit.Fields["System.CreatedDate"].Value = sourceWI.Fields["System.CreatedDate"].Value; }
8989
if (_config.UpdateCreatedBy) { newwit.Fields["System.CreatedBy"].Value = sourceWI.Fields["System.CreatedBy"].Value; }
9090
newwit.Save();
91-
Trace.WriteLine(string.Format("...Saved as {0}", newwit.Id));
91+
Trace.WriteLine(string.Format("...Saved as {0}", newwit.Id), this.Name);
9292
if (sourceWI.Fields.Contains(me.ReflectedWorkItemIdFieldName) && _config.UpdateSoureReflectedId)
9393
{
9494
sourceWI.Fields[me.ReflectedWorkItemIdFieldName].Value = targetStore.CreateReflectedWorkItemId(newwit);
9595
}
9696
sourceWI.Save();
97-
Trace.WriteLine(string.Format("...and Source Updated {0}", sourceWI.Id));
97+
Trace.WriteLine(string.Format("...and Source Updated {0}", sourceWI.Id), this.Name);
9898
}
9999
catch (Exception ex)
100100
{
101-
Trace.WriteLine("...FAILED to Save");
101+
Trace.WriteLine("...FAILED to Save", this.Name);
102102
foreach (Field f in newwit.Fields)
103103
{
104-
Trace.WriteLine(string.Format("{0} | {1}", f.ReferenceName, f.Value));
104+
Trace.WriteLine(string.Format("{0} | {1}", f.ReferenceName, f.Value), this.Name);
105105
}
106-
Trace.WriteLine(ex.ToString());
106+
Trace.WriteLine(ex.ToString(), this.Name);
107107
}
108108
}
109109
}
@@ -122,7 +122,7 @@ internal override void InternalExecute()
122122
count++;
123123
TimeSpan average = new TimeSpan(0, 0, 0, 0, (int)(elapsedms / count));
124124
TimeSpan remaining = new TimeSpan(0, 0, 0, 0, (int)(average.TotalMilliseconds * current));
125-
Trace.WriteLine(string.Format("Average time of {0} per work item and {1} estimated to completion", string.Format(@"{0:s\:fff} seconds", average), string.Format(@"{0:%h} hours {0:%m} minutes {0:s\:fff} seconds", remaining)));
125+
Trace.WriteLine(string.Format("Average time of {0} per work item and {1} estimated to completion", string.Format(@"{0:s\:fff} seconds", average), string.Format(@"{0:%h} hours {0:%m} minutes {0:s\:fff} seconds", remaining)), this.Name);
126126
}
127127
//////////////////////////////////////////////////
128128
stopwatch.Stop();
@@ -141,7 +141,7 @@ private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destPr
141141
Stopwatch fieldMappingTimer = new Stopwatch();
142142

143143
bool except = false;
144-
Trace.Write("... Building");
144+
Trace.Write("... Building", "WorkItemMigrationContext");
145145
List<String> ignore = new List<string>();
146146
ignore.Add("System.CreatedDate");
147147
ignore.Add("System.CreatedBy");
@@ -175,7 +175,7 @@ private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destPr
175175
WorkItem newwit = destProject.WorkItemTypes[destType].NewWorkItem();
176176
NewWorkItemTimer.Stop();
177177
Telemetry.Current.TrackDependency("TeamService", "NewWorkItem", NewWorkItemstartTime, NewWorkItemTimer.Elapsed, true);
178-
Trace.WriteLine(string.Format("Dependnacy: {0} - {1} - {2} - {3} - {4}", "TeamService", "NewWorkItem", NewWorkItemstartTime, NewWorkItemTimer.Elapsed, true));
178+
Trace.WriteLine(string.Format("Dependnacy: {0} - {1} - {2} - {3} - {4}", "TeamService", "NewWorkItem", NewWorkItemstartTime, NewWorkItemTimer.Elapsed, true), "WorkItemMigrationContext");
179179
newwit.Title = oldWi.Title;
180180
newwit.State = oldWi.State;
181181
switch (newwit.State)
@@ -234,17 +234,17 @@ private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destPr
234234

235235
if (except)
236236
{
237-
Trace.Write("...buildErrors");
237+
Trace.WriteLine("...buildErrors", "WorkItemMigrationContext");
238238
System.Threading.Thread.Sleep(1000);
239239

240240
}
241241
else
242242
{
243-
Trace.Write("...buildComplete");
243+
Trace.WriteLine("...buildComplete", "WorkItemMigrationContext");
244244
}
245245
fieldMappingTimer.Stop();
246246
Telemetry.Current.TrackMetric( "FieldMappingTime", fieldMappingTimer.ElapsedMilliseconds);
247-
Trace.WriteLine(string.Format("FieldMapOnNewWorkItem: {0} - {1}", NewWorkItemstartTime, fieldMappingTimer.Elapsed.ToString("c")));
247+
Trace.WriteLine(string.Format("FieldMapOnNewWorkItem: {0} - {1}", NewWorkItemstartTime, fieldMappingTimer.Elapsed.ToString("c")), "WorkItemMigrationContext");
248248
return newwit;
249249
}
250250

TfsWitMigrator.Core/MigrationEngine.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,20 @@ private void ProcessConfiguration(EngineConfiguration config)
4848
{
4949
foreach (IFieldMapConfig fieldmapConfig in config.FieldMaps)
5050
{
51+
Trace.WriteLine(string.Format("Adding FieldMap {0}", fieldmapConfig.FieldMap.Name), "MigrationEngine");
5152
this.AddFieldMap(fieldmapConfig.WorkItemTypeName, (IFieldMap)Activator.CreateInstance(fieldmapConfig.FieldMap, fieldmapConfig));
5253
}
5354
}
5455
foreach (string key in config.WorkItemTypeDefinition.Keys)
5556
{
57+
Trace.WriteLine(string.Format("Adding Work Item Type {0}", key), "MigrationEngine");
5658
this.AddWorkItemTypeDefinition(key, new DescreteWitdMapper(config.WorkItemTypeDefinition[key]));
5759
}
5860
foreach (ITfsProcessingConfig processorConfig in config.Processors)
5961
{
6062
if (processorConfig.Enabled)
6163
{
64+
Trace.WriteLine(string.Format("Adding Processor {0}", processorConfig.Processor.Name), "MigrationEngine");
6265
this.AddProcessor((ITfsProcessingContext)Activator.CreateInstance(processorConfig.Processor, this, processorConfig));
6366
}
6467
}
@@ -106,7 +109,7 @@ public ProcessingStatus Run()
106109
Stopwatch engineTimer = new Stopwatch();
107110
engineTimer.Start();
108111
ProcessingStatus ps = ProcessingStatus.Complete;
109-
Trace.WriteLine("Beginning run of {0} processors", processors.Count.ToString());
112+
Trace.WriteLine(string.Format("Beginning run of {0} processors", processors.Count.ToString()), "MigrationEngine");
110113
foreach (ITfsProcessingContext process in processors)
111114
{
112115
Stopwatch processorTimer = new Stopwatch();
@@ -117,7 +120,7 @@ public ProcessingStatus Run()
117120
if (process.Status == ProcessingStatus.Failed)
118121
{
119122
ps = ProcessingStatus.Failed;
120-
Trace.WriteLine("The Processor {0} entered the failed state...stopping run", process.Name);
123+
Trace.WriteLine(string.Format("The Processor {0} entered the failed state...stopping run", process.Name), "MigrationEngine");
121124
break;
122125
}
123126
}

0 commit comments

Comments
 (0)