Exemple #1
0
        //public void CustomizeTargetFilterString(MigrationTestEnvironment env, Configuration config)
        //{
        // Replace target filter string as the default filter string would not
        // work in edit/edit conflict test scenarios
        //FilterItem targetFilterItem = TestEnvironment.GetTargetFilterItem(config.SessionGroup.Sessions.Session[0].Filters.FilterPair[0]);
        //targetFilterItem.FilterString = string.Format("[System.ChangedDate] > '{0}'", TestStartTime);
        //}

        /// Single Edit/Edit conflict
        ///
        /// 1. Source (S) and Target (T) are in sync
        ///
        /// Both ends have changes
        /// 2. Source revisions: A1 -> B
        /// 3. Target revisions: A2
        ///
        /// 4. Start Bi-directional migration (1st round)
        /// 5. Tool generates 1 edit/edit conflict with chained conflicts
        ///    Raise edit/edit conflicts for S:A1 and T:A2
        ///    Raise chained conflicts for S:B
        ///
        private void EditEditConflictScenario(out int sourceId, out int targetId)
        {
            // test edit/edit conflit in bi-directional work flow
            //TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(CustomizeTargetFilterString);

            // add a work item on source side
            sourceId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            // sync
            RunAndNoValidate();

            // verify there's no conflicts raised
            m_conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            // update work items on both sides
            WITChangeAction sourceAction = new WITChangeAction();
            WITChangeAction targetAction = new WITChangeAction();

            targetId = QueryTargetWorkItemID(sourceId);

            sourceAction.Description = SOURCE_R1_DESC; // S:A1
            SourceAdapter.UpdateWorkItem(sourceId, sourceAction);
            sourceAction.Title = SOURCE_R2_TITLE;      // S:B
            SourceAdapter.UpdateWorkItem(sourceId, sourceAction);

            targetAction.Description = TARGET_R1_DESC; // T:A2
            TargetAdapter.UpdateWorkItem(targetId, targetAction);

            // sync again
            // 1 edit/edit conflict with chained conflicts
            RunAndNoValidate(true);
        }
Exemple #2
0
        public void Mapping_FieldMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetFieldMap);

            // add a work item on source side
            int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            RunAndNoValidate();

            // verify there's no conflicts raised
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            // verify sync result excluding expected mismatches
            WitDiffResult result = GetDiffResult();

            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH,
                FIELD_TITLE, FIELD_DESCRIPTION
            });

            // Title <-> Description
            int    targetId = QueryTargetWorkItemID(workitemId);
            string srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreEqual(srcTitle, tarDesc);
            Assert.AreEqual(srcDesc, tarTitle);
        }
Exemple #3
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 #4
0
        public void Mapping_AggregatedFieldTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetAggregatedFieldMap);

            // add a work item on source side
            string title = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));

            int workitemId = SourceAdapter.AddWorkItem("Bug", title, "description1");

            RunAndNoValidate();

            // verify there's no conflicts raised
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            // Title <-> Description
            int    mirroredId = QueryMirroredWorkItemID(workitemId);
            string srcTitle   = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE);
            string srcRev     = SourceAdapter.GetFieldValue(workitemId, "System.Rev");
            string tarDesc    = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION);

            Assert.AreEqual(tarDesc, string.Format(AggregationFormat, srcTitle, srcRev));
        }
Exemple #5
0
        public override void Initialize()
        {
            base.Initialize();

            SourceWorkItemIdList = new List <int>();
            TargetWorkItemIdList = new List <int>();

            TestEnvironment.Mappings.Clear();

            EndPoint sourceTCAdapterEnv = TestEnvironment.SourceEndPoint;
            EndPoint targetTCAdapterEnv = TestEnvironment.TargetEndPoint;

            SourceAdapter = (IWITTestCaseAdapter)TestAdapterManager.LoadAdapter(sourceTCAdapterEnv.TCAdapterID);
            TargetAdapter = (IWITTestCaseAdapter)TestAdapterManager.LoadAdapter(targetTCAdapterEnv.TCAdapterID);

            SourceAdapter.Initialize(sourceTCAdapterEnv);
            TargetAdapter.Initialize(targetTCAdapterEnv);

            SourceAdapter.WorkItemAdded += OnSourceWorkItemAdded;
            TargetAdapter.WorkItemAdded += OnTargetWorkItemAdded;

            // set the title string that all work items will start with.  This is what the WIT query filter strings will use.
            TestTitle = String.Format("{0}_{1}", TestName, DateTime.Now.ToString("MM'_'HH'_'mm'_'ss"));
            SourceAdapter.TitlePrefix = TestTitle;
            TargetAdapter.TitlePrefix = TestTitle;

            Trace.TraceInformation("Loaded WIT test environment successfully");
        }
