public void GetLibraryBasePath_should_get_correct_paths_with_mocking(string rootTestFolder, string expectedRootTestFolder)
        {
            var assemblyCodeBase = Path.Combine(
                RequirePlatform.GetCurrentOperatingSystem() == SupportedOperatingSystem.Windows ? "C:/" : @"\\data",
                rootTestFolder,
                GetCommonTestAssemblyFolderEnding(),
                "MongoDB.Driver.Core.dll");
            var testAssemblyCodeBaseUri = new Uri(assemblyCodeBase).ToString();
            var subject = new TestRelativeLibraryLocator(mockedAssemblyUri: testAssemblyCodeBaseUri);

            var result = subject.GetBaseAssemblyDirectory();

            var expectedResult = Path.Combine(expectedRootTestFolder, GetCommonTestAssemblyFolderEnding());

            result.Should().EndWith(expectedResult);
        }
Example #2
0
        public void SelectServer_loadbalancing_prose_test([Values(false, true)] bool async)
        {
            RequireServer.Check()
            .Supports(Feature.ShardedTransactions, Feature.FailPointsBlockConnection)
            .ClusterType(ClusterType.Sharded);
            RequireMultipleShardRouters();

            // temporary disable the test on Win Auth topologies, due to operations timings irregularities
            if (CoreTestConfiguration.ConnectionString.Tls == true &&
                RequirePlatform.GetCurrentOperatingSystem() == SupportedOperatingSystem.Windows)
            {
                throw new SkipException("Win Auth topologies temporary not supported due to timings irregularities.");
            }

            const string applicationName              = "loadBalancingTest";
            const int    threadsCount                 = 10;
            const int    commandsPerThreadCount       = 10;
            const double maxCommandsOnSlowServerRatio = 0.3; // temporary set slow server load to 30% from 25% until find timings are investigated
            const double operationsCountTolerance     = 0.10;

            var failCommand = BsonDocument.Parse($"{{ configureFailPoint: 'failCommand', mode : {{ times : 10000 }}, data : {{ failCommands : [\"find\"], blockConnection: true, blockTimeMS: 500, appName: '{applicationName}' }} }}");

            DropCollection();
            var eventCapturer = CreateEventCapturer();

            using (var client = CreateDisposableClient(eventCapturer, applicationName))
            {
                var slowServer = client.Cluster.SelectServer(WritableServerSelector.Instance, default);
                var fastServer = client.Cluster.SelectServer(new DelegateServerSelector((_, servers) => servers.Where(s => s.ServerId != slowServer.ServerId)), default);

                using var failPoint = FailPoint.Configure(slowServer, NoCoreSession.NewHandle(), failCommand);

                var database = client.GetDatabase(_databaseName);
                CreateCollection();
                var collection = database.GetCollection <BsonDocument>(_collectionName);

                // warm up connections
                var channels = new ConcurrentBag <IChannelHandle>();
                ThreadingUtilities.ExecuteOnNewThreads(threadsCount, i =>
                {
                    channels.Add(slowServer.GetChannel(default));
                    channels.Add(fastServer.GetChannel(default));