Beispiel #1
0
        public void Config_NewConfigTest()
        {
            TextReader input = File.OpenText("Config_TestSiloConfig.xml");
            ClusterConfiguration config = new ClusterConfiguration();
            config.Load(input);
            input.Close();

            Assert.AreEqual<int>(2, config.Globals.SeedNodes.Count, "Seed node count is incorrect");
            Assert.AreEqual<IPEndPoint>(new IPEndPoint(IPAddress.Loopback, 11111), config.Globals.SeedNodes[0], "First seed node is set incorrectly");
            Assert.AreEqual<IPEndPoint>(new IPEndPoint(IPAddress.IPv6Loopback, 22222), config.Globals.SeedNodes[1], "Second seed node is set incorrectly");

            Assert.AreEqual<int>(12345, config.Defaults.Port, "Default port is set incorrectly");
            Assert.AreEqual<string>("UnitTests.General.TestStartup,Tester", config.Defaults.StartupTypeName);

            NodeConfiguration nc;
            bool hasNodeConfig = config.TryGetNodeConfigurationForSilo("Node1", out nc);
            Assert.IsTrue(hasNodeConfig, "Node Node1 has config");
            Assert.AreEqual<int>(11111, nc.Port, "Port is set incorrectly for node Node1");
            Assert.IsTrue(nc.IsPrimaryNode, "Node1 should be primary node");
            Assert.IsTrue(nc.IsSeedNode, "Node1 should be seed node");
            Assert.IsFalse(nc.IsGatewayNode, "Node1 should not be gateway node");
            Assert.AreEqual<string>("UnitTests.General.TestStartup,Tester", nc.StartupTypeName, "Startup type should be copied automatically");

            hasNodeConfig = config.TryGetNodeConfigurationForSilo("Node2", out nc);
            Assert.IsTrue(hasNodeConfig, "Node Node2 has config");
            Assert.AreEqual<int>(22222, nc.Port, "Port is set incorrectly for node Node2");
            Assert.IsFalse(nc.IsPrimaryNode, "Node2 should not be primary node");
            Assert.IsTrue(nc.IsSeedNode, "Node2 should be seed node");
            Assert.IsTrue(nc.IsGatewayNode, "Node2 should be gateway node");

            hasNodeConfig = config.TryGetNodeConfigurationForSilo("Store", out nc);
            Assert.IsTrue(hasNodeConfig, "Node Store has config");
            Assert.AreEqual<int>(12345, nc.Port, "IP port is set incorrectly for node Store");
            Assert.IsFalse(nc.IsPrimaryNode, "Store should not be primary node");
            Assert.IsFalse(nc.IsSeedNode, "Store should not be seed node");
            Assert.IsFalse(nc.IsGatewayNode, "Store should not be gateway node");

            //IPAddress[] ips = Dns.GetHostAddresses("");
            //IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, 12345);
            //for (int i = 0; i < ips.Length; i++)
            //{
            //    if ((ips[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) && !IPAddress.Loopback.Equals(ips[i]))
            //    {
            //        ep = new IPEndPoint(ips[i], 12345);
            //        break;
            //    }
            //}

            //Assert.AreEqual<IPEndPoint>(ep, nc.Endpoint, "IP endpoint is set incorrectly for node Store");
        }
Beispiel #2
0
        public void Limits_ServerConfig_NotSpecified_WithDefault()
        {
            const string filename = "Config_LogConsumers-OrleansConfiguration.xml";
            var orleansConfig = new ClusterConfiguration();
            orleansConfig.LoadFromFile(filename);
            NodeConfiguration config;
            bool hasNodeConfig = orleansConfig.TryGetNodeConfigurationForSilo("Primary", out config);
            Assert.IsTrue(hasNodeConfig, "Node Primary has config");

            string limitName;
            LimitValue limit;
            for (int i = 1; i <= 3; i++)
            {
                limitName = "NotPresent" + i;
                limit = config.LimitManager.GetLimit(limitName, i);
                Assert.IsNotNull(limit);
                Assert.AreEqual(limitName, limit.Name, "Limit name " + i);
                Assert.AreEqual(i, limit.SoftLimitThreshold, "Soft limit " + i);
                Assert.AreEqual(0, limit.HardLimitThreshold, "No Hard limit " + i);
            }
            for (int i = 1; i <= 3; i++)
            {
                limitName = "NotPresent" + i;
                limit = config.LimitManager.GetLimit(limitName, i, 2 * i);
                Assert.IsNotNull(limit);
                Assert.AreEqual(limitName, limit.Name, "Limit name " + i);
                Assert.AreEqual(i, limit.SoftLimitThreshold, "Soft limit " + i);
                Assert.AreEqual(2 * i, limit.HardLimitThreshold, "Hard limit " + i);
            }
        }
