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);
        }
Esempio n. 2
0
        private Task <IStoppedFdbServer> BuildServer(FdbServerVersion version)
        {
            var builder = new FdbServerBuilder();

            builder.WithVersion(version);

            return(builder.BuildAsync());
        }
Esempio n. 3
0
        public async Task ClusterFile_ReturnsPath(FdbServerVersion version)
        {
            var fdbServer = await BuildServer(version).ConfigureAwait(false);

            try
            {
                Assert.NotNull(fdbServer.ClusterFile);
            }
            finally
            {
                fdbServer.Destruct();
            }
        }
Esempio n. 4
0
        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}.");
            }
        }
Esempio n. 6
0
        public async Task TestFullCycle(FdbServerVersion version)
        {
            var fdbServer = await BuildServer(version).ConfigureAwait(false);

            try
            {
                fdbServer
                .Start()
                .Initialize()
                .Stop()
                .Destroy();
            }
            catch
            {
                fdbServer.Destruct();

                throw;
            }
        }
Esempio n. 7
0
        public FdbServerBuilder WithVersion(FdbServerVersion version)
        {
            _version = version;

            return(this);
        }
Esempio n. 8
0
 public FdbServerUrl(FdbServerVersion version, Uri uri, string sha512Hash)
 {
     Version    = version;
     Uri        = uri;
     Sha512Hash = sha512Hash;
 }
Esempio n. 9
0
 public static FdbServerUrl GetUrl(FdbServerVersion version)
 {
     return(_repository[version]);
 }