protected override void VerifyMigration(bool AddOnBranchSourceNotFound) { if (IsTfsToTfsMigration()) { // This is Tfs to Tfs migration, use TfsServerDiff Trace.TraceInformation("==================== TfsServerDiff BEGIN ===================="); TfsServerDiff diff = new TfsServerDiff(new Guid(base.VCSession.SessionUniqueId), TestEnvironment, AddOnBranchSourceNotFound, true); diff.QueryHistory(); diff.RemoveSimilarHistory(); TfsServerDiff.LogFailures(diff); Assert.IsTrue(diff.VerifyContentMatchAtLatest(), "The latest content is different"); // If the migration is from TFS2008 to TFS2008 or TFS2010 to TFS2010, verify changeset metadata. if (TestEnvironment.SourceEndPoint.AdapterType == TestEnvironment.TargetEndPoint.AdapterType) { // verify change types in all changesets Assert.AreEqual(0, diff.TargetChanges.Count, "Some changes were left in the target system"); Assert.AreEqual(0, diff.SourceChanges.Count, "Some changes were left in the source system"); } Trace.TraceInformation("==================== TfsServerDiff END ===================="); } else { Trace.TraceInformation("==================== VCServerDiff BEGIN ===================="); Guid sessionGuid = new Guid(base.VCSession.SessionUniqueId); ServerDiffEngine diff = new ServerDiffEngine(sessionGuid, false, true, SessionTypeEnum.VersionControl); VCDiffComparer diffComparer = new VCDiffComparer(diff); diff.RegisterDiffComparer(diffComparer); Assert.IsTrue(diff.VerifyContentsMatch(null, null), "The latest content is different"); Trace.TraceInformation("==================== VCServerDiff END ===================="); } }
protected bool VerifyContents() { Trace.TraceInformation("====================VerifyContents BEGIN ===================="); Guid sessionGuid = new Guid(base.VCSession.SessionUniqueId); ServerDiffEngine diff = new ServerDiffEngine(sessionGuid, false, true, SessionTypeEnum.VersionControl); VCDiffComparer diffComparer = new VCDiffComparer(diff); diff.RegisterDiffComparer(diffComparer); Trace.TraceInformation("==================== VerifyContents END ===================="); return(diff.VerifyContentsMatch(null, null)); }
protected override void VerifyMigration(bool AddOnBranchSourceNotFound) { Trace.TraceInformation("==================== VCServerDiff BEGIN ===================="); Guid sessionGuid = new Guid(base.VCSession.SessionUniqueId); ServerDiffEngine diff = new ServerDiffEngine(sessionGuid, false, true, SessionTypeEnum.VersionControl); VCDiffComparer diffComparer = new VCDiffComparer(diff); diff.RegisterDiffComparer(diffComparer); Assert.IsTrue(diff.VerifyContentsMatch(null, null), "The latest content is different"); Trace.TraceInformation("==================== VCServerDiff END ===================="); }
protected override void DoJob() { TraceManager.TraceInformation(String.Format(ServerDiffResources.ServerDiffJobRunning, FriendlyName, SessionTypeEnum.VersionControl.ToString())); try { List <Guid> activeVCSessions = ServerDiffEngine.FindAllActiveSessionsOfType(SessionTypeEnum.VersionControl); if (activeVCSessions.Count == 0) { TraceManager.TraceInformation(String.Format(ServerDiffResources.NoActiveSessionsWithTypeFound, SessionTypeEnum.VersionControl.ToString())); } else { foreach (Guid activeVCSessionId in activeVCSessions) { ServerDiffEngine diffEngine = new ServerDiffEngine(activeVCSessionId, m_noContentComparison, m_verbose, SessionTypeEnum.VersionControl, true, true); try { VCDiffComparer vcDiffComparer = new VCDiffComparer(diffEngine); diffEngine.RegisterDiffComparer(vcDiffComparer); if (diffEngine.VerifyContentsMatch(null, null)) { diffEngine.LogResult(ServerDiffResources.AllContentsMatch); } else { diffEngine.LogResult(ServerDiffResources.ContentsDoNotMatch); } } catch (Exception e) { diffEngine.LogError(String.Format(CultureInfo.InvariantCulture, ServerDiffResources.ExceptionRunningServerDiff, m_verbose ? e.ToString() : e.Message)); } } } } catch (MigrationSessionNotFoundException sessionNotFoundException) { TraceManager.TraceInformation(sessionNotFoundException.Message); } finally { TraceManager.TraceInformation(String.Format(ServerDiffResources.ServerDiffJobSleeping, FriendlyName)); } }
/// <summary> /// TfsServerDiff will verify the first VC session in the given configuration file /// </summary> /// <param name="configFileName"></param> public TfsServerDiff(Guid sessionGuid, MigrationTestEnvironment env, bool addOnBranchSourceNotFound, bool verbose) { m_testEnvironment = env; m_serverDiffEngine = new ServerDiffEngine(sessionGuid, false, verbose, SessionTypeEnum.VersionControl); m_diffComparer = new VCDiffComparer(m_serverDiffEngine); m_serverDiffEngine.RegisterDiffComparer(m_diffComparer); m_targetHistory = new List <Changeset>(); m_sourceHistory = new List <Changeset>(); m_sourceClient = GetTfsClient(env.SourceEndPoint.ServerUrl); m_targetClient = GetTfsClient(env.TargetEndPoint.ServerUrl); m_changeToAddOnBranchSourceNotFound = addOnBranchSourceNotFound; // TODO: //m_session.TryGetValue("SkipChangeComment", out m_skipChangeComment); Trace.WriteLine("[TODO] Skipped setting SkipChangeComment"); }
/// <summary> /// TfsServerDiff will verify the first VC session in the given configuration file /// </summary> /// <param name="configFileName"></param> public TfsServerDiff(Guid sessionGuid, bool addOnBranchSourceNotFound, bool verbose) { m_serverDiffEngine = new ServerDiffEngine(sessionGuid, false, verbose, SessionTypeEnum.VersionControl); m_diffComparer = new VCDiffComparer(m_serverDiffEngine); m_serverDiffEngine.RegisterDiffComparer(m_diffComparer); m_targetHistory = new List <Changeset>(); m_sourceHistory = new List <Changeset>(); var sources = m_serverDiffEngine.Config.SessionGroup.MigrationSources.MigrationSource; m_sourceClient = GetTfsClient(sources[0].ServerUrl); m_targetClient = GetTfsClient(sources[1].ServerUrl); m_changeToAddOnBranchSourceNotFound = addOnBranchSourceNotFound; // TODO: //m_session.TryGetValue("SkipChangeComment", out m_skipChangeComment); Trace.WriteLine("[TODO] Skipped setting SkipChangeComment"); }
/// <summary> /// The entry point for the executable. /// Takes the path to a migration configuration file in from the command line and compares /// the history of the first VC session in that file. Logs the differences to the standard out. /// </summary> /// <param name="args">Command line parameters</param> static void Main(string[] args) { bool noContentComparison = false; bool verbose = false; if (args.Length == 0) { LogError(ServerDiffConsoleResources.ServerDiffUsage); Environment.Exit(1); } if (string.Equals(args[0], "vc", StringComparison.InvariantCultureIgnoreCase)) { string leftVersion = null; string rightVersion = null; Guid sessionGuid = Guid.Empty; for (int i = 1; i < args.Length; i++) { string arg = RemoveQuotes(args[i]); if ((arg.StartsWith("/s", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/session", StringComparison.InvariantCultureIgnoreCase)))) { try { sessionGuid = new Guid(arg.Substring(arg.IndexOf(':') + 1)); } catch { LogError(String.Format(CultureInfo.InvariantCulture, ServerDiffConsoleResources.SessionArgIsNotGuid, args[0])); Environment.Exit(1); } } else if ((arg.StartsWith("/l:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/leftVersion:", StringComparison.InvariantCultureIgnoreCase)))) { leftVersion = arg.Substring(arg.IndexOf(':') + 1); } else if ((arg.StartsWith("/r:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/rightVersion:", StringComparison.InvariantCultureIgnoreCase)))) { rightVersion = arg.Substring(arg.IndexOf(':') + 1); } else if ((arg.Equals("/n", StringComparison.InvariantCultureIgnoreCase) || (arg.Equals("/noContentComparison ", StringComparison.InvariantCultureIgnoreCase)))) { noContentComparison = true; } else if ((arg.Equals("/v", StringComparison.InvariantCultureIgnoreCase) || (arg.Equals("/verbose", StringComparison.InvariantCultureIgnoreCase)))) { verbose = true; } else { LogError(ServerDiffConsoleResources.ServerDiffUsage); Environment.Exit(1); } } try { ServerDiffEngine diffEngine = new ServerDiffEngine(sessionGuid, noContentComparison, verbose, SessionTypeEnum.VersionControl); VCDiffComparer vcDiffComparer = new VCDiffComparer(diffEngine); diffEngine.RegisterDiffComparer(vcDiffComparer); if (diffEngine.VerifyContentsMatch(leftVersion, rightVersion)) { diffEngine.LogResult(ServerDiffResources.AllContentsMatch); } else { diffEngine.LogResult(ServerDiffResources.ContentsDoNotMatch); } } catch (Exception e) { LogError(String.Format(CultureInfo.InvariantCulture, ServerDiffResources.ExceptionRunningServerDiff, verbose ? e.ToString() : e.Message)); } } else if (string.Equals(args[0], "wit", StringComparison.InvariantCultureIgnoreCase)) { string forceSyncFile = null; string leftQueryCondition = null; string rightQueryCondition = null; HashSet <string> leftFieldNamesToIgnore = new HashSet <string>(); HashSet <string> rightFieldNamesToIgnore = new HashSet <string>(); Guid sessionGuid = Guid.Empty; for (int i = 1; i < args.Length; i++) { string arg = RemoveQuotes(args[i]); if ((arg.StartsWith("/s", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/session", StringComparison.InvariantCultureIgnoreCase)))) { try { sessionGuid = new Guid(arg.Substring(arg.IndexOf(':') + 1)); } catch { LogError(String.Format(CultureInfo.InvariantCulture, ServerDiffConsoleResources.SessionArgIsNotGuid, args[0])); Environment.Exit(1); } } else if ((arg.StartsWith("/f:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/ForceSyncFile:", StringComparison.InvariantCultureIgnoreCase)))) { forceSyncFile = arg.Substring(arg.IndexOf(':') + 1); if (!forceSyncFile.EndsWith(".csv", StringComparison.OrdinalIgnoreCase)) { LogError(ServerDiffConsoleResources.ForceSyncFileRequiresCsvExtension); Environment.Exit(1); } } else if ((arg.StartsWith("/l:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/leftQueryCondition:", StringComparison.InvariantCultureIgnoreCase)))) { leftQueryCondition = arg.Substring(arg.IndexOf(':') + 1); } else if ((arg.StartsWith("/r:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/rightQueryCondition:", StringComparison.InvariantCultureIgnoreCase)))) { rightQueryCondition = arg.Substring(arg.IndexOf(':') + 1); } else if ((arg.StartsWith("/il:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/IgnoreLeftFields:", StringComparison.InvariantCultureIgnoreCase)))) { string [] leftFieldNames = arg.Substring(arg.IndexOf(':') + 1).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string fieldName in leftFieldNames) { leftFieldNamesToIgnore.Add(fieldName.Trim()); } } else if ((arg.StartsWith("/ir:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/IgnoreRightFields:", StringComparison.InvariantCultureIgnoreCase)))) { string[] rightFieldNames = arg.Substring(arg.IndexOf(':') + 1).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string fieldName in rightFieldNames) { rightFieldNamesToIgnore.Add(fieldName.Trim()); } } else if ((arg.Equals("/n", StringComparison.InvariantCultureIgnoreCase) || (arg.Equals("/noContentComparison ", StringComparison.InvariantCultureIgnoreCase)))) { noContentComparison = true; } else if ((arg.Equals("/v", StringComparison.InvariantCultureIgnoreCase) || (arg.Equals("/verbose", StringComparison.InvariantCultureIgnoreCase)))) { verbose = true; } else { LogError(ServerDiffConsoleResources.ServerDiffUsage); Environment.Exit(1); } } try { ServerDiffEngine diffEngine = new ServerDiffEngine(sessionGuid, noContentComparison, verbose, SessionTypeEnum.WorkItemTracking); WITDiffComparer witDiffComparer = new WITDiffComparer(diffEngine); witDiffComparer.ForceSyncFile = forceSyncFile; witDiffComparer.LeftFieldNamesToIgnore = leftFieldNamesToIgnore; witDiffComparer.RightFieldNamesToIgnore = rightFieldNamesToIgnore; diffEngine.RegisterDiffComparer(witDiffComparer); if (diffEngine.VerifyContentsMatch(leftQueryCondition, rightQueryCondition)) { diffEngine.LogResult(ServerDiffResources.AllContentsMatch); } else { diffEngine.LogResult(ServerDiffResources.ContentsDoNotMatch); } } catch (Exception e) { LogError(String.Format(CultureInfo.InvariantCulture, ServerDiffResources.ExceptionRunningServerDiff, verbose ? e.ToString() : e.Message)); } } else { LogError(ServerDiffConsoleResources.ServerDiffUsage); Environment.Exit(1); } }
/// <summary> /// The entry point for the executable. /// Takes the path to a migration configuration file in from the command line and compares /// the history of the first VC session in that file. Logs the differences to the standard out. /// </summary> /// <param name="args">Command line parameters</param> static void Main(string[] args) { bool noContentComparison = false; bool verbose = false; if (args.Length == 0) { LogError(ServerDiffConsoleResources.ServerDiffUsage); Environment.Exit(1); } if (string.Equals(args[0], "vc", StringComparison.InvariantCultureIgnoreCase)) { string leftVersion = null; string rightVersion = null; Guid sessionGuid = Guid.Empty; for (int i = 1; i < args.Length; i++) { string arg = RemoveQuotes(args[i]); if ((arg.StartsWith("/s", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/session", StringComparison.InvariantCultureIgnoreCase)))) { try { sessionGuid = new Guid(arg.Substring(arg.IndexOf(':') + 1)); } catch { LogError(String.Format(CultureInfo.InvariantCulture, ServerDiffConsoleResources.SessionArgIsNotGuid, args[0])); Environment.Exit(1); } } else if ((arg.StartsWith("/l:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/leftVersion:", StringComparison.InvariantCultureIgnoreCase)))) { leftVersion = arg.Substring(arg.IndexOf(':') + 1); } else if ((arg.StartsWith("/r:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/rightVersion:", StringComparison.InvariantCultureIgnoreCase)))) { rightVersion = arg.Substring(arg.IndexOf(':') + 1); } else if ((arg.Equals("/n", StringComparison.InvariantCultureIgnoreCase) || (arg.Equals("/noContentComparison ", StringComparison.InvariantCultureIgnoreCase)))) { noContentComparison = true; } else if ((arg.Equals("/v", StringComparison.InvariantCultureIgnoreCase) || (arg.Equals("/verbose", StringComparison.InvariantCultureIgnoreCase)))) { verbose = true; } else { LogError(ServerDiffConsoleResources.ServerDiffUsage); Environment.Exit(1); } } try { ServerDiffEngine diffEngine = new ServerDiffEngine(sessionGuid, noContentComparison, verbose, SessionTypeEnum.VersionControl); VCDiffComparer vcDiffComparer = new VCDiffComparer(diffEngine); diffEngine.RegisterDiffComparer(vcDiffComparer); if (diffEngine.VerifyContentsMatch(leftVersion, rightVersion)) { diffEngine.LogResult(ServerDiffResources.AllContentsMatch); } else { diffEngine.LogResult(ServerDiffResources.ContentsDoNotMatch); } } catch (Exception e) { LogError(String.Format(CultureInfo.InvariantCulture, ServerDiffResources.ExceptionRunningServerDiff, verbose ? e.ToString() : e.Message)); } } else if (string.Equals(args[0], "wit", StringComparison.InvariantCultureIgnoreCase)) { string leftQueryCondition = null; string rightQueryCondition = null; Guid sessionGuid = Guid.Empty; for (int i = 1; i < args.Length; i++) { string arg = RemoveQuotes(args[i]); if ((arg.StartsWith("/s", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/session", StringComparison.InvariantCultureIgnoreCase)))) { try { sessionGuid = new Guid(arg.Substring(arg.IndexOf(':') + 1)); } catch { LogError(String.Format(CultureInfo.InvariantCulture, ServerDiffConsoleResources.SessionArgIsNotGuid, args[0])); Environment.Exit(1); } } else if ((arg.StartsWith("/l:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/leftQueryCondition:", StringComparison.InvariantCultureIgnoreCase)))) { leftQueryCondition = arg.Substring(arg.IndexOf(':') + 1); } else if ((arg.StartsWith("/r:", StringComparison.InvariantCultureIgnoreCase) || (arg.StartsWith("/rightQueryCondition:", StringComparison.InvariantCultureIgnoreCase)))) { rightQueryCondition = arg.Substring(arg.IndexOf(':') + 1); } else if ((arg.Equals("/n", StringComparison.InvariantCultureIgnoreCase) || (arg.Equals("/noContentComparison ", StringComparison.InvariantCultureIgnoreCase)))) { noContentComparison = true; } else if ((arg.Equals("/v", StringComparison.InvariantCultureIgnoreCase) || (arg.Equals("/verbose", StringComparison.InvariantCultureIgnoreCase)))) { verbose = true; } else { LogError(ServerDiffConsoleResources.ServerDiffUsage); Environment.Exit(1); } } try { ServerDiffEngine diffEngine = new ServerDiffEngine(sessionGuid, noContentComparison, verbose, SessionTypeEnum.WorkItemTracking); WITDiffComparer witDiffComparer = new WITDiffComparer(diffEngine); diffEngine.RegisterDiffComparer(witDiffComparer); if (diffEngine.VerifyContentsMatch(leftQueryCondition, rightQueryCondition)) { diffEngine.LogResult(ServerDiffResources.AllContentsMatch); } else { diffEngine.LogResult(ServerDiffResources.ContentsDoNotMatch); } } catch (Exception e) { LogError(String.Format(CultureInfo.InvariantCulture, ServerDiffResources.ExceptionRunningServerDiff, verbose ? e.ToString() : e.Message)); } } else { LogError(ServerDiffConsoleResources.ServerDiffUsage); Environment.Exit(1); } }