Exemplo n.º 1
0
        public void OneTimeSetUp()
        {
            Process process = Process.GetCurrentProcess();

            _appId = process.ProcessName + "-" + process.Id;

            // TODO Pull out common parts of test setup/teardown into separate class that all runner tests can use

            _options = new IsIdentifiableMongoOptions()
            {
                HostName     = DEFAULT_HOSTNAME,
                Port         = DEFAULT_PORT,
                DatabaseName = "IsIdentifiableTests",

                StoreReport = true,
                TreeReport  = true,

                DestinationCsvFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestReports")
            };

            var mongoClient = new MongoClient(new MongoClientSettings
            {
                ApplicationName = _appId,
                Server          = new MongoServerAddress(DEFAULT_HOSTNAME, DEFAULT_PORT)
            });

            _testDatabase = mongoClient.GetDatabase(DB_NAME);
            CreateTestData(_testDatabase);
        }
Exemplo n.º 2
0
        private static int OnParse(GlobalOptions globals, object parsedOpts)
        {
            var opts = SmiCliInit.Verify <IsIdentifiableAbstractOptions>(parsedOpts);

            return(opts switch
            {
                IsIdentifiableRelationalDatabaseOptions o => Run(o),
                IsIdentifiableDicomFileOptions o => Run(o),
                IsIdentifiableMongoOptions o => Run(o),
                IsIdentifiableServiceOptions o => Run(o),
                IsIdentifiableFileOptions o => Run(o),
                _ => throw new NotImplementedException($"No case for '{opts.GetType()}'")
            });
Exemplo n.º 3
0
        public IsIdentifiableMongoRunner(IsIdentifiableMongoOptions opts, string appId)
            : base(opts)
        {
            _logger = LogManager.GetLogger(GetType().Name);
            _opts   = opts;

            if (opts.TreeReport)
            {
                _treeReport = new TreeFailureReport(opts.GetTargetName());
                Reports.Add(_treeReport);
            }

            var mongoClient = new MongoClient(new MongoClientSettings
            {
                Server          = new MongoServerAddress(_opts.HostName, _opts.Port),
                ApplicationName = appId
            });

            IMongoDatabase db = mongoClient.TryGetDatabase(_opts.DatabaseName);

            _collection = db.TryGetCollection(_opts.CollectionName);

            if (!string.IsNullOrWhiteSpace(_opts.QueryFile))
            {
                _queryString = File.ReadAllText(_opts.QueryFile);
            }

            // if specified, batch size must be g.t. 1:
            // https://docs.mongodb.com/manual/reference/method/cursor.batchSize/
            if (_opts.MongoDbBatchSize > 1)
            {
                _findOptionsBase.BatchSize = _opts.MongoDbBatchSize;
            }

            _factory = new MongoDbFailureFactory();

            if (_opts.UseMaxThreads)
            {
                _parallelOptions.MaxDegreeOfParallelism = -1;
            }
        }