TFM tests for TimerC

This commit is contained in:
Ivan Ribakov
2022-01-26 13:12:22 +01:00
parent c11b35c6c4
commit 2369967646
6 changed files with 184 additions and 73 deletions

View File

@@ -149,6 +149,8 @@ ReproFixture::tearDown()
}
}
// Restore default QValueTargetHandler config
dynamic_cast<TestRepro *>(proxy)->setQValueTargetHandlerCancelGroups(true);
jason->clean();
jason1->clean();
jason2->clean();

View File

@@ -48,74 +48,14 @@ TfmProxyConfig::TfmProxyConfig(AbstractDb* db, const CommandLineParser& args)
insertConfigValue("QValueMsBetweenForkGroups", "5000");
insertConfigValue("QValueMsBeforeCancel", "5000");
insertConfigValue("TimerC", "30");
insertConfigValue("ForceRecordRouting", "true");
//insertConfigValue("RecordRouteUri", "sip:127.0.0.1:5060"); // Set below per transport
}
static ProcessorChain&
makeRequestProcessorChain(ProcessorChain& chain,
ProxyConfig& config,
Dispatcher* authRequestDispatcher,
RegistrationPersistenceManager& regData,
SipStack* stack)
{
ProcessorChain* locators = new ProcessorChain(Processor::REQUEST_CHAIN);
ProcessorChain* authenticators = new ProcessorChain(Processor::REQUEST_CHAIN);
IsTrustedNode* isTrusted = new IsTrustedNode(config);
authenticators->addProcessor(std::unique_ptr<Processor>(isTrusted));
DigestAuthenticator* da = new DigestAuthenticator(config, authRequestDispatcher);
authenticators->addProcessor(std::unique_ptr<Processor>(da));
StrictRouteFixup* srf = new StrictRouteFixup;
locators->addProcessor(std::unique_ptr<Processor>(srf));
AmIResponsible* isme = new AmIResponsible;
locators->addProcessor(std::unique_ptr<Processor>(isme));
StaticRoute* sr = new StaticRoute(config);
locators->addProcessor(std::unique_ptr<Processor>(sr));
LocationServer* ls = new LocationServer(config, regData, authRequestDispatcher);
locators->addProcessor(std::unique_ptr<Processor>(ls));
chain.addProcessor(std::unique_ptr<Processor>(authenticators));
chain.addProcessor(std::unique_ptr<Processor>(locators));
return chain;
}
static ProcessorChain&
makeResponseProcessorChain(ProcessorChain& chain,
RegistrationPersistenceManager& regData)
{
ProcessorChain* lemurs = new ProcessorChain(Processor::RESPONSE_CHAIN);
OutboundTargetHandler* ob = new OutboundTargetHandler(regData);
lemurs->addProcessor(std::unique_ptr<Processor>(ob));
chain.addProcessor(std::unique_ptr<Processor>(lemurs));
return chain;
}
static ProcessorChain&
makeTargetProcessorChain(ProcessorChain& chain, ProxyConfig& config)
{
ProcessorChain* baboons = new ProcessorChain(Processor::TARGET_CHAIN);
QValueTargetHandler* qval = new QValueTargetHandler(config);
baboons->addProcessor(std::unique_ptr<Processor>(qval));
SimpleTargetHandler* smpl = new SimpleTargetHandler;
baboons->addProcessor(std::unique_ptr<Processor>(smpl));
chain.addProcessor(std::unique_ptr<Processor>(baboons));
return chain;
}
static Uri
makeUri(const resip::Data& domain, int port)
static Uri
makeUri(const resip::Data &domain, int port)
{
Uri uri;
uri.host() = domain;
@@ -322,6 +262,8 @@ TestRepro::TestRepro(const resip::Data& name,
TestRepro::~TestRepro()
{
mQValueTargetHandler = nullptr;
mDumThread->shutdown();
mDumThread->join();
delete mAuthRequestDispatcher;
@@ -341,6 +283,70 @@ TestRepro::~TestRepro()
delete mDb;
}
ProcessorChain &
TestRepro::makeRequestProcessorChain(ProcessorChain &chain,
ProxyConfig &config,
Dispatcher *authRequestDispatcher,
RegistrationPersistenceManager &regData,
SipStack *stack)
{
ProcessorChain *locators = new ProcessorChain(Processor::REQUEST_CHAIN);
ProcessorChain *authenticators = new ProcessorChain(Processor::REQUEST_CHAIN);
IsTrustedNode *isTrusted = new IsTrustedNode(config);
authenticators->addProcessor(std::unique_ptr<Processor>(isTrusted));
DigestAuthenticator *da = new DigestAuthenticator(config, authRequestDispatcher);
authenticators->addProcessor(std::unique_ptr<Processor>(da));
StrictRouteFixup *srf = new StrictRouteFixup;
locators->addProcessor(std::unique_ptr<Processor>(srf));
AmIResponsible *isme = new AmIResponsible;
locators->addProcessor(std::unique_ptr<Processor>(isme));
StaticRoute *sr = new StaticRoute(config);
locators->addProcessor(std::unique_ptr<Processor>(sr));
LocationServer *ls = new LocationServer(config, regData, authRequestDispatcher);
locators->addProcessor(std::unique_ptr<Processor>(ls));
chain.addProcessor(std::unique_ptr<Processor>(authenticators));
chain.addProcessor(std::unique_ptr<Processor>(locators));
return chain;
}
ProcessorChain &
TestRepro::makeResponseProcessorChain(ProcessorChain &chain,
RegistrationPersistenceManager &regData)
{
ProcessorChain *lemurs = new ProcessorChain(Processor::RESPONSE_CHAIN);
OutboundTargetHandler *ob = new OutboundTargetHandler(regData);
lemurs->addProcessor(std::unique_ptr<Processor>(ob));
chain.addProcessor(std::unique_ptr<Processor>(lemurs));
return chain;
}
ProcessorChain &
TestRepro::makeTargetProcessorChain(ProcessorChain &chain, ProxyConfig &config)
{
ProcessorChain *baboons = new ProcessorChain(Processor::TARGET_CHAIN);
QValueTargetHandler *qval = new QValueTargetHandler(config);
baboons->addProcessor(std::unique_ptr<Processor>(qval));
// Store QValueTargetHandler pointer for dynamic behaviour adjustment from within test cases
mQValueTargetHandler = qval;
SimpleTargetHandler *smpl = new SimpleTargetHandler;
baboons->addProcessor(std::unique_ptr<Processor>(smpl));
chain.addProcessor(std::unique_ptr<Processor>(baboons));
return chain;
}
void
TestRepro::addUser(const Data& userid, const Uri& aor, const Data& password)
{
@@ -407,3 +413,15 @@ TestRepro::deleteTrustedHost(const resip::Data& host, resip::TransportType trans
static_cast<const short&>(transport));
}
void
TestRepro::setQValueTargetHandlerCancelGroups(bool enabled)
{
if (mQValueTargetHandler)
{
mQValueTargetHandler->setCancelBetweenForkGroups(enabled);
}
else
{
ErrLog(<< "Unable to adjust QValueCancelBetweenForkGroups setting: QValueTargetHandler is NULL");
}
}

View File

@@ -21,6 +21,11 @@
#include <memory>
namespace repro
{
class QValueTargetHandler;
}
class TfmProxyConfig : public repro::ProxyConfig
{
public:
@@ -53,8 +58,19 @@ class TestRepro : public TestProxy
virtual bool addTrustedHost(const resip::Data& host, resip::TransportType transport, short port = 0, short mask = 0, short family=resip::V4);
virtual void deleteTrustedHost(const resip::Data& host, resip::TransportType transport, short port = 0, short mask = 0, short family=resip::V4);
void setQValueTargetHandlerCancelGroups(bool enabled);
private:
resip::FdPollGrp* mPollGrp;
repro::ProcessorChain &makeRequestProcessorChain(repro::ProcessorChain &chain,
repro::ProxyConfig &config,
resip::Dispatcher *authRequestDispatcher,
resip::RegistrationPersistenceManager &regData,
resip::SipStack *stack);
repro::ProcessorChain &makeResponseProcessorChain(repro::ProcessorChain &chain,
resip::RegistrationPersistenceManager &regData);
repro::ProcessorChain &makeTargetProcessorChain(repro::ProcessorChain &chain, repro::ProxyConfig &config);
resip::FdPollGrp *mPollGrp;
resip::EventThreadInterruptor* mInterruptor;
resip::SipStack* mStack;
resip::EventStackThread* mStackThread;
@@ -72,6 +88,8 @@ class TestRepro : public TestProxy
resip::DialogUsageManager* mDum;
resip::DumThread* mDumThread;
std::unique_ptr<resip::CongestionManager> mCongestionManager;
repro::QValueTargetHandler *mQValueTargetHandler;
};
#endif

View File

@@ -14,6 +14,7 @@
#include "rutil/Random.hxx"
#include "tfm/repro/CommandLineParser.hxx"
#include "tfm/repro/ReproFixture.hxx"
#include "tfm/repro/TestRepro.hxx"
#include "tfm/RouteGuard.hxx"
#include "tfm/Sequence.hxx"
#include "tfm/SipEvent.hxx"
@@ -3482,7 +3483,8 @@ class TestHolder : public ReproFixture
derek->expect(REGISTER/200, from(proxy), WaitForRegistration, derek->noAction()),
WaitForEndOfSeq);
ExecuteSequences();
dynamic_cast<TestRepro *>(ReproFixture::proxy)->setQValueTargetHandlerCancelGroups(false);
Seq
(
jason->invite(*derek),
@@ -3492,7 +3494,7 @@ class TestHolder : public ReproFixture
optional(jason->expect(INVITE/100, from(proxy),WaitFor100,jason->noAction())),
derek->expect(INVITE,contact(jason),WaitForResponse,derek->ring()),
jason->expect(INVITE/180,contact(derek),WaitForResponse,jason->noAction()),
derek->expect(CANCEL,from(proxy),200000,chain(derek->ok(),derek->send487())),
derek->expect(CANCEL,from(proxy),31000,chain(derek->ok(),derek->send487())),
And
(
Sub
@@ -10416,8 +10418,9 @@ class TestHolder : public ReproFixture
WaitForEndOfSeq);
ExecuteSequences();
CountDown count487(2, "count487");
CountDown count487(2, "count487");
dynamic_cast<TestRepro *>(ReproFixture::proxy)->setQValueTargetHandlerCancelGroups(false);
Seq
(
derek->invite(*jason),
@@ -10431,14 +10434,14 @@ class TestHolder : public ReproFixture
(
jason2->expect(INVITE, contact(derek), WaitForCommand, jason2->ring()),
derek->expect(INVITE/180, from(jason2), WaitFor180, derek->noAction()),
jason2->expect(CANCEL,from(proxy),200000,chain(jason2->ok(), jason2->send487(),count487.dec())),
jason2->expect(CANCEL,from(proxy),31000,chain(jason2->ok(), jason2->send487(),count487.dec())),
jason2->expect(ACK,from(proxy),WaitForResponse,jason2->noAction())
),
Sub
(
jason1->expect(INVITE, contact(derek), WaitForCommand, jason1->ring()),
derek->expect(INVITE/180, from(jason1), WaitFor180, derek->noAction()),
jason1->expect(CANCEL,from(proxy),200000,chain(jason1->ok(), jason1->send487(),count487.dec())),
jason1->expect(CANCEL,from(proxy),31000,chain(jason1->ok(), jason1->send487(),count487.dec())),
jason1->expect(ACK,from(proxy),WaitForResponse,jason1->noAction())
)
),
@@ -10447,8 +10450,69 @@ class TestHolder : public ReproFixture
WaitForEndOfTest);
ExecuteSequences();
}
void testTimerCForkedSequential()
{
WarningLog(<<"*!testTimerCForkedSequential!*");
if(resip::InteropHelper::getRRTokenHackEnabled())
{
WarningLog(<<"This test uses third-party registrations, and will not work with the flow-token hack enabled.");
return;
}
NameAddr con2 = *(jason->getDefaultContacts().begin());
con2.param(p_q)=0.2;
NameAddr con1 = *(derek->getDefaultContacts().begin());
con1.param(p_q)=0.1;
ExecuteSequences();
std::set<resip::NameAddr> contacts;
contacts.insert(con1);
contacts.insert(con2);
Seq
(
derek->registerUser(60,contacts),
derek->expect(REGISTER/407, from(proxy), WaitForResponse, derek->digestRespond()),
derek->expect(REGISTER/200, from(proxy), WaitForResponse, derek->noAction()),
WaitForEndOfSeq
);
ExecuteSequences();
dynamic_cast<TestRepro *>(ReproFixture::proxy)->setQValueTargetHandlerCancelGroups(false);
Seq
(
cullen->invite(*derek),
optional(cullen->expect(INVITE/100, from(proxy), WaitFor100, cullen->noAction())),
cullen->expect(INVITE/407, from(proxy), WaitForResponse, chain(cullen->ack(),cullen->digestRespond())),
And
(
Sub
(
optional(cullen->expect(INVITE/100, from(proxy), WaitFor100, cullen->noAction()))
),
Sub
(
jason->expect(INVITE, from(cullen), WaitForCommand, jason->ring()),
cullen->expect(INVITE/180, from(jason), WaitForResponse, cullen->noAction()),
jason->expect(CANCEL, from(proxy), 31000, chain(jason->ok(), jason->send487())),
jason->expect(ACK,from(proxy),WaitForResponse,jason->noAction()),
derek->expect(INVITE, from(cullen), WaitForCommand, chain(derek->ring(),derek->ok())),
cullen->expect(INVITE/180, from(derek), WaitForResponse,cullen->noAction()),
cullen->expect(INVITE/200, from(derek), WaitForResponse, cullen->ack()),
derek->expect(ACK, from(cullen),WaitForCommand, derek->noAction())
)
),
WaitForEndOfSeq
);
ExecuteSequences();
}
/* Test that the routing logic can make decisions based on the method
@@ -10927,7 +10991,9 @@ class MyTestCase
TEST(testInvite1xxDropped);
TEST(testInviteClientRetransmitsAfter200);
TEST(testInviteClientMissedAck);
TEST(testTimerC); //This test takes a long time
TEST(testTimerC);
TEST(testTimerCForked);
TEST(testTimerCForkedSequential);
TEST(testInviteServerSpams200);
TEST(testInviteServerSends180After200);
TEST(testInviteClientSpamsInvite); //tfm is asserting on this test, will look into