Exemple #1
0
        public void CanPutKeyTwice()
        {
            LocalKeyValueStore store = new LocalKeyValueStore();

            TestUtils.SinglePutGet(store, "key1", "value1");
            TestUtils.SinglePutGet(store, "key1", "value2");
        }
Exemple #2
0
        public void CannotPutEmptyStringKey()
        {
            LocalKeyValueStore store = new LocalKeyValueStore();

            Assert.Throws <ArgumentException>(() =>
            {
                TestUtils.SinglePutGet(store, string.Empty, "value");
            });
        }
Exemple #3
0
        public void CanPutEmptyString()
        {
            LocalKeyValueStore store = new LocalKeyValueStore();

            TestUtils.SinglePutGet(store, "key1", string.Empty);

            Assert.Throws <ArgumentNullException>(() =>
            {
                TestUtils.SinglePutGet(store, "key1", null);
            });
        }
Exemple #4
0
        public void CanPutAndRetrieve()
        {
            LocalKeyValueStore store = new LocalKeyValueStore();

            TestUtils.SinglePutGet(store, "key1", "value1");
            TestUtils.SinglePutGet(store, "key2", "value2");

            // Keys are case-sensitive:
            string notFound = string.Empty;

            TestUtils.AssertGet(store, "KEY1", notFound);
        }
Exemple #5
0
        public void CanDeleteKey()
        {
            LocalKeyValueStore store = new LocalKeyValueStore();

            const string key = "key_to_be_deleted";

            TestUtils.SinglePutGet(store, key, "value");

            store.Delete(key);

            TestUtils.AssertGet(store, key, string.Empty);

            // Delete non-existent key:
            store.Delete(key);

            TestUtils.AssertGet(store, key, string.Empty);
        }
Exemple #6
0
        private async Task <ServiceRegistry> CreateServiceRegistryAsync()
        {
            Stopwatch watch = Stopwatch.StartNew();

            IKeyValueStore keyValueStore = await TryGetEtcdKeyValueStore();

            List <AgentConfiguration> serviceAgents = new List <AgentConfiguration>();

            if (keyValueStore != null)
            {
                _logger.LogInformation("Connected to distributed key-value store in {millis}ms",
                                       watch.ElapsedMilliseconds);
            }
            else
            {
                _logger.LogWarning(
                    "Unable to connect to distributed key-value store. Using Worker agents from configuration:");

                keyValueStore = new LocalKeyValueStore();

                _keyValueStoreIsLocal = true;

                serviceAgents.AddRange(KnownAgents.Get(WellKnownAgentType.Worker));
            }

            ServiceRegistry serviceRegistry = new ServiceRegistry(keyValueStore, string.Empty);

            AddServices(serviceRegistry, serviceAgents);

            int endpointCount = serviceRegistry.GetTotalEndpointCount(out var serviceCount);

            _logger.LogInformation(
                "Service registry contains {serviceCount} service type(s) at {endpointCount} " +
                "different endpoints.", serviceCount, endpointCount);

            return(serviceRegistry);
        }
Exemple #7
0
        public void CanGetNonExistingKey()
        {
            LocalKeyValueStore store = new LocalKeyValueStore();

            TestUtils.AssertGet(store, "noes not exist", string.Empty);
        }
Exemple #8
0
        public void CanGetRange()
        {
            LocalKeyValueStore store = new LocalKeyValueStore();

            TestUtils.AssertCanGetRange(store);
        }