예제 #1
0
        public void Link_CyclicLinkSamePairBidirectionalTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_SetBidirectionalNoContextSync);

            // Legend: x->y (y is a parent of x)
            // T1: Source: a b
            // T2: Sync
            // T3: Target: a b
            // T4: Source: add a->b ==> a->b
            //     Target: add b->a ==> b->a
            // T5: Sync
            // We should detect cyclic link and raise a conflict


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

            string titleB      = string.Format("B {0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemIdB = SourceAdapter.AddWorkItem("Bug", titleB, "B");


            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetTargetFilterString);

            RunAndNoValidate();
            int mirroredIdA = QueryMirroredWorkItemID(workitemIdA);
            int mirroredIdB = QueryMirroredWorkItemID(workitemIdB);


            TfsSourceAdapter.AddParentChildLink(workitemIdB, workitemIdA);
            TfsTargetAdapter.AddParentChildLink(mirroredIdA, mirroredIdB);

            RunAndNoValidate(true);

            // verify the expected conflict
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

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

            Guid TFSCyclicLinkConflictTypeReferenceName = new Guid("BF1277E9-A218-4a2d-8C3C-A9501D30ECD5");

            Assert.IsTrue(TFSCyclicLinkConflictTypeReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be a TFS cyclic link reference conflict");
            Assert.IsTrue(TFSCyclicLinkConflictTypeReferenceName.Equals(conflicts[1].ConflictTypeReference.Value.ReferenceName),
                          "It should be a TFS cyclic link reference conflict");

            // fix the hierarchy on target, delete b->a ==> a b
            TfsTargetAdapter.DeleteParentChildLink(mirroredIdA, mirroredIdB);

            // resolve the conflict by retrying
            conflictResolver.TryResolveConflict(conflicts[0], new ManualConflictResolutionAction(), "/");

            // restart the session
            RunAndNoValidate(true);

            // resolve the conflict by retrying
            conflictResolver.TryResolveConflict(conflicts[1], new ManualConflictResolutionAction(), "/");

            // restart the session
            RunAndNoValidate(true);

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

            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(workitemIdA));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(workitemIdB));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(mirroredIdA));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(mirroredIdB));

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

            // ignore Area/Iteration path mismatches
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });
        }
예제 #2
0
        private void Link_CyclicLinkScenarioTwoWay()
        {
            // Legend: x->y (y is a parent of x)
            // T1: Source: a->b->c  d
            // T2: Sync
            // T3: Target: a->b->c  d
            // T4: Source: delete b->c, add c->a ==> a->b  c->a  d
            //     Target: delete b->c, add b->d , d->c ==> a->b->d->c
            // T5: Sync
            // We should detect cyclic link and raise a conflict


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

            string titleB      = string.Format("B {0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemIdB = SourceAdapter.AddWorkItem("Bug", titleB, "B");

            string titleC      = string.Format("C {0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemIdC = SourceAdapter.AddWorkItem("Bug", titleC, "C");

            string titleD      = string.Format("C {0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemIdD = SourceAdapter.AddWorkItem("Bug", titleD, "D");

            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetTargetFilterString);

            RunAndNoValidate();

            TfsSourceAdapter.AddParentChildLink(workitemIdC, workitemIdB);
            TfsSourceAdapter.AddParentChildLink(workitemIdB, workitemIdA);

            // after sync,
            // Source: a->b->c d
            // Target: a->b->c d
            RunAndNoValidate(true);

            // Source: delete b->c, add c->a => c->a->b d
            TfsSourceAdapter.DeleteParentChildLink(workitemIdC, workitemIdB);
            TfsSourceAdapter.AddParentChildLink(workitemIdA, workitemIdC);
            // Target: delete b->c, add b->d , d->c => a->b->d->c
            int mirroredIdA = QueryMirroredWorkItemID(workitemIdA);
            int mirroredIdB = QueryMirroredWorkItemID(workitemIdB);
            int mirroredIdC = QueryMirroredWorkItemID(workitemIdC);
            int mirroredIdD = QueryMirroredWorkItemID(workitemIdD);

            TfsTargetAdapter.DeleteParentChildLink(mirroredIdC, mirroredIdB);
            TfsTargetAdapter.AddParentChildLink(mirroredIdD, mirroredIdB);
            TfsTargetAdapter.AddParentChildLink(mirroredIdC, mirroredIdD);

            // c->a from source will create cyclic link on target
            RunAndNoValidate(true);

            // verify the expected conflict
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

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

            Guid TFSCyclicLinkConflictTypeReferenceName = new Guid("BF1277E9-A218-4a2d-8C3C-A9501D30ECD5");

            Assert.IsTrue(TFSCyclicLinkConflictTypeReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be a TFS cyclic link reference conflict");
            Assert.IsTrue(TFSCyclicLinkConflictTypeReferenceName.Equals(conflicts[1].ConflictTypeReference.Value.ReferenceName),
                          "It should be a TFS cyclic link reference conflict");

            // fix the hierarchy on target, delete a->b => a b->d->c
            TfsTargetAdapter.DeleteParentChildLink(mirroredIdB, mirroredIdA);

            // resolve the conflict by retrying
            conflictResolver.TryResolveConflict(conflicts[0], new ManualConflictResolutionAction(), "/");

            // restart the migration tool, after sync,
            RunAndNoValidate(true);

            // resolve the conflict by retrying
            conflictResolver.TryResolveConflict(conflicts[1], new ManualConflictResolutionAction(), "/");

            RunAndNoValidate(true);

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

            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(workitemIdA));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(workitemIdB));
            Assert.AreEqual(2, TfsSourceAdapter.GetRelatedLinkCount(workitemIdC));
            Assert.AreEqual(2, TfsSourceAdapter.GetRelatedLinkCount(workitemIdD));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(mirroredIdA));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(mirroredIdB));
            Assert.AreEqual(2, TfsTargetAdapter.GetRelatedLinkCount(mirroredIdC));
            Assert.AreEqual(2, TfsTargetAdapter.GetRelatedLinkCount(mirroredIdD));
        }
예제 #3
0
        public void Link_MultiAddDeleteRelatedLinkTestOneWay()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

            for (int i = 0; i < 7; ++i)
            {
                // add a work item on source side
                string title = CreateWorkItemTitle(i.ToString());
                int    id    = SourceAdapter.AddWorkItem("Bug", title, "description1");
                SourceWorkItemIdList[i] = id;
            }

            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[0]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[2]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[3]);

            RunAndNoValidate();

            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[0]));
            Assert.AreEqual(3, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[1]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[2]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[3]));

            TfsSourceAdapter.DeleteRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[0]);
            TfsSourceAdapter.DeleteRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[2]);
            TfsSourceAdapter.DeleteRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[3]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[4]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[5]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[6]);
            RunAndNoValidate(true);

            RunAndNoValidate(true);

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

            Assert.AreEqual(0, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[0]));
            Assert.AreEqual(3, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[1]));
            Assert.AreEqual(0, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[2]));
            Assert.AreEqual(0, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[3]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[4]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[5]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[6]));

            int[] targetWorkItemIds = new int[SourceWorkItemIdList.Count];
            for (int i = 0; i < SourceWorkItemIdList.Count; ++i)
            {
                targetWorkItemIds[i] = QueryMirroredWorkItemID(SourceWorkItemIdList[i]);
            }

            Assert.AreEqual(0, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[0]));
            Assert.AreEqual(3, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[1]));
            Assert.AreEqual(0, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[2]));
            Assert.AreEqual(0, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[3]));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[4]));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[5]));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[6]));
        }