123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- 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;
- 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(), null, "VectorRenderModuleStressTests.TestConcurrentRepeatedDraw");
- }
- 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;
-
- 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++;
- }
- }
- }
- }
- }
|