summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2021-02-21 19:20:31 +0100
committerGitHub <noreply@github.com>2021-02-21 19:20:31 +0100
commit9d70ea2e9f03d7c12407f117cf11d2a99d55c8f8 (patch)
treeaf9699876b632ac452d0cd6214647cb3598eaec6 /cli/tests
parentaf93256d05993b53debe0552828b6ae7df521750 (diff)
feat(unstable): per op metrics (#9240)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/metrics_test.ts28
1 files changed, 19 insertions, 9 deletions
diff --git a/cli/tests/unit/metrics_test.ts b/cli/tests/unit/metrics_test.ts
index a60aae427..2f12ac90d 100644
--- a/cli/tests/unit/metrics_test.ts
+++ b/cli/tests/unit/metrics_test.ts
@@ -2,30 +2,40 @@
import { assert, unitTest } from "./test_util.ts";
unitTest(async function metrics(): Promise<void> {
+ // Write to stdout to ensure a "data" message gets sent instead of just
+ // control messages.
+ const dataMsg = new Uint8Array([13, 13, 13]); // "\r\r\r",
+ await Deno.stdout.write(dataMsg);
+
const m1 = Deno.metrics();
assert(m1.opsDispatched > 0);
- assert(m1.opsDispatchedSync > 0);
assert(m1.opsCompleted > 0);
- assert(m1.opsCompletedSync > 0);
assert(m1.bytesSentControl > 0);
assert(m1.bytesSentData >= 0);
assert(m1.bytesReceived > 0);
+ const m1OpWrite = m1.ops["op_write"];
+ assert(m1OpWrite.opsDispatchedAsync > 0);
+ assert(m1OpWrite.opsCompletedAsync > 0);
+ assert(m1OpWrite.bytesSentControl > 0);
+ assert(m1OpWrite.bytesSentData >= 0);
+ assert(m1OpWrite.bytesReceived > 0);
- // Write to stdout to ensure a "data" message gets sent instead of just
- // control messages.
- const dataMsg = new Uint8Array([13, 13, 13]); // "\r\r\r",
await Deno.stdout.write(dataMsg);
const m2 = Deno.metrics();
- assert(m2.opsDispatched > m1.opsDispatched);
- assert(m2.opsDispatchedSync > m1.opsDispatchedSync);
assert(m2.opsDispatchedAsync > m1.opsDispatchedAsync);
- assert(m2.opsCompleted > m1.opsCompleted);
- assert(m2.opsCompletedSync > m1.opsCompletedSync);
assert(m2.opsCompletedAsync > m1.opsCompletedAsync);
assert(m2.bytesSentControl > m1.bytesSentControl);
assert(m2.bytesSentData >= m1.bytesSentData + dataMsg.byteLength);
assert(m2.bytesReceived > m1.bytesReceived);
+ const m2OpWrite = m2.ops["op_write"];
+ assert(m2OpWrite.opsDispatchedAsync > m1OpWrite.opsDispatchedAsync);
+ assert(m2OpWrite.opsCompletedAsync > m1OpWrite.opsCompletedAsync);
+ assert(m2OpWrite.bytesSentControl > m1OpWrite.bytesSentControl);
+ assert(
+ m2OpWrite.bytesSentData >= m1OpWrite.bytesSentData + dataMsg.byteLength,
+ );
+ assert(m2OpWrite.bytesReceived > m1OpWrite.bytesReceived);
});
unitTest(