示例#1
0
        private void InvalidateSidebandFile(string sidebandFile, SidebandIntegrityCheckFailReason kind)
        {
            XAssert.FileExists(sidebandFile, "Sideband file for pipA not found.");
            switch (kind)
            {
            case SidebandIntegrityCheckFailReason.FileNotFound:
                AssertDeleteFile(sidebandFile, "Could not delete sideband file for pipA.");
                break;

            case SidebandIntegrityCheckFailReason.ChecksumMismatch:
                File.WriteAllText(path: sidebandFile, contents: "bogus sideband file");
                break;

            case SidebandIntegrityCheckFailReason.MetadataMismatch:
                SidebandMetadata alteredMetadata;
                // read the header and the metadata from the original
                using (var reader = new SidebandReader(sidebandFile))
                {
                    XAssert.IsTrue(reader.ReadHeader(ignoreChecksum: false));
                    var originalMetadata = reader.ReadMetadata();
                    alteredMetadata = new SidebandMetadata(originalMetadata.PipSemiStableHash + 1, originalMetadata.StaticPipFingerprint);
                }
                // overwrite the original with a different metadata file where PiPSemiStableHash is different than in the original
                using (var writer = new SidebandWriter(alteredMetadata, sidebandFile, null))
                {
                    writer.EnsureHeaderWritten();
                }
                break;

            default:
                XAssert.Fail($"Unknown kind: {kind}");
                break;
            }
        }
示例#2
0
        public void TestSidebandIntegrityCheckFail(SidebandIntegrityCheckFailReason kind)
        {
            // Setup: PipA => sharedOpaqueDir; invalidate PipA's sideband file afterwards
            var sharedOpaqueDir = Path.Combine(ObjectRoot, $"sod-{nameof(TestSidebandIntegrityCheckFail)}");

            var pipA = CreateAndScheduleSharedOpaqueProducer(sharedOpaqueDir, filesToProduceDynamically: CreateOutputFileArtifact(sharedOpaqueDir, prefix: "PipA"));

            var result = RunScheduler().AssertCacheMiss(pipA.Process.PipId);

            AssertSharedOpaqueOutputDeletionNotPostponed();
            AssertVerboseEventLogged(EventId.SidebandIntegrityCheckForProcessFailed);

            // invalidate sideband file and run again
            InvalidateSidebandFile(GetSidebandFile(result, pipA.Process), kind);
            RunScheduler().AssertCacheHit(pipA.Process.PipId);
            AssertSharedOpaqueOutputDeletionNotPostponed();
            AssertVerboseEventLogged(EventId.SidebandIntegrityCheckForProcessFailed);

            if (kind == SidebandIntegrityCheckFailReason.ChecksumMismatch)
            {
                AssertWarningEventLogged(global::BuildXL.Processes.Tracing.LogEventId.CannotReadSidebandFileWarning);
            }
        }