diff options
| author | Stefan Boberg <[email protected]> | 2023-04-24 15:48:55 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-24 15:48:55 +0200 |
| commit | 1a345a720f728438d0884c3ade4aa37d5c994701 (patch) | |
| tree | 8c06d8142b9774913c5de8a661080c25e1e74b6c /zenserver-test/zenserver-test.cpp | |
| parent | 0.2.5-pre4 (diff) | |
| download | zen-1a345a720f728438d0884c3ade4aa37d5c994701.tar.xz zen-1a345a720f728438d0884c3ade4aa37d5c994701.zip | |
fixed dashboard file serving bug (#255)
a recent change which introduced support for specifying accept: implicitly via the file extension in the URI caused fallout in the dashboard which would fail to serve any content because the extension was stripped from the RelativeUri accessor. This change fixes that by retaining a copy of the Uri string view which includes the suffix
additionally, in order to test this change with both asio/http.sys paths I made the path used for all tests configurable in zenserver-test which involved pulling in a change from sb/proto which makes testing configuration a bit more flexible
Diffstat (limited to 'zenserver-test/zenserver-test.cpp')
| -rw-r--r-- | zenserver-test/zenserver-test.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp index 1f320f2f6..3195181d1 100644 --- a/zenserver-test/zenserver-test.cpp +++ b/zenserver-test/zenserver-test.cpp @@ -300,7 +300,7 @@ main() return 0; } #elif 0 -//#include <restinio/all.hpp> +// #include <restinio/all.hpp> int main() @@ -317,6 +317,8 @@ zen::ZenServerEnvironment TestEnv; int main(int argc, char** argv) { + using namespace std::literals; + # if ZEN_USE_MIMALLOC mi_version(); # endif @@ -333,11 +335,31 @@ main(int argc, char** argv) std::filesystem::path ProgramBaseDir = std::filesystem::path(argv[0]).parent_path(); std::filesystem::path TestBaseDir = ProgramBaseDir.parent_path().parent_path() / ".test"; - TestEnv.InitializeForTest(ProgramBaseDir, TestBaseDir); + // This is pretty janky because we're passing most of the options through to the test + // framework, so we can't just use cxxopts (I think). This should ideally be cleaned up + // somehow in the future + + std::string ServerClass; + + for (int i = 1; i < argc; ++i) + { + if (argv[i] == "--http"sv) + { + if ((i + 1) < argc) + { + ServerClass = argv[++i]; + } + } + } + + TestEnv.InitializeForTest(ProgramBaseDir, TestBaseDir, ServerClass); ZEN_INFO("Running tests...(base dir: '{}')", TestBaseDir); - return ZEN_RUN_TESTS(argc, argv); + zen::testing::TestRunner Runner; + Runner.ApplyCommandLine(argc, argv); + + return Runner.Run(); } namespace zen::tests { @@ -454,7 +476,7 @@ TEST_CASE("project.basic") ZenServerInstance Instance1(TestEnv); Instance1.SetTestDir(TestDir); - Instance1.SpawnServer(PortNumber, "--http asio"); + Instance1.SpawnServer(PortNumber); Instance1.WaitUntilReady(); std::atomic<uint64_t> RequestCount{0}; @@ -1711,19 +1733,17 @@ TEST_CASE("zcache.failing.upstream") using namespace std::literals; using namespace utils; - const uint16_t Upstream1PortNumber = 13338; - ZenConfig Upstream1Cfg = ZenConfig::New(Upstream1PortNumber); - Upstream1Cfg.Args += (" --http asio"); + const uint16_t Upstream1PortNumber = 13338; + ZenConfig Upstream1Cfg = ZenConfig::New(Upstream1PortNumber); ZenServerInstance Upstream1Server(TestEnv); - const uint16_t Upstream2PortNumber = 13339; - ZenConfig Upstream2Cfg = ZenConfig::New(Upstream2PortNumber); - Upstream2Cfg.Args += (" --http asio"); + const uint16_t Upstream2PortNumber = 13339; + ZenConfig Upstream2Cfg = ZenConfig::New(Upstream2PortNumber); ZenServerInstance Upstream2Server(TestEnv); std::vector<std::uint16_t> UpstreamPorts = {Upstream1PortNumber, Upstream2PortNumber}; ZenConfig LocalCfg = ZenConfig::NewWithThreadedUpstreams(UpstreamPorts, false); - LocalCfg.Args += (" --http asio --upstream-thread-count 2"); + LocalCfg.Args += (" --upstream-thread-count 2"); ZenServerInstance LocalServer(TestEnv); const uint16_t LocalPortNumber = 13337; const auto LocalUri = fmt::format("http://localhost:{}/z$", LocalPortNumber); |