diff options
Diffstat (limited to 'OpenSim/Tests/Clients/Grid')
-rw-r--r-- | OpenSim/Tests/Clients/Grid/GridClient.cs | 177 | ||||
-rw-r--r-- | OpenSim/Tests/Clients/Grid/GridForm.html | 11 |
2 files changed, 188 insertions, 0 deletions
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs new file mode 100644 index 0000000..941406e --- /dev/null +++ b/OpenSim/Tests/Clients/Grid/GridClient.cs | |||
@@ -0,0 +1,177 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.Reflection; | ||
5 | |||
6 | using OpenMetaverse; | ||
7 | using log4net; | ||
8 | using log4net.Appender; | ||
9 | using log4net.Layout; | ||
10 | |||
11 | using OpenSim.Framework; | ||
12 | using OpenSim.Services.Interfaces; | ||
13 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
14 | using OpenSim.Services.Connectors; | ||
15 | |||
16 | namespace OpenSim.Tests.Clients.GridClient | ||
17 | { | ||
18 | public class GridClient | ||
19 | { | ||
20 | private static readonly ILog m_log = | ||
21 | LogManager.GetLogger( | ||
22 | MethodBase.GetCurrentMethod().DeclaringType); | ||
23 | |||
24 | public static void Main(string[] args) | ||
25 | { | ||
26 | ConsoleAppender consoleAppender = new ConsoleAppender(); | ||
27 | consoleAppender.Layout = | ||
28 | new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); | ||
29 | log4net.Config.BasicConfigurator.Configure(consoleAppender); | ||
30 | |||
31 | string serverURI = "http://127.0.0.1:8002"; | ||
32 | GridServicesConnector m_Connector = new GridServicesConnector(serverURI); | ||
33 | |||
34 | GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000); | ||
35 | GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000); | ||
36 | GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); | ||
37 | |||
38 | Console.WriteLine("[GRID CLIENT]: *** Registering region 1"); | ||
39 | bool success = m_Connector.RegisterRegion(UUID.Zero, r1); | ||
40 | if (success) | ||
41 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 1"); | ||
42 | else | ||
43 | Console.WriteLine("[GRID CLIENT]: region 1 failed to register"); | ||
44 | |||
45 | Console.WriteLine("[GRID CLIENT]: *** Registering region 2"); | ||
46 | success = m_Connector.RegisterRegion(UUID.Zero, r2); | ||
47 | if (success) | ||
48 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 2"); | ||
49 | else | ||
50 | Console.WriteLine("[GRID CLIENT]: region 2 failed to register"); | ||
51 | |||
52 | Console.WriteLine("[GRID CLIENT]: *** Registering region 3"); | ||
53 | success = m_Connector.RegisterRegion(UUID.Zero, r3); | ||
54 | if (success) | ||
55 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); | ||
56 | else | ||
57 | Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); | ||
58 | |||
59 | |||
60 | Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3"); | ||
61 | success = m_Connector.DeregisterRegion(r3.RegionID); | ||
62 | if (success) | ||
63 | Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3"); | ||
64 | else | ||
65 | Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); | ||
66 | Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again"); | ||
67 | success = m_Connector.RegisterRegion(UUID.Zero, r3); | ||
68 | if (success) | ||
69 | Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); | ||
70 | else | ||
71 | Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); | ||
72 | |||
73 | Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1"); | ||
74 | List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID); | ||
75 | if (regions == null) | ||
76 | Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed"); | ||
77 | else if (regions.Count > 0) | ||
78 | { | ||
79 | if (regions.Count != 1) | ||
80 | Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count); | ||
81 | else | ||
82 | Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName); | ||
83 | } | ||
84 | else | ||
85 | Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours"); | ||
86 | |||
87 | |||
88 | Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)"); | ||
89 | GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID); | ||
90 | if (region == null) | ||
91 | Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null"); | ||
92 | else | ||
93 | Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName); | ||
94 | |||
95 | Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)"); | ||
96 | region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random()); | ||
97 | if (region == null) | ||
98 | Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null"); | ||
99 | else | ||
100 | Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName); | ||
101 | |||
102 | Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)"); | ||
103 | region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName); | ||
104 | if (region == null) | ||
105 | Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null"); | ||
106 | else | ||
107 | Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName); | ||
108 | |||
109 | Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)"); | ||
110 | region = m_Connector.GetRegionByName(UUID.Zero, "Foo"); | ||
111 | if (region == null) | ||
112 | Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null"); | ||
113 | else | ||
114 | Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName); | ||
115 | |||
116 | Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)"); | ||
117 | regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10); | ||
118 | if (regions == null) | ||
119 | Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null"); | ||
120 | else | ||
121 | Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions"); | ||
122 | |||
123 | Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)"); | ||
124 | regions = m_Connector.GetRegionRange(UUID.Zero, | ||
125 | 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize, | ||
126 | 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize); | ||
127 | if (regions == null) | ||
128 | Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); | ||
129 | else | ||
130 | Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); | ||
131 | Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)"); | ||
132 | regions = m_Connector.GetRegionRange(UUID.Zero, | ||
133 | 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize, | ||
134 | 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize); | ||
135 | if (regions == null) | ||
136 | Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); | ||
137 | else | ||
138 | Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); | ||
139 | |||
140 | Console.Write("Proceed to deregister? Press enter..."); | ||
141 | Console.ReadLine(); | ||
142 | |||
143 | // Deregister them all | ||
144 | Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1"); | ||
145 | success = m_Connector.DeregisterRegion(r1.RegionID); | ||
146 | if (success) | ||
147 | Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 1"); | ||
148 | else | ||
149 | Console.WriteLine("[GRID CLIENT]: region 1 failed to deregister"); | ||
150 | Console.WriteLine("[GRID CLIENT]: *** Deregistering region 2"); | ||
151 | success = m_Connector.DeregisterRegion(r2.RegionID); | ||
152 | if (success) | ||
153 | Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 2"); | ||
154 | else | ||
155 | Console.WriteLine("[GRID CLIENT]: region 2 failed to deregister"); | ||
156 | Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3"); | ||
157 | success = m_Connector.DeregisterRegion(r3.RegionID); | ||
158 | if (success) | ||
159 | Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3"); | ||
160 | else | ||
161 | Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); | ||
162 | |||
163 | } | ||
164 | |||
165 | private static GridRegion CreateRegion(string name, uint xcell, uint ycell) | ||
166 | { | ||
167 | GridRegion region = new GridRegion(xcell, ycell); | ||
168 | region.RegionName = name; | ||
169 | region.RegionID = UUID.Random(); | ||
170 | region.ExternalHostName = "127.0.0.1"; | ||
171 | region.HttpPort = 9000; | ||
172 | region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000); | ||
173 | |||
174 | return region; | ||
175 | } | ||
176 | } | ||
177 | } | ||
diff --git a/OpenSim/Tests/Clients/Grid/GridForm.html b/OpenSim/Tests/Clients/Grid/GridForm.html new file mode 100644 index 0000000..252920f --- /dev/null +++ b/OpenSim/Tests/Clients/Grid/GridForm.html | |||
@@ -0,0 +1,11 @@ | |||
1 | <html> | ||
2 | |||
3 | <form name="input" action="http://127.0.0.1:8002/grid" method="post"> | ||
4 | xmin:<input type="text" name="XMIN" value="0"> | ||
5 | xmax:<input type="text" name="XMAX" value="0"> | ||
6 | ymin:<input type="text" name="YMIN" value="0"> | ||
7 | ymax:<input type="text" name="YMAX" value="0"> | ||
8 | <input type="hidden" name="METHOD" value="get_region_range"> | ||
9 | <input type="submit" value="Submit" /> | ||
10 | </form> | ||
11 | </html> | ||