Skip to content

Commit

Permalink
Fix #1659, replace whitespace with dash. (#1677)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepoviola authored Jan 14, 2024
1 parent 0b55697 commit 443be9d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/src/network-definition-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The network config can be provided both in `json` or `toml` format and each sect
- `random_nominators_count`: (number, optional), if is set _and the stacking pallet is enabled_ zombienet will generate `x` nominators and will be injected in the genesis.
- `max_nominations`: (number, default 24), the max allowed number of nominations by a nominator. This should match the value set in the runtime (e.g Kusama is 24 and Polkadot 16).
- `nodes`:
- `*name`: (String) Name of the node.
- `*name`: (String) Name of the node. *Note*: Any whitespace in the name will be replaced with a dash (e.g 'new alice' -> 'new-alice').
- `image`: (String) Override default docker image to use for this node.
- `command`: (String) Override default command.
- `command_with_args`: (String) Override default command and args.
Expand All @@ -59,7 +59,7 @@ The network config can be provided both in `json` or `toml` format and each sect
- `prometheus_prefix`: A parameter for customizing the metric's prefix for the specific node. Will apply only to this node; Defaults to 'substrate'.
- `keystore_key_types`: Defines which keystore keys should be created, for more details checkout details below.
- `node_groups`:
- `*name`: (String) Group name, used for naming the nodes (e.g name-1)
- `*name`: (String) Group name, used for naming the nodes (e.g name-1) *Note*: Any whitespace in the name will be replaced with a dash (e.g 'new group' -> 'new-group').
- `*count` (Number), Number of `nodes` to launch for this group.
- `image`: (String) Override default docker image to use for this node.
- `command`: (String) Override default command.
Expand All @@ -86,7 +86,7 @@ The network config can be provided both in `json` or `toml` format and each sect
- `prometheus_prefix`: A parameter for customizing the metric's prefix for the specific node. Will apply only to all parachain nodes/collators; Defaults to 'substrate'.
- `collator`:

- `*name`: (String) Name of the collator.
- `*name`: (String) Name of the collator. *Note*: Any whitespace in the name will be replaced with a dash (e.g 'new alice' -> 'new-alice').
- `image`: (String) Image to use.
- `command`: (String, default `polkadot-parachain`) Command to run.
- `args`: (Array of strings) An array of arguments to use as default to pass to the `command`.
Expand All @@ -99,7 +99,7 @@ The network config can be provided both in `json` or `toml` format and each sect

- `collator_groups`:

- `*name`: (String) Name of the collator.
- `*name`: (String) Name of the collator. *Note*: Any whitespace in the name will be replaced with a dash (e.g 'new alice' -> 'new-alice').
- `*count`: (Number) Number of `collators` to launch for this group.
- `image`: (String) Image to use.
- `command`: (String, default `polkadot-parachain`) Command to run.
Expand Down
12 changes: 10 additions & 2 deletions javascript/packages/orchestrator/src/configGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ export async function generateNetworkSpec(
for (const nodeGroup of config.relaychain.node_groups || []) {
for (let i = 0; i < (nodeGroup.count as number); i++) {
const node: NodeConfig = {
name: `${nodeGroup.name}-${i}`,
// Replace whitespaces with dashes for node names
// see https://github.com/paritytech/zombienet/issues/1659
name: `${nodeGroup.name.replaceAll(" ", "-")}-${i}`,
image: nodeGroup.image || networkSpec.relaychain.defaultImage,
command: nodeGroup.command,
args: sanitizeArgs(nodeGroup.args || []),
Expand Down Expand Up @@ -289,7 +291,9 @@ export async function generateNetworkSpec(
for (const collatorGroup of parachain.collator_groups || []) {
for (let i = 0; i < (collatorGroup.count as number); i++) {
const node: NodeConfig = {
name: `${collatorGroup.name}-${i}`,
// Replace whitespaces with dashes for node names
// see https://github.com/paritytech/zombienet/issues/1659
name: `${collatorGroup.name.replaceAll(" ", "-")}-${i}`,
image: collatorGroup.image || DEFAULT_COLLATOR_IMAGE,
command: collatorGroup.command || DEFAULT_CUMULUS_COLLATOR_BIN,
args: sanitizeArgs(collatorGroup.args || [], { "listen-addr": 2 }),
Expand Down Expand Up @@ -502,6 +506,10 @@ interface UsedNames {
const mUsedNames: UsedNames = {};

export function getUniqueName(name: string): string {
// Transform whitespaces to dashes in name, since
// whitespaces in names are not supported
// see https://github.com/paritytech/zombienet/issues/1659
name = name.replaceAll(" ", "-");
let uniqueName;
if (!mUsedNames[name]) {
mUsedNames[name] = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/smoke/0001-smoke.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ command = "polkadot"
name = "alice"

[[relaychain.nodes]]
name = "bob"
name = "new bob"

[[relaychain.nodes]]
name = "charlie"
Expand Down
2 changes: 1 addition & 1 deletion tests/smoke/0001-smoke.zndsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Network: ./0001-smoke.toml
Creds: config

alice: is up
bob: is up
new-bob: is up

alice: reports block height is at least 4 within 200 seconds

Expand Down

0 comments on commit 443be9d

Please sign in to comment.