mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
test(cli): http test reliability fixes (#21246)
This commit is contained in:
parent
0223ff36f1
commit
9bc489d2d0
2 changed files with 27 additions and 16 deletions
|
@ -1136,7 +1136,7 @@ Deno.test(
|
||||||
{ permissions: { net: true } },
|
{ permissions: { net: true } },
|
||||||
async function droppedConnSenderNoPanic() {
|
async function droppedConnSenderNoPanic() {
|
||||||
async function server() {
|
async function server() {
|
||||||
const listener = Deno.listen({ port: 8000 });
|
const listener = Deno.listen({ port: listenPort });
|
||||||
const conn = await listener.accept();
|
const conn = await listener.accept();
|
||||||
const http = Deno.serveHttp(conn);
|
const http = Deno.serveHttp(conn);
|
||||||
const evt = await http.nextRequest();
|
const evt = await http.nextRequest();
|
||||||
|
@ -1151,7 +1151,7 @@ Deno.test(
|
||||||
|
|
||||||
async function client() {
|
async function client() {
|
||||||
try {
|
try {
|
||||||
const resp = await fetch("http://127.0.0.1:8000/");
|
const resp = await fetch(`http://127.0.0.1:${listenPort}/`);
|
||||||
await resp.body?.cancel();
|
await resp.body?.cancel();
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore error
|
// Ignore error
|
||||||
|
|
|
@ -3640,22 +3640,22 @@ Deno.test(
|
||||||
async function httpServeCurlH2C() {
|
async function httpServeCurlH2C() {
|
||||||
const ac = new AbortController();
|
const ac = new AbortController();
|
||||||
const server = Deno.serve(
|
const server = Deno.serve(
|
||||||
{ signal: ac.signal },
|
{ port: servePort, signal: ac.signal },
|
||||||
() => new Response("hello world!"),
|
() => new Response("hello world!"),
|
||||||
);
|
);
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"hello world!",
|
"hello world!",
|
||||||
await curlRequest(["http://localhost:8000/path"]),
|
await curlRequest([`http://localhost:${servePort}/path`]),
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"hello world!",
|
"hello world!",
|
||||||
await curlRequest(["http://localhost:8000/path", "--http2"]),
|
await curlRequest([`http://localhost:${servePort}/path`, "--http2"]),
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"hello world!",
|
"hello world!",
|
||||||
await curlRequest([
|
await curlRequest([
|
||||||
"http://localhost:8000/path",
|
`http://localhost:${servePort}/path`,
|
||||||
"--http2",
|
"--http2",
|
||||||
"--http2-prior-knowledge",
|
"--http2-prior-knowledge",
|
||||||
]),
|
]),
|
||||||
|
@ -3712,6 +3712,7 @@ Deno.test(
|
||||||
const server = Deno.serve(
|
const server = Deno.serve(
|
||||||
{
|
{
|
||||||
signal: ac.signal,
|
signal: ac.signal,
|
||||||
|
port: servePort,
|
||||||
cert: Deno.readTextFileSync("cli/tests/testdata/tls/localhost.crt"),
|
cert: Deno.readTextFileSync("cli/tests/testdata/tls/localhost.crt"),
|
||||||
key: Deno.readTextFileSync("cli/tests/testdata/tls/localhost.key"),
|
key: Deno.readTextFileSync("cli/tests/testdata/tls/localhost.key"),
|
||||||
},
|
},
|
||||||
|
@ -3720,16 +3721,20 @@ Deno.test(
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"hello world!",
|
"hello world!",
|
||||||
await curlRequest(["https://localhost:8000/path", "-k"]),
|
await curlRequest([`https://localhost:${servePort}/path`, "-k"]),
|
||||||
);
|
|
||||||
assertEquals(
|
|
||||||
"hello world!",
|
|
||||||
await curlRequest(["https://localhost:8000/path", "-k", "--http2"]),
|
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"hello world!",
|
"hello world!",
|
||||||
await curlRequest([
|
await curlRequest([
|
||||||
"https://localhost:8000/path",
|
`https://localhost:${servePort}/path`,
|
||||||
|
"-k",
|
||||||
|
"--http2",
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
"hello world!",
|
||||||
|
await curlRequest([
|
||||||
|
`https://localhost:${servePort}/path`,
|
||||||
"-k",
|
"-k",
|
||||||
"--http2",
|
"--http2",
|
||||||
"--http2-prior-knowledge",
|
"--http2-prior-knowledge",
|
||||||
|
@ -3742,12 +3747,15 @@ Deno.test(
|
||||||
);
|
);
|
||||||
|
|
||||||
async function curlRequest(args: string[]) {
|
async function curlRequest(args: string[]) {
|
||||||
const { success, stdout } = await new Deno.Command("curl", {
|
const { success, stdout, stderr } = await new Deno.Command("curl", {
|
||||||
args,
|
args,
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
stderr: "null",
|
stderr: "piped",
|
||||||
}).output();
|
}).output();
|
||||||
assert(success);
|
assert(
|
||||||
|
success,
|
||||||
|
`Failed to cURL ${args}: stdout\n\n${stdout}\n\nstderr:\n\n${stderr}`,
|
||||||
|
);
|
||||||
return new TextDecoder().decode(stdout);
|
return new TextDecoder().decode(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3757,7 +3765,10 @@ async function curlRequestWithStdErr(args: string[]) {
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
stderr: "piped",
|
stderr: "piped",
|
||||||
}).output();
|
}).output();
|
||||||
assert(success);
|
assert(
|
||||||
|
success,
|
||||||
|
`Failed to cURL ${args}: stdout\n\n${stdout}\n\nstderr:\n\n${stderr}`,
|
||||||
|
);
|
||||||
return [new TextDecoder().decode(stdout), new TextDecoder().decode(stderr)];
|
return [new TextDecoder().decode(stdout), new TextDecoder().decode(stderr)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue