public Task PinSurvivesRestartingServer() { return(RunSessionTestAsync(ImplicitPin.None, async(context, session) => { // Put some random content for requests that want to use it. var r1 = await session.PutRandomAsync(context, ContentHashType, false, ContentByteCount, Token).ShouldBeSuccess(); // Pin the content - we'll make sure the pin survives the server restart below. await session.PinAsync(context, r1.ContentHash, Token).ShouldBeSuccess(); // Restart the server. ITestServiceClientContentStore store = ((TestServiceClientContentSession)session).Store; await store.RestartServerAsync(context); // Put content until LRU has to remove content. for (var i = 0; i < 3 * 2; i++) { long size = (MaxSize - ContentByteCount) / 3; await session.PutRandomAsync(context, ContentHashType, false, size, Token).ShouldBeSuccess(); } // Verify pinning above survived the server restart and LRU. var r4 = await session.OpenStreamAsync(context, r1.ContentHash, Token); r4.Stream.Should().NotBeNull(); using (r4.Stream) { r4.ShouldBeSuccess(); } })); }
private Task TimesOutAfterServerShutdown(Func <Context, IContentSession, ContentHash, Task <ResultBase> > requestFunc) { return(RunSessionTestAsync(ImplicitPin.None, async(context, session) => { ITestServiceClientContentStore store = ((TestServiceClientContentSession)session).Store; await store.ShutdownServerAsync(context); var r = await requestFunc(context, session, ContentHash.Random()); r.ErrorMessage.Should().Contain("service"); })); }
public TestServiceClientContentSession( string name, ImplicitPin implicitPin, RetryPolicy retryPolicy, AbsolutePath rootPath, string cacheName, ILogger logger, IAbsFileSystem fileSystem, string scenario, ITestServiceClientContentStore store, ServiceClientContentSessionTracer sessionTracer, ServiceClientRpcConfiguration rpcConfiguration) : base(name, implicitPin, logger, fileSystem, sessionTracer, new ServiceClientContentStoreConfiguration(cacheName, rpcConfiguration, scenario, retryPolicy)) { _rootPath = rootPath; Store = store; }
public Task BuildIdServicesRestartingServer() { var mockLogger = new MockLogger(); Logger = mockLogger; var sessionId = Guid.NewGuid().ToString(); // Creating session with build id in it. SessionName = $"{Constants.BuildIdPrefix}{sessionId}"; return(RunSessionTestAsync(ImplicitPin.None, async(context, session) => { mockLogger.CurrentBuildId.Should().Be(sessionId); // Restart the server. ITestServiceClientContentStore store = ((TestServiceClientContentSession)session).Store; await store.RestartServerAsync(context); // Check that build id is still set. mockLogger.CurrentBuildId.Should().Be(sessionId); })); }
private Task WorksBeforeAndAfterServerRestart(Func <Context, IContentSession, ContentHash, Task> requestFunc) { int retryCount = 0; int maxRetryCount = 2; List <string> errorMessages = new List <string>(); while (retryCount < maxRetryCount) { try { return(RunSessionTestAsync(ImplicitPin.None, async(context, session) => { // Put some random content for requests that want to use it. var r1 = await session.PutRandomAsync(context, ContentHashType, false, ContentByteCount, Token).ShouldBeSuccess(); // Pin the content - this should survive the server restart. await session.PinAsync(context, r1.ContentHash, Token).ShouldBeSuccess(); // Make sure request works before restarting the server. await requestFunc(context, session, r1.ContentHash); ITestServiceClientContentStore store = ((TestServiceClientContentSession)session).Store; await store.RestartServerAsync(context); // Make sure request works after restarting the server. await requestFunc(context, session, r1.ContentHash); })); } catch (Xunit.Sdk.XunitException e) { errorMessages.Add(e.Message); retryCount++; } } Assert.True(false, $"Failed after {retryCount} tries." + string.Join(Environment.NewLine, errorMessages)); return(null); }
private Task WorksBeforeAndAfterServerRestart(Func <Context, IContentSession, ContentHash, Task> requestFunc) { // Scenario must be unique for different test cases to avoid getting CacheException like: // BuildXL.Cache.ContentStore.Exceptions.CacheException : Shutdown event name=[InProcessServiceRequestsWorkAcrossServerRestartTestsDEBUGDEBUG] already exists Scenario += Guid.NewGuid().ToString(); return(RunSessionTestAsync(ImplicitPin.None, async(context, session) => { // Put some random content for requests that want to use it. var r1 = await session.PutRandomAsync(context, ContentHashType, false, ContentByteCount, Token).ShouldBeSuccess(); // Pin the content - this should survive the server restart. await session.PinAsync(context, r1.ContentHash, Token).ShouldBeSuccess(); // Make sure request works before restarting the server. await requestFunc(context, session, r1.ContentHash); ITestServiceClientContentStore store = ((TestServiceClientContentSession)session).Store; await store.RestartServerAsync(context); // Make sure request works after restarting the server. await requestFunc(context, session, r1.ContentHash); })); }