change syncronization method

LSLKeyTest
UbitUmarov 2015-11-22 08:31:54 +00:00
parent e28eecd0bf
commit ec069edead
1 changed files with 65 additions and 76 deletions

View File

@ -66,6 +66,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
protected TaskInventoryItem m_soundItem; protected TaskInventoryItem m_soundItem;
private AutoResetEvent m_oarEvent = new AutoResetEvent(false);
[SetUp] [SetUp]
public override void SetUp() public override void SetUp()
{ {
@ -87,8 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
m_lastRequestId = requestId; m_lastRequestId = requestId;
m_lastErrorMessage = errorMessage; m_lastErrorMessage = errorMessage;
Console.WriteLine("About to pulse ArchiverTests on LoadCompleted"); Console.WriteLine("About to pulse ArchiverTests on LoadCompleted");
m_oarEvent.Set();
Monitor.PulseAll(this);
} }
} }
@ -99,7 +100,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
m_lastRequestId = requestId; m_lastRequestId = requestId;
m_lastErrorMessage = errorMessage; m_lastErrorMessage = errorMessage;
Console.WriteLine("About to pulse ArchiverTests on SaveCompleted"); Console.WriteLine("About to pulse ArchiverTests on SaveCompleted");
Monitor.PulseAll(this); m_oarEvent.Set();
} }
} }
@ -195,15 +196,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
lock (this) m_oarEvent.Reset();
{
m_archiverModule.ArchiveRegion(archiveWriteStream, requestId); m_archiverModule.ArchiveRegion(archiveWriteStream, requestId);
//AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer; //AssetServerBase assetServer = (AssetServerBase)scene.CommsManager.AssetCache.AssetServer;
//while (assetServer.HasWaitingRequests()) //while (assetServer.HasWaitingRequests())
// assetServer.ProcessNextRequest(); // assetServer.ProcessNextRequest();
Monitor.Wait(this, 60000); Monitor.Wait( m_oarEvent, 60000);
}
Assert.That(m_lastRequestId, Is.EqualTo(requestId)); Assert.That(m_lastRequestId, Is.EqualTo(requestId));
@ -289,6 +288,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Dictionary<string, Object> options = new Dictionary<string, Object>(); Dictionary<string, Object> options = new Dictionary<string, Object>();
options.Add("noassets", true); options.Add("noassets", true);
m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options);
// Don't wait for completion - with --noassets save oar happens synchronously // Don't wait for completion - with --noassets save oar happens synchronously
@ -397,12 +397,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_oarEvent.Reset();
m_archiverModule.DearchiveRegion(archiveReadStream); m_archiverModule.DearchiveRegion(archiveReadStream);
Monitor.Wait(this, 60000);
} Monitor.Wait(m_oarEvent, 60000);
Assert.That(m_lastErrorMessage, Is.Null); Assert.That(m_lastErrorMessage, Is.Null);
@ -447,12 +446,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_oarEvent.Reset();
m_archiverModule.DearchiveRegion(archiveReadStream); m_archiverModule.DearchiveRegion(archiveReadStream);
Monitor.Wait(this, 60000);
} Monitor.Wait(m_oarEvent, 60000);
Assert.That(m_lastErrorMessage, Is.Null); Assert.That(m_lastErrorMessage, Is.Null);
@ -498,13 +496,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
lock (this) m_oarEvent.Reset();
{
m_archiverModule.ArchiveRegion( m_archiverModule.ArchiveRegion(
archiveWriteStream, requestId, new Dictionary<string, Object>() { { "wipe-owners", Boolean.TrueString } }); archiveWriteStream, requestId, new Dictionary<string, Object>() { { "wipe-owners", Boolean.TrueString } });
Monitor.Wait(this, 60000); Monitor.Wait(m_oarEvent, 60000);
}
Assert.That(m_lastRequestId, Is.EqualTo(requestId)); Assert.That(m_lastRequestId, Is.EqualTo(requestId));
@ -530,11 +526,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner; scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner;
lock (this)
{
scene2.EventManager.OnOarFileLoaded += LoadCompleted; scene2.EventManager.OnOarFileLoaded += LoadCompleted;
m_oarEvent.Reset();
archiverModule.DearchiveRegion(archiveReadStream); archiverModule.DearchiveRegion(archiveReadStream);
}
Monitor.Wait(m_oarEvent, 60000);
Assert.That(m_lastErrorMessage, Is.Null); Assert.That(m_lastErrorMessage, Is.Null);
@ -595,11 +591,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
oarStream = new MemoryStream(oarStream.ToArray()); oarStream = new MemoryStream(oarStream.ToArray());
// Load OAR // Load OAR
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_oarEvent.Reset();
m_archiverModule.DearchiveRegion(oarStream); m_archiverModule.DearchiveRegion(oarStream);
}
Monitor.Wait(m_oarEvent, 60000);
ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16); ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
LandData rLd = rLo.LandData; LandData rLd = rLo.LandData;
@ -667,12 +663,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_oarEvent.Reset();
m_archiverModule.DearchiveRegion(archiveReadStream); m_archiverModule.DearchiveRegion(archiveReadStream);
Monitor.Wait(this, 60000);
} Monitor.Wait(m_oarEvent, 60000);
Assert.That(m_lastErrorMessage, Is.Null); Assert.That(m_lastErrorMessage, Is.Null);
RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings; RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings;
@ -742,13 +737,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false);
// Write out this scene // Write out this scene
scene.EventManager.OnOarFileSaved += SaveCompleted;
lock (this) scene.EventManager.OnOarFileSaved += SaveCompleted;
{ m_oarEvent.Reset();
m_archiverModule.ArchiveRegion(archiveWriteStream); m_archiverModule.ArchiveRegion(archiveWriteStream);
Monitor.Wait(this, 60000);
} Monitor.Wait(m_oarEvent, 60000);
} }
{ {
@ -759,14 +753,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
byte[] archive = archiveWriteStream.ToArray(); byte[] archive = archiveWriteStream.ToArray();
MemoryStream archiveReadStream = new MemoryStream(archive); MemoryStream archiveReadStream = new MemoryStream(archive);
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
Dictionary<string, object> archiveOptions = new Dictionary<string, object>(); Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
archiveOptions.Add("merge", null); archiveOptions.Add("merge", null);
m_oarEvent.Reset();
m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions); m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions);
Monitor.Wait(this, 60000);
} Monitor.Wait(m_oarEvent, 60000);
SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
@ -839,18 +832,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
// Save OAR // Save OAR
MemoryStream archiveWriteStream = new MemoryStream(); MemoryStream archiveWriteStream = new MemoryStream();
m_scene.EventManager.OnOarFileSaved += SaveCompleted;
Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
Dictionary<string, Object> options = new Dictionary<string, Object>(); Dictionary<string, Object> options = new Dictionary<string, Object>();
options.Add("all", true); options.Add("all", true);
lock (this) m_scene.EventManager.OnOarFileSaved += SaveCompleted;
{ m_oarEvent.Reset();
m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options);
Monitor.Wait(this, 60000);
} Monitor.Wait(m_oarEvent, 60000);
// Check that the OAR contains the expected data // Check that the OAR contains the expected data
@ -1017,14 +1009,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
Dictionary<string, object> archiveOptions = new Dictionary<string, object>(); m_oarEvent.Reset();
// archiveOptions.Add("merge", null); m_archiverModule.DearchiveRegion(archiveReadStream);
m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions);
Monitor.Wait(this, 60000); Monitor.Wait(m_oarEvent, 60000);
}
Assert.That(m_lastErrorMessage, Is.Null); Assert.That(m_lastErrorMessage, Is.Null);