public RequireServer StorageEngine(string storageEngine)
        {
            var actualStorageEngine = CoreTestConfiguration.GetStorageEngine();

            if (actualStorageEngine.Equals(storageEngine, StringComparison.OrdinalIgnoreCase))
            {
                return(this);
            }
            throw new SkipTestException($"Test skipped because storage engine is \"{actualStorageEngine}\" and not \"{storageEngine}\".");
        }
Esempio n. 2
0
        private static void CheckStorageEngines(string storageEngines)
        {
            var requiredStorageEngines = storageEngines.Split(',');
            var actualStorageEngine    = CoreTestConfiguration.GetStorageEngine();

            if (!requiredStorageEngines.Contains(actualStorageEngine))
            {
                var requiredCsv = string.Join(", ", requiredStorageEngines.Select(e => "\"" + e + "\"").ToArray());
                throw new SkipTestException($"Test skipped because \"{actualStorageEngine}\" is not one of the required storage engines: {requiredCsv}.");
            }
        }
Esempio n. 3
0
        // private methods
        private void VerifyServerRequirements(BsonDocument definition)
        {
            if (definition.TryGetValue("runOn", out var runOn))
            {
                RequireServer.Check().RunOn(runOn.AsBsonArray);
            }

            if (CoreTestConfiguration.GetStorageEngine() == "mmapv1")
            {
                throw new SkipException("Test skipped because mmapv1 does not support retryable writes.");
            }
        }
Esempio n. 4
0
        public RequireServer StorageEngines(params string[] storageEngines)
        {
            var actualStorageEngine = CoreTestConfiguration.GetStorageEngine();

            if (storageEngines.Contains(actualStorageEngine, StringComparer.OrdinalIgnoreCase))
            {
                return(this);
            }
            var storageEnginesString = string.Join(", ", storageEngines.Select(e => "\"" + e + "\""));

            throw new SkipTestException($"Test skipped because storage engine is \"{actualStorageEngine}\" and not one of ({storageEnginesString}).");
        }
Esempio n. 5
0
 private void EnsureStorageEngine()
 {
     if (_storageEngines != null)
     {
         var storageEngine = CoreTestConfiguration.GetStorageEngine();
         if (!_storageEngines.Contains(storageEngine))
         {
             var message = string.Format("Requires storage engine \"{0}\", but currently connected to a server using storage engine \"{1}\".", StorageEngines, storageEngine);
             Assert.Ignore(message);
         }
     }
 }
        public void TestCreateCollectionSetIndexOptionDefaults()
        {
            RequireServer.Check().Supports(Feature.IndexOptionsDefaults).ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet);
            var collection = _database.GetCollection("testindexoptiondefaults");

            collection.Drop();
            Assert.False(collection.Exists());
            var storageEngine        = CoreTestConfiguration.GetStorageEngine();
            var storageEngineOptions = new BsonDocument(storageEngine, new BsonDocument());
            var indexOptionDefaults  = new IndexOptionDefaults {
                StorageEngine = storageEngineOptions
            };
            var expectedIndexOptionDefaultsDocument = new BsonDocument("storageEngine", storageEngineOptions);
            var options = CollectionOptions.SetIndexOptionDefaults(indexOptionDefaults);

            _database.CreateCollection(collection.Name, options);

            var commandResult  = _database.RunCommand("listCollections");
            var collectionInfo = commandResult.Response["cursor"]["firstBatch"].AsBsonArray.Where(doc => doc["name"] == collection.Name).Single().AsBsonDocument;

            Assert.Equal(expectedIndexOptionDefaultsDocument, collectionInfo["options"]["indexOptionDefaults"]);
        }
        // private methods
        private void VerifyServerRequirements(BsonDocument definition)
        {
            RequireServer.Check().ClusterType(ClusterType.ReplicaSet);

            if (CoreTestConfiguration.GetStorageEngine() == "mmapv1")
            {
                throw new SkipException("Test skipped because mmapv1 does not support retryable writes.");
            }

            BsonValue minServerVersion;

            if (definition.TryGetValue("minServerVersion", out minServerVersion))
            {
                RequireServer.Check().VersionGreaterThanOrEqualTo(minServerVersion.AsString);
            }

            BsonValue maxServerVersion;

            if (definition.TryGetValue("maxServerVersion", out maxServerVersion))
            {
                RequireServer.Check().VersionLessThanOrEqualTo(maxServerVersion.AsString);
            }
        }