Add VectorRenderModuleStressTests that contains a long running test that generates thousands of vector textures concurrently.

Intended for use if there are future issues with mono crashes whilst generate dynamic textures.
This test is triggered via a new test-stress nant target.
Not run by default.
0.7.4-extended
Justin Clark-Casey (justincc) 2012-08-29 23:04:00 +01:00
parent 9a92d8d57e
commit 980678846d
3 changed files with 184 additions and 1 deletions

View File

@ -135,6 +135,17 @@
<delete dir="%temp%"/> <delete dir="%temp%"/>
</target> </target>
<target name="test-stress" depends="build, find-nunit">
<setenv name="MONO_THREADS_PER_CPU" value="100" />
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.stress">
<arg value="./bin/OpenSim.Tests.Stress.dll" />
</exec>
<fail message="Failures reported in stress tests." unless="${int::parse(testresult.opensim.tests.stress)==0}" />
<delete dir="%temp%"/>
</target>
<target name="torture" depends="build, find-nunit"> <target name="torture" depends="build, find-nunit">
<setenv name="MONO_THREADS_PER_CPU" value="100" /> <setenv name="MONO_THREADS_PER_CPU" value="100" />
@ -142,7 +153,7 @@
<arg value="./bin/OpenSim.Tests.Torture.dll" /> <arg value="./bin/OpenSim.Tests.Torture.dll" />
</exec> </exec>
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests.torture)==0}" /> <fail message="Failures reported in torture tests." unless="${int::parse(testresult.opensim.tests.torture)==0}" />
<delete dir="%temp%"/> <delete dir="%temp%"/>
</target> </target>

View File

@ -0,0 +1,132 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using log4net.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenMetaverse.Assets;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
using OpenSim.Region.CoreModules.Scripting.VectorRender;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Tests.Stress
{
[TestFixture]
public class VectorRenderModuleStressTests : OpenSimTestCase
{
public Scene Scene { get; private set; }
public DynamicTextureModule Dtm { get; private set; }
public VectorRenderModule Vrm { get; private set; }
private void SetupScene(bool reuseTextures)
{
Scene = new SceneHelpers().SetupScene();
Dtm = new DynamicTextureModule();
Dtm.ReuseTextures = reuseTextures;
Vrm = new VectorRenderModule();
SceneHelpers.SetupSceneModules(Scene, Dtm, Vrm);
}
[Test]
public void TestConcurrentRepeatedDraw()
{
int threads = 4;
TestHelpers.InMethod();
SetupScene(false);
List<Drawer> drawers = new List<Drawer>();
for (int i = 0; i < threads; i++)
{
Drawer d = new Drawer(this, i);
drawers.Add(d);
Console.WriteLine("Starting drawer {0}", i);
Util.FireAndForget(o => d.Draw());
}
Thread.Sleep(10 * 60 * 1000);
drawers.ForEach(d => d.Ready = false);
drawers.ForEach(d => Console.WriteLine("Drawer {0} drew {1} textures", d.Number, d.Pass + 1));
}
class Drawer
{
public int Number { get; private set; }
public int Pass { get; private set; }
public bool Ready { get; set; }
private VectorRenderModuleStressTests m_tests;
public Drawer(VectorRenderModuleStressTests tests, int number)
{
m_tests = tests;
Number = number;
Ready = true;
}
public void Draw()
{
SceneObjectGroup so = SceneHelpers.AddSceneObject(m_tests.Scene);
while (Ready)
{
UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
// Ensure unique text
string text = string.Format("{0:D2}{1}", Number, Pass);
m_tests.Dtm.AddDynamicTextureData(
m_tests.Scene.RegionInfo.RegionID,
so.UUID,
m_tests.Vrm.GetContentType(),
string.Format("PenColour BLACK; MoveTo 40,220; FontSize 32; Text {0};", text),
"",
0);
Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
Pass++;
}
}
}
}
}

View File

@ -3250,6 +3250,46 @@
</Files> </Files>
</Project> </Project>
<Project frameworkVersion="v3_5" name="OpenSim.Tests.Stress" path="OpenSim/Tests/Stress" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Xml"/>
<Reference name="System.Data"/>
<Reference name="log4net" path="../../../bin/"/>
<Reference name="Nini" path="../../../bin/"/>
<Reference name="nunit.framework" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
<Reference name="XMLRPC" path="../../../bin/"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.OptionalModules"/>
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
<Reference name="OpenSim.Region.ScriptEngine.XEngine"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Services.AvatarService"/>
<Reference name="OpenSim.Tests.Common"/>
<Files>
<Match pattern="*.cs" recurse="false"/>
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Tests.Torture" path="OpenSim/Tests/Torture" type="Library"> <Project frameworkVersion="v3_5" name="OpenSim.Tests.Torture" path="OpenSim/Tests/Torture" type="Library">
<Configuration name="Debug"> <Configuration name="Debug">
<Options> <Options>