Esempio n. 1
0
        /// <summary>
        /// Validates that a pip was a cache hit without asserting all pips being successful.
        /// This method works even if incremental scheduling filtered out the pip.
        /// </summary>
        public ScheduleRunResult AssertCacheHitWithoutAssertingSuccess(params PipId[] pipIds)
        {
            PipResultStatus status;

            for (int i = 0; i < pipIds.Length; i++)
            {
                PipId pipId = pipIds[i];
                if (PipResults.TryGetValue(pipId, out status))
                {
                    XAssert.AreNotEqual(PipResultStatus.Succeeded, status, "A pip ran, but it should have been a cache hit. Pip at 0-based parameter index: " + i);
                    XAssert.AreNotEqual(PipResultStatus.Failed, status, "A pip ran, but it should have been a cache hit. Pip at 0-based parameter index: " + i);
                }
            }

            return(this);
        }
Esempio n. 2
0
        /// <summary>
        /// Validates that a pip was a cache hit without asserting all pips being successful.
        /// This method works even if incremental scheduling filtered out the pip.
        /// </summary>
        public ScheduleRunResult AssertCacheHitWithoutAssertingSuccess(params PipId[] pipIds)
        {
            XAssert.IsTrue(pipIds.Length > 0, "Cache hit assertions should specify the pip ids in question");

            PipResultStatus status;

            for (int i = 0; i < pipIds.Length; i++)
            {
                PipId pipId = pipIds[i];
                if (PipResults.TryGetValue(pipId, out status))
                {
                    XAssert.IsFalse(IsExecutedPipResult(status), "A pip ran, but it should have been a cache hit. Pip at 0-based parameter index: " + i);
                }
            }

            return(this);
        }
Esempio n. 3
0
        /// <summary>
        /// Validates that a pip was a cache miss without asserting all pips being successful.
        /// </summary>
        public ScheduleRunResult AssertCacheMissWithoutAssertingSuccess(params PipId[] pipIds)
        {
            PipResultStatus status;

            for (int i = 0; i < pipIds.Length; i++)
            {
                PipId pipId = pipIds[i];
                if (PipResults.TryGetValue(pipId, out status))
                {
                    XAssert.AreEqual(PipResultStatus.Succeeded, status, "A pip was a cache hit, but it should have been a cache miss. Pip at 0-based parameter index: " + i);
                }
                else
                {
                    XAssert.Fail("A pip did not run, but it should have been a cache miss. Pip at 0-based parameter index: " + i);
                }
            }

            // Check that our counters for cache misses are working
            ValidateCacheMissTypesSumToTotal();

            return(this);
        }
Esempio n. 4
0
        /// <summary>
        /// Validates that a pip was a cache miss without asserting all pips being successful.
        /// </summary>
        public ScheduleRunResult AssertCacheMissWithoutAssertingSuccess(params PipId[] pipIds)
        {
            XAssert.IsTrue(pipIds.Length > 0, "Cache hit assertions should specify the pip ids in question");

            PipResultStatus status;

            for (int i = 0; i < pipIds.Length; i++)
            {
                PipId pipId = pipIds[i];
                if (PipResults.TryGetValue(pipId, out status))
                {
                    XAssert.IsTrue(IsExecutedPipResult(status), "A pip was a cache hit, but it should have been a cache miss. Pip at 0-based parameter index: " + i);
                }
                else
                {
                    XAssert.Fail("A pip did not run, but it should have been a cache miss. Pip at 0-based parameter index: " + i);
                }
            }

            // Check that our counters for cache misses are working
            ValidateCacheMissTypesSumToTotal();

            return(this);
        }
Esempio n. 5
0
        public void AssertPipResults(
            Pip[] expectedSuccessfulPips  = null,
            Pip[] expectedFailedPips      = null,
            Pip[] expectedSkippedPips     = null,
            Pip[] expectedCanceledPips    = null,
            Pip[] expectedUnscheduledPips = null)
        {
            Dictionary <PipId, PipResultStatus?> expectedPipResults = new Dictionary <PipId, PipResultStatus?>();

            expectedSuccessfulPips  = expectedSuccessfulPips ?? new Pip[0];
            expectedFailedPips      = expectedFailedPips ?? new Pip[0];
            expectedSkippedPips     = expectedSkippedPips ?? new Pip[0];
            expectedCanceledPips    = expectedCanceledPips ?? new Pip[0];
            expectedUnscheduledPips = expectedUnscheduledPips ?? new Pip[0];

            foreach (var pip in expectedSuccessfulPips)
            {
                Contract.Assume(pip.PipId.IsValid, "Expected results must be added after the pip has been added to the scheduler");
                expectedPipResults.Add(pip.PipId, PipResultStatus.Succeeded);
            }

            foreach (var pip in expectedFailedPips)
            {
                Contract.Assume(pip.PipId.IsValid, "Expected results must be added after the pip has been added to the scheduler");
                expectedPipResults.Add(pip.PipId, PipResultStatus.Failed);
            }

            foreach (var pip in expectedSkippedPips)
            {
                Contract.Assume(pip.PipId.IsValid, "Expected results must be added after the pip has been added to the scheduler");
                expectedPipResults.Add(pip.PipId, PipResultStatus.Skipped);
            }

            foreach (var pip in expectedCanceledPips)
            {
                Contract.Assume(pip.PipId.IsValid, "Expected results must be added after the pip has been added to the scheduler");
                expectedPipResults.Add(pip.PipId, PipResultStatus.Canceled);
            }

            foreach (var pip in expectedUnscheduledPips)
            {
                Contract.Assume(pip.PipId.IsValid, "Expected results must be added after the pip has been added to the scheduler");
                expectedPipResults.Add(pip.PipId, null);
            }

            foreach (var expectedPipResult in expectedPipResults)
            {
                PipResultStatus actualPipResult;

                XAssert.AreEqual(expectedPipResult.Value.HasValue, PipResults.TryGetValue(expectedPipResult.Key, out actualPipResult));

                if (expectedPipResult.Value.HasValue)
                {
                    // Treat DeployedFromCache as Succeeded if that's what we wanted anyway; otherwise it is very hard to guess
                    // if a WriteFile / CopyFile pip will be satisfied from content-cache (many identical files in some tests).
                    if (actualPipResult == PipResultStatus.DeployedFromCache && expectedPipResult.Value.Value == PipResultStatus.Succeeded)
                    {
                        continue;
                    }

                    XAssert.AreEqual(expectedPipResult.Value.Value, actualPipResult);
                }
            }
        }