示例#1
0
        public StarsMongoDbPersistenceTest()
        {
            var MONGO_ENABLED      = Environment.GetEnvironmentVariable("MONGO_ENABLED") ?? "true";
            var MONGO_DB           = Environment.GetEnvironmentVariable("MONGO_DB") ?? "test";
            var MONGO_COLLECTION   = Environment.GetEnvironmentVariable("MONGO_COLLECTION") ?? "stars";
            var MONGO_SERVICE_HOST = Environment.GetEnvironmentVariable("MONGO_SERVICE_HOST") ?? "localhost";
            var MONGO_SERVICE_PORT = Environment.GetEnvironmentVariable("MONGO_SERVICE_PORT") ?? "27017";
            var MONGO_SERVICE_URI  = Environment.GetEnvironmentVariable("MONGO_SERVICE_URI");

            _enabled = BooleanConverter.ToBoolean(MONGO_ENABLED);

            if (_enabled)
            {
                var config = ConfigParams.FromTuples(
                    "collection", MONGO_COLLECTION,
                    "connection.database", MONGO_DB,
                    "connection.host", MONGO_SERVICE_HOST,
                    "connection.port", MONGO_SERVICE_PORT,
                    "connection.uri", MONGO_SERVICE_URI
                    );

                _persistence = new StarsMongoDbPersistence();
                _persistence.Configure(config);
                _persistence.OpenAsync(null).Wait();
                _persistence.ClearAsync(null).Wait();

                _fixture = new StarsPersistenceFixture(_persistence);
            }
        }
示例#2
0
        public ElasticSearchLoggerTest()
        {
            var ELASTICSEARCH_ENABLED      = Environment.GetEnvironmentVariable("ELASTICSEARCH_ENABLED") ?? "true";
            var ELASTICSEARCH_SERVICE_HOST = Environment.GetEnvironmentVariable("ELASTICSEARCH_SERVICE_HOST") ?? "localhost";
            var ELASTICSEARCH_SERVICE_PORT = Environment.GetEnvironmentVariable("ELASTICSEARCH_SERVICE_PORT") ?? "9200";

            _enabled = BooleanConverter.ToBoolean(ELASTICSEARCH_ENABLED);

            if (_enabled)
            {
                _logger = new TestElasticSearchLogger();
                _logger.Configure(ConfigParams.FromTuples(
                                      "level", "trace",
                                      "source", "test",
                                      "index", "log",
                                      "date_format", _dateFormat,
                                      "daily", true,
                                      "connection.host", ELASTICSEARCH_SERVICE_HOST,
                                      "connection.port", ELASTICSEARCH_SERVICE_PORT
                                      ));

                _fixture   = new LoggerFixture(_logger);
                _esFixture = new ElasticSearchLoggerFixture(_logger);

                _logger.OpenAsync(null).Wait();
                // _logger.OpenAsync(null).Wait();
            }
        }
        public CloudWatchLoggerTest()
        {
            var AWS_ENABLED    = Environment.GetEnvironmentVariable("AWS_ENABLED") ?? "true";
            var AWS_REGION     = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1";
            var AWS_ACCOUNT    = Environment.GetEnvironmentVariable("AWS_ACCOUNT");
            var AWS_ACCESS_ID  = Environment.GetEnvironmentVariable("AWS_ACCESS_ID") ?? "AKIAI2B3PGHEAAK4BPUQ";
            var AWS_ACCESS_KEY = Environment.GetEnvironmentVariable("AWS_ACCESS_KEY") ?? "zQZGX0vGL6OD936fCcP1v6YmpiSdW28oUcezAnb7";

            _enabled = BooleanConverter.ToBoolean(AWS_ENABLED);

            if (_enabled)
            {
                _logger = new CloudWatchLogger();
                _logger.Configure(ConfigParams.FromTuples(
                                      "group", "TestGroup",
                                      "stream", "TestStream",
                                      "connection.region", AWS_REGION,
                                      "connection.account", AWS_ACCOUNT,
                                      "credential.access_id", AWS_ACCESS_ID,
                                      "credential.access_key", AWS_ACCESS_KEY
                                      ));

                _fixture = new LoggerFixture(_logger);

                try
                {
                    _logger.OpenAsync(null).Wait();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    throw ex;
                }
            }
        }
        public RabbitMQMessageQueueTest()
        {
            var RABBITMQ_ENABLED  = Environment.GetEnvironmentVariable("RABBITMQ_ENABLED") ?? "true";
            var RABBITMQ_URI      = Environment.GetEnvironmentVariable("RABBITMQ_URI");
            var RABBITMQ_HOST     = Environment.GetEnvironmentVariable("RABBITMQ_HOST") ?? "localhost";
            var RABBITMQ_PORT     = Environment.GetEnvironmentVariable("RABBITMQ_PORT") ?? "5672";
            var RABBITMQ_QUEUE    = Environment.GetEnvironmentVariable("RABBITMQ_QUEUE") ?? "test";
            var RABBITMQ_EXCHANGE = Environment.GetEnvironmentVariable("RABBITMQ_EXCHANGE") ?? "test";
            var RABBITMQ_USER     = Environment.GetEnvironmentVariable("RABBITMQ_USER") ?? "user";
            var RABBITMQ_PASS     = Environment.GetEnvironmentVariable("RABBITMQ_PASS") ?? "pass123";

            _enabled = BooleanConverter.ToBoolean(RABBITMQ_ENABLED);

            if (_enabled)
            {
                _queue = new RabbitMQMessageQueue("TestQueue");
                _queue.Configure(ConfigParams.FromTuples(
                                     "exchange", RABBITMQ_EXCHANGE,
                                     "queue", RABBITMQ_QUEUE,
                                     "options.auto_create", true,
                                     "connection.uri", RABBITMQ_URI,
                                     "connection.host", RABBITMQ_HOST,
                                     "connection.port", RABBITMQ_PORT,
                                     "credential.username", RABBITMQ_USER,
                                     "credential.password", RABBITMQ_PASS
                                     ));
                _queue.Interval = 100;

                _queue.OpenAsync(null).Wait();
                _queue.ClearAsync(null).Wait();

                _fixture = new MessageQueueFixture(_queue);
            }
        }
        public PrometheusCountersTest()
        {
            var PUSHGATEWAY_ENABLED      = Environment.GetEnvironmentVariable("PUSHGATEWAY_ENABLED") ?? "true";
            var PUSHGATEWAY_SERVICE_HOST = Environment.GetEnvironmentVariable("PUSHGATEWAY_SERVICE_HOST") ?? "localhost";
            var PUSHGATEWAY_SERVICE_PORT = Environment.GetEnvironmentVariable("PUSHGATEWAY_SERVICE_PORT") ?? "9091";

            _enabled = BooleanConverter.ToBoolean(PUSHGATEWAY_ENABLED);
            if (_enabled)
            {
                _counters = new PrometheusCounters();
                _counters.Configure(ConfigParams.FromTuples(
                                        "interval", "5000",
                                        "connection.host", PUSHGATEWAY_SERVICE_HOST,
                                        "connection.port", PUSHGATEWAY_SERVICE_PORT
                                        ));

                var contextInfo = new ContextInfo();
                contextInfo.Name        = "Test";
                contextInfo.Description = "This is a test container";

                var references = References.FromTuples(
                    new Descriptor("pip-services", "context-info", "default", "default", "1.0"), contextInfo,
                    new Descriptor("pip-services", "counters", "prometheus", "default", "1.0"), _counters
                    );
                _counters.SetReferences(references);

                _fixture = new CountersFixture(_counters);

                _counters.OpenAsync(null).Wait();
            }
        }
