Exemple #1
0
        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.");
        }
Exemple #2
0
        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());
            }
        }
Exemple #3
0
        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());
        }
Exemple #4
0
        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.");
        }
Exemple #5
0
        public void AddAddConflictTakeLocalTest()
        {
            // initial migration
            MigrationItemStrings file1 = new MigrationItemStrings("1.txt", "1.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file1.LocalPath);
            RunAndValidate();

            // add a same file on both ends
            string fileName = "a.txt";

            MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, true);
            MigrationItemStrings targetFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, false);

            int sourceAdd = SourceAdapter.AddFile(sourceFile.LocalPath);

            TargetAdapter.AddFile(targetFile.LocalPath);

            Run();
            VerifyHistory(2, 1);

            // 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");

            // resolve the vc content conflict. The chained conflict will be resolved automatically
            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeLocalChangeAction(), "$/");

            // continue migration
            Run(true, true);

            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(0, conflicts.Count, "There should be 0 conflict");

            Assert.IsFalse(VerifyContents(), "Content should be different as we skip the add from source system.");

            SourceAdapter.EditFile(sourceFile.LocalPath);
            Run(true, true);

            Assert.IsTrue(VerifyContents());
        }
Exemple #6
0
        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());
        }
Exemple #7
0
        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());
        }
Exemple #8
0
        public void AddAddConflictTakeOtherTest()
        {
            // 1. migrate a.txt -> a.txt
            string fileName1    = "a.txt";
            string fileName2    = "b.txt";
            string sameFileName = "same.txt";

            MigrationItemStrings sourceFile1    = new MigrationItemStrings(fileName1, null, TestEnvironment, true);
            MigrationItemStrings sourceSameFile = new MigrationItemStrings(sameFileName, null, TestEnvironment, true);
            MigrationItemStrings targetFile1    = new MigrationItemStrings(fileName2, null, TestEnvironment, false);
            MigrationItemStrings targetSameFile = new MigrationItemStrings(sameFileName, null, TestEnvironment, false);

            SourceAdapter.AddFiles(new string[] { sourceFile1.LocalPath, sourceSameFile.LocalPath });
            TargetAdapter.AddFiles(new string[] { targetFile1.LocalPath, targetSameFile.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.AreEqual(contentConflict.ReferenceName, conflicts[0].ConflictTypeReference.Value.ReferenceName, "It should be vc content conflict");
            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeOtherChangesAction(), conflicts[0].ScopeHint);

            // sync
            Run();

            // 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.");
        }
Exemple #9
0
        public void AddAddConflictTakeOtherTest()
        {
            // initial migration
            MigrationItemStrings file1 = new MigrationItemStrings("1.txt", "1.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file1.LocalPath);
            RunAndValidate();

            // add a same file on both ends
            string fileName = "a.txt";
            MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, true);
            MigrationItemStrings targetFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, false);

            SourceAdapter.AddFile(sourceFile.LocalPath);
            TargetAdapter.AddFile(targetFile.LocalPath);

            Run();
            VerifyHistory(2, 1);

            // 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");

            // resolve the vc content conflict. The chained conflict will be resolved automatically
            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeOtherChangesAction(), "$/");

            // The user decide to accept other, so he deleted the items on target system
            TargetAdapter.DeleteItem(targetFile.ServerPath, "Delete source items to accept other side's adds **NOMIGRATION**");

            Run(true, true);
            Assert.IsTrue(VerifyContents());
        }
Exemple #10
0
        public void AddAddConflictTakeOtherNoDeleteTest()
        {
            // initial migration
            MigrationItemStrings file1 = new MigrationItemStrings("1.txt", "1.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file1.LocalPath);
            RunAndValidate();

            // add a same file on both ends
            string fileName = "a.txt";
            MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, true);
            MigrationItemStrings targetFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, false);

            int sourceAdd = SourceAdapter.AddFile(sourceFile.LocalPath);

            TargetAdapter.AddFile(targetFile.LocalPath);

            Run();

            VerifyHistory(2, 1);

            // 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");

            // resolve the vc content conflict. The chained conflict will be resolved automatically
            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeOtherChangesAction(), "$/");

            // The user decided to accept other but forgot deleting the items on target system

            // start a conflict resolution thread to detect 'future' TfsCheckinConflict and resolve it asynchronously
            ConflictResolutionWorker resolutionWorker = new ConflictResolutionWorker()
            {
                ConflictResolver = conflictResolver,
            };

            resolutionWorker.ConflictResolutionList.Add(new ConflictResolutionEntry()
            {
                Conflict   = ConflictConstant.TfsCheckinConflict,
                Resolution = ConflictConstant.TfsCheckinSkipAction,
            });

            resolutionWorker.ConflictResolutionList.Add(new ConflictResolutionEntry()
            {
                Conflict   = ConflictConstant.TFSZeroCheckinConflict,
                Resolution = new TFSZeroCheckinSkipAction().ReferenceName,
            });

            resolutionWorker.Start();

            // restart the migraiton tool
            // migration tool will be in a loop until the TfsCheckinConflict gets resolved
            Run(true, true);

            Assert.IsTrue(VerifyContents(), "Content should be the same.");

            SourceAdapter.EditFile(sourceFile.LocalPath);
            Run(true, true);

            Trace.WriteLine("Stopping ConflictResolutionWorker");
            resolutionWorker.Stop();

            Assert.IsTrue(VerifyContents(), "Content should match!");
        }