aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2015-11-22 08:31:54 +0000
committerUbitUmarov2015-11-22 08:31:54 +0000
commitec069edeadb21097ae8966a04715fed33b9fcba7 (patch)
treed52c7c6cc449068aed1766aca180e7cd01146978
parent revert take the Monitor.wait out of the locks (diff)
downloadopensim-SC-ec069edeadb21097ae8966a04715fed33b9fcba7.zip
opensim-SC-ec069edeadb21097ae8966a04715fed33b9fcba7.tar.gz
opensim-SC-ec069edeadb21097ae8966a04715fed33b9fcba7.tar.bz2
opensim-SC-ec069edeadb21097ae8966a04715fed33b9fcba7.tar.xz
change syncronization method
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs141
1 files changed, 65 insertions, 76 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 385510d..4fd0718 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -66,6 +66,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
66 66
67 protected TaskInventoryItem m_soundItem; 67 protected TaskInventoryItem m_soundItem;
68 68
69 private AutoResetEvent m_oarEvent = new AutoResetEvent(false);
70
69 [SetUp] 71 [SetUp]
70 public override void SetUp() 72 public override void SetUp()
71 { 73 {
@@ -87,8 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
87 m_lastRequestId = requestId; 89 m_lastRequestId = requestId;
88 m_lastErrorMessage = errorMessage; 90 m_lastErrorMessage = errorMessage;
89 Console.WriteLine("About to pulse ArchiverTests on LoadCompleted"); 91 Console.WriteLine("About to pulse ArchiverTests on LoadCompleted");
90 92 m_oarEvent.Set();
91 Monitor.PulseAll(this);
92 } 93 }
93 } 94 }
94 95
@@ -99,7 +100,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
99 m_lastRequestId = requestId; 100 m_lastRequestId = requestId;
100 m_lastErrorMessage = errorMessage; 101 m_lastErrorMessage = errorMessage;
101 Console.WriteLine("About to pulse ArchiverTests on SaveCompleted"); 102 Console.WriteLine("About to pulse ArchiverTests on SaveCompleted");
102 Monitor.PulseAll(this); 103 m_oarEvent.Set();
103 } 104 }
104 } 105 }
105 106
@@ -194,16 +195,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
194 m_scene.EventManager.OnOarFileSaved += SaveCompleted; 195 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
195 196
196 Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); 197 Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
197 198
198 lock (this) 199 m_oarEvent.Reset();
199 { 200 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId);
200 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId); 201 //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer;
201 //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; 202 //while (assetServer.HasWaitingRequests())
202 //while (assetServer.HasWaitingRequests()) 203 // assetServer.ProcessNextRequest();
203 // assetServer.ProcessNextRequest(); 204
204 205 Monitor.Wait( m_oarEvent, 60000);
205 Monitor.Wait(this, 60000);
206 }
207 206
208 Assert.That(m_lastRequestId, Is.EqualTo(requestId)); 207 Assert.That(m_lastRequestId, Is.EqualTo(requestId));
209 208
@@ -289,6 +288,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
289 288
290 Dictionary<string, Object> options = new Dictionary<string, Object>(); 289 Dictionary<string, Object> options = new Dictionary<string, Object>();
291 options.Add("noassets", true); 290 options.Add("noassets", true);
291
292 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); 292 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options);
293 293
294 // Don't wait for completion - with --noassets save oar happens synchronously 294 // Don't wait for completion - with --noassets save oar happens synchronously
@@ -397,13 +397,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
397 397
398 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 398 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
399 399
400 lock (this) 400 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
401 { 401 m_oarEvent.Reset();
402 m_scene.EventManager.OnOarFileLoaded += LoadCompleted; 402 m_archiverModule.DearchiveRegion(archiveReadStream);
403 m_archiverModule.DearchiveRegion(archiveReadStream);
404 Monitor.Wait(this, 60000);
405 }
406 403
404 Monitor.Wait(m_oarEvent, 60000);
405
407 Assert.That(m_lastErrorMessage, Is.Null); 406 Assert.That(m_lastErrorMessage, Is.Null);
408 407
409 TestLoadedRegion(part1, soundItemName, soundData); 408 TestLoadedRegion(part1, soundItemName, soundData);
@@ -447,12 +446,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
447 446
448 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 447 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
449 448
450 lock (this) 449 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
451 { 450 m_oarEvent.Reset();
452 m_scene.EventManager.OnOarFileLoaded += LoadCompleted; 451 m_archiverModule.DearchiveRegion(archiveReadStream);
453 m_archiverModule.DearchiveRegion(archiveReadStream); 452
454 Monitor.Wait(this, 60000); 453 Monitor.Wait(m_oarEvent, 60000);
455 }
456 454
457 Assert.That(m_lastErrorMessage, Is.Null); 455 Assert.That(m_lastErrorMessage, Is.Null);
458 456
@@ -498,14 +496,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
498 496
499 Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); 497 Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
500 498
501 lock (this) 499 m_oarEvent.Reset();
502 { 500 m_archiverModule.ArchiveRegion(
503 m_archiverModule.ArchiveRegion( 501 archiveWriteStream, requestId, new Dictionary<string, Object>() { { "wipe-owners", Boolean.TrueString } });
504 archiveWriteStream, requestId, new Dictionary<string, Object>() { { "wipe-owners", Boolean.TrueString } });
505
506 Monitor.Wait(this, 60000);
507 }
508 502
503 Monitor.Wait(m_oarEvent, 60000);
504
509 Assert.That(m_lastRequestId, Is.EqualTo(requestId)); 505 Assert.That(m_lastRequestId, Is.EqualTo(requestId));
510 506
511 byte[] archive = archiveWriteStream.ToArray(); 507 byte[] archive = archiveWriteStream.ToArray();
@@ -530,11 +526,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
530 526
531 scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner; 527 scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner;
532 528
533 lock (this) 529 scene2.EventManager.OnOarFileLoaded += LoadCompleted;
534 { 530 m_oarEvent.Reset();
535 scene2.EventManager.OnOarFileLoaded += LoadCompleted; 531 archiverModule.DearchiveRegion(archiveReadStream);
536 archiverModule.DearchiveRegion(archiveReadStream); 532
537 } 533 Monitor.Wait(m_oarEvent, 60000);
538 534
539 Assert.That(m_lastErrorMessage, Is.Null); 535 Assert.That(m_lastErrorMessage, Is.Null);
540 536
@@ -595,11 +591,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
595 oarStream = new MemoryStream(oarStream.ToArray()); 591 oarStream = new MemoryStream(oarStream.ToArray());
596 592
597 // Load OAR 593 // Load OAR
598 lock (this) 594 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
599 { 595 m_oarEvent.Reset();
600 m_scene.EventManager.OnOarFileLoaded += LoadCompleted; 596 m_archiverModule.DearchiveRegion(oarStream);
601 m_archiverModule.DearchiveRegion(oarStream); 597
602 } 598 Monitor.Wait(m_oarEvent, 60000);
603 599
604 ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16); 600 ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
605 LandData rLd = rLo.LandData; 601 LandData rLd = rLo.LandData;
@@ -667,12 +663,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
667 663
668 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 664 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
669 665
670 lock (this) 666 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
671 { 667 m_oarEvent.Reset();
672 m_scene.EventManager.OnOarFileLoaded += LoadCompleted; 668 m_archiverModule.DearchiveRegion(archiveReadStream);
673 m_archiverModule.DearchiveRegion(archiveReadStream); 669
674 Monitor.Wait(this, 60000); 670 Monitor.Wait(m_oarEvent, 60000);
675 }
676 671
677 Assert.That(m_lastErrorMessage, Is.Null); 672 Assert.That(m_lastErrorMessage, Is.Null);
678 RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings; 673 RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings;
@@ -742,13 +737,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
742 m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); 737 m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false);
743 738
744 // Write out this scene 739 // Write out this scene
745 scene.EventManager.OnOarFileSaved += SaveCompleted;
746 740
747 lock (this) 741 scene.EventManager.OnOarFileSaved += SaveCompleted;
748 { 742 m_oarEvent.Reset();
749 m_archiverModule.ArchiveRegion(archiveWriteStream); 743 m_archiverModule.ArchiveRegion(archiveWriteStream);
750 Monitor.Wait(this, 60000); 744
751 } 745 Monitor.Wait(m_oarEvent, 60000);
752 } 746 }
753 747
754 { 748 {
@@ -759,14 +753,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
759 byte[] archive = archiveWriteStream.ToArray(); 753 byte[] archive = archiveWriteStream.ToArray();
760 MemoryStream archiveReadStream = new MemoryStream(archive); 754 MemoryStream archiveReadStream = new MemoryStream(archive);
761 755
762 lock (this) 756 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
763 { 757 Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
764 m_scene.EventManager.OnOarFileLoaded += LoadCompleted; 758 archiveOptions.Add("merge", null);
765 Dictionary<string, object> archiveOptions = new Dictionary<string, object>(); 759 m_oarEvent.Reset();
766 archiveOptions.Add("merge", null); 760 m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions);
767 m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions); 761
768 Monitor.Wait(this, 60000); 762 Monitor.Wait(m_oarEvent, 60000);
769 }
770 763
771 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); 764 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
772 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); 765 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
@@ -839,18 +832,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
839 832
840 // Save OAR 833 // Save OAR
841 MemoryStream archiveWriteStream = new MemoryStream(); 834 MemoryStream archiveWriteStream = new MemoryStream();
842 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
843 835
844 Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); 836 Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
845 837
846 Dictionary<string, Object> options = new Dictionary<string, Object>(); 838 Dictionary<string, Object> options = new Dictionary<string, Object>();
847 options.Add("all", true); 839 options.Add("all", true);
848 840
849 lock (this) 841 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
850 { 842 m_oarEvent.Reset();
851 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); 843 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options);
852 Monitor.Wait(this, 60000); 844
853 } 845 Monitor.Wait(m_oarEvent, 60000);
854 846
855 847
856 // Check that the OAR contains the expected data 848 // Check that the OAR contains the expected data
@@ -1017,14 +1009,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
1017 1009
1018 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 1010 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
1019 1011
1020 lock (this) 1012 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
1021 { 1013 m_oarEvent.Reset();
1022 m_scene.EventManager.OnOarFileLoaded += LoadCompleted; 1014 m_archiverModule.DearchiveRegion(archiveReadStream);
1023 Dictionary<string, object> archiveOptions = new Dictionary<string, object>(); 1015
1024// archiveOptions.Add("merge", null); 1016 Monitor.Wait(m_oarEvent, 60000);
1025 m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions);
1026 Monitor.Wait(this, 60000);
1027 }
1028 1017
1029 Assert.That(m_lastErrorMessage, Is.Null); 1018 Assert.That(m_lastErrorMessage, Is.Null);
1030 1019