public void TwoWay_EditEditConflictTakeOtherTest() { // continuous manual, bi-directional sync TestEnvironment.WorkFlowType = new WorkFlowType(); TestEnvironment.WorkFlowType.DirectionOfFlow = DirectionOfFlow.Bidirectional; TestEnvironment.WorkFlowType.Frequency = Frequency.ContinuousManual; TestEnvironment.WorkFlowType.SyncContext = SyncContext.Disabled; // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, null, TestEnvironment, false); SourceAdapter.AddFile(sourceFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> edit SourceAdapter.EditFile(sourceFile.LocalPath); // 3. target system: a.txt -> edit TargetAdapter.EditFile(targetFile.LocalPath); // 4. Migration will detect a conflict Run(); // 5. resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc content conflict"); conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeOtherChangesAction(), conflicts[0].ScopeHint); // sync Run(true, true); // validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content should match Assert.IsTrue(VerifyContents(), "The latest content should match."); // 6. edit a.txt on source system SourceAdapter.EditFile(sourceFile.LocalPath); // 7. sync Run(true, true); // validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content should match Assert.IsTrue(VerifyContents(), "The latest content should match."); }
public void EditEditConflictTakeLocalTest() { // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, null, TestEnvironment, false); SourceAdapter.AddFile(sourceFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> edit SourceAdapter.EditFile(sourceFile.LocalPath); // 3. target system: a.txt -> edit TargetAdapter.EditFile(targetFile.LocalPath); // 4. Migration will detect a conflict Run(); VerifyHistory(2, 1); // 5. resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.AreEqual(contentConflict.ReferenceName, conflicts[0].ConflictTypeReference.Value.ReferenceName, "It should be vc content conflict"); conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeLocalChangeAction(), "$/"); // 6. restart Run(); // 7. validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); if (TestEnvironment.MigrationTestType == MigrationTestType.OneWay) { // content should not match for one-way sync Assert.IsFalse(VerifyContents(), "The latest content should be different as a.txt is not migrated."); SourceAdapter.EditFile(sourceFile.LocalPath); Run(); Assert.IsTrue(VerifyContents()); } else { Assert.IsTrue(VerifyContents()); } }
public void EditEditConflictUserMergeTest() { // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, null, TestEnvironment, false); SourceAdapter.AddFile(sourceFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> edit int contentConflictChangeset = SourceAdapter.EditFile(sourceFile.LocalPath); // 3. target system: a.txt -> edit TargetAdapter.EditFile(targetFile.LocalPath); // 4. Migration will detect a conflict Run(); VerifyHistory(2, 1); // 5. resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc content conflict"); int deltaChangeId = SourceAdapter.EditFile(sourceFile.LocalPath); int miChangeId = TargetAdapter.EditFile(targetFile.LocalPath, sourceFile.LocalPath); Dictionary <string, string> dataFields = new Dictionary <string, string>(); dataFields.Add(VCContentConflictUserMergeChangeAction.MigrationInstructionChangeId, miChangeId.ToString()); dataFields.Add(VCContentConflictUserMergeChangeAction.DeltaTableChangeId, deltaChangeId.ToString()); conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictUserMergeChangeAction(), string.Format("$/;{0}", contentConflictChangeset), dataFields); // 6. restart Run(true, true); // 7. validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content should match Assert.IsTrue(VerifyContents()); }
public void EditEditMultipleItemsTest() { // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, null, TestEnvironment, false); MigrationItemStrings nonConflictFile = new MigrationItemStrings("b.txt", null, TestEnvironment, true); SourceAdapter.AddFile(sourceFile.LocalPath); SourceAdapter.AddFile(nonConflictFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> edit SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite); TestUtils.EditRandomFile(nonConflictFile.LocalPath); SourceWorkspace.PendEdit(nonConflictFile.LocalPath); // This will checkin both a.txt and b.txt int contentConflictChangeset = SourceAdapter.EditFile(sourceFile.LocalPath); // 3. target system: a.txt -> edit TargetAdapter.EditFile(targetFile.LocalPath); // 4. Migration will detect a conflict Run(); VerifyHistory(2, 1); // 5. resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(2, conflicts.Count, "There should be 2 conflicts"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc content conflict"); conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeLocalChangeAction(), "$/"); // 6. restart Run(true, true); // TfsCheckinConflict needs to be resolved manually. Otherwise, this test will loop until time-out. // 7. validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content should not match Assert.IsFalse(VerifyContents(), "The latest content should be different as a.txt is not migrated."); }
public void EditMultipleEditConflictTakeOtherTest() { // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, null, TestEnvironment, false); MigrationItemStrings targetFile2 = new MigrationItemStrings("b.txt", null, TestEnvironment, false); SourceAdapter.AddFile(sourceFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> edit SourceAdapter.EditFile(sourceFile.LocalPath); // 3. target system: a.txt -> edit TargetAdapter.EditFile(targetFile.LocalPath); TargetAdapter.EditFile(targetFile.LocalPath); // 4. Migration will detect a conflict Run(); VerifyHistory(2, 2); // 5. resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc content conflict"); conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeOtherChangesAction(), "$/"); // 6. restart Run(true, true); // 7. validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content should match Assert.IsTrue(VerifyContents()); }
public void AddAddConflictUserMergeTest() { string fileName = "file.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, false); // Initial sync. Run(); int deltaChangeId = SourceAdapter.AddFile(sourceFile.LocalPath); TargetAdapter.AddFile(targetFile.LocalPath); // Don't check in extra.txt Run(false, false, false); VerifyHistory(1, 1); // User checkin files to make the system in sync. int miChangeId = TargetAdapter.EditFile(targetFile.LocalPath, sourceFile.LocalPath, "user: delete items on target to resolve add,add conflict **NOMIGRATION**"); // resolve conflicts ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict"); VCContentConflictType contentConflict = new VCContentConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc content conflict"); Dictionary <string, string> dataFields = new Dictionary <string, string>(); dataFields.Add(VCContentConflictUserMergeChangeAction.MigrationInstructionChangeId, miChangeId.ToString()); dataFields.Add(VCContentConflictUserMergeChangeAction.DeltaTableChangeId, deltaChangeId.ToString()); conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictUserMergeChangeAction(), string.Format("{0};{1}", "$/", (deltaChangeId - 1).ToString()), dataFields); Run(true, true, false); Assert.IsTrue(VerifyContents()); }
public void PathPeerSnapshotTest() { // Add files // Create a tree structure so that we can test path compression logic. int snapshotChangesetId1 = 0; int peerSnapshotChangesetId1 = 0; for (int i = 0; i < 4; i++) { MigrationItemStrings sourceFile = new MigrationItemStrings(string.Format("source/path1/addFile{0}.txt", i), null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(string.Format("source/path1/addFile{0}.txt", i), null, TestEnvironment, false); if (i < 2) { snapshotChangesetId1 = SourceAdapter.AddFile(sourceFile.LocalPath); TargetAdapter.AddFile(targetFile.LocalPath); peerSnapshotChangesetId1 = TargetAdapter.EditFile(targetFile.LocalPath, sourceFile.LocalPath); } else { SourceAdapter.AddFile(sourceFile.LocalPath); } } int snapshotChangesetId2 = 0; int peerSnapshotChangesetId2 = 0; for (int i = 0; i < 4; i++) { MigrationItemStrings sourceFile = new MigrationItemStrings(string.Format("source/path2/addFile{0}.txt", i), null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(string.Format("source/path2/addFile{0}.txt", i), null, TestEnvironment, false); if (i < 3) { snapshotChangesetId2 = SourceAdapter.AddFile(sourceFile.LocalPath); TargetAdapter.AddFile(targetFile.LocalPath); peerSnapshotChangesetId2 = TargetAdapter.EditFile(targetFile.LocalPath, sourceFile.LocalPath); } else { SourceAdapter.AddFile(sourceFile.LocalPath); } } // We need to map to the sub item level MappingPair rootMapping = TestEnvironment.Mappings[0]; TestEnvironment.Mappings.Clear(); TestEnvironment.Mappings.Add( new MappingPair( rootMapping.SourcePath + "/source/path1", rootMapping.TargetPath + "/source/path1", false, snapshotChangesetId1.ToString(), peerSnapshotChangesetId1.ToString(), null, null, peerSnapshotChangesetId1.ToString(), snapshotChangesetId1.ToString())); TestEnvironment.Mappings.Add( new MappingPair( rootMapping.SourcePath + "/source/path2", rootMapping.TargetPath + "/source/path2", false, snapshotChangesetId2.ToString(), peerSnapshotChangesetId2.ToString(), null, null, peerSnapshotChangesetId2.ToString(), snapshotChangesetId2.ToString())); Run(); MigrationItemStrings newFile = new MigrationItemStrings("source/path1/newFile.txt", null, TestEnvironment, true); SourceAdapter.AddFile(newFile.LocalPath); Run(); Assert.IsTrue(VerifyContents()); }
public void RenameEditConflictUserMergeTest() { // 1. migrate a.txt -> a.txt string fileName = "a.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, "b.txt", TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, "b.txt", TestEnvironment, false); SourceAdapter.AddFile(sourceFile.LocalPath); RunAndValidate(); // 2. source system: a.txt -> b.txt int sourceChangeId = SourceAdapter.RenameItem(sourceFile.ServerPath, sourceFile.NewServerPath); // 3. target system: a.txt -> edit a.txt int editChangesetId = TargetAdapter.EditFile(targetFile.LocalPath); // 4. migrate Run(); // 5. resolve conflicts // 5.1 check if we have correct conflicts in db ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(1, conflicts.Count, "There should be only 1 conflict"); VCNameSpaceContentConflictType namespaceConflict = new VCNameSpaceContentConflictType(); Assert.AreEqual(namespaceConflict.ReferenceName, conflicts[0].ConflictTypeReference.Value.ReferenceName, "It should be vc namespace content conflict"); // 5.2 user merge actions // 1) revert edit on a.txt // revert edit on a.txt PendEditToRevertFile(TargetWorkspace, targetFile, editChangesetId, editChangesetId - 1); TargetWorkspace.CheckIn(TargetWorkspace.GetPendingChanges(), "user: revert edit change on a.txt **NOMIGRATION**"); // 2) rename a.txt to b.txt on target system int targetChangeId = TargetAdapter.RenameItem(targetFile.ServerPath, targetFile.NewServerPath, "user: rename a.txt to b.txt **NOMIGRATION**"); int deltaChangeId = sourceChangeId; int miChangeId = targetChangeId; if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight) { deltaChangeId = editChangesetId; miChangeId = sourceChangeId; } Dictionary <string, string> dataFields = new Dictionary <string, string>(); dataFields.Add(VCContentConflictUserMergeChangeAction.MigrationInstructionChangeId, miChangeId.ToString()); dataFields.Add(VCContentConflictUserMergeChangeAction.DeltaTableChangeId, deltaChangeId.ToString()); foreach (RTConflict conflict in conflicts) { conflictResolver.TryResolveConflict(conflict, new VCContentConflictUserMergeChangeAction(), string.Format("$/;{0}", deltaChangeId), dataFields); } // 6. migrate Run(); // 7. validation // no remaining conflicts conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be NO conflict"); // content match Assert.IsTrue(VerifyContents()); }