Skip to content

Commit

Permalink
Rename alice -> dialer and bob -> listener
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger committed Sep 19, 2023
1 parent 46a9a0a commit d6faacb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions hole-punch-interop/src/compose-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export async function run(namespace: string, compose: ComposeSpecification, logD
const stderrLogFile = path.join(logDir, `${sanitizedComposeName}.stderr`);

try {
const { stdout, stderr } = await exec(`docker compose -f ${path.join(dir, "compose.yaml")} up --exit-code-from alice --abort-on-container-exit`, { timeout: 60 * 1000 })
const { stdout, stderr } = await exec(`docker compose -f ${path.join(dir, "compose.yaml")} up --exit-code-from dialer --abort-on-container-exit`, { timeout: 60 * 1000 })

await fs.writeFile(stdoutLogFile, stdout);
await fs.writeFile(stderrLogFile, stderr);

return JSON.parse(lastStdoutLine(stdout, "alice", sanitizedComposeName)) as Report
return JSON.parse(lastStdoutLine(stdout, "dialer", sanitizedComposeName)) as Report
} catch (e: unknown) {
if (isExecException(e)) {
await fs.writeFile(stdoutLogFile, e.stdout)
Expand Down
54 changes: 27 additions & 27 deletions hole-punch-interop/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ export async function buildTestSpecs(versions: Array<Version>, nameFilter: strin

// Generate the testing combinations by SELECT'ing from transports tables the distinct combinations where the transports of the different libp2p implementations match.
const queryResults =
await db.all(`SELECT DISTINCT a.id as alice, b.id as bob, a.transport
await db.all(`SELECT DISTINCT a.id as dialer, b.id as listener, a.transport
FROM transports a, transports b
WHERE a.transport == b.transport;`
);
await db.close();

return queryResults.map((test): ComposeSpecification => (
buildSpec(containerImages, {
name: `${test.alice} x ${test.bob} (${test.transport})`,
aliceImage: test.alice,
bobImage: test.bob,
name: `${test.dialer} x ${test.listener} (${test.transport})`,
dialerImage: test.dialer,
listenerImage: test.listener,
transport: test.transport,
extraEnv: buildExtraEnv(timeoutOverride, test.id1, test.id2)
}, nameFilter, nameIgnore, routerImageId, relayImageId, routerDelay, relayDelay)
Expand All @@ -66,16 +66,16 @@ export async function buildTestSpecs(versions: Array<Version>, nameFilter: strin

interface TestSpec {
name: string,
aliceImage: string,
bobImage: string,
dialerImage: string,
listenerImage: string,
transport: string,
extraEnv?: { [key: string]: string }
}

function buildSpec(containerImages: { [key: string]: () => string }, {
name,
aliceImage,
bobImage,
dialerImage,
listenerImage,
transport,
extraEnv
}: TestSpec, nameFilter: string | null, nameIgnore: string | null, routerImageId: string, relayImageId: string, routerDelay: number, relayDelay: number): ComposeSpecification | null {
Expand All @@ -89,7 +89,7 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
const rustLog = "debug,netlink_proto=warn,rustls=warn,multistream_select=warn";
let internetNetworkName = `${sanitizeComposeName(name)}_internet`

let startupScriptFn = (actor: "alice" | "bob") => (`
let startupScriptFn = (actor: "dialer" | "listener") => (`
set -ex;
# Wait for router to be online
Expand Down Expand Up @@ -132,60 +132,60 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
},
cap_add: ["NET_ADMIN"]
},
alice_router: {
dialer_router: {
depends_on: ["redis"],
image: routerImageId,
init: true,
environment: {
DELAY_MS: routerDelay
},
networks: {
alice_lan: {},
dialer_lan: {},
internet: {},
},
cap_add: ["NET_ADMIN"]
},
alice: {
depends_on: ["relay", "alice_router", "redis"],
image: containerImages[aliceImage](),
dialer: {
depends_on: ["relay", "dialer_router", "redis"],
image: containerImages[dialerImage](),
init: true,
command: ["/bin/sh", "-c", startupScriptFn("alice")],
command: ["/bin/sh", "-c", startupScriptFn("dialer")],
environment: {
TRANSPORT: transport,
MODE: "dial",
RUST_LOG: rustLog,
},
networks: {
alice_lan: {},
dialer_lan: {},
},
cap_add: ["NET_ADMIN"],
volumes: [dockerSocketVolume]
},
bob_router: {
listener_router: {
depends_on: ["redis"],
image: routerImageId,
init: true,
environment: {
DELAY_MS: routerDelay
},
networks: {
bob_lan: {},
listener_lan: {},
internet: {},
},
cap_add: ["NET_ADMIN"]
},
bob: {
depends_on: ["relay", "bob_router", "redis"],
image: containerImages[bobImage](),
listener: {
depends_on: ["relay", "listener_router", "redis"],
image: containerImages[listenerImage](),
init: true,
command: ["/bin/sh", "-c", startupScriptFn("bob")],
command: ["/bin/sh", "-c", startupScriptFn("listener")],
environment: {
TRANSPORT: transport,
MODE: "listen",
RUST_LOG: rustLog,
},
networks: {
bob_lan: {},
listener_lan: {},
},
cap_add: ["NET_ADMIN"],
volumes: [dockerSocketVolume]
Expand All @@ -199,18 +199,18 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
internet: {
aliases: ["redis"]
},
alice_lan: {
dialer_lan: {
aliases: ["redis"]
},
bob_lan: {
listener_lan: {
aliases: ["redis"]
},
}
}
},
networks: {
alice_lan: { },
bob_lan: { },
dialer_lan: { },
listener_lan: { },
internet: { },
}
}
Expand Down
8 changes: 4 additions & 4 deletions hole-punch-interop/src/stdoutParser.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {lastStdoutLine} from "./compose-runner";

let exampleStdout = `
Attaching to rust-v0_52_x_rust-v0_52__quic_-alice-1, rust-v0_52_x_rust-v0_52__quic_-alice_router-1, rust-v0_52_x_rust-v0_52__quic_-bob-1, rust-v0_52_x_rust-v0_52__quic_-bob_router-1, rust-v0_52_x_rust-v0_52__quic_-redis-1, rust-v0_52_x_rust-v0_52__quic_-relay-1
Attaching to rust-v0_52_x_rust-v0_52__quic_-dialer-1, rust-v0_52_x_rust-v0_52__quic_-dialer_router-1, rust-v0_52_x_rust-v0_52__quic_-listener-1, rust-v0_52_x_rust-v0_52__quic_-listener_router-1, rust-v0_52_x_rust-v0_52__quic_-redis-1, rust-v0_52_x_rust-v0_52__quic_-relay-1
rust-v0_52_x_rust-v0_52__quic_-redis-1 | 1:C 19 Sep 2023 05:19:20.620 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
rust-v0_52_x_rust-v0_52__quic_-redis-1 | 1:C 19 Sep 2023 05:19:20.620 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
rust-v0_52_x_rust-v0_52__quic_-redis-1 | 1:C 19 Sep 2023 05:19:20.620 * Redis version=7.2.1, bits=64, commit=00000000, modified=0, pid=1, just started
Expand All @@ -10,11 +10,11 @@ rust-v0_52_x_rust-v0_52__quic_-redis-1 | 1:M 19 Sep 2023 05:19:20.620 *
rust-v0_52_x_rust-v0_52__quic_-redis-1 | 1:M 19 Sep 2023 05:19:20.621 * Running mode=standalone, port=6379.
rust-v0_52_x_rust-v0_52__quic_-redis-1 | 1:M 19 Sep 2023 05:19:20.621 * Server initialized
rust-v0_52_x_rust-v0_52__quic_-redis-1 | 1:M 19 Sep 2023 05:19:20.621 * Ready to accept connections tcp
rust-v0_52_x_rust-v0_52__quic_-alice-1 | {"rtt_to_holepunched_peer_millis":201}
rust-v0_52_x_rust-v0_52__quic_-alice-1 exited with code 0
rust-v0_52_x_rust-v0_52__quic_-dialer-1 | {"rtt_to_holepunched_peer_millis":201}
rust-v0_52_x_rust-v0_52__quic_-dialer-1 exited with code 0
`;

const line = lastStdoutLine(exampleStdout, "alice", "rust-v0_52_x_rust-v0_52__quic_");
const line = lastStdoutLine(exampleStdout, "dialer", "rust-v0_52_x_rust-v0_52__quic_");

if (line != `{"rtt_to_holepunched_peer_millis":201}`) {
throw new Error("Unexpected stdout")
Expand Down

0 comments on commit d6faacb

Please sign in to comment.