From 2f30ba37c475c22fc4975b205ad13cca561409d6 Mon Sep 17 00:00:00 2001 From: F5 Date: Tue, 21 Nov 2023 21:07:00 +0800 Subject: [PATCH] mtp: Add example testing --- src/mtp/CMakeLists.txt | 10 +- src/mtp/test/mtp-fat-tree-incast.reflog | 53 ++++++ src/mtp/test/mtp-fat-tree.reflog | 53 ++++++ .../mtp-tcp-validation-cubic-50ms-ecn.reflog | 0 ...tp-tcp-validation-cubic-50ms-no-ecn.reflog | 0 .../test/mtp-tcp-validation-dctcp-10ms.reflog | 0 .../test/mtp-tcp-validation-dctcp-80ms.reflog | 0 src/mtp/test/mtp-test-suite.cc | 164 +++++++++++++----- 8 files changed, 233 insertions(+), 47 deletions(-) create mode 100644 src/mtp/test/mtp-fat-tree-incast.reflog create mode 100644 src/mtp/test/mtp-fat-tree.reflog create mode 100644 src/mtp/test/mtp-tcp-validation-cubic-50ms-ecn.reflog create mode 100644 src/mtp/test/mtp-tcp-validation-cubic-50ms-no-ecn.reflog create mode 100644 src/mtp/test/mtp-tcp-validation-dctcp-10ms.reflog create mode 100644 src/mtp/test/mtp-tcp-validation-dctcp-80ms.reflog diff --git a/src/mtp/CMakeLists.txt b/src/mtp/CMakeLists.txt index e7d1f7713..d539b03e1 100644 --- a/src/mtp/CMakeLists.txt +++ b/src/mtp/CMakeLists.txt @@ -1,3 +1,10 @@ +set(example_as_test_suite) +if(${ENABLE_EXAMPLES}) + set(example_as_test_suite + test/mtp-test-suite.cc + ) +endif() + build_lib( LIBNAME mtp SOURCE_FILES @@ -10,6 +17,5 @@ build_lib( model/multithreaded-simulator-impl.h LIBRARIES_TO_LINK ${libcore} ${libnetwork} - TEST_SOURCES - test/mtp-test-suite.cc + TEST_SOURCES ${example_as_test_suite} ) diff --git a/src/mtp/test/mtp-fat-tree-incast.reflog b/src/mtp/test/mtp-fat-tree-incast.reflog new file mode 100644 index 000000000..c3551f6af --- /dev/null +++ b/src/mtp/test/mtp-fat-tree-incast.reflog @@ -0,0 +1,53 @@ + +- Setup the topology... + +- Calculating routes... + Host NodeId System Address + 0 20 0 10.0.0.1 + 1 21 0 10.0.0.3 + 2 22 0 10.0.1.1 + 3 23 0 10.0.1.3 + 4 24 0 10.1.0.1 + 5 25 0 10.1.0.3 + 6 26 0 10.1.1.1 + 7 27 0 10.1.1.3 + 8 28 0 10.2.0.1 + 9 29 0 10.2.0.3 + 10 30 0 10.2.1.1 + 11 31 0 10.2.1.3 + 12 32 0 10.3.0.1 + 13 33 0 10.3.0.3 + 14 34 0 10.3.1.1 + 15 35 0 10.3.1.3 + +- Generating traffic... + Expected data rate = 0.48Gbps + Generated data rate = 0.433455Gbps + Expected avg flow size = 1.71125MB + Generated avg flow size = 1.56604MB + Total flow count = 36 + +- Start simulation... + Progressed to 0.1s + Progressed to 0.2s + Progressed to 0.3s + Progressed to 0.4s + Progressed to 0.5s + Progressed to 0.6s + Progressed to 0.7s + Progressed to 0.8s + Progressed to 0.9s + Detected #flow = 70 + Finished #flow = 66 + Average FCT (all) = 208267us + Average FCT (finished) = 209978us + Average end to end delay = 23173us + Average flow throughput = 0.00944586Gbps + Network throughput = 0.0958292Gbps + Total Tx packets = 12007 + Total Rx packets = 11904 + Dropped packets = 0 + +- Done! + Event count = 172947 + diff --git a/src/mtp/test/mtp-fat-tree.reflog b/src/mtp/test/mtp-fat-tree.reflog new file mode 100644 index 000000000..d71a56452 --- /dev/null +++ b/src/mtp/test/mtp-fat-tree.reflog @@ -0,0 +1,53 @@ + +- Setup the topology... + +- Calculating routes... + Host NodeId System Address + 0 20 0 10.0.0.1 + 1 21 0 10.0.0.3 + 2 22 0 10.0.1.1 + 3 23 0 10.0.1.3 + 4 24 0 10.1.0.1 + 5 25 0 10.1.0.3 + 6 26 0 10.1.1.1 + 7 27 0 10.1.1.3 + 8 28 0 10.2.0.1 + 9 29 0 10.2.0.3 + 10 30 0 10.2.1.1 + 11 31 0 10.2.1.3 + 12 32 0 10.3.0.1 + 13 33 0 10.3.0.3 + 14 34 0 10.3.1.1 + 15 35 0 10.3.1.3 + +- Generating traffic... + Expected data rate = 0.48Gbps + Generated data rate = 0.433455Gbps + Expected avg flow size = 1.71125MB + Generated avg flow size = 1.56604MB + Total flow count = 36 + +- Start simulation... + Progressed to 0.1s + Progressed to 0.2s + Progressed to 0.3s + Progressed to 0.4s + Progressed to 0.5s + Progressed to 0.6s + Progressed to 0.7s + Progressed to 0.8s + Progressed to 0.9s + Detected #flow = 70 + Finished #flow = 65 + Average FCT (all) = 92536.3us + Average FCT (finished) = 77992.9us + Average end to end delay = 66398.2us + Average flow throughput = 0.0312583Gbps + Network throughput = 0.246348Gbps + Total Tx packets = 29014 + Total Rx packets = 25782 + Dropped packets = 0 + +- Done! + Event count = 355408 + diff --git a/src/mtp/test/mtp-tcp-validation-cubic-50ms-ecn.reflog b/src/mtp/test/mtp-tcp-validation-cubic-50ms-ecn.reflog new file mode 100644 index 000000000..e69de29bb diff --git a/src/mtp/test/mtp-tcp-validation-cubic-50ms-no-ecn.reflog b/src/mtp/test/mtp-tcp-validation-cubic-50ms-no-ecn.reflog new file mode 100644 index 000000000..e69de29bb diff --git a/src/mtp/test/mtp-tcp-validation-dctcp-10ms.reflog b/src/mtp/test/mtp-tcp-validation-dctcp-10ms.reflog new file mode 100644 index 000000000..e69de29bb diff --git a/src/mtp/test/mtp-tcp-validation-dctcp-80ms.reflog b/src/mtp/test/mtp-tcp-validation-dctcp-80ms.reflog new file mode 100644 index 000000000..e69de29bb diff --git a/src/mtp/test/mtp-test-suite.cc b/src/mtp/test/mtp-test-suite.cc index bab5825cd..dcf9ca2dd 100644 --- a/src/mtp/test/mtp-test-suite.cc +++ b/src/mtp/test/mtp-test-suite.cc @@ -1,68 +1,142 @@ -// TODO: Add multithreaded tests - -// Include a header file from your module to test. +#include "ns3/example-as-test.h" #include "ns3/mtp-module.h" - -// An essential include is test.h #include "ns3/test.h" -// Do not put your test classes in namespace ns3. You may find it useful -// to use the using directive to access the ns3 namespace directly +#include + using namespace ns3; -// This is an example TestCase. -class MtpTestCase1 : public TestCase +class MtpTestCase : public ExampleAsTestCase { -public: - MtpTestCase1 (); - virtual ~MtpTestCase1 (); + public: + /** + * \copydoc ns3::ExampleAsTestCase::ExampleAsTestCase + * + * \param [in] postCmd The post processing command + */ + MtpTestCase(const std::string name, + const std::string program, + const std::string dataDir, + const std::string args = "", + const std::string postCmd = "", + const bool shouldNotErr = true); -private: - virtual void DoRun (void); + /** Destructor */ + ~MtpTestCase() override + { + } + + /** + * Produce the `--command-template` argument + * + * \returns The `--command-template` string. + */ + std::string GetCommandTemplate() const override; + + /** + * Remove time statistics + * + * \returns The post processing command + */ + std::string GetPostProcessingCommand() const override; + + private: + /** The post processing command. */ + std::string m_postCmd; }; -// Add some help text to this case to describe what it is intended to test -MtpTestCase1::MtpTestCase1 () - : TestCase ("Mtp test case (does nothing)") +MtpTestCase::MtpTestCase(const std::string name, + const std::string program, + const std::string dataDir, + const std::string args /* = "" */, + const std::string postCmd /* = "" */, + const bool shouldNotErr /* = true */) + : ExampleAsTestCase(name, program, dataDir, args, shouldNotErr), + m_postCmd(postCmd) { } -// This destructor does nothing but we include it as a reminder that -// the test case should clean up after itself -MtpTestCase1::~MtpTestCase1 () +std::string +MtpTestCase::GetCommandTemplate() const { + std::stringstream ss; + ss << "%s " << m_args; + return ss.str(); } -// -// This method is the pure virtual method from class TestCase that every -// TestCase must implement -// -void -MtpTestCase1::DoRun (void) +std::string +MtpTestCase::GetPostProcessingCommand() const { - // A wide variety of test macros are available in src/core/test.h - NS_TEST_ASSERT_MSG_EQ (true, true, "true doesn't equal true for some reason"); - // Use this one for floating point comparisons - NS_TEST_ASSERT_MSG_EQ_TOL (0.01, 0.01, 0.001, "Numbers are not equal within tolerance"); + std::string command(m_postCmd); + return command; } -// The TestSuite class names the TestSuite, identifies what type of TestSuite, -// and enables the TestCases to be run. Typically, only the constructor for -// this class must be defined -// class MtpTestSuite : public TestSuite { -public: - MtpTestSuite (); -}; + public: + /** + * \copydoc MpiTestCase::MpiTestCase + * + * \param [in] duration Amount of time this test takes to execute + * (defaults to QUICK). + */ + MtpTestSuite(const std::string name, + const std::string program, + const std::string dataDir, + const std::string args = "", + const std::string postCmd = "", + const TestDuration duration = QUICK, + const bool shouldNotErr = true) + : TestSuite(name, EXAMPLE) + { + AddTestCase(new MtpTestCase(name, program, dataDir, args, postCmd, shouldNotErr), duration); + } -MtpTestSuite::MtpTestSuite () - : TestSuite ("mtp", UNIT) -{ - // TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER - AddTestCase (new MtpTestCase1, TestCase::QUICK); -} +}; // class MtpTestSuite -// Do not forget to allocate an instance of this TestSuite -static MtpTestSuite smtpTestSuite; +static MtpTestSuite g_mtpFatTree1("mtp-fat-tree", + "fat-tree-mtp", + NS_TEST_SOURCEDIR, + "--bandwidth=100Mbps --thread=4 --flowmon=true", + "| grep -v 'Simulation time'", + TestCase::TestDuration::QUICK); +static MtpTestSuite g_mtpFatTree2("mtp-fat-tree-incast", + "fat-tree-mtp", + NS_TEST_SOURCEDIR, + "--bandwidth=100Mbps --incast=1 --thread=4 --flowmon=true", + "| grep -v 'Simulation time'", + TestCase::TestDuration::QUICK); + +static MtpTestSuite g_mtpTcpValidation1("mtp-tcp-validation-dctcp-10ms", + "tcp-validation-mtp", + NS_TEST_SOURCEDIR, + "--firstTcpType=dctcp --linkRate=50Mbps --baseRtt=10ms " + "--queueUseEcn=1 --stopTime=15s --validate=dctcp-10ms", + "", + TestCase::TestDuration::QUICK); + +static MtpTestSuite g_mtpTcpValidation2("mtp-tcp-validation-dctcp-80ms", + "tcp-validation-mtp", + NS_TEST_SOURCEDIR, + "--firstTcpType=dctcp --linkRate=50Mbps --baseRtt=80ms " + "--queueUseEcn=1 --stopTime=40s --validate=dctcp-80ms", + "", + TestCase::TestDuration::QUICK); + +static MtpTestSuite g_mtpTcpValidation3( + "mtp-tcp-validation-cubic-50ms-no-ecn", + "tcp-validation-mtp", + NS_TEST_SOURCEDIR, + "--firstTcpType=cubic --linkRate=50Mbps --baseRtt=50ms --queueUseEcn=0 --stopTime=20s " + "--validate=cubic-50ms-no-ecn", + "", + TestCase::TestDuration::QUICK); + +static MtpTestSuite g_mtpTcpValidation4("mtp-tcp-validation-cubic-50ms-ecn", + "tcp-validation-mtp", + NS_TEST_SOURCEDIR, + "--firstTcpType=cubic --linkRate=50Mbps --baseRtt=50ms " + "--queueUseEcn=1 --stopTime=20s --validate=cubic-50ms-ecn", + "", + TestCase::TestDuration::QUICK);