示例#6
0
        public GuidesMongoDbPersistenceTest()
        {
            var mongoEnabled     = Environment.GetEnvironmentVariable("MONGO_ENABLED") ?? "true";
            var mongoDb          = Environment.GetEnvironmentVariable("MONGO_DB") ?? "test";
            var mongoCollection  = Environment.GetEnvironmentVariable("MONGO_COLLECTION") ?? "guides";
            var mongoServiceHost = Environment.GetEnvironmentVariable("MONGO_SERVICE_HOST") ?? "localhost";
            var mongoServicePort = Environment.GetEnvironmentVariable("MONGO_SERVICE_PORT") ?? "27017";
            var mongoServiceUri  = Environment.GetEnvironmentVariable("MONGO_SERVICE_URI");

            _enabled = BooleanConverter.ToBoolean(mongoEnabled);

            if (_enabled)
            {
                var config = ConfigParams.FromTuples(
                    "collection", mongoCollection,
                    "connection.database", mongoDb,
                    "connection.host", mongoServiceHost,
                    "connection.port", mongoServicePort,
                    "connection.uri", mongoServiceUri
                    );

                _persistence = new GuidesMongoDbPersistence();
                _persistence.Configure(config);
                _persistence.OpenAsync(null).Wait();
                _persistence.ClearAsync(null).Wait();

                _fixture = new GuidesPersistenceFixture(_persistence);
            }
        }
示例#7
0
        public void ObjectBooleanTest()
        {
            One one = new One();
            One two = null;

            Assert.False(BooleanConverter.ToBoolean(one));
            Assert.False(BooleanConverter.ToBoolean(two));
        }
