summaryrefslogtreecommitdiff
path: root/test/storage/http_load.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/storage/http_load.cpp')
-rw-r--r--test/storage/http_load.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/storage/http_load.cpp b/test/storage/http_load.cpp
new file mode 100644
index 0000000000..fff662da29
--- /dev/null
+++ b/test/storage/http_load.cpp
@@ -0,0 +1,42 @@
+#include "storage.hpp"
+
+#include <uv.h>
+
+#include <mbgl/storage/default_file_source.hpp>
+
+TEST_F(Storage, HTTPLoad) {
+ SCOPED_TEST(HTTPLoad)
+
+ using namespace mbgl;
+
+ DefaultFileSource fs(nullptr, uv_default_loop());
+
+ const int concurrency = 50;
+ const int max = 10000;
+ int number = 1;
+
+ std::function<void()> req = [&]() {
+ const auto current = number++;
+ fs.request({ Resource::Unknown, std::string("http://127.0.0.1:3000/load/") + std::to_string(current) }, uv_default_loop(), [&, current](const Response &res) {
+ EXPECT_EQ(Response::Successful, res.status);
+ EXPECT_EQ(std::string("Request ") + std::to_string(current), res.data);
+ EXPECT_EQ(0, res.expires);
+ EXPECT_EQ(0, res.modified);
+ EXPECT_EQ("", res.etag);
+ EXPECT_EQ("", res.message);
+
+ if (number <= max) {
+ req();
+ } else if (current == max) {
+ HTTPLoad.finish();
+ }
+ });
+ };
+
+
+ for (int i = 0; i < concurrency; i++) {
+ req();
+ }
+
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+}