public virtual void TestCaching() { Configuration conf = new Configuration(); conf.SetClass(CommonConfigurationKeysPublic.NetTopologyNodeSwitchMappingImplKey, typeof(TestRackResolver.MyResolver), typeof(DNSToSwitchMapping)); RackResolver.Init(conf); try { IPAddress iaddr = Sharpen.Extensions.GetAddressByName("host1"); TestRackResolver.MyResolver.resolvedHost1 = iaddr.GetHostAddress(); } catch (UnknownHostException) { } // Ignore if not found Node node = RackResolver.Resolve("host1"); NUnit.Framework.Assert.AreEqual("/rack1", node.GetNetworkLocation()); node = RackResolver.Resolve("host1"); NUnit.Framework.Assert.AreEqual("/rack1", node.GetNetworkLocation()); node = RackResolver.Resolve(invalidHost); NUnit.Framework.Assert.AreEqual(NetworkTopology.DefaultRack, node.GetNetworkLocation ()); }
public virtual void TestScriptName() { Configuration conf = new Configuration(); conf.SetClass(CommonConfigurationKeysPublic.NetTopologyNodeSwitchMappingImplKey, typeof(ScriptBasedMapping), typeof(DNSToSwitchMapping)); conf.Set(CommonConfigurationKeysPublic.NetTopologyScriptFileNameKey, "testScript" ); RackResolver.Init(conf); NUnit.Framework.Assert.AreEqual(RackResolver.GetDnsToSwitchMapping().ToString(), "script-based mapping with script testScript"); }