summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuha Alanen <juha.alanen@mapbox.com>2020-01-16 12:18:17 +0200
committerJuha Alanen <juha.alanen@mapbox.com>2020-01-30 13:52:09 +0200
commitf2845990bb8ad6ef11ec0e03a5812e4616f9cda0 (patch)
tree8af73d48746484430b10ceec6f8606b0f277e9b9
parentb0e16ec9cb353150355580aa544e4284fe11b8fe (diff)
downloadqtlocation-mapboxgl-f2845990bb8ad6ef11ec0e03a5812e4616f9cda0.tar.gz
[test] Remove node.js based HTTP server
-rw-r--r--test/include/mbgl/test/util.hpp9
-rw-r--r--test/src/mbgl/test/util.cpp79
-rwxr-xr-xtest/storage/server.js175
3 files changed, 0 insertions, 263 deletions
diff --git a/test/include/mbgl/test/util.hpp b/test/include/mbgl/test/util.hpp
index b499b5750c..42be19e9ae 100644
--- a/test/include/mbgl/test/util.hpp
+++ b/test/include/mbgl/test/util.hpp
@@ -65,15 +65,6 @@ class Server;
namespace mbgl {
namespace test {
-class Server {
-public:
- Server(const char* script);
- ~Server();
-
-private:
- int fd = -1;
-};
-
class HttpServer {
public:
HttpServer();
diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp
index 30eea19bdf..cde3d6e9de 100644
--- a/test/src/mbgl/test/util.cpp
+++ b/test/src/mbgl/test/util.cpp
@@ -6,88 +6,9 @@
#include <mapbox/pixelmatch.hpp>
-#include <csignal>
-#include <future>
-
-#include <unistd.h>
-
-#define xstr(s) str(s)
-#define str(s) #s
-
namespace mbgl {
namespace test {
-Server::Server(const char* script) {
- int input[2];
- int output[2];
-
- if (pipe(input)) {
- throw std::runtime_error("Cannot create server input pipe");
- }
- if (pipe(output)) {
- throw std::runtime_error("Cannot create server output pipe");
- }
-
- // Store the parent => child pipe so that we can close it in the destructor.
- fd = input[1];
-
- pid_t pid = fork();
- if (pid < 0) {
- Log::Error(Event::Setup, "Cannot create server process");
- exit(1);
- } else if (pid == 0) {
- // This is the child process.
-
- // Connect the parent => child pipe to stdin.
- while ((dup2(input[0], STDIN_FILENO) == -1) && (errno == EINTR)) {}
- close(input[0]);
- close(input[1]);
-
- // Move the child => parent side of the pipe to stdout.
- while ((dup2(output[1], STDOUT_FILENO) == -1) && (errno == EINTR)) {}
- close(output[1]);
- close(output[0]);
-
- const char* executable = xstr(NODE_EXECUTABLE);
-
- // Launch the actual server process.
- int ret = execl(executable, executable, script, nullptr);
-
- // This call should not return. In case execl failed, we exit anyway.
- if (ret < 0) {
- Log::Error(Event::Setup, "Failed to start server: %s", strerror(errno));
- }
- abort();
- } else {
- // This is the parent process.
-
- // Close the unneeded sides of the pipes.
- close(output[1]);
- close(input[0]);
-
- // Wait until the server process sends at least 2 bytes or closes the handle.
- char buffer[2];
- ssize_t bytes, total = 0;
- while (total < 2 && (bytes = read(output[0], buffer + total, 2 - total)) != 0) {
- total += bytes;
- }
-
- // Close child => parent pipe.
- close(output[0]);
-
- // Check signature
- if (total != 2 || strncmp(buffer, "OK", 2) != 0) {
- throw std::runtime_error("Failed to start server: Invalid signature");
- }
- }
-}
-
-Server::~Server() {
- if (fd > 0) {
- close(fd);
- }
-}
-
void checkImage(const std::string& base,
const PremultipliedImage& actual,
double imageThreshold,
diff --git a/test/storage/server.js b/test/storage/server.js
deleted file mode 100755
index d6429e4635..0000000000
--- a/test/storage/server.js
+++ /dev/null
@@ -1,175 +0,0 @@
-#!/usr/bin/env node
-/* jshint node: true */
-'use strict';
-
-// This needs to be here to make sure the pipe stays open.
-// We're waiting until the stdin pipe gets closed (e.g. because the parent
-// process dies)
-process.stdin.on('readable', function() {});
-process.stdin.on('end', function() { process.exit(0); });
-
-
-var fs = require('fs');
-var express = require('express');
-var app = express();
-
-// We're manually setting Etag headers.
-app.disable('etag');
-
-app.get('/test', function (req, res) {
- if (req.query.modified) {
- res.setHeader('Last-Modified', (new Date(req.query.modified * 1000)).toUTCString());
- }
- if (req.query.expires) {
- res.setHeader('Expires', (new Date(req.query.expires * 1000)).toUTCString());
- }
- if (req.query.etag) {
- res.setHeader('ETag', req.query.etag);
- }
- if (req.query.cachecontrol) {
- res.setHeader('Cache-Control', req.query.cachecontrol);
- }
- res.send('Hello World!');
-});
-
-app.get('/stale/*', function() {
- // Never respond.
-});
-
-var cacheCounter = 0;
-app.get('/cache', function(req, res) {
- res.setHeader('Cache-Control', 'max-age=30'); // Allow caching for 30 seconds
- res.send('Response ' + (++cacheCounter));
-});
-
-app.get('/revalidate-same', function(req, res) {
- if (req.headers['if-none-match'] == 'snowfall') {
- // Second request can be cached for 1 second.
- res.setHeader('Cache-Control', 'max-age=1, must-revalidate');
- res.status(304).end();
- } else {
- // First request must always be revalidated.
- res.setHeader('ETag', 'snowfall');
- res.setHeader('Cache-Control', 'must-revalidate');
- res.status(200).send('Response');
- }
-});
-
-var expiresCounter = 0;
-app.get('/clockskew', function (req, res) {
- res.setHeader('Expires', (new Date(2010, 1, 1, 10, ++expiresCounter, 0)).toUTCString());
- res.status(200).send('Response');
-});
-
-app.get('/revalidate-modified', function(req, res) {
- var jan1 = new Date('jan 1 2015 utc');
-
- if (req.headers['if-modified-since']) {
- var modified_since = new Date(req.headers['if-modified-since']);
- if (modified_since >= jan1) {
- res.setHeader('Cache-Control', 'max-age=1, must-revalidate');
- res.status(304).end();
- return;
- }
- }
-
- // First request must always be revalidated.
- res.setHeader('Last-Modified', jan1.toUTCString());
- res.setHeader('Cache-Control', 'must-revalidate');
- res.status(200).send('Response');
-});
-
-
-var revalidateEtagCounter = 1;
-app.get('/revalidate-etag', function(req, res) {
- res.setHeader('ETag', 'response-' + revalidateEtagCounter);
- res.setHeader('Cache-Control', 'must-revalidate');
-
- res.status(200).send('Response ' + revalidateEtagCounter);
- revalidateEtagCounter++;
-});
-
-app.get('/empty-data', function(req, res) {
- res.status(200).send();
-});
-
-app.get('/no-content', function(req, res) {
- res.status(204).send();
-});
-
-app.get('/not-found', function(req, res) {
- res.status(404).send('Not Found!');
-});
-
-app.get('/permanent-error', function(req, res) {
- res.status(500).send('Server Error!');
-});
-
-var temporaryErrorCounter = 0;
-app.get('/temporary-error', function(req, res) {
- if (temporaryErrorCounter === 0) {
- res.status(500).end();
- } else {
- res.status(200).send('Hello World!');
- }
-
- temporaryErrorCounter++;
-});
-
-app.get('/rate-limit', function(req, res) {
-
- if (req.query.std) {
- res.setHeader('Retry-After', 1);
- } else if (req.query.mbx) {
- res.setHeader('x-rate-limit-reset', Math.round(Date.now() / 1000) + 1);
- }
-
- res.status(429).end();
-});
-
-var styleFailOnce500 = true;
-app.get('/style-fail-once-500', function (req, res) {
- if (styleFailOnce500) {
- res.status(500).send('Server Error!');
- styleFailOnce500 = false;
- } else {
- res.status(200).send('{ "version": 8, "name": "Teste Style" }');
- }
-});
-
-var styleFailOnce404 = true;
-app.get('/style-fail-once-404', function (req, res) {
- if (styleFailOnce404) {
- res.status(404).send('Not found!');
- styleFailOnce404 = false;
- } else {
- res.status(200).send('{ "version": 8, "name": "Teste Style" }');
- }
-});
-
-var styleFailOnce404Cache = true;
-app.get('/style-fail-once-404-cache', function (req, res) {
- if (styleFailOnce404Cache) {
- res.setHeader('Cache-Control', 'max-age=30');
- res.status(404).send('Not found!');
- styleFailOnce404Cache = false;
- } else {
- res.status(200).send('{ "version": 8, "name": "Teste Style" }');
- }
-});
-
-app.get('/delayed', function(req, res) {
- setTimeout(function() {
- res.status(200).send('Response');
- }, 200);
-});
-
-
-app.get('/load/:number(\\d+)', function(req, res) {
- res.send('Request ' + req.params.number);
-});
-
-var server = app.listen(3000, function () {
- // Tell parent that we're now listening.
- process.stdout.write("OK");
-});