diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-07-17 20:58:14 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-07-17 20:58:14 +0100 |
commit | 0af3dc144672dbaa7a60e50270a9744f6b68ee8d (patch) | |
tree | dc61808b3240e032e380873ecbce7dbb006d8ee1 | |
parent | Replace select with epoll (diff) | |
download | icespider-0af3dc144672dbaa7a60e50270a9744f6b68ee8d.tar.bz2 icespider-0af3dc144672dbaa7a60e50270a9744f6b68ee8d.tar.xz icespider-0af3dc144672dbaa7a60e50270a9744f6b68ee8d.zip |
Testability
Silently pass siege tests if wrk isn't present.
Add a test that uses curl such that functional testing remains.
Change test port number to something less conflicty.
-rw-r--r-- | icespider/unittests/testEmbedded.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/icespider/unittests/testEmbedded.cpp b/icespider/unittests/testEmbedded.cpp index d104977..e77b114 100644 --- a/icespider/unittests/testEmbedded.cpp +++ b/icespider/unittests/testEmbedded.cpp @@ -1,5 +1,6 @@ #define BOOST_TEST_MODULE TestEmbedded #include <boost/test/unit_test.hpp> +#include <boost/filesystem/convenience.hpp> #include <embedded.h> #include <thread> @@ -7,7 +8,7 @@ class EmbeddedIceSpiderInstance : public IceSpider::Embedded::Listener { public: EmbeddedIceSpiderInstance() : - fd(listen(8080)) + fd(listen(18080)) { BOOST_REQUIRE_GE(fd, 0); } @@ -28,6 +29,11 @@ class EmbeddedIceSpiderRunner : public EmbeddedIceSpiderInstance { th.join(); } + static bool wrk_exists() + { + return boost::filesystem::exists("/usr/bin/wrk"); + } + std::thread th; }; @@ -44,11 +50,19 @@ BOOST_AUTO_TEST_CASE(startup_and_shutdown_cycle, * boost::unit_test::timeout(2)) BOOST_FIXTURE_TEST_SUITE(EmbeddedIceSpider, EmbeddedIceSpiderRunner); +BOOST_AUTO_TEST_CASE(simple_curl_test, + * boost::unit_test::timeout(5)) +{ + BOOST_REQUIRE_EQUAL(0, system("curl -s http://localhost:18080/")); +} + // Throw some requests at it, get a general performance overview BOOST_AUTO_TEST_CASE(quick_siege_test, * boost::unit_test::timeout(5)) { - BOOST_REQUIRE_EQUAL(0, system("wrk -t2 http://localhost:8080/ -c10 -T 15 -d 2")); + if (wrk_exists()) { + BOOST_REQUIRE_EQUAL(0, system("wrk -t2 http://localhost:18080/ -c10 -T 15 -d 2")); + } } // Throw lots of requests at it, get a good performance overview @@ -56,7 +70,9 @@ BOOST_AUTO_TEST_CASE(simple_performance_test, * boost::unit_test::disabled() // Not usually interested * boost::unit_test::timeout(15)) { - BOOST_REQUIRE_EQUAL(0, system("wrk -t20 http://localhost:8080/ -c100 -T 15")); + if (wrk_exists()) { + BOOST_REQUIRE_EQUAL(0, system("wrk -t20 http://localhost:18080/ -c100 -T 15")); + } } BOOST_AUTO_TEST_SUITE_END(); |