29 using System.Collections.Generic;
31 using System.Reflection;
32 using System.Threading;
35 using NUnit.Framework;
38 using OpenSim.Framework;
39 using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
40 using OpenSim.Region.Framework.Scenes;
42 using OpenSim.Tests.Common;
56 IConfigSource config =
new IniConfigSource();
57 config.AddConfig(
"Modules");
58 config.AddConfig(
"GridService");
59 config.Configs[
"Modules"].Set(
"GridServices",
"LocalGridServicesConnector");
60 config.Configs[
"GridService"].Set(
"LocalServiceModule",
"OpenSim.Services.GridService.dll:GridService");
61 config.Configs[
"GridService"].Set(
"StorageProvider",
"OpenSim.Data.Null.dll");
62 config.Configs[
"GridService"].Set(
"Region_Test_Region_1",
"DefaultRegion");
63 config.Configs[
"GridService"].Set(
"Region_Test_Region_2",
"FallbackRegion");
64 config.Configs[
"GridService"].Set(
"Region_Test_Region_3",
"FallbackRegion");
65 config.Configs[
"GridService"].Set(
"Region_Other_Region_4",
"FallbackRegion");
76 TestHelpers.InMethod();
81 r1.RegionName =
"Test Region 1";
82 r1.RegionID =
new UUID(1);
84 r1.RegionLocY = 1000 * (
int)Constants.RegionSize;
85 r1.ExternalHostName =
"127.0.0.1";
87 r1.InternalEndPoint =
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(
"0.0.0.0"), 0);
89 s.RegionInfo.RegionID = r1.RegionID;
90 m_LocalConnector.AddRegion(s);
93 r2.RegionName =
"Test Region 2";
94 r2.RegionID =
new UUID(2);
96 r2.RegionLocY = 1000 * (
int)Constants.RegionSize;
97 r2.ExternalHostName =
"127.0.0.1";
99 r2.InternalEndPoint =
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(
"0.0.0.0"), 0);
101 s.RegionInfo.RegionID = r2.RegionID;
102 m_LocalConnector.AddRegion(s);
105 r3.RegionName =
"Test Region 3";
106 r3.RegionID =
new UUID(3);
108 r3.RegionLocY = 1000 * (
int)Constants.RegionSize;
109 r3.ExternalHostName =
"127.0.0.1";
111 r3.InternalEndPoint =
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(
"0.0.0.0"), 0);
113 s.RegionInfo.RegionID = r3.RegionID;
114 m_LocalConnector.AddRegion(s);
117 r4.RegionName =
"Other Region 4";
118 r4.RegionID =
new UUID(4);
120 r4.RegionLocY = 1002 * (
int)Constants.RegionSize;
121 r4.ExternalHostName =
"127.0.0.1";
123 r4.InternalEndPoint =
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(
"0.0.0.0"), 0);
125 s.RegionInfo.RegionID = r4.RegionID;
126 m_LocalConnector.AddRegion(s);
128 m_LocalConnector.RegisterRegion(UUID.Zero, r1);
130 GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero,
"Test");
131 Assert.IsNull(result,
"Retrieved GetRegionByName \"Test\" is not null");
133 result = m_LocalConnector.GetRegionByName(UUID.Zero,
"Test Region 1");
134 Assert.IsNotNull(result,
"Retrieved GetRegionByName is null");
135 Assert.That(result.RegionName, Is.EqualTo(
"Test Region 1"),
"Retrieved region's name does not match");
137 m_LocalConnector.RegisterRegion(UUID.Zero, r2);
138 m_LocalConnector.RegisterRegion(UUID.Zero, r3);
139 m_LocalConnector.RegisterRegion(UUID.Zero, r4);
141 result = m_LocalConnector.GetRegionByUUID(UUID.Zero,
new UUID(1));
142 Assert.IsNotNull(result,
"Retrieved GetRegionByUUID is null");
143 Assert.That(result.RegionID, Is.EqualTo(
new UUID(1)),
"Retrieved region's UUID does not match");
145 result = m_LocalConnector.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000));
146 Assert.IsNotNull(result,
"Retrieved GetRegionByPosition is null");
147 Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)
Constants.
RegionSize),
"Retrieved region's position does not match");
149 List<GridRegion> results = m_LocalConnector.GetNeighbours(UUID.Zero,
new UUID(1));
150 Assert.IsNotNull(results,
"Retrieved neighbours list is null");
151 Assert.That(results.Count, Is.EqualTo(1),
"Retrieved neighbour collection is greater than expected");
152 Assert.That(results[0].RegionID, Is.EqualTo(
new UUID(2)),
"Retrieved region's UUID does not match");
154 results = m_LocalConnector.GetRegionsByName(UUID.Zero,
"Test", 10);
155 Assert.IsNotNull(results,
"Retrieved GetRegionsByName collection is null");
156 Assert.That(results.Count, Is.EqualTo(3),
"Retrieved neighbour collection is less than expected");
158 results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)
Constants.
RegionSize, 1002 * (
int)Constants.RegionSize,
160 Assert.IsNotNull(results,
"Retrieved GetRegionRange collection is null");
161 Assert.That(results.Count, Is.EqualTo(2),
"Retrieved neighbour collection is not the number expected");
163 results = m_LocalConnector.GetDefaultRegions(UUID.Zero);
164 Assert.IsNotNull(results,
"Retrieved GetDefaultRegions collection is null");
165 Assert.That(results.Count, Is.EqualTo(1),
"Retrieved default regions collection has not the expected size");
166 Assert.That(results[0].RegionID, Is.EqualTo(
new UUID(1)),
"Retrieved default region's UUID does not match");
168 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r1.RegionLocX, r1.RegionLocY);
169 Assert.IsNotNull(results,
"Retrieved GetFallbackRegions collection for region 1 is null");
170 Assert.That(results.Count, Is.EqualTo(3),
"Retrieved fallback regions collection for region 1 has not the expected size");
171 Assert.That(results[0].RegionID, Is.EqualTo(
new UUID(2)),
"Retrieved fallback regions for default region are not in the expected order 2-4-3");
172 Assert.That(results[1].RegionID, Is.EqualTo(
new UUID(4)),
"Retrieved fallback regions for default region are not in the expected order 2-4-3");
173 Assert.That(results[2].RegionID, Is.EqualTo(
new UUID(3)),
"Retrieved fallback regions for default region are not in the expected order 2-4-3");
175 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r2.RegionLocX, r2.RegionLocY);
176 Assert.IsNotNull(results,
"Retrieved GetFallbackRegions collection for region 2 is null");
177 Assert.That(results.Count, Is.EqualTo(3),
"Retrieved fallback regions collection for region 2 has not the expected size");
178 Assert.That(results[0].RegionID, Is.EqualTo(
new UUID(2)),
"Retrieved fallback regions are not in the expected order 2-4-3");
179 Assert.That(results[1].RegionID, Is.EqualTo(
new UUID(4)),
"Retrieved fallback regions are not in the expected order 2-4-3");
180 Assert.That(results[2].RegionID, Is.EqualTo(
new UUID(3)),
"Retrieved fallback regions are not in the expected order 2-4-3");
182 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r3.RegionLocX, r3.RegionLocY);
183 Assert.IsNotNull(results,
"Retrieved GetFallbackRegions collection for region 3 is null");
184 Assert.That(results.Count, Is.EqualTo(3),
"Retrieved fallback regions collection for region 3 has not the expected size");
185 Assert.That(results[0].RegionID, Is.EqualTo(
new UUID(3)),
"Retrieved fallback regions are not in the expected order 3-4-2");
186 Assert.That(results[1].RegionID, Is.EqualTo(
new UUID(4)),
"Retrieved fallback regions are not in the expected order 3-4-2");
187 Assert.That(results[2].RegionID, Is.EqualTo(
new UUID(2)),
"Retrieved fallback regions are not in the expected order 3-4-2");
189 results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r4.RegionLocX, r4.RegionLocY);
190 Assert.IsNotNull(results,
"Retrieved GetFallbackRegions collection for region 4 is null");
191 Assert.That(results.Count, Is.EqualTo(3),
"Retrieved fallback regions collection for region 4 has not the expected size");
192 Assert.That(results[0].RegionID, Is.EqualTo(
new UUID(4)),
"Retrieved fallback regions are not in the expected order 4-3-2");
193 Assert.That(results[1].RegionID, Is.EqualTo(
new UUID(3)),
"Retrieved fallback regions are not in the expected order 4-3-2");
194 Assert.That(results[2].RegionID, Is.EqualTo(
new UUID(2)),
"Retrieved fallback regions are not in the expected order 4-3-2");
196 results = m_LocalConnector.GetHyperlinks(UUID.Zero);
197 Assert.IsNotNull(results,
"Retrieved GetHyperlinks list is null");
198 Assert.That(results.Count, Is.EqualTo(0),
"Retrieved linked regions collection is not the number expected");
OpenSim.Framework.RegionInfo RegionInfo
void TestRegisterRegion()
Test region registration.
Interactive OpenSim region server
OpenSim.Services.Interfaces.GridRegion GridRegion
OpenSim.Services.Interfaces.GridRegion GridRegion