Exemple #6
0
        public void Mapping_UserMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetUserValueMap);

            // add a work item on source side
            int sourceId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            SourceUser = SourceAdapter.GetFieldValue(sourceId, FIELD_ASSIGNEDTO);

            RunAndNoValidate();

            // verify there's no conflicts raised
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            // verify sync result excluding expected mismatches
            WitDiffResult result = GetDiffResult();

            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH, FIELD_ASSIGNEDTO
            });

            // verify the user mapping
            int    targetId   = QueryTargetWorkItemID(sourceId);
            string sourceUser = SourceAdapter.GetFieldValue(sourceId, FIELD_ASSIGNEDTO);
            string targetUser = TargetAdapter.GetFieldValue(targetId, FIELD_ASSIGNEDTO);

            Assert.AreEqual(sourceUser, SourceUser);
            Assert.AreEqual(targetUser, TargetUser);
        }
Exemple #7
0
        public void EditEditConflictIgnoreByFieldChangeTest()
        {
            int sourceId;
            int targetId;

            EditEditConflictScenario(out sourceId, out targetId);

            string srcTitle = SourceAdapter.GetFieldValue(sourceId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            // verify we have edit/edit conflict
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict");
            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            // resolve the conflict by ignoring conflicts it edits are on different fields
            bool isResolved = m_conflictResolver.TryResolveConflict(conflicts[0],
                                                                    new WITEditEditConflictIgnoreByFieldChangeAction(), "/" + sourceId);

            Assert.IsFalse(isResolved, "Conflict resolution should fail as both ends edited a same field");

            if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight)
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeTargetChangesAction(), "/" + targetId);
            }
            else
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + sourceId);
            }
            Assert.IsTrue(isResolved, "Conflict resolution should succeed");

            // restart the migration tool
            RunAndNoValidate(true);

            // verify sync result
            WitDiffResult result = GetDiffResult();

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });

            srcDesc = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);
            Assert.AreEqual(srcDesc, SOURCE_R1_DESC);
            Assert.AreEqual(tarDesc, SOURCE_R1_DESC);
        }
Exemple #8
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 #9
0
        public void RenameRenameConflictUserMergeTest()
        {
            // 1. migrate a.txt -> a.txt
            string fileName = "a.txt";
            MigrationItemStrings sourceFile          = new MigrationItemStrings(fileName, "b.txt", TestEnvironment, true);
            MigrationItemStrings targetFile          = new MigrationItemStrings(fileName, "c.txt", TestEnvironment, false);
            MigrationItemStrings targetUserMergeFile = new MigrationItemStrings("c.txt", "b.txt", TestEnvironment, false);

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

            // 2. source system: a.txt -> b.txt
            int deltaChangeId = SourceAdapter.RenameItem(sourceFile.ServerPath, sourceFile.NewServerPath);

            // 3. target system: a.txt -> c.txt
            TargetAdapter.RenameItem(targetFile.ServerPath, targetFile.NewServerPath);

            // 4. migrate
            Run();
            VerifyHistory(2, 1);

            // 5. resolve conflicts
            // 5.1 User merge actions
            // The user decided to accept other so he reverted the rename change on target system. c.txt -> a.txt
            int miChangeId = TargetAdapter.RenameItem(targetUserMergeFile.ServerPath, targetUserMergeFile.NewServerPath,
                                                      "Rename target items to accept other side's renames **NOMIGRATION**");

            // 5.2 resolve conflicts by VCContentConflictUserMergeChangeAction
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict");
            VCNameSpaceContentConflictType nameSpaceContentConflict = new VCNameSpaceContentConflictType();

            Assert.IsTrue(nameSpaceContentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be vc namespace 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}", deltaChangeId), dataFields);

            // 6. Migration will detect a conflict
            Run(true, true);
            Assert.IsTrue(VerifyContents());

            SourceAdapter.EditFile(sourceFile.NewLocalPath);
            Run(true, true);
            Assert.IsTrue(VerifyContents());
        }
