protected Task TestStore( Context context, ITestClock clock, Func <TestFileSystemContentStoreInternal, Task> func) { return(TestStoreImpl(context, clock, func)); }
protected FileSystemContentStoreInternalPurgeTests(Func <IAbsFileSystem> createFileSystemFunc, ILogger logger, ITestOutputHelper output = null) : base(createFileSystemFunc, logger, output) { Context = new Context(Logger); Clock = FileSystem is MemoryFileSystem fileSystem ? fileSystem.Clock : new TestSystemClock(); }
//private static TestDistributedContentCopier CreateTestCopier() private static TestDistributedContentCopier CreateTestCopier(ITestClock clock, AbsolutePath rootDirectory) { var(copier, _) = DistributedContentCopierTests.CreateMocks( new MemoryFileSystem(clock), rootDirectory, TimeSpan.FromSeconds(1)); return(copier); }
protected Task TestStore( Context context, ITestClock clock, IContentChangeAnnouncer announcer, Func <TestFileSystemContentStoreInternal, Task> func) { return(TestStoreImpl(context, clock, func, announcer: announcer)); }
protected Task TestStore( Context context, ITestClock clock, DisposableDirectory testDirectory, Func <TestFileSystemContentStoreInternal, Task> func, Action <TestFileSystemContentStoreInternal> preStartupAction = null) { return(TestStoreImpl(context, clock, func, testDirectory, preStartupAction: preStartupAction)); }
protected Task TestStore ( Context context, ITestClock clock, Func <TestFileSystemContentStoreInternal, Task> func, NagleQueue <ContentHash> nagleBlock ) { return(TestStoreImpl(context, clock, func, nagleBlock: nagleBlock)); }
public MockContentLocationStoreFactory( ITestRedisDatabase primaryRedisDatabase, ITestRedisDatabase secondaryRedisDatabase, AbsolutePath rootDirectory, ITestClock mockClock = null, RedisContentLocationStoreConfiguration configuration = null) : base(mockClock ?? TestSystemClock.Instance, configuration ?? CreateDefaultConfiguration(rootDirectory), CreateTestCopier(mockClock ?? TestSystemClock.Instance, rootDirectory)) { _primaryRedisDatabase = primaryRedisDatabase; _secondaryRedisDatabase = secondaryRedisDatabase; }
protected virtual TestFileSystemContentStoreInternal CreateElastic( AbsolutePath rootPath, ITestClock clock, MaxSizeQuota initialQuota = null, int?windowSize = default(int?)) { var maxSizeQuota = initialQuota ?? new MaxSizeQuota(MaxSizeHard, MaxSizeSoft); // Some tests rely on maxSizeQuota being set in the configuration although it is ignored if elasticity is enabled. var config = new ContentStoreConfiguration(maxSizeQuota: maxSizeQuota, enableElasticity: true, initialElasticSize: maxSizeQuota, historyWindowSize: windowSize); return(new TestFileSystemContentStoreInternal(FileSystem, clock, rootPath, config, settings: ContentStoreSettings)); }
/// <summary> /// Initializes a new instance of the <see cref="MemoryFileSystem" /> class. /// </summary> /// <param name="clock">Clock to use.</param> /// <param name="drives">Drives to support. If null, have the same drive letters as the current OS.</param> /// <param name="useHardLinks">Whether all drives support hardlinks.</param> /// <param name="tempPath">Optional override of default temporary directory.</param> public MemoryFileSystem(ITestClock clock, IEnumerable <char> drives = null, bool useHardLinks = true, AbsolutePath tempPath = null) { Contract.Requires(clock != null); Clock = clock; _useHardLinks = useHardLinks; if (OperatingSystemHelper.IsUnixOS) { _drives.Add(Path.VolumeSeparatorChar, new FileObject()); } else { drives = drives ?? Directory.GetLogicalDrives().Select(driveString => driveString[0]); foreach (char driveLetter in drives) { _drives.Add(char.ToUpperInvariant(driveLetter), new FileObject()); } } if (tempPath != null) { if (!_drives.ContainsKey(char.ToUpperInvariant(tempPath.Path[0]))) { throw new ArgumentException("tempPath is not on an available drive"); } _tempPath = tempPath; } else { if (OperatingSystemHelper.IsUnixOS) { _tempPath = new AbsolutePath(Path.VolumeSeparatorChar + "temp"); } else { var firstDriveLetter = _drives.Keys.First(); var path = string.Format(CultureInfo.InvariantCulture, "{0}:\\temp", firstDriveLetter); _tempPath = new AbsolutePath(path); } } }
private async Task TestStoreImpl ( Context context, ITestClock clock, Func <TestFileSystemContentStoreInternal, Task> func, DisposableDirectory testDirectory = null, IContentChangeAnnouncer announcer = null, NagleQueue <ContentHash> nagleBlock = null, Action <TestFileSystemContentStoreInternal> preStartupAction = null ) { using (var tempTestDirectory = new DisposableDirectory(FileSystem)) { DisposableDirectory disposableDirectory = testDirectory ?? tempTestDirectory; using (var store = Create(disposableDirectory.Path, clock, nagleBlock)) { if (announcer != null) { store.Announcer = announcer; } store.Should().NotBeNull(); try { preStartupAction?.Invoke(store); var r = await store.StartupAsync(context); r.ShouldBeSuccess(); await func(store); } finally { if (!store.ShutdownStarted) { await store.ShutdownAsync(context).ShouldBeSuccess(); } } } } }
public MyMemoryFileSystem(ITestClock clock, long volumeSize) : base(clock, volumeSize) { }
protected override TestFileSystemContentStoreInternal Create(AbsolutePath rootPath, ITestClock clock, NagleQueue <ContentHash> nagleBlock = null) { Contract.Assert(ReferenceEquals(clock, Clock)); var config = new ContentStoreConfiguration(null, _quota); return(new TestFileSystemContentStoreInternal( FileSystem, clock, rootPath, config, contentHashWithSize => ((MyMemoryFileSystem)FileSystem).ContentAdded(contentHashWithSize.Size), contentHashWithSize => ((MyMemoryFileSystem)FileSystem).ContentEvicted(contentHashWithSize.Size), nagleBlock )); }
protected override TestFileSystemContentStoreInternal Create(AbsolutePath rootPath, ITestClock clock) { return(CreateElastic(rootPath, clock, new MaxSizeQuota(InitialMaxSizeHard), WindowSize)); }
protected override TestFileSystemContentStoreInternal Create(AbsolutePath rootPath, ITestClock clock) { var config = new ContentStoreConfiguration(_quota); return new TestFileSystemContentStoreInternal(FileSystem, clock, rootPath, config, settings: ContentStoreSettings); }
public MockFileSystem(ITestClock clock) : base(clock) { }
public GeneralSteps(ITestClock testClock) { _testClock = testClock; }
protected MemoryFileSystem(ITestClock clock, long volumeSize) : this(clock) { Contract.Requires(volumeSize > 0); _volumeSize = volumeSize; }
protected override TestFileSystemContentStoreInternal Create(AbsolutePath rootPath, ITestClock clock, NagleQueue <ContentHash> nagleBlock = null) { var config = new ContentStoreConfiguration(_quota); return(new TestFileSystemContentStoreInternal(FileSystem, clock, rootPath, config, nagleQueue: nagleBlock)); }
protected override TestFileSystemContentStoreInternal Create(AbsolutePath rootPath, ITestClock clock) { return(CreateElastic(rootPath, clock, _quota)); }
protected virtual TestFileSystemContentStoreInternal Create(AbsolutePath rootPath, ITestClock clock) { return(new TestFileSystemContentStoreInternal(FileSystem, clock, rootPath, Config, settings: ContentStoreSettings)); }
protected override TestFileSystemContentStoreInternal Create(AbsolutePath rootPath, ITestClock clock, NagleQueue <ContentHash> nagleBlock = null) { return(CreateElastic(rootPath, clock, nagleBlock, new MaxSizeQuota(MaxSizeHard))); }
protected virtual TestFileSystemContentStoreInternal Create(AbsolutePath rootPath, ITestClock clock, NagleQueue <ContentHash> nagleBlock = null) { return(new TestFileSystemContentStoreInternal(FileSystem, clock, rootPath, Config, nagleQueue: nagleBlock, settings: ContentStoreSettings)); }