From 5f4f9f02309b7df4d1bdcc560cee96d266c48a07 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 8 Jun 2012 03:12:23 +0100
Subject: Add regression test for client logout due to ack timeout.
---
.../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 10 +-
.../Linden/UDP/Tests/BasicCircuitTests.cs | 175 +++++++++++----------
.../Linden/UDP/Tests/TestLLUDPServer.cs | 9 ++
3 files changed, 103 insertions(+), 91 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index a292a6c..58a3b1c 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -147,11 +147,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private int m_elapsed500MSOutgoingPacketHandler;
/// Flag to signal when clients should check for resends
- private bool m_resendUnacked;
+ protected bool m_resendUnacked;
+
/// Flag to signal when clients should send ACKs
- private bool m_sendAcks;
+ protected bool m_sendAcks;
+
/// Flag to signal when clients should send pings
- private bool m_sendPing;
+ protected bool m_sendPing;
private int m_defaultRTO = 0;
private int m_maxRTO = 0;
@@ -1244,7 +1246,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Watchdog.RemoveThread();
}
- private void ClientOutgoingPacketHandler(IClientAPI client)
+ protected void ClientOutgoingPacketHandler(IClientAPI client)
{
m_currentOutgoingClient = client;
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
index 1321470..45d0e2a 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
@@ -45,6 +45,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
[TestFixture]
public class BasicCircuitTests
{
+ private Scene m_scene;
+ private TestLLUDPServer m_udpServer;
+
[TestFixtureSetUp]
public void FixtureInit()
{
@@ -61,83 +64,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
}
-// ///
-// /// Add a client for testing
-// ///
-// ///
-// ///
-// ///
-// /// Agent circuit manager used in setting up the stack
-// protected void SetupStack(
-// IScene scene, out TestLLUDPServer testLLUDPServer, out TestLLPacketServer testPacketServer,
-// out AgentCircuitManager acm)
-// {
-// IConfigSource configSource = new IniConfigSource();
-// ClientStackUserSettings userSettings = new ClientStackUserSettings();
-// testLLUDPServer = new TestLLUDPServer();
-// acm = new AgentCircuitManager();
-//
-// uint port = 666;
-// testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm);
-// testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings);
-// testLLUDPServer.LocalScene = scene;
-// }
-
-// ///
-// /// Set up a client for tests which aren't concerned with this process itself and where only one client is being
-// /// tested
-// ///
-// ///
-// ///
-// ///
-// ///
-// protected void AddClient(
-// uint circuitCode, EndPoint epSender, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm)
-// {
-// UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
-// UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
-//
-// AddClient(circuitCode, epSender, myAgentUuid, mySessionUuid, testLLUDPServer, acm);
-// }
-
-// ///
-// /// Set up a client for tests which aren't concerned with this process itself
-// ///
-// ///
-// ///
-// ///
-// ///
-// ///
-// ///
-// protected void AddClient(
-// uint circuitCode, EndPoint epSender, UUID agentId, UUID sessionId,
-// TestLLUDPServer testLLUDPServer, AgentCircuitManager acm)
-// {
-// AgentCircuitData acd = new AgentCircuitData();
-// acd.AgentID = agentId;
-// acd.SessionID = sessionId;
-//
-// UseCircuitCodePacket uccp = new UseCircuitCodePacket();
-//
-// UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
-// = new UseCircuitCodePacket.CircuitCodeBlock();
-// uccpCcBlock.Code = circuitCode;
-// uccpCcBlock.ID = agentId;
-// uccpCcBlock.SessionID = sessionId;
-// uccp.CircuitCode = uccpCcBlock;
-//
-// acm.AddNewCircuit(circuitCode, acd);
-//
-// testLLUDPServer.LoadReceive(uccp, epSender);
-// testLLUDPServer.ReceiveData(null);
-// }
+ [SetUp]
+ public void SetUp()
+ {
+ m_scene = new SceneHelpers().SetupScene();
+ }
///
/// Build an object name packet for test purposes
///
///
///
- protected ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName)
+ private ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName)
{
ObjectNamePacket onp = new ObjectNamePacket();
ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock();
@@ -148,6 +86,55 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
return onp;
}
+
+ private void AddUdpServer()
+ {
+ AddUdpServer(new IniConfigSource());
+ }
+
+ private void AddUdpServer(IniConfigSource configSource)
+ {
+ uint port = 0;
+ AgentCircuitManager acm = m_scene.AuthenticateHandler;
+
+ m_udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm);
+ m_udpServer.AddScene(m_scene);
+ }
+
+ ///
+ /// Used by tests that aren't testing this stage.
+ ///
+ private ScenePresence AddClient()
+ {
+ UUID myAgentUuid = TestHelpers.ParseTail(0x1);
+ UUID mySessionUuid = TestHelpers.ParseTail(0x2);
+ uint myCircuitCode = 123456;
+ IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999);
+
+ UseCircuitCodePacket uccp = new UseCircuitCodePacket();
+
+ UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
+ = new UseCircuitCodePacket.CircuitCodeBlock();
+ uccpCcBlock.Code = myCircuitCode;
+ uccpCcBlock.ID = myAgentUuid;
+ uccpCcBlock.SessionID = mySessionUuid;
+ uccp.CircuitCode = uccpCcBlock;
+
+ byte[] uccpBytes = uccp.ToBytes();
+ UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length);
+ upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor.
+ Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length);
+
+ AgentCircuitData acd = new AgentCircuitData();
+ acd.AgentID = myAgentUuid;
+ acd.SessionID = mySessionUuid;
+
+ m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd);
+
+ m_udpServer.PacketReceived(upb);
+
+ return m_scene.GetScenePresence(myAgentUuid);
+ }
///
/// Test adding a client to the stack
@@ -158,19 +145,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
TestHelpers.InMethod();
// XmlConfigurator.Configure();
- TestScene scene = new SceneHelpers().SetupScene();
- uint myCircuitCode = 123456;
+ AddUdpServer();
+
UUID myAgentUuid = TestHelpers.ParseTail(0x1);
UUID mySessionUuid = TestHelpers.ParseTail(0x2);
+ uint myCircuitCode = 123456;
IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999);
- uint port = 0;
- AgentCircuitManager acm = scene.AuthenticateHandler;
-
- TestLLUDPServer llUdpServer
- = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, new IniConfigSource(), acm);
- llUdpServer.AddScene(scene);
-
UseCircuitCodePacket uccp = new UseCircuitCodePacket();
UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
@@ -185,26 +166,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor.
Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length);
- llUdpServer.PacketReceived(upb);
+ m_udpServer.PacketReceived(upb);
// Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet
- Assert.That(scene.GetScenePresence(myAgentUuid), Is.Null);
+ Assert.That(m_scene.GetScenePresence(myAgentUuid), Is.Null);
AgentCircuitData acd = new AgentCircuitData();
acd.AgentID = myAgentUuid;
acd.SessionID = mySessionUuid;
- acm.AddNewCircuit(myCircuitCode, acd);
+ m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd);
- llUdpServer.PacketReceived(upb);
+ m_udpServer.PacketReceived(upb);
// Should succeed now
- ScenePresence sp = scene.GetScenePresence(myAgentUuid);
+ ScenePresence sp = m_scene.GetScenePresence(myAgentUuid);
Assert.That(sp.UUID, Is.EqualTo(myAgentUuid));
- Assert.That(llUdpServer.PacketsSent.Count, Is.EqualTo(1));
+ Assert.That(m_udpServer.PacketsSent.Count, Is.EqualTo(1));
- Packet packet = llUdpServer.PacketsSent[0];
+ Packet packet = m_udpServer.PacketsSent[0];
Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket)));
PacketAckPacket ackPacket = packet as PacketAckPacket;
@@ -212,6 +193,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
Assert.That(ackPacket.Packets[0].ID, Is.EqualTo(0));
}
+ [Test]
+ public void TestLogoutClientDueToAck()
+ {
+ TestHelpers.InMethod();
+ TestHelpers.EnableLogging();
+
+ IniConfigSource ics = new IniConfigSource();
+ IConfig config = ics.AddConfig("ClientStack.LindenUDP");
+ config.Set("AckTimeout", -1);
+ AddUdpServer(ics);
+
+ ScenePresence sp = AddClient();
+ m_udpServer.ClientOutgoingPacketHandler(sp.ControllingClient, true, false, false);
+
+ ScenePresence spAfterAckTimeout = m_scene.GetScenePresence(sp.UUID);
+ Assert.That(spAfterAckTimeout, Is.Null);
+
+ TestHelpers.DisableLogging();
+ }
+
// ///
// /// Test removing a client from the stack
// ///
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs
index 0302385..27b9e5b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs
@@ -59,6 +59,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
PacketsSent.Add(packet);
}
+ public void ClientOutgoingPacketHandler(IClientAPI client, bool resendUnacked, bool sendAcks, bool sendPing)
+ {
+ m_resendUnacked = resendUnacked;
+ m_sendAcks = sendAcks;
+ m_sendPing = sendPing;
+
+ ClientOutgoingPacketHandler(client);
+ }
+
//// ///
//// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive
//// ///
--
cgit v1.1