Exemple #10
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 #11
0
 public DependencyPropertyAdapter(DependencyObject target, DependencyProperty property)
 {
     _property = property;
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     if (property == null)
     {
         throw new ArgumentNullException("property");
     }
     _valueChangedCallback = newValue => { };
     _targetAdapter        = new TargetAdapter(target, property, PropertyChangedHandler);
 }
Exemple #12
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 #13
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 #14
0
        public void Link_UpdateTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

            // add a work item on source side
            string title      = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemId = SourceAdapter.AddWorkItem("Bug", title, "description1");

            string location             = "link1";
            WITLinkChangeAction action1 = new WITLinkChangeAction(LinkChangeActionType.Add);

            action1.AddLink(new WITLink(location, "comment1"));
            SourceAdapter.UpdateWorkItemLink(workitemId, action1);

            // update link comment
            string newComment           = "new comment 2";
            WITLinkChangeAction action2 = new WITLinkChangeAction(LinkChangeActionType.Edit);

            action2.AddLink(new WITLink(location, newComment));
            SourceAdapter.UpdateWorkItemLink(workitemId, action2);

            RunAndNoValidate();

            // verify there's no conflicts raised
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            // verify sync result
            WitDiffResult result = GetDiffResult();

            // ignore Area/Iteration path mismatches
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });

            // Title <-> Description
            int mirroredId = QueryMirroredWorkItemID(workitemId);

            Assert.AreEqual(TfsTargetAdapter.GetHyperLinkCount(mirroredId), 1);
            WITLink tarLink = TargetAdapter.GetHyperLink(mirroredId, location);

            Assert.AreEqual(tarLink.Comment, newComment);
        }
Exemple #15
0
        /// Single Edit/Edit conflict
        ///
        /// 1. Source (S) and Target (T) are in sync
        ///
        /// Both ends have changes
        /// 2. Source revisions: A1 -> B
        /// 3. Target revisions: A2
        ///
        /// 4. Start Bi-directional migration (1st round)
        /// 5. Tool generates 1 edit/edit conflict with chained conflicts
        ///    Raise edit/edit conflicts for S:A1 and T:A2
        ///    Raise chained conflicts for S:B
        ///
        private void EditEditConflictScenario(out int workitemId, out int mirroredId)
        {
            // test edit/edit conflit in bi-directional work flow
            TestEnvironment.WorkFlowType = new WorkFlowType();
            TestEnvironment.WorkFlowType.DirectionOfFlow = DirectionOfFlow.Bidirectional;
            TestEnvironment.WorkFlowType.Frequency       = Frequency.ContinuousManual;
            TestEnvironment.WorkFlowType.SyncContext     = SyncContext.Disabled;
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(CustomizeTargetFilterString);

            // add a work item on source side
            string title = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));

            workitemId = SourceAdapter.AddWorkItem("Bug", title, "description1");

            // sync
            RunAndNoValidate();

            // verify there's no conflicts raised
            m_conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            // update work items on both sides
            WITChangeAction action1 = new WITChangeAction();
            WITChangeAction action2 = new WITChangeAction();

            mirroredId = QueryMirroredWorkItemID(workitemId);

            action1.Description = SOURCE_R1_DESC; // S:A1
            SourceAdapter.UpdateWorkItem(workitemId, action1);
            action1.Title = SOURCE_R2_TITLE;      // S:B
            SourceAdapter.UpdateWorkItem(workitemId, action1);
            action2.Description = TARGET_R1_DESC; // T:A2
            TargetAdapter.UpdateWorkItem(mirroredId, action2);

            //WITChangeAction action3 = new WITChangeAction();
            //action3.Title = TestContext.TestName + " title T:D"; // T:D
            //TargetAdapter.UpdateWorkItem(mirroredId, action3);

            // sync again
            // 1 edit/edit conflict with chained conflicts
            RunAndNoValidate(true);
        }
Exemple #16
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 #17
0
        public void AddMappingRoot()
        {
            MigrationItemStrings folderOnSource = new MigrationItemStrings("folder", "folder", TestEnvironment, true);
            MigrationItemStrings folderOnTarget = new MigrationItemStrings("folder", "folder", TestEnvironment, false);

            SourceAdapter.AddFolder(folderOnSource.LocalPath);
            TargetAdapter.AddFolder(folderOnTarget.LocalPath);

            //Remap the migration
            string source = TestEnvironment.FirstSourceServerPath;
            string target = TestEnvironment.FirstTargetServerPath;

            TestEnvironment.Mappings.Clear();
            TestEnvironment.AddMapping(new MappingPair(
                                           source + SrcPathSeparator + folderOnSource.Name,
                                           target + TarPathSeparator + folderOnTarget.Name, false));

            RunAndValidate();
        }