Beispiel #3
0
        public void Limits_ServerConfig()
        {
            const string filename = "Config_LogConsumers-OrleansConfiguration.xml";
            var orleansConfig = new ClusterConfiguration();
            orleansConfig.LoadFromFile(filename);
            NodeConfiguration config;
            bool hasNodeConfig = orleansConfig.TryGetNodeConfigurationForSilo("Primary", out config);
            Assert.IsTrue(hasNodeConfig, "Node Primary has config");


            string limitName;
            LimitValue limit;
            //Assert.IsTrue(config.LimitManager.LimitValues.Count >= 3, "Number of LimitValues: " + string.Join(",", config.LimitValues));
            for (int i = 1; i <= 3; i++)
            {
                limitName = "Limit" + i;
                limit = config.LimitManager.GetLimit(limitName);
                Assert.IsNotNull(limit);
                Assert.AreEqual(limitName, limit.Name, "Limit name " + i);
                Assert.AreEqual(i, limit.SoftLimitThreshold, "Soft limit " + i);
                Assert.AreEqual(2 * i, limit.HardLimitThreshold, "Hard limit " + i);
            }

            limitName = "NoHardLimit";
            limit = config.LimitManager.GetLimit(limitName);
            Assert.IsNotNull(limit);
            Assert.AreEqual(limitName, limit.Name, "Limit name " + limitName);
            Assert.AreEqual(4, limit.SoftLimitThreshold, "Soft limit " + limitName);
            Assert.AreEqual(0, limit.HardLimitThreshold, "Hard limit " + limitName);
        }
Beispiel #4
0
        public void Limits_ServerConfig_NotSpecified()
        {
            const string filename = "Config_LogConsumers-OrleansConfiguration.xml";
            var orleansConfig = new ClusterConfiguration();
            orleansConfig.LoadFromFile(filename);
            NodeConfiguration config;
            bool hasNodeConfig = orleansConfig.TryGetNodeConfigurationForSilo("Primary", out config);
            Assert.IsTrue(hasNodeConfig, "Node Primary has config");


            string limitName = "NotPresent";
            LimitValue limit = config.LimitManager.GetLimit(limitName);
            Assert.AreEqual(0, limit.SoftLimitThreshold);
            Assert.AreEqual(0, limit.HardLimitThreshold);
            Assert.AreEqual(limitName, limit.Name);
        }
Beispiel #5
0
        public void Limits_LimitsManager_ServerConfig()
        {
            const string filename = "Config_LogConsumers-OrleansConfiguration.xml";
            var orleansConfig = new ClusterConfiguration();
            orleansConfig.LoadFromFile(filename);
            NodeConfiguration config;
            bool hasNodeConfig = orleansConfig.TryGetNodeConfigurationForSilo("Primary", out config);
            Assert.True(hasNodeConfig, "Node Primary has config");


            string limitName;
            LimitValue limit;
            for (int i = 1; i <= 3; i++)
            {
                limitName = "Limit" + i;
                limit = config.LimitManager.GetLimit(limitName);
                Assert.NotNull(limit);
                Assert.Equal(limitName, limit.Name); // Limit name " + i
                Assert.Equal(i, limit.SoftLimitThreshold); // Soft limit " + i
                Assert.Equal(2 * i, limit.HardLimitThreshold); // Hard limit " + i
            }

            limitName = "NoHardLimit";
            limit = config.LimitManager.GetLimit(limitName);
            Assert.NotNull(limit);
            Assert.Equal(limitName, limit.Name); // Limit name " + limitName
            Assert.Equal(4, limit.SoftLimitThreshold); // Soft limit " + limitName
            Assert.Equal(0, limit.HardLimitThreshold); // No Hard limit " + limitName

            limitName = "NotPresent";
            limit = config.LimitManager.GetLimit(limitName);
            Assert.NotNull(limit);
            Assert.Equal(limitName, limit.Name); // Limit name " + limitName
            Assert.Equal(0, limit.SoftLimitThreshold); // No Soft limit " + limitName
            Assert.Equal(0, limit.HardLimitThreshold); // No Hard limit " + limitName
        }