diff options
author | Justin Clark-Casey (justincc) | 2010-09-06 23:00:24 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-09-06 23:00:24 +0100 |
commit | 953b7f491798e97b7b36808e716975b22d80114b (patch) | |
tree | ca42d90b890b05457b6a9fd736929382911c85cd /OpenSim/Region/Framework | |
parent | Reflect the ParcelPropertiesUpdateRequest into Scene.EventManager, because (diff) | |
download | opensim-SC_OLD-953b7f491798e97b7b36808e716975b22d80114b.zip opensim-SC_OLD-953b7f491798e97b7b36808e716975b22d80114b.tar.gz opensim-SC_OLD-953b7f491798e97b7b36808e716975b22d80114b.tar.bz2 opensim-SC_OLD-953b7f491798e97b7b36808e716975b22d80114b.tar.xz |
Add test to check persistence of newly added pre-linked objects
Added a MockRegionDataPlugin to do in-memory persistence for tests since adding this to OpenSim.Data.Null.NullDataStore doesn't seem appropriate
NullDataStore can do nothing because OpenSim only ever retrieve region objects from the database on startup. Adding an in-memory store here would be unecessary overhead.
Diffstat (limited to 'OpenSim/Region/Framework')
7 files changed, 78 insertions, 21 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 7bcc4db..c434e4f 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -684,7 +684,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
684 | } | 684 | } |
685 | } | 685 | } |
686 | 686 | ||
687 | public void TriggerOnBackup(IRegionDataStore dstore) | 687 | public void TriggerOnBackup(IRegionDataStore dstore, bool forced) |
688 | { | 688 | { |
689 | OnBackupDelegate handlerOnAttach = OnBackup; | 689 | OnBackupDelegate handlerOnAttach = OnBackup; |
690 | if (handlerOnAttach != null) | 690 | if (handlerOnAttach != null) |
@@ -693,7 +693,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
693 | { | 693 | { |
694 | try | 694 | try |
695 | { | 695 | { |
696 | d(dstore, false); | 696 | d(dstore, forced); |
697 | } | 697 | } |
698 | catch (Exception e) | 698 | catch (Exception e) |
699 | { | 699 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 49f29ad..93882ba 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1531,15 +1531,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1531 | Backup(); | 1531 | Backup(); |
1532 | } | 1532 | } |
1533 | 1533 | ||
1534 | public void Backup() | ||
1535 | { | ||
1536 | Backup(false); | ||
1537 | } | ||
1538 | |||
1534 | /// <summary> | 1539 | /// <summary> |
1535 | /// Backup the scene. This acts as the main method of the backup thread. | 1540 | /// Backup the scene. This acts as the main method of the backup thread. |
1536 | /// </summary> | 1541 | /// </summary> |
1542 | /// <param name="forced"> | ||
1543 | /// If true, then any changes that have not yet been persisted are persisted. If false, | ||
1544 | /// then the persistence decision is left to the backup code (in some situations, such as object persistence, | ||
1545 | /// it's much more efficient to backup multiple changes at once rather than every single one). | ||
1537 | /// <returns></returns> | 1546 | /// <returns></returns> |
1538 | public void Backup() | 1547 | public void Backup(bool forced) |
1539 | { | 1548 | { |
1540 | lock (m_returns) | 1549 | lock (m_returns) |
1541 | { | 1550 | { |
1542 | EventManager.TriggerOnBackup(m_storageManager.DataStore); | 1551 | EventManager.TriggerOnBackup(m_storageManager.DataStore, forced); |
1543 | m_backingup = false; | 1552 | m_backingup = false; |
1544 | 1553 | ||
1545 | foreach (KeyValuePair<UUID, ReturnInfo> ret in m_returns) | 1554 | foreach (KeyValuePair<UUID, ReturnInfo> ret in m_returns) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 64a6dd5..b8b3db5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -1383,12 +1383,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1383 | if (!m_isBackedUp) | 1383 | if (!m_isBackedUp) |
1384 | return; | 1384 | return; |
1385 | 1385 | ||
1386 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | ||
1387 | // any exception propogate upwards. | ||
1388 | |||
1389 | if (IsDeleted || UUID == UUID.Zero) | 1386 | if (IsDeleted || UUID == UUID.Zero) |
1390 | return; | 1387 | return; |
1391 | 1388 | ||
1389 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | ||
1390 | // any exception propogate upwards. | ||
1392 | try | 1391 | try |
1393 | { | 1392 | { |
1394 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 1393 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs index e140cd5..3a0dd00 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs | |||
@@ -28,20 +28,21 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using NUnit.Framework; | ||
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
33 | 34 | using OpenSim.Tests.Common; | |
34 | using NUnit.Framework; | ||
35 | 35 | ||
36 | namespace OpenSim.Region.Framework.Scenes.Tests | 36 | namespace OpenSim.Region.Framework.Scenes.Tests |
37 | { | 37 | { |
38 | [TestFixture] | 38 | [TestFixture] |
39 | public class BorderTests | 39 | public class BorderTests |
40 | { | 40 | { |
41 | |||
42 | [Test] | 41 | [Test] |
43 | public void TestCross() | 42 | public void TestCross() |
44 | { | 43 | { |
44 | TestHelper.InMethod(); | ||
45 | |||
45 | List<Border> testborders = new List<Border>(); | 46 | List<Border> testborders = new List<Border>(); |
46 | 47 | ||
47 | Border NorthBorder = new Border(); | 48 | Border NorthBorder = new Border(); |
@@ -75,8 +76,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
75 | position = new Vector3(200,280,21); | 76 | position = new Vector3(200,280,21); |
76 | Assert.That(NorthBorder.TestCross(position)); | 77 | Assert.That(NorthBorder.TestCross(position)); |
77 | 78 | ||
78 | |||
79 | |||
80 | // Test automatic border crossing | 79 | // Test automatic border crossing |
81 | // by setting the border crossing aabb to be the whole region | 80 | // by setting the border crossing aabb to be the whole region |
82 | position = new Vector3(25,25,21); // safely within one 256m region | 81 | position = new Vector3(25,25,21); // safely within one 256m region |
@@ -95,12 +94,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
95 | 94 | ||
96 | WestBorder.BorderLine = new Vector3(0, 256, 255); // automatic border cross in the region | 95 | WestBorder.BorderLine = new Vector3(0, 256, 255); // automatic border cross in the region |
97 | Assert.That(WestBorder.TestCross(position)); | 96 | Assert.That(WestBorder.TestCross(position)); |
98 | |||
99 | } | 97 | } |
100 | 98 | ||
101 | [Test] | 99 | [Test] |
102 | public void TestCrossSquare512() | 100 | public void TestCrossSquare512() |
103 | { | 101 | { |
102 | TestHelper.InMethod(); | ||
103 | |||
104 | List<Border> testborders = new List<Border>(); | 104 | List<Border> testborders = new List<Border>(); |
105 | 105 | ||
106 | Border NorthBorder = new Border(); | 106 | Border NorthBorder = new Border(); |
@@ -174,12 +174,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
174 | Assert.That(!b.TestCross(position)); | 174 | Assert.That(!b.TestCross(position)); |
175 | 175 | ||
176 | } | 176 | } |
177 | |||
178 | } | 177 | } |
179 | 178 | ||
180 | [Test] | 179 | [Test] |
181 | public void TestCrossRectangle512x256() | 180 | public void TestCrossRectangle512x256() |
182 | { | 181 | { |
182 | TestHelper.InMethod(); | ||
183 | |||
183 | List<Border> testborders = new List<Border>(); | 184 | List<Border> testborders = new List<Border>(); |
184 | 185 | ||
185 | Border NorthBorder = new Border(); | 186 | Border NorthBorder = new Border(); |
@@ -258,6 +259,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
258 | [Test] | 259 | [Test] |
259 | public void TestCrossOdd512x512w256hole() | 260 | public void TestCrossOdd512x512w256hole() |
260 | { | 261 | { |
262 | TestHelper.InMethod(); | ||
263 | |||
261 | List<Border> testborders = new List<Border>(); | 264 | List<Border> testborders = new List<Border>(); |
262 | // 512____ | 265 | // 512____ |
263 | // | | | 266 | // | | |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs index 3e2a2af..b3c3e22 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs | |||
@@ -53,7 +53,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
53 | public void T010_AddObjects() | 53 | public void T010_AddObjects() |
54 | { | 54 | { |
55 | TestHelper.InMethod(); | 55 | TestHelper.InMethod(); |
56 | // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); | ||
57 | 56 | ||
58 | random = new Random(); | 57 | random = new Random(); |
59 | SceneObjectGroup found; | 58 | SceneObjectGroup found; |
@@ -89,7 +88,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
89 | public void T011_ThreadAddRemoveTest() | 88 | public void T011_ThreadAddRemoveTest() |
90 | { | 89 | { |
91 | TestHelper.InMethod(); | 90 | TestHelper.InMethod(); |
92 | // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); | ||
93 | 91 | ||
94 | // This test adds and removes with mutiple threads, attempting to break the | 92 | // This test adds and removes with mutiple threads, attempting to break the |
95 | // uuid and localid dictionary coherence. | 93 | // uuid and localid dictionary coherence. |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index 0b7608d..bfed204 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | |||
@@ -26,13 +26,13 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using NUnit.Framework; | 31 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | 32 | using NUnit.Framework.SyntaxHelpers; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
35 | |||
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
38 | using OpenSim.Tests.Common.Mock; | 38 | using OpenSim.Tests.Common.Mock; |
@@ -260,5 +260,54 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
260 | && (part4.RotationOffset.W - compareQuaternion.W < 0.00003), | 260 | && (part4.RotationOffset.W - compareQuaternion.W < 0.00003), |
261 | "Badness 3"); | 261 | "Badness 3"); |
262 | } | 262 | } |
263 | |||
264 | /// <summary> | ||
265 | /// Test that a new scene object which is already linked is correctly persisted to the persistence layer. | ||
266 | /// </summary> | ||
267 | [Test] | ||
268 | public void TestNewSceneObjectLinkPersistence() | ||
269 | { | ||
270 | TestHelper.InMethod(); | ||
271 | log4net.Config.XmlConfigurator.Configure(); | ||
272 | |||
273 | TestScene scene = SceneSetupHelpers.SetupScene(); | ||
274 | |||
275 | string rootPartName = "rootpart"; | ||
276 | UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); | ||
277 | string linkPartName = "linkpart"; | ||
278 | UUID linkPartUuid = new UUID("00000000-0000-0000-0001-000000000000"); | ||
279 | |||
280 | SceneObjectPart rootPart | ||
281 | = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | ||
282 | { Name = rootPartName, UUID = rootPartUuid }; | ||
283 | SceneObjectPart linkPart | ||
284 | = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | ||
285 | { Name = linkPartName, UUID = linkPartUuid }; | ||
286 | |||
287 | SceneObjectGroup sog = new SceneObjectGroup(rootPart); | ||
288 | sog.AddPart(linkPart); | ||
289 | scene.AddNewSceneObject(sog, true); | ||
290 | |||
291 | // In a test, we have to crank the backup handle manually. Normally this would be done by the timer invoked | ||
292 | // scene backup thread. | ||
293 | scene.Backup(true); | ||
294 | |||
295 | List<SceneObjectGroup> storedObjects = scene.StorageManager.DataStore.LoadObjects(scene.RegionInfo.RegionID); | ||
296 | Assert.That(storedObjects.Count, Is.EqualTo(1)); | ||
297 | Assert.That(storedObjects[0].Children.Count, Is.EqualTo(2)); | ||
298 | Assert.That(storedObjects[0].RootPart.UUID, Is.EqualTo(rootPartUuid)); | ||
299 | // TODO: assertion for child prim | ||
300 | } | ||
301 | |||
302 | /// <summary> | ||
303 | /// Test that a delink is correctly persisted to the database | ||
304 | /// </summary> | ||
305 | // [Test] | ||
306 | // public void TestDelinkPersistence() | ||
307 | // { | ||
308 | // TestHelper.InMethod(); | ||
309 | // | ||
310 | // Scene scene = SceneSetupHelpers.SetupScene(); | ||
311 | // } | ||
263 | } | 312 | } |
264 | } | 313 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index e39a362..ab5968c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -173,6 +173,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
173 | 173 | ||
174 | Assert.That(neighbours.Count, Is.EqualTo(2)); | 174 | Assert.That(neighbours.Count, Is.EqualTo(2)); |
175 | } | 175 | } |
176 | |||
176 | public void fixNullPresence() | 177 | public void fixNullPresence() |
177 | { | 178 | { |
178 | string firstName = "testfirstname"; | 179 | string firstName = "testfirstname"; |
@@ -389,8 +390,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
389 | 390 | ||
390 | public static string GetRandomCapsObjectPath() | 391 | public static string GetRandomCapsObjectPath() |
391 | { | 392 | { |
392 | TestHelper.InMethod(); | ||
393 | |||
394 | UUID caps = UUID.Random(); | 393 | UUID caps = UUID.Random(); |
395 | string capsPath = caps.ToString(); | 394 | string capsPath = caps.ToString(); |
396 | capsPath = capsPath.Remove(capsPath.Length - 4, 4); | 395 | capsPath = capsPath.Remove(capsPath.Length - 4, 4); |
@@ -429,4 +428,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
429 | return name.ToString(); | 428 | return name.ToString(); |
430 | } | 429 | } |
431 | } | 430 | } |
432 | } | 431 | } \ No newline at end of file |