diff options
author | Diva Canto | 2015-05-10 21:04:46 -0700 |
---|---|---|
committer | Diva Canto | 2015-05-10 21:04:46 -0700 |
commit | c2cf22ea4fc42d8582aa6aa2df48a3ce06813d56 (patch) | |
tree | 67002a585778c1a1729bf5831f27f4e61c861e04 /OpenSim | |
parent | Improved comments on fetch inventory tests (diff) | |
download | opensim-SC-c2cf22ea4fc42d8582aa6aa2df48a3ce06813d56.zip opensim-SC-c2cf22ea4fc42d8582aa6aa2df48a3ce06813d56.tar.gz opensim-SC-c2cf22ea4fc42d8582aa6aa2df48a3ce06813d56.tar.bz2 opensim-SC-c2cf22ea4fc42d8582aa6aa2df48a3ce06813d56.tar.xz |
Added the beginning of a new test framework for robust connectors and services. For now, just Grid and Presence. This framework starts a robust server (as a thread) listening on a port in localhost, then the tests are client code.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Server/Base/ServicesServerBase.cs | 10 | ||||
-rw-r--r-- | OpenSim/Tests/Robust/Clients/Grid/GridClient.cs | 133 | ||||
-rw-r--r-- | OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs | 81 | ||||
-rw-r--r-- | OpenSim/Tests/Robust/Server/DemonServer.cs | 67 |
4 files changed, 289 insertions, 2 deletions
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index d7d1306..1f2c54d 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs | |||
@@ -82,7 +82,9 @@ namespace OpenSim.Server.Base | |||
82 | argvConfig.AddSwitch("Startup", "logconfig", "g"); | 82 | argvConfig.AddSwitch("Startup", "logconfig", "g"); |
83 | 83 | ||
84 | // Automagically create the ini file name | 84 | // Automagically create the ini file name |
85 | string fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); | 85 | string fileName = ""; |
86 | if (Assembly.GetEntryAssembly() != null) | ||
87 | fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); | ||
86 | string iniFile = fileName + ".ini"; | 88 | string iniFile = fileName + ".ini"; |
87 | string logConfig = null; | 89 | string logConfig = null; |
88 | 90 | ||
@@ -158,7 +160,11 @@ namespace OpenSim.Server.Base | |||
158 | MainConsole.Instance = new RemoteConsole(prompt); | 160 | MainConsole.Instance = new RemoteConsole(prompt); |
159 | ((RemoteConsole)MainConsole.Instance).ReadConfig(Config); | 161 | ((RemoteConsole)MainConsole.Instance).ReadConfig(Config); |
160 | } | 162 | } |
161 | else | 163 | else if (consoleType == "mock") |
164 | { | ||
165 | MainConsole.Instance = new MockConsole(); | ||
166 | } | ||
167 | else if (consoleType == "local") | ||
162 | { | 168 | { |
163 | MainConsole.Instance = new LocalConsole(prompt, startupConfig); | 169 | MainConsole.Instance = new LocalConsole(prompt, startupConfig); |
164 | } | 170 | } |
diff --git a/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs b/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs new file mode 100644 index 0000000..671aca7 --- /dev/null +++ b/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using NUnit.Framework; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | using OpenSim.Services.Connectors; | ||
40 | |||
41 | namespace Robust.Tests | ||
42 | { | ||
43 | [TestFixture] | ||
44 | public class GridClient | ||
45 | { | ||
46 | // private static readonly ILog m_log = | ||
47 | // LogManager.GetLogger( | ||
48 | // MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | [Test] | ||
51 | public void Grid_001() | ||
52 | { | ||
53 | GridServicesConnector m_Connector = new GridServicesConnector(DemonServer.Address); | ||
54 | |||
55 | GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000); | ||
56 | GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000); | ||
57 | GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); | ||
58 | |||
59 | string msg = m_Connector.RegisterRegion(UUID.Zero, r1); | ||
60 | Assert.AreEqual(msg, string.Empty, "Region 1 failed to register"); | ||
61 | |||
62 | msg = m_Connector.RegisterRegion(UUID.Zero, r2); | ||
63 | Assert.AreEqual(msg, string.Empty, "Region 2 failed to register"); | ||
64 | |||
65 | msg = m_Connector.RegisterRegion(UUID.Zero, r3); | ||
66 | Assert.AreEqual(msg, string.Empty, "Region 3 failed to register"); | ||
67 | |||
68 | bool success; | ||
69 | success = m_Connector.DeregisterRegion(r3.RegionID); | ||
70 | Assert.AreEqual(success, true, "Region 3 failed to deregister"); | ||
71 | |||
72 | msg = m_Connector.RegisterRegion(UUID.Zero, r3); | ||
73 | Assert.AreEqual(msg, string.Empty, "Region 3 failed to re-register"); | ||
74 | |||
75 | List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID); | ||
76 | Assert.AreNotEqual(regions, null, "GetNeighbours of region 1 failed"); | ||
77 | Assert.AreEqual(regions.Count, 1, "Region 1 should have 1 neighbor"); | ||
78 | Assert.AreEqual(regions[0].RegionName, "Test Region 2", "Region 1 has the wrong neighbor"); | ||
79 | |||
80 | GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID); | ||
81 | Assert.AreNotEqual(region, null, "GetRegionByUUID for region 2 failed"); | ||
82 | Assert.AreEqual(region.RegionName, "Test Region 2", "GetRegionByUUID of region 2 returned wrong region"); | ||
83 | |||
84 | region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random()); | ||
85 | Assert.AreEqual(region, null, "Region with randon id should not exist"); | ||
86 | |||
87 | region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName); | ||
88 | Assert.AreNotEqual(region, null, "GetRegionByUUID for region 3 failed"); | ||
89 | Assert.AreEqual(region.RegionName, "Test Region 3", "GetRegionByUUID of region 3 returned wrong region"); | ||
90 | |||
91 | region = m_Connector.GetRegionByName(UUID.Zero, "Foo"); | ||
92 | Assert.AreEqual(region, null, "Region Foo should not exist"); | ||
93 | |||
94 | regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10); | ||
95 | Assert.AreNotEqual(regions, null, "GetRegionsByName failed"); | ||
96 | Assert.AreEqual(regions.Count, 3, "GetRegionsByName should return 3"); | ||
97 | |||
98 | regions = m_Connector.GetRegionRange(UUID.Zero, | ||
99 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002), | ||
100 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) ); | ||
101 | Assert.AreNotEqual(regions, null, "GetRegionRange failed"); | ||
102 | Assert.AreEqual(regions.Count, 2, "GetRegionRange should return 2"); | ||
103 | |||
104 | regions = m_Connector.GetRegionRange(UUID.Zero, | ||
105 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950), | ||
106 | (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) ); | ||
107 | Assert.AreNotEqual(regions, null, "GetRegionRange (bis) failed"); | ||
108 | Assert.AreEqual(regions.Count, 0, "GetRegionRange (bis) should return 0"); | ||
109 | |||
110 | // Deregister them all | ||
111 | success = m_Connector.DeregisterRegion(r1.RegionID); | ||
112 | Assert.AreEqual(success, true, "Region 1 failed to deregister"); | ||
113 | |||
114 | success = m_Connector.DeregisterRegion(r2.RegionID); | ||
115 | Assert.AreEqual(success, true, "Region 2 failed to deregister"); | ||
116 | |||
117 | success = m_Connector.DeregisterRegion(r3.RegionID); | ||
118 | Assert.AreEqual(success, true, "Region 3 failed to deregister"); | ||
119 | } | ||
120 | |||
121 | private static GridRegion CreateRegion(string name, uint xcell, uint ycell) | ||
122 | { | ||
123 | GridRegion region = new GridRegion(xcell, ycell); | ||
124 | region.RegionName = name; | ||
125 | region.RegionID = UUID.Random(); | ||
126 | region.ExternalHostName = "127.0.0.1"; | ||
127 | region.HttpPort = 9000; | ||
128 | region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000); | ||
129 | |||
130 | return region; | ||
131 | } | ||
132 | } | ||
133 | } | ||
diff --git a/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs new file mode 100644 index 0000000..31c8ee9 --- /dev/null +++ b/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using NUnit.Framework; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Services.Connectors; | ||
39 | |||
40 | namespace Robust.Tests | ||
41 | { | ||
42 | [TestFixture] | ||
43 | public class PresenceClient | ||
44 | { | ||
45 | [Test] | ||
46 | public void Presence_001() | ||
47 | { | ||
48 | PresenceServicesConnector m_Connector = new PresenceServicesConnector(DemonServer.Address); | ||
49 | |||
50 | UUID user1 = UUID.Random(); | ||
51 | UUID session1 = UUID.Random(); | ||
52 | UUID region1 = UUID.Random(); | ||
53 | |||
54 | bool success = m_Connector.LoginAgent(user1.ToString(), session1, UUID.Zero); | ||
55 | Assert.AreEqual(success, true, "Failed to add user session"); | ||
56 | |||
57 | PresenceInfo pinfo = m_Connector.GetAgent(session1); | ||
58 | Assert.AreNotEqual(pinfo, null, "Unable to retrieve session"); | ||
59 | Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID"); | ||
60 | Assert.AreNotEqual(pinfo.RegionID, region1, "Retrieved session is unexpectedly in region"); | ||
61 | |||
62 | success = m_Connector.ReportAgent(session1, region1); | ||
63 | Assert.AreEqual(success, true, "Failed to report session in region 1"); | ||
64 | |||
65 | pinfo = m_Connector.GetAgent(session1); | ||
66 | Assert.AreNotEqual(pinfo, null, "Unable to session presence"); | ||
67 | Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID"); | ||
68 | Assert.AreEqual(pinfo.RegionID, region1, "Retrieved session is not in expected region"); | ||
69 | |||
70 | success = m_Connector.LogoutAgent(session1); | ||
71 | Assert.AreEqual(success, true, "Failed to remove session"); | ||
72 | |||
73 | pinfo = m_Connector.GetAgent(session1); | ||
74 | Assert.AreEqual(pinfo, null, "Session is still there, even though it shouldn't"); | ||
75 | |||
76 | success = m_Connector.ReportAgent(session1, UUID.Random()); | ||
77 | Assert.AreEqual(success, false, "Remove non-existing session should fail"); | ||
78 | } | ||
79 | |||
80 | } | ||
81 | } | ||
diff --git a/OpenSim/Tests/Robust/Server/DemonServer.cs b/OpenSim/Tests/Robust/Server/DemonServer.cs new file mode 100644 index 0000000..b51a6bb --- /dev/null +++ b/OpenSim/Tests/Robust/Server/DemonServer.cs | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Threading; | ||
32 | |||
33 | using Nini.Config; | ||
34 | using log4net; | ||
35 | using NUnit.Framework; | ||
36 | |||
37 | using OpenSim.Server; | ||
38 | |||
39 | namespace Robust.Tests | ||
40 | { | ||
41 | [SetUpFixture] | ||
42 | public class DemonServer : OpenSimServer | ||
43 | { | ||
44 | private Thread m_demon; | ||
45 | |||
46 | public static string Address = "http://localhost:8888"; | ||
47 | |||
48 | [SetUp] | ||
49 | public void StartDemon() | ||
50 | { | ||
51 | if (File.Exists("Robust.Tests.log")) | ||
52 | File.Delete("Robust.Tests.log"); | ||
53 | |||
54 | Console.WriteLine("**** Starting demon Robust server ****"); | ||
55 | m_demon = new Thread( () => Main(new string[] {"-inifile=Robust.Tests.ini"})); | ||
56 | m_demon.Start(); | ||
57 | Console.WriteLine("**** Setup Finished ****"); | ||
58 | } | ||
59 | |||
60 | [TearDown] | ||
61 | public void StopDemon() | ||
62 | { | ||
63 | Console.WriteLine("**** Killing demon Robust Server ****"); | ||
64 | m_Server.Shutdown(); | ||
65 | } | ||
66 | } | ||
67 | } | ||