Exemple #18
0
        public void EditEditConflictTakeSourceTest()
        {
            int workitemId, mirroredId;

            EditEditConflictScenario(out workitemId, out mirroredId);

            string srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(mirroredId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            // verify we have edit/edit conflict
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict");
            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            // resolve the conflict by taking source side changes
            m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + workitemId);

            // restart the migration tool
            RunAndNoValidate(true);

            // verify sync result
            WitDiffResult result = GetDiffResult();

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });

            srcDesc = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            tarDesc = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION);
            Assert.AreEqual(srcDesc, SOURCE_R1_DESC);
            Assert.AreEqual(tarDesc, SOURCE_R1_DESC);
        }
Exemple #19
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 #20
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 #21
0
        public void Mapping_ConditionalHybridValueMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetConditionalHybridPriorityValueMap);

            // add a work item on source side
            string title = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));

            int workitemId = SourceAdapter.AddWorkItem("Bug", title, ConditionalValueMapDescription);

            WITChangeAction action1 = new WITChangeAction();

            action1.Priority = "2";
            SourceAdapter.UpdateWorkItem(workitemId, action1);

            RunAndNoValidate();

            // verify there's no conflicts raised
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            // verify sync result excluding expected mismatches
            WitDiffResult result = GetDiffResult();

            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH,
                FIELD_PRIORITY
            });

            // P1 == P2
            int    mirroredId = QueryMirroredWorkItemID(workitemId);
            string srcPri     = SourceAdapter.GetFieldValue(workitemId, FIELD_PRIORITY);
            string tarPri     = TargetAdapter.GetFieldValue(mirroredId, FIELD_PRIORITY);

            Assert.AreEqual(srcPri, "2");
            Assert.AreEqual(tarPri, "3");
        }
Exemple #22
0
        public void Mapping_ConditionalWildcardValueMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetConditionalWildcardPriorityValueMap);

            // add a work item on source side
            int workitemId = SourceAdapter.AddWorkItem("Bug", "title", ConditionalValueMapDescription);

            WITChangeAction action1 = new WITChangeAction();

            action1.Priority = "2";
            SourceAdapter.UpdateWorkItem(workitemId, action1);

            RunAndNoValidate();

            // verify there's no conflicts raised
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            // verify sync result excluding expected mismatches
            WitDiffResult result = GetDiffResult();

            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH,
                FIELD_PRIORITY
            });

            // P1 == P2
            int    targetId       = QueryTargetWorkItemID(workitemId);
            string sourcePriority = SourceAdapter.GetFieldValue(workitemId, FIELD_PRIORITY);
            string targetPriority = TargetAdapter.GetFieldValue(targetId, FIELD_PRIORITY);

            Assert.AreEqual(sourcePriority, "2");
            Assert.AreEqual(targetPriority, "3");
        }
Exemple #23
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 #24
0
        public void Mapping_UserMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetUserValueMap);

            // add a work item on source side
            string title = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));

            int    workitemId    = SourceAdapter.AddWorkItem("Bug", title, "description1");
            string srcAssignedTo = SourceAdapter.GetFieldValue(workitemId, FIELD_ASSIGNEDTO);

            SourceUser = SourceAdapter.GetFieldValue(workitemId, FIELD_ASSIGNEDTO);

            RunAndNoValidate();

            // verify there's no conflicts raised
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            // verify sync result excluding expected mismatches
            WitDiffResult result = GetDiffResult();

            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH, FIELD_ASSIGNEDTO
            });

            // verify the user mapping
            int    mirroredId = QueryMirroredWorkItemID(workitemId);
            string srcUser    = SourceAdapter.GetFieldValue(workitemId, FIELD_ASSIGNEDTO);
            string tarUser    = TargetAdapter.GetFieldValue(mirroredId, FIELD_ASSIGNEDTO);

            Assert.AreEqual(srcUser, SourceUser);
            Assert.AreEqual(tarUser, TargetUser);
        }
