summaryrefslogtreecommitdiff
path: root/std/http/racing_server_test.ts
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-02-02 19:05:46 +0800
committerGitHub <noreply@github.com>2021-02-02 12:05:46 +0100
commit6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch)
treefd94c013a19fcb38954844085821ec1601c20e18 /std/http/racing_server_test.ts
parenta2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff)
chore: remove std directory (#9361)
This removes the std folder from the tree. Various parts of the tests are pretty tightly dependent on std (47 direct imports and 75 indirect imports, not counting the cli tests that use them as fixtures) so I've added std as a submodule for now.
Diffstat (limited to 'std/http/racing_server_test.ts')
-rw-r--r--std/http/racing_server_test.ts81
1 files changed, 0 insertions, 81 deletions
diff --git a/std/http/racing_server_test.ts b/std/http/racing_server_test.ts
deleted file mode 100644
index 8018a4312..000000000
--- a/std/http/racing_server_test.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-import { assert, assertEquals } from "../testing/asserts.ts";
-import { BufReader, BufWriter } from "../io/bufio.ts";
-import { TextProtoReader } from "../textproto/mod.ts";
-import { dirname, fromFileUrl } from "../path/mod.ts";
-
-const moduleDir = dirname(fromFileUrl(import.meta.url));
-
-let server: Deno.Process<Deno.RunOptions & { stdout: "piped" }>;
-async function startServer(): Promise<void> {
- server = Deno.run({
- cmd: [Deno.execPath(), "run", "--quiet", "-A", "racing_server.ts"],
- cwd: moduleDir,
- stdout: "piped",
- });
- // Once racing server is ready it will write to its stdout.
- assert(server.stdout != null);
- const r = new TextProtoReader(new BufReader(server.stdout));
- const s = await r.readLine();
- assert(s !== null && s.includes("Racing server listening..."));
-}
-function killServer(): void {
- server.close();
- server.stdout.close();
-}
-
-const input = [
- "GET / HTTP/1.1\r\n\r\n",
- "GET / HTTP/1.1\r\n\r\n",
- "GET / HTTP/1.1\r\n\r\n",
- "POST / HTTP/1.1\r\ncontent-length: 4\r\n\r\ndeno",
- "POST / HTTP/1.1\r\ntransfer-encoding: chunked\r\n\r\n4\r\ndeno\r\n0\r\n\r\n",
- "POST / HTTP/1.1\r\ntransfer-encoding: chunked\r\ntrailer: deno\r\n\r\n4\r\ndeno\r\n0\r\n\r\ndeno: land\r\n\r\n",
- "GET / HTTP/1.1\r\n\r\n",
-].join("");
-const HUGE_BODY_SIZE = 1024 * 1024;
-const output = `HTTP/1.1 200 OK
-content-length: 6
-
-Step1
-HTTP/1.1 200 OK
-content-length: ${HUGE_BODY_SIZE}
-
-${"a".repeat(HUGE_BODY_SIZE)}HTTP/1.1 200 OK
-content-length: ${HUGE_BODY_SIZE}
-
-${"b".repeat(HUGE_BODY_SIZE)}HTTP/1.1 200 OK
-content-length: 6
-
-Step4
-HTTP/1.1 200 OK
-content-length: 6
-
-Step5
-HTTP/1.1 200 OK
-content-length: 6
-
-Step6
-HTTP/1.1 200 OK
-content-length: 6
-
-Step7
-`;
-
-Deno.test("serverPipelineRace", async function (): Promise<void> {
- await startServer();
-
- const conn = await Deno.connect({ port: 4501 });
- const r = new TextProtoReader(new BufReader(conn));
- const w = new BufWriter(conn);
- await w.write(new TextEncoder().encode(input));
- await w.flush();
- const outLines = output.split("\n");
- // length - 1 to disregard last empty line
- for (let i = 0; i < outLines.length - 1; i++) {
- const s = await r.readLine();
- assertEquals(s, outLines[i]);
- }
- killServer();
- conn.close();
-});