Skip to content

Commit

Permalink
nfdmgmt-interop: make console output more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed Dec 21, 2024
1 parent 0f73b0d commit 60c652b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 16 deletions.
7 changes: 6 additions & 1 deletion integ/nfdmgmt-interop/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# `@ndn/nfdmgmt` Interoperability Test

`NDNTS_UPLINK` must point to a running NFD as a local-scope face.
`NDNTS_UPLINK` must point to a running NFD or YaNFD as a local-scope face, such as:

* `export NDNTS_UPLINK=unix:///run/nfd/nfd.sock`
* `export NDNTS_UPLINK=tcp://127.0.0.1:6363`

To perform the tests, run one of these scripts and observe the stdout:

```bash
corepack pnpm literate integ/nfdmgmt-interop/general.ts
Expand Down
6 changes: 6 additions & 0 deletions integ/nfdmgmt-interop/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import { Name } from "@ndn/packet";

await openUplinks();

console.group("[CsInfo]");
for (const csInfo of await list(CsInfo)) {
console.log(csInfo.toString());
}
console.groupEnd();
console.log();

console.group("[cs/erase]");
console.log(await invokeCsErase(new Name("/ndn")));
console.groupEnd();
console.log();

closeUplinks();
37 changes: 24 additions & 13 deletions integ/nfdmgmt-interop/face-rib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,95 @@ import { Name } from "@ndn/packet";

await openUplinks();

console.log("[FaceStatus]");
console.group("[FaceStatus]");
for (const face of await list(FaceStatus)) {
console.log(face.toString());
}
console.groupEnd();
console.log();

console.log("[faces/create]");
console.group("[faces/create]");
const resF0 = await invoke("faces/create", {
uri: "udp4://127.0.0.1:7001",
facePersistency: FacePersistency.Permanent,
mtu: 1300,
});
assert.equal(resF0.statusCode, 200);
assert(resF0.body !== undefined);
const bodyF0 = ControlParameters.decodeFromResponseBody(resF0);
console.log(bodyF0.toString());
assert.equal(bodyF0.facePersistency, FacePersistency.Permanent);
assert.equal(bodyF0.mtu, 1300);
const faceId = bodyF0.faceId!;
console.groupEnd();
console.log();

console.log("[faces/update]");
console.group("[faces/update]");
const resF1 = await invoke("faces/update", {
faceId,
mtu: 1250,
});
assert.equal(resF1.statusCode, 200);
assert(resF1.body !== undefined);
const bodyF1 = ControlParameters.decodeFromResponseBody(resF1);
console.log(bodyF1.toString());
assert.equal(bodyF1.faceId, faceId);
assert.equal(bodyF1.facePersistency, FacePersistency.Permanent);
assert.equal(bodyF1.mtu, 1250);
console.groupEnd();
console.log();

console.log("[FaceQuery]");
console.group("[FaceQuery]");
for (const face of await list(FaceQuery({ faceId }))) {
console.log(face.toString());
}
console.groupEnd();
console.log();

console.log("[rib/register]");
console.group("[rib/register]");
const resR0 = await invoke("rib/register", {
faceId,
name: new Name("/NDNts-nfdmgmt-interop"),
});
assert.equal(resR0.statusCode, 200);
assert(resR0.body !== undefined);
const bodyR0 = ControlParameters.decodeFromResponseBody(resR0);
console.log(bodyR0.toString());
assert.equal(bodyR0.faceId, faceId);
assert.equal(bodyR0.name?.toString(), "/8=NDNts-nfdmgmt-interop");
assert.equal(bodyR0.origin, 0);
assert.equal(bodyR0.flagChildInherit, true);
assert.equal(bodyR0.flagCapture, false);
console.groupEnd();
console.log();

console.log("[RibEntry]");
console.group("[RibEntry]");
for (const ribEntry of await list(RibEntry)) {
console.log(ribEntry.toString());
}
console.groupEnd();
console.log();

console.log("[rib/unregister]");
console.group("[rib/unregister]");
const resR1 = await invoke("rib/unregister", {
faceId,
name: new Name("/NDNts-nfdmgmt-interop"),
});
assert.equal(resR1.statusCode, 200);
assert(resR1.body !== undefined);
const bodyR1 = ControlParameters.decodeFromResponseBody(resR1);
console.log(bodyR1.toString());
assert.equal(bodyR1.faceId, faceId);
assert.equal(bodyR1.name?.toString(), "/8=NDNts-nfdmgmt-interop");
assert.equal(bodyR1.origin, 0);
console.groupEnd();
console.log();

console.log("[faces/destroy]");
console.group("[faces/destroy]");
const resF2 = await invoke("faces/destroy", {
faceId,
});
assert.equal(resF2.statusCode, 200);
assert(resF2.body !== undefined);
const bodyF2 = ControlParameters.decodeFromResponseBody(resF2);
console.log(bodyF2.toString());
assert.equal(bodyF2.faceId, faceId);
console.groupEnd();
console.log();

closeUplinks();
14 changes: 12 additions & 2 deletions integ/nfdmgmt-interop/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Name } from "@ndn/packet";

await openUplinks();

console.group("[strategy-choice/set]");
const res0 = await invoke("strategy-choice/set", {
name: new Name("/NDNts-nfdmgmt-interop"),
strategy: new Name("/localhost/nfd/strategy/unknown"),
Expand All @@ -14,21 +15,30 @@ assert.equal(res0.statusCode, 404);

const res1 = await invoke("strategy-choice/set", {
name: new Name("/NDNts-nfdmgmt-interop"),
strategy: new Name("/localhost/nfd/strategy/access"),
strategy: new Name("/localhost/nfd/strategy/multicast"),
});
assert.equal(res1.statusCode, 200);
assert.equal(res1.statusCode, 200);
assert(res1.body !== undefined);
const body1 = ControlParameters.decodeFromResponseBody(res1);
console.log(body1.toString());
console.groupEnd();
console.log();

console.group("[StrategyChoice]");
for (const sc of await list(StrategyChoice)) {
console.log(sc.toString());
}
console.groupEnd();
console.log();

console.group("[strategy-choice/unset]");
const res2 = await invoke("strategy-choice/unset", {
name: new Name("/NDNts-nfdmgmt-interop"),
});
assert.equal(res2.statusCode, 200);
const body2 = ControlParameters.decodeFromResponseBody(res2);
console.log(body2.toString());
console.groupEnd();
console.log();

closeUplinks();

0 comments on commit 60c652b

Please sign in to comment.