public async Task RoundtripSimpleStructure() { var context = BuildXLContext.CreateInstanceForTesting(); var cache = new InMemoryArtifactContentCache(context); var originalEntry = new PipCacheDescriptorV2Metadata() { Id = 123, NumberOfWarnings = 456, TraceInfo = "Good job." }; Possible <ContentHash> maybeStored = await cache.TrySerializeAndStoreContent(originalEntry); XAssert.IsTrue(maybeStored.Succeeded); var maybeDeserialized = await cache.TryLoadAndDeserializeContent <PipCacheDescriptorV2Metadata>(maybeStored.Result); XAssert.IsTrue(maybeDeserialized.Succeeded); PipCacheDescriptorV2Metadata roundtripped = maybeDeserialized.Result; XAssert.IsNotNull(roundtripped, "Expected content available"); XAssert.AreEqual(originalEntry.Id, roundtripped.Id); XAssert.AreEqual(originalEntry.NumberOfWarnings, roundtripped.NumberOfWarnings); XAssert.AreEqual(originalEntry.TraceInfo, roundtripped.TraceInfo); }
public async Task DeserializationReturnsNullIfUnavailable() { var cache = new InMemoryArtifactContentCache(); ContentHash imaginaryContent = ContentHashingUtilities.HashBytes(Encoding.UTF8.GetBytes("Imagination")); var maybeDeserialized = await cache.TryLoadAndDeserializeContent <PipCacheDescriptorV2Metadata>(imaginaryContent); XAssert.IsTrue(maybeDeserialized.Succeeded); XAssert.IsNull(maybeDeserialized.Result, "Should be a miss (cache empty)"); }
/// <summary> /// Gets an artifact cache for the given context /// </summary> public InMemoryArtifactContentCache GetArtifacts(PipExecutionContext context) { if (m_artifacts == null) { m_artifacts = new InMemoryArtifactContentCache(context); } else { m_artifacts = m_artifacts.WrapForContext(context); } return(m_artifacts); }
/// <summary> /// Gets an artifact cache for the given context /// </summary> public InMemoryArtifactContentCache GetArtifacts() { if (m_artifacts == null) { m_artifacts = new InMemoryArtifactContentCache(); } else { m_artifacts = m_artifacts.Wrap(); } return(m_artifacts); }
private void CreateHistoricCache( LoggingContext loggingContext, string locationName, out PipExecutionContext context, out HistoricMetadataCache cache, out InMemoryArtifactContentCache memoryCache, Func <HistoricMetadataCache, Task> loadTask = null) { context = BuildXLContext.CreateInstanceForTesting(); memoryCache = new InMemoryArtifactContentCache(); cache = new HistoricMetadataCache( loggingContext, new EngineCache( memoryCache, new InMemoryTwoPhaseFingerprintStore()), context, new PathExpander(), AbsolutePath.Create(context.PathTable, Path.Combine(TemporaryDirectory, locationName)), loadTask); }
public HarnessArtifactContentCache() { m_cache = new InMemoryArtifactContentCache(); }
public HarnessArtifactContentCache() { var context = BuildXLContext.CreateInstanceForTesting(); m_cache = new InMemoryArtifactContentCache(context); }