示例#8
0
        public SqsMessageQueueTest()
        {
            AWS_ENABLED    = Environment.GetEnvironmentVariable("AWS_ENABLED") ?? "true";
            AWS_REGION     = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1";
            AWS_ACCOUNT    = Environment.GetEnvironmentVariable("AWS_ACCOUNT");
            AWS_ACCESS_ID  = Environment.GetEnvironmentVariable("AWS_ACCESS_ID") ?? "AKIAI2B3PGHEAAK4BPUQ";
            AWS_ACCESS_KEY = Environment.GetEnvironmentVariable("AWS_ACCESS_KEY") ?? "zQZGX0vGL6OD936fCcP1v6YmpiSdW28oUcezAnb7";

            _enabled = BooleanConverter.ToBoolean(AWS_ENABLED);

            if (_enabled)
            {
                Setup();
            }
        }
        public MemcachedLockTest()
        {
            var MEMCACHED_ENABLED      = Environment.GetEnvironmentVariable("MEMCACHED_ENABLED") ?? "true";
            var MEMCACHED_SERVICE_HOST = Environment.GetEnvironmentVariable("MEMCACHED_SERVICE_HOST") ?? "localhost";
            var MEMCACHED_SERVICE_PORT = Environment.GetEnvironmentVariable("MEMCACHED_SERVICE_PORT") ?? "11211";

            _enabled = BooleanConverter.ToBoolean(MEMCACHED_ENABLED);
            if (_enabled)
            {
                _lock = new MemcachedLock();
                _lock.Configure(ConfigParams.FromTuples(
                                    "connection.host", MEMCACHED_SERVICE_HOST,
                                    "connection.port", MEMCACHED_SERVICE_PORT
                                    ));

                _fixture = new LockFixture(_lock);

                _lock.OpenAsync(null).Wait();
            }
        }
示例#10
0
        public RedisCacheTest()
        {
            var REDIS_ENABLED      = Environment.GetEnvironmentVariable("REDIS_ENABLED") ?? "true";
            var REDIS_SERVICE_HOST = Environment.GetEnvironmentVariable("REDIS_SERVICE_HOST") ?? "localhost";
            var REDIS_SERVICE_PORT = Environment.GetEnvironmentVariable("REDIS_SERVICE_PORT") ?? "6379";

            _enabled = BooleanConverter.ToBoolean(REDIS_ENABLED);
            if (_enabled)
            {
                _cache = new RedisCache();
                _cache.Configure(ConfigParams.FromTuples(
                                     "connection.host", REDIS_SERVICE_HOST,
                                     "connection.port", REDIS_SERVICE_PORT
                                     ));

                _fixture = new CacheFixture(_cache);

                _cache.OpenAsync(null).Wait();
            }
        }
        public CloudWatchCountersTest()
        {
            var AWS_ENABLED    = Environment.GetEnvironmentVariable("AWS_ENABLED") ?? "true";
            var AWS_REGION     = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1";
            var AWS_ACCOUNT    = Environment.GetEnvironmentVariable("AWS_ACCOUNT");
            var AWS_ACCESS_ID  = Environment.GetEnvironmentVariable("AWS_ACCESS_ID") ?? "AKIAI2B3PGHEAAK4BPUQ";
            var AWS_ACCESS_KEY = Environment.GetEnvironmentVariable("AWS_ACCESS_KEY") ?? "zQZGX0vGL6OD936fCcP1v6YmpiSdW28oUcezAnb7";

            _enabled = BooleanConverter.ToBoolean(AWS_ENABLED);

            if (_enabled)
            {
                _counters = new CloudWatchCounters();
                _counters.Configure(ConfigParams.FromTuples(
                                        "interval", "5000",
                                        "connection.region", AWS_REGION,
                                        "connection.account", AWS_ACCOUNT,
                                        "credential.access_id", AWS_ACCESS_ID,
                                        "credential.access_key", AWS_ACCESS_KEY
                                        ));

                var contextInfo = new ContextInfo();
                contextInfo.Name        = "Test";
                contextInfo.Description = "This is a test container";

                var references = References.FromTuples(
                    new Descriptor("pip-services3", "context-info", "default", "default", "1.0"), contextInfo,
                    new Descriptor("pip-services3", "counters", "prometheus", "default", "1.0"), _counters
                    );
                _counters.SetReferences(references);

                _fixture = new CountersFixture(_counters);

                _counters.OpenAsync(null).Wait();
            }
        }
示例#12
0
        public async Task <BlobInfoV1> GetBlobByIdAsync(string correlationId, string id)
        {
            CheckOpened(correlationId);

            try
            {
                var result = await _client.GetObjectMetadataAsync(new GetObjectMetadataRequest
                {
                    BucketName = _bucket,
                    Key        = id
                });

                var item = new BlobInfoV1
                {
                    Id          = id,
                    Group       = DecodeString(result.Metadata["group"]),
                    Name        = DecodeString(result.Metadata["name"]),
                    Size        = result.ContentLength,
                    ContentType = result.Headers.ContentType,
                    CreateTime  = result.LastModified,
                    ExpireTime  = result.Headers.Expires,
                    Completed   = BooleanConverter.ToBoolean(result.Metadata["completed"])
                };

                return(item);
            }
            catch (AmazonS3Exception ex)
            {
                if (ex.ErrorCode == "NotFound")
                {
                    return(null);
                }

                throw;
            }
        }
示例#13
0
 public void VerbaAliasFalseBooleanTest(string alias)
 {
     Assert.False(BooleanConverter.ToBoolean(alias));
 }