public FdbFixture() { const int fallbackFdbApiVersion = 520; var apiVersion = Environment.GetEnvironmentVariable("FdbApiVersion"); var serverVersion = Environment.GetEnvironmentVariable("FdbServerVersion"); if (apiVersion == null || !int.TryParse(apiVersion, out int fdbApiVersion)) { fdbApiVersion = fallbackFdbApiVersion; } var availableVersions = Enum.GetNames(typeof(FdbServerVersion)); if (serverVersion != null && availableVersions.Contains(serverVersion)) { _serverVersion = (FdbServerVersion)Enum.Parse(typeof(FdbServerVersion), serverVersion); } else { _serverVersion = FdbServerVersion.v6_0_15; } EnsureApiVersionAndServerVersionCompatible(fdbApiVersion, _serverVersion); Fdb = Fdb.Instance; Fdb.SelectApiVersion(fdbApiVersion); }
private Task <IStoppedFdbServer> BuildServer(FdbServerVersion version) { var builder = new FdbServerBuilder(); builder.WithVersion(version); return(builder.BuildAsync()); }
public async Task ClusterFile_ReturnsPath(FdbServerVersion version) { var fdbServer = await BuildServer(version).ConfigureAwait(false); try { Assert.NotNull(fdbServer.ClusterFile); } finally { fdbServer.Destruct(); } }
public async Task <IResult> InstallToDestination(FdbServerVersion version, string destinationFolder) { var zipFileName = Path.GetTempFileName(); var url = FdbServerUrlRepository.GetUrl(version); var result = (await Cache .CheckAvailability(url) .OnFailureAsync(_ => Cache.Load(url)).ConfigureAwait(false)) .Then(_ => Cache.Retrieve(url, zipFileName)) .Then(_ => ExtractArchive(zipFileName, destinationFolder)) .ThenAlways(_ => File.Delete(zipFileName)); return(result); }
private void EnsureApiVersionAndServerVersionCompatible(int fdbApiVersion, FdbServerVersion serverVersion) { var normalizedServerVersion = serverVersion.ToString().Substring(1).Replace("_", string.Empty); if (fdbApiVersion.ToString().CompareTo(normalizedServerVersion) > 0) { throw new InvalidOperationException($"FdbApiVersion {fdbApiVersion} is not compatible with FdbServerVersion {serverVersion}."); } var maxApiVersion = Fdb.Instance.GetMaxApiVersion(); if (maxApiVersion.ToString().CompareTo(normalizedServerVersion) > 0) { throw new InvalidOperationException($"Native library has max version {maxApiVersion} and is not compatible with FdbServerVersion {serverVersion}."); } }
public async Task TestFullCycle(FdbServerVersion version) { var fdbServer = await BuildServer(version).ConfigureAwait(false); try { fdbServer .Start() .Initialize() .Stop() .Destroy(); } catch { fdbServer.Destruct(); throw; } }
public FdbServerBuilder WithVersion(FdbServerVersion version) { _version = version; return(this); }
public FdbServerUrl(FdbServerVersion version, Uri uri, string sha512Hash) { Version = version; Uri = uri; Sha512Hash = sha512Hash; }
public static FdbServerUrl GetUrl(FdbServerVersion version) { return(_repository[version]); }