Exemple #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="V86Target"/> class.
 /// </summary>
 /// <param name="adapter">The adapter for the Target domain.</param>
 public V85Target(TargetAdapter adapter)
 {
     this.adapter = adapter;
     adapter.DetachedFromTarget += OnDetachedFromTarget;
 }
Exemple #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="V89Target"/> class.
 /// </summary>
 /// <param name="adapter">The adapter for the Target domain.</param>
 public V89Target(TargetAdapter adapter)
 {
     this.adapter = adapter;
 }
Exemple #27
0
        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());
        }
Exemple #28
0
        public void EditEditConflictTakeTargetTest()
        {
            int sourceId;
            int targetId;

            EditEditConflictScenario(out sourceId, out targetId);

            string srcTitle = SourceAdapter.GetFieldValue(sourceId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            // verify we have edit/edit conflict
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict");
            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            // resolve the conflict by taking target side changes
            bool isResolved = false;

            if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight)
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + targetId);
            }
            else
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeTargetChangesAction(), "/" + sourceId);
            }
            Assert.IsTrue(isResolved, "Conflict resolution should succeed");

            // restart the migration tool
            RunAndNoValidate(true);

            srcDesc = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreEqual(TARGET_R1_DESC, tarDesc);

            if (TestEnvironment.MigrationTestType == MigrationTestType.OneWay)
            {
                // VerifySyncResult does not apply to Oneway since we expect differences when we
                // resolve conflicts by taking Target changes

                // Source does not get updated on one-way migration
                Assert.AreEqual(SOURCE_R1_DESC, srcDesc);
            }
            else
            {
                // verify sync result
                WitDiffResult result = GetDiffResult();

                // ignore Area/Iteration path mismatches due to test environments
                VerifySyncResult(result, new List <string> {
                    FIELD_ITERATION_PATH, FIELD_AREA_PATH
                });

                Assert.AreEqual(TARGET_R1_DESC, srcDesc);
            }
        }
Exemple #29
0
        public void EditRenameConflictTakeMergeTest()
        {
            // 1. migrate a.txt -> a.txt
            string fileName = "a.txt";
            MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true);
            MigrationItemStrings targetFile = new MigrationItemStrings(fileName, "b.txt", TestEnvironment, false);
            int changeset;

            changeset = SourceAdapter.AddFile(sourceFile.LocalPath);
            TraceManager.TraceInformation("Add Changeset: {0}, {1}", changeset, SourceAdapter.AdapterType);

            RunAndValidate();

            // 2. source system: a.txt -> b.txt
            int editChangesetId = SourceAdapter.EditFile(sourceFile.LocalPath);

            TraceManager.TraceInformation("Edit Changeset: {0}, {1}", editChangesetId, SourceAdapter.AdapterType);

            // 3. target system: a.txt -> edit
            changeset = TargetAdapter.RenameItem(targetFile.ServerPath, targetFile.NewServerPath);
            TraceManager.TraceInformation("Rename Changeset: {0}, {1}", changeset, TargetAdapter.AdapterType);

            // 4. Migration will detect a conflict
            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 actions
            //
            // revert edit on a.txt
            PendEditToRevertFile(SourceWorkspace, sourceFile, editChangesetId, editChangesetId - 1);
            int sourceChangeId = SourceWorkspace.CheckIn(SourceWorkspace.GetPendingChanges(), "user: revert edit change on a.txt **NOMIGRATION**");

            TraceManager.TraceInformation("Undo Edit Changeset: {0}, {1}", sourceChangeId, SourceAdapter.AdapterType);

            // revert rename on target
            int targetChangeId = TargetAdapter.RenameItem(targetFile.NewServerPath, targetFile.ServerPath,
                                                          "Revert rename change on target side **NOMIGRATION**");

            TraceManager.TraceInformation("Undo Rename Changeset: {0}, {1}", targetChangeId, TargetAdapter.AdapterType);

            int deltaChangeId = sourceChangeId;
            int miChangeId    = targetChangeId;

            if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight)
            {
                deltaChangeId = targetChangeId;
                miChangeId    = sourceChangeId;
            }

            // resolve conflicts
            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(), "$/", dataFields);
            }

            // 6. migrate
            Run();

            // 7. validation
            // no remaining conflicts and content match
            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(0, conflicts.Count, "There should be NO conflict");
            // content match
            Assert.IsTrue(VerifyContents());
        }
Exemple #30
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!");
        }