chore: add current provisioning state before migration
This commit is contained in:
parent
a9703b4748
commit
50745b0f22
660 changed files with 88126 additions and 0 deletions
|
|
@ -0,0 +1,61 @@
|
|||
# Polkadot Zombienet Environment Configuration
|
||||
# Generated by provisioning system
|
||||
|
||||
ZOMBIENET_VERSION={{ polkadot_zombienet.version }}
|
||||
ZOMBIENET_RUN_USER={{ polkadot_zombienet.run_user.name }}
|
||||
ZOMBIENET_RUN_GROUP={{ polkadot_zombienet.run_user.group }}
|
||||
ZOMBIENET_RUN_USER_HOME={{ polkadot_zombienet.run_user.home }}
|
||||
ZOMBIENET_WORK_PATH={{ polkadot_zombienet.work_path }}
|
||||
ZOMBIENET_CONFIG_PATH={{ polkadot_zombienet.config_path }}
|
||||
ZOMBIENET_BIN_PATH={{ polkadot_zombienet.bin_path }}
|
||||
ZOMBIENET_BINARY={{ polkadot_zombienet.zombienet_binary }}
|
||||
|
||||
# Zombienet Paths
|
||||
ZOMBIENET_NETWORKS_PATH={{ polkadot_zombienet.networks_path }}
|
||||
ZOMBIENET_BINARIES_PATH={{ polkadot_zombienet.binaries_path }}
|
||||
ZOMBIENET_LOGS_PATH={{ polkadot_zombienet.logs_path }}
|
||||
|
||||
# Settings Configuration
|
||||
ZOMBIENET_TIMEOUT={{ polkadot_zombienet.settings.timeout }}
|
||||
{% if polkadot_zombienet.settings.node_spawn_timeout is defined %}
|
||||
ZOMBIENET_NODE_SPAWN_TIMEOUT={{ polkadot_zombienet.settings.node_spawn_timeout }}
|
||||
{% endif %}
|
||||
ZOMBIENET_PROVIDER={{ polkadot_zombienet.settings.provider }}
|
||||
ZOMBIENET_ENABLE_TRACING={{ polkadot_zombienet.settings.enable_tracing | default(false) | lower }}
|
||||
ZOMBIENET_BACKCHANNEL={{ polkadot_zombienet.settings.backchannel | default(true) | lower }}
|
||||
|
||||
# Relay Chain Configuration
|
||||
ZOMBIENET_RELAYCHAIN_CHAIN={{ polkadot_zombienet.relaychain.chain }}
|
||||
{% if polkadot_zombienet.relaychain.default_image is defined %}
|
||||
ZOMBIENET_RELAYCHAIN_IMAGE={{ polkadot_zombienet.relaychain.default_image }}
|
||||
{% endif %}
|
||||
{% if polkadot_zombienet.relaychain.default_command is defined %}
|
||||
ZOMBIENET_RELAYCHAIN_COMMAND={{ polkadot_zombienet.relaychain.default_command }}
|
||||
{% endif %}
|
||||
|
||||
# Provider Specific Configuration
|
||||
{% if polkadot_zombienet.settings.provider == "kubernetes" and polkadot_zombienet.kubernetes_config is defined %}
|
||||
ZOMBIENET_K8S_NAMESPACE={{ polkadot_zombienet.kubernetes_config.namespace | default("zombienet") }}
|
||||
ZOMBIENET_K8S_MONITORING={{ polkadot_zombienet.kubernetes_config.monitoring | default(true) | lower }}
|
||||
{% if polkadot_zombienet.kubernetes_config.prometheus_prefix is defined %}
|
||||
ZOMBIENET_K8S_PROMETHEUS_PREFIX={{ polkadot_zombienet.kubernetes_config.prometheus_prefix }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if polkadot_zombienet.settings.provider == "podman" and polkadot_zombienet.podman_config is defined %}
|
||||
ZOMBIENET_PODMAN_MONITORING={{ polkadot_zombienet.podman_config.monitoring | default(true) | lower }}
|
||||
{% if polkadot_zombienet.podman_config.monitoring_port is defined %}
|
||||
ZOMBIENET_PODMAN_MONITORING_PORT={{ polkadot_zombienet.podman_config.monitoring_port }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if polkadot_zombienet.settings.provider == "native" and polkadot_zombienet.native_config is defined %}
|
||||
ZOMBIENET_NATIVE_MONITORING={{ polkadot_zombienet.native_config.monitoring | default(false) | lower }}
|
||||
{% endif %}
|
||||
|
||||
# Logging Configuration
|
||||
ZOMBIENET_LOG_LEVEL={{ polkadot_zombienet.log_level }}
|
||||
|
||||
# Network Configuration
|
||||
ZOMBIENET_RELAYCHAIN_NODES="{{ polkadot_zombienet.relaychain.nodes | length }}"
|
||||
ZOMBIENET_PARACHAINS_COUNT="{{ polkadot_zombienet.parachains | length }}"
|
||||
321
taskservs/polkadot/zombienet/default/install-polkadot-zombienet.sh
Executable file
321
taskservs/polkadot/zombienet/default/install-polkadot-zombienet.sh
Executable file
|
|
@ -0,0 +1,321 @@
|
|||
#!/bin/bash
|
||||
# Info: Script to install Polkadot Zombienet
|
||||
# Author: Provisioning System
|
||||
# Release: 1.0
|
||||
# Date: 2025-07-24
|
||||
|
||||
USAGE="install-polkadot-zombienet.sh"
|
||||
[ "$1" == "-h" ] && echo "$USAGE" && exit 1
|
||||
|
||||
[ -r "env-polkadot-zombienet" ] && . ./env-polkadot-zombienet
|
||||
|
||||
ZOMBIENET_VERSION=${ZOMBIENET_VERSION:-1.3.133}
|
||||
ZOMBIENET_PROVIDER=${ZOMBIENET_PROVIDER:-native}
|
||||
|
||||
# Determine architecture and OS
|
||||
ARCH="$(uname -m)"
|
||||
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
||||
|
||||
case "$ARCH" in
|
||||
x86_64) ZOMBIE_ARCH="x64" ;;
|
||||
aarch64|arm64) ZOMBIE_ARCH="arm64" ;;
|
||||
*) echo "Unsupported architecture: $ARCH" && exit 1 ;;
|
||||
esac
|
||||
|
||||
case "$OS" in
|
||||
linux) ZOMBIE_OS="linux" ;;
|
||||
darwin) ZOMBIE_OS="macos" ;;
|
||||
*) echo "Unsupported OS: $OS" && exit 1 ;;
|
||||
esac
|
||||
|
||||
ZOMBIENET_URL="https://github.com/paritytech/zombienet/releases/download"
|
||||
ZOMBIENET_BINARY="zombienet-${ZOMBIE_OS}-${ZOMBIE_ARCH}"
|
||||
|
||||
ZOMBIENET_BIN_PATH=${ZOMBIENET_BIN_PATH:-/usr/local/bin}
|
||||
ZOMBIENET_BINARY_NAME=${ZOMBIENET_BINARY:-zombienet}
|
||||
ZOMBIENET_SYSTEMCTL_MODE=${ZOMBIENET_SYSTEMCTL_MODE:-enabled}
|
||||
|
||||
ZOMBIENET_CONFIG_PATH=${ZOMBIENET_CONFIG_PATH:-/etc/zombienet}
|
||||
ZOMBIENET_WORK_PATH=${ZOMBIENET_WORK_PATH:-/var/lib/zombienet}
|
||||
ZOMBIENET_NETWORKS_PATH=${ZOMBIENET_NETWORKS_PATH:-/var/lib/zombienet/networks}
|
||||
ZOMBIENET_BINARIES_PATH=${ZOMBIENET_BINARIES_PATH:-/var/lib/zombienet/binaries}
|
||||
ZOMBIENET_LOGS_PATH=${ZOMBIENET_LOGS_PATH:-/var/lib/zombienet/logs}
|
||||
|
||||
ZOMBIENET_RUN_USER=${ZOMBIENET_RUN_USER:-zombienet}
|
||||
ZOMBIENET_RUN_GROUP=${ZOMBIENET_RUN_GROUP:-zombienet}
|
||||
ZOMBIENET_RUN_USER_HOME=${ZOMBIENET_RUN_USER_HOME:-/home/zombienet}
|
||||
|
||||
echo "Installing Polkadot Zombienet ${ZOMBIENET_VERSION}..."
|
||||
|
||||
# Install dependencies based on provider
|
||||
echo "Installing dependencies for provider: $ZOMBIENET_PROVIDER..."
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
apt-get update
|
||||
DEPS="curl ca-certificates jq"
|
||||
|
||||
case "$ZOMBIENET_PROVIDER" in
|
||||
"kubernetes")
|
||||
DEPS="$DEPS kubectl"
|
||||
;;
|
||||
"podman")
|
||||
DEPS="$DEPS podman"
|
||||
;;
|
||||
"native")
|
||||
# Native provider needs no additional system packages
|
||||
;;
|
||||
esac
|
||||
|
||||
apt-get install -y $DEPS
|
||||
elif command -v yum >/dev/null 2>&1; then
|
||||
yum update -y
|
||||
DEPS="curl ca-certificates jq"
|
||||
|
||||
case "$ZOMBIENET_PROVIDER" in
|
||||
"kubernetes")
|
||||
DEPS="$DEPS kubectl"
|
||||
;;
|
||||
"podman")
|
||||
DEPS="$DEPS podman"
|
||||
;;
|
||||
esac
|
||||
|
||||
yum install -y $DEPS
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
dnf update -y
|
||||
DEPS="curl ca-certificates jq"
|
||||
|
||||
case "$ZOMBIENET_PROVIDER" in
|
||||
"kubernetes")
|
||||
DEPS="$DEPS kubectl"
|
||||
;;
|
||||
"podman")
|
||||
DEPS="$DEPS podman"
|
||||
;;
|
||||
esac
|
||||
|
||||
dnf install -y $DEPS
|
||||
else
|
||||
echo "Package manager not found. Please install dependencies manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create user and group
|
||||
if ! id "$ZOMBIENET_RUN_USER" &>/dev/null; then
|
||||
groupadd -r "$ZOMBIENET_RUN_GROUP"
|
||||
useradd -r -g "$ZOMBIENET_RUN_GROUP" -d "$ZOMBIENET_RUN_USER_HOME" -s /bin/bash -c "Zombienet service user" "$ZOMBIENET_RUN_USER"
|
||||
fi
|
||||
|
||||
# Create directories
|
||||
mkdir -p "$ZOMBIENET_CONFIG_PATH"
|
||||
mkdir -p "$ZOMBIENET_WORK_PATH"
|
||||
mkdir -p "$ZOMBIENET_NETWORKS_PATH"
|
||||
mkdir -p "$ZOMBIENET_BINARIES_PATH"
|
||||
mkdir -p "$ZOMBIENET_LOGS_PATH"
|
||||
mkdir -p "$ZOMBIENET_RUN_USER_HOME"
|
||||
|
||||
# Download and install Zombienet binary
|
||||
cd /tmp
|
||||
echo "Downloading Zombienet from ${ZOMBIENET_URL}/v${ZOMBIENET_VERSION}/${ZOMBIENET_BINARY}..."
|
||||
curl -L -o zombienet "${ZOMBIENET_URL}/v${ZOMBIENET_VERSION}/${ZOMBIENET_BINARY}"
|
||||
|
||||
if [ ! -f "zombienet" ]; then
|
||||
echo "Failed to download Zombienet binary"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install binary
|
||||
chmod +x zombienet
|
||||
mv zombienet "$ZOMBIENET_BIN_PATH/$ZOMBIENET_BINARY_NAME"
|
||||
|
||||
# Download required binaries for native provider
|
||||
if [ "$ZOMBIENET_PROVIDER" = "native" ]; then
|
||||
echo "Setting up binaries for native provider..."
|
||||
|
||||
# Download Polkadot binary
|
||||
POLKADOT_VERSION="latest"
|
||||
POLKADOT_URL="https://github.com/paritytech/polkadot/releases/latest/download/polkadot"
|
||||
|
||||
echo "Downloading Polkadot binary..."
|
||||
curl -L -o "$ZOMBIENET_BINARIES_PATH/polkadot" "$POLKADOT_URL"
|
||||
chmod +x "$ZOMBIENET_BINARIES_PATH/polkadot"
|
||||
|
||||
# Download Polkadot-Parachain binary
|
||||
PARACHAIN_URL="https://github.com/paritytech/polkadot-sdk/releases/latest/download/polkadot-parachain"
|
||||
|
||||
echo "Downloading Polkadot-Parachain binary..."
|
||||
curl -L -o "$ZOMBIENET_BINARIES_PATH/polkadot-parachain" "$PARACHAIN_URL" || {
|
||||
echo "Warning: Could not download polkadot-parachain binary"
|
||||
echo "You may need to build it manually or provide your own parachain binary"
|
||||
}
|
||||
|
||||
if [ -f "$ZOMBIENET_BINARIES_PATH/polkadot-parachain" ]; then
|
||||
chmod +x "$ZOMBIENET_BINARIES_PATH/polkadot-parachain"
|
||||
fi
|
||||
|
||||
# Create symbolic links in PATH
|
||||
ln -sf "$ZOMBIENET_BINARIES_PATH/polkadot" "$ZOMBIENET_BIN_PATH/polkadot"
|
||||
if [ -f "$ZOMBIENET_BINARIES_PATH/polkadot-parachain" ]; then
|
||||
ln -sf "$ZOMBIENET_BINARIES_PATH/polkadot-parachain" "$ZOMBIENET_BIN_PATH/polkadot-parachain"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy network templates
|
||||
if [ -f "simple-network.toml" ]; then
|
||||
cp simple-network.toml "$ZOMBIENET_NETWORKS_PATH/"
|
||||
fi
|
||||
|
||||
if [ -f "parachain-network.toml" ]; then
|
||||
cp parachain-network.toml "$ZOMBIENET_NETWORKS_PATH/"
|
||||
fi
|
||||
|
||||
# Create default network configuration from template if available
|
||||
if [ -f "network-config.toml.j2" ]; then
|
||||
cp network-config.toml.j2 "$ZOMBIENET_CONFIG_PATH/"
|
||||
fi
|
||||
|
||||
# Set ownership
|
||||
chown -R "$ZOMBIENET_RUN_USER:$ZOMBIENET_RUN_GROUP" "$ZOMBIENET_WORK_PATH"
|
||||
chown -R "$ZOMBIENET_RUN_USER:$ZOMBIENET_RUN_GROUP" "$ZOMBIENET_NETWORKS_PATH"
|
||||
chown -R "$ZOMBIENET_RUN_USER:$ZOMBIENET_RUN_GROUP" "$ZOMBIENET_BINARIES_PATH"
|
||||
chown -R "$ZOMBIENET_RUN_USER:$ZOMBIENET_RUN_GROUP" "$ZOMBIENET_LOGS_PATH"
|
||||
chown -R "$ZOMBIENET_RUN_USER:$ZOMBIENET_RUN_GROUP" "$ZOMBIENET_RUN_USER_HOME"
|
||||
chown -R "$ZOMBIENET_RUN_USER:$ZOMBIENET_RUN_GROUP" "$ZOMBIENET_CONFIG_PATH"
|
||||
|
||||
# Create zombienet management script
|
||||
cat > "$ZOMBIENET_BIN_PATH/zombienet-manager" << EOF
|
||||
#!/bin/bash
|
||||
# Zombienet Network Manager
|
||||
|
||||
ZOMBIENET_BIN="$ZOMBIENET_BIN_PATH/$ZOMBIENET_BINARY_NAME"
|
||||
NETWORKS_PATH="$ZOMBIENET_NETWORKS_PATH"
|
||||
LOGS_PATH="$ZOMBIENET_LOGS_PATH"
|
||||
PROVIDER="$ZOMBIENET_PROVIDER"
|
||||
|
||||
case "\$1" in
|
||||
"spawn")
|
||||
NETWORK_FILE="\${2:-\$NETWORKS_PATH/simple-network.toml}"
|
||||
if [ ! -f "\$NETWORK_FILE" ]; then
|
||||
echo "Network file not found: \$NETWORK_FILE"
|
||||
exit 1
|
||||
fi
|
||||
echo "Spawning network with \$NETWORK_FILE using \$PROVIDER provider..."
|
||||
sudo -u $ZOMBIENET_RUN_USER "\$ZOMBIENET_BIN" spawn --provider "\$PROVIDER" "\$NETWORK_FILE"
|
||||
;;
|
||||
"test")
|
||||
TEST_FILE="\${2}"
|
||||
if [ ! -f "\$TEST_FILE" ]; then
|
||||
echo "Test file not found: \$TEST_FILE"
|
||||
exit 1
|
||||
fi
|
||||
echo "Running test: \$TEST_FILE"
|
||||
sudo -u $ZOMBIENET_RUN_USER "\$ZOMBIENET_BIN" test --provider "\$PROVIDER" "\$TEST_FILE"
|
||||
;;
|
||||
"setup")
|
||||
echo "Setting up Zombienet binaries..."
|
||||
sudo -u $ZOMBIENET_RUN_USER "\$ZOMBIENET_BIN" setup
|
||||
;;
|
||||
"list")
|
||||
echo "Available network configurations:"
|
||||
ls -la "\$NETWORKS_PATH"/*.toml 2>/dev/null || echo "No network configurations found"
|
||||
;;
|
||||
"logs")
|
||||
echo "Recent Zombienet logs:"
|
||||
find "\$LOGS_PATH" -name "*.log" -type f -exec tail -n 20 {} + 2>/dev/null || echo "No logs found"
|
||||
;;
|
||||
"clean")
|
||||
echo "Cleaning up Zombienet processes and logs..."
|
||||
pkill -f zombienet || echo "No zombienet processes found"
|
||||
rm -rf "\$LOGS_PATH"/*
|
||||
echo "Cleanup completed"
|
||||
;;
|
||||
"help"|*)
|
||||
echo "Zombienet Network Manager"
|
||||
echo "Usage: \$0 [command] [options]"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " spawn [network.toml] Spawn a network (default: simple-network.toml)"
|
||||
echo " test [test.zndsl] Run a test file"
|
||||
echo " setup Setup required binaries"
|
||||
echo " list List available network configurations"
|
||||
echo " logs Show recent logs"
|
||||
echo " clean Clean up processes and logs"
|
||||
echo " help Show this help message"
|
||||
echo ""
|
||||
echo "Provider: \$PROVIDER"
|
||||
echo "Networks path: \$NETWORKS_PATH"
|
||||
echo "Logs path: \$LOGS_PATH"
|
||||
;;
|
||||
esac
|
||||
EOF
|
||||
|
||||
chmod +x "$ZOMBIENET_BIN_PATH/zombienet-manager"
|
||||
|
||||
# Create zombienet info file
|
||||
cat > "$ZOMBIENET_CONFIG_PATH/zombienet-info.json" << EOF
|
||||
{
|
||||
"version": "$ZOMBIENET_VERSION",
|
||||
"provider": "$ZOMBIENET_PROVIDER",
|
||||
"binary_path": "$ZOMBIENET_BIN_PATH/$ZOMBIENET_BINARY_NAME",
|
||||
"networks_path": "$ZOMBIENET_NETWORKS_PATH",
|
||||
"binaries_path": "$ZOMBIENET_BINARIES_PATH",
|
||||
"logs_path": "$ZOMBIENET_LOGS_PATH",
|
||||
"user": "$ZOMBIENET_RUN_USER",
|
||||
"manager_script": "$ZOMBIENET_BIN_PATH/zombienet-manager",
|
||||
"templates": [
|
||||
"simple-network.toml",
|
||||
"parachain-network.toml"
|
||||
]
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "=========================================="
|
||||
echo "Polkadot Zombienet installation completed!"
|
||||
echo "=========================================="
|
||||
echo "Version: $ZOMBIENET_VERSION"
|
||||
echo "Provider: $ZOMBIENET_PROVIDER"
|
||||
echo "Binary: $ZOMBIENET_BIN_PATH/$ZOMBIENET_BINARY_NAME"
|
||||
echo "Manager: $ZOMBIENET_BIN_PATH/zombienet-manager"
|
||||
echo ""
|
||||
echo "Paths:"
|
||||
echo "Networks: $ZOMBIENET_NETWORKS_PATH"
|
||||
echo "Binaries: $ZOMBIENET_BINARIES_PATH"
|
||||
echo "Logs: $ZOMBIENET_LOGS_PATH"
|
||||
echo "Config: $ZOMBIENET_CONFIG_PATH"
|
||||
echo ""
|
||||
echo "Quick start:"
|
||||
echo "# List available networks"
|
||||
echo "$ZOMBIENET_BIN_PATH/zombienet-manager list"
|
||||
echo ""
|
||||
echo "# Spawn simple network"
|
||||
echo "$ZOMBIENET_BIN_PATH/zombienet-manager spawn"
|
||||
echo ""
|
||||
echo "# Spawn network with parachains"
|
||||
echo "$ZOMBIENET_BIN_PATH/zombienet-manager spawn $ZOMBIENET_NETWORKS_PATH/parachain-network.toml"
|
||||
echo ""
|
||||
echo "# View logs"
|
||||
echo "$ZOMBIENET_BIN_PATH/zombienet-manager logs"
|
||||
echo ""
|
||||
echo "# Clean up"
|
||||
echo "$ZOMBIENET_BIN_PATH/zombienet-manager clean"
|
||||
|
||||
if [ "$ZOMBIENET_PROVIDER" = "native" ]; then
|
||||
echo ""
|
||||
echo "Native provider binaries installed:"
|
||||
ls -la "$ZOMBIENET_BINARIES_PATH"
|
||||
fi
|
||||
|
||||
# Test Zombienet installation
|
||||
echo ""
|
||||
echo "Testing Zombienet installation..."
|
||||
if "$ZOMBIENET_BIN_PATH/$ZOMBIENET_BINARY_NAME" --version >/dev/null 2>&1; then
|
||||
echo "✅ Zombienet binary is working"
|
||||
else
|
||||
echo "⚠️ Zombienet binary test failed"
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
cd /
|
||||
rm -rf /tmp/zombienet
|
||||
|
||||
echo ""
|
||||
echo "Installation completed! Use 'zombienet-manager help' for usage instructions."
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
# Multi-Parachain Zombienet Network Template
|
||||
# Relay chain with multiple parachains for testing XCM
|
||||
|
||||
[settings]
|
||||
timeout = 1200
|
||||
enable_tracing = false
|
||||
|
||||
[relaychain]
|
||||
default_image = "parity/polkadot:latest"
|
||||
chain = "rococo-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "charlie"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "dave"
|
||||
validator = true
|
||||
|
||||
# First parachain (Asset Hub)
|
||||
[[parachains]]
|
||||
id = 1000
|
||||
balance = 1000000
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "asset-hub-collator"
|
||||
image = "parity/polkadot-parachain:latest"
|
||||
command = "polkadot-parachain"
|
||||
|
||||
# Second parachain (Custom)
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
balance = 1000000
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "custom-collator-01"
|
||||
image = "parity/polkadot-parachain:latest"
|
||||
command = "polkadot-parachain"
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "custom-collator-02"
|
||||
image = "parity/polkadot-parachain:latest"
|
||||
command = "polkadot-parachain"
|
||||
|
||||
# Third parachain (Test)
|
||||
[[parachains]]
|
||||
id = 3000
|
||||
balance = 1000000
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "test-collator"
|
||||
image = "parity/polkadot-parachain:latest"
|
||||
command = "polkadot-parachain"
|
||||
83
taskservs/polkadot/zombienet/default/network-config.toml.j2
Normal file
83
taskservs/polkadot/zombienet/default/network-config.toml.j2
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
# Zombienet Network Configuration
|
||||
# Generated by provisioning system
|
||||
|
||||
[settings]
|
||||
timeout = {{ polkadot_zombienet.settings.timeout }}
|
||||
{% if polkadot_zombienet.settings.node_spawn_timeout is defined %}
|
||||
node_spawn_timeout = {{ polkadot_zombienet.settings.node_spawn_timeout }}
|
||||
{% endif %}
|
||||
{% if polkadot_zombienet.settings.enable_tracing is defined %}
|
||||
enable_tracing = {{ polkadot_zombienet.settings.enable_tracing | lower }}
|
||||
{% endif %}
|
||||
{% if polkadot_zombienet.settings.backchannel is defined %}
|
||||
backchannel = {{ polkadot_zombienet.settings.backchannel | lower }}
|
||||
{% endif %}
|
||||
|
||||
[relaychain]
|
||||
chain = "{{ polkadot_zombienet.relaychain.chain }}"
|
||||
{% if polkadot_zombienet.relaychain.default_image is defined %}
|
||||
default_image = "{{ polkadot_zombienet.relaychain.default_image }}"
|
||||
{% endif %}
|
||||
{% if polkadot_zombienet.relaychain.default_command is defined %}
|
||||
default_command = "{{ polkadot_zombienet.relaychain.default_command }}"
|
||||
{% endif %}
|
||||
{% if polkadot_zombienet.relaychain.genesis is defined %}
|
||||
genesis = "{{ polkadot_zombienet.relaychain.genesis }}"
|
||||
{% endif %}
|
||||
{% if polkadot_zombienet.relaychain.runtime_genesis_patch is defined %}
|
||||
runtime_genesis_patch = "{{ polkadot_zombienet.relaychain.runtime_genesis_patch }}"
|
||||
{% endif %}
|
||||
|
||||
{% for node in polkadot_zombienet.relaychain.nodes %}
|
||||
[[relaychain.nodes]]
|
||||
name = "{{ node.name }}"
|
||||
{% if node.image is defined %}
|
||||
image = "{{ node.image }}"
|
||||
{% endif %}
|
||||
{% if node.command is defined %}
|
||||
command = "{{ node.command }}"
|
||||
{% endif %}
|
||||
{% if node.args %}
|
||||
args = [{{ node.args | map('tojsonquote') | join(', ') }}]
|
||||
{% endif %}
|
||||
validator = {{ node.validator | lower }}
|
||||
{% if node.balance is defined %}
|
||||
balance = {{ node.balance }}
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% for parachain in polkadot_zombienet.parachains %}
|
||||
[[parachains]]
|
||||
id = {{ parachain.id }}
|
||||
{% if parachain.chain is defined %}
|
||||
chain = "{{ parachain.chain }}"
|
||||
{% endif %}
|
||||
{% if parachain.balance is defined %}
|
||||
balance = {{ parachain.balance }}
|
||||
{% endif %}
|
||||
{% if parachain.genesis_wasm is defined %}
|
||||
genesis_wasm = "{{ parachain.genesis_wasm }}"
|
||||
{% endif %}
|
||||
{% if parachain.genesis_state is defined %}
|
||||
genesis_state = "{{ parachain.genesis_state }}"
|
||||
{% endif %}
|
||||
|
||||
{% for collator in parachain.collators %}
|
||||
[[parachains.collators]]
|
||||
name = "{{ collator.name }}"
|
||||
{% if collator.image is defined %}
|
||||
image = "{{ collator.image }}"
|
||||
{% endif %}
|
||||
{% if collator.command is defined %}
|
||||
command = "{{ collator.command }}"
|
||||
{% endif %}
|
||||
{% if collator.args %}
|
||||
args = [{{ collator.args | map('tojsonquote') | join(', ') }}]
|
||||
{% endif %}
|
||||
{% if collator.balance is defined %}
|
||||
balance = {{ collator.balance }}
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
30
taskservs/polkadot/zombienet/default/parachain-network.toml
Normal file
30
taskservs/polkadot/zombienet/default/parachain-network.toml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Parachain Zombienet Network Template
|
||||
# Relay chain with one parachain
|
||||
|
||||
[settings]
|
||||
timeout = 1000
|
||||
|
||||
[relaychain]
|
||||
default_image = "parity/polkadot:latest"
|
||||
chain = "rococo-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "charlie"
|
||||
validator = true
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
balance = 1000000
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "collator01"
|
||||
image = "parity/polkadot-parachain:latest"
|
||||
command = "polkadot-parachain"
|
||||
156
taskservs/polkadot/zombienet/default/prepare
Executable file
156
taskservs/polkadot/zombienet/default/prepare
Executable file
|
|
@ -0,0 +1,156 @@
|
|||
#!/bin/bash
|
||||
# Info: Polkadot Zombienet preparation script
|
||||
# Author: Provisioning System
|
||||
# Release: 1.0
|
||||
|
||||
echo "Preparing Polkadot Zombienet installation..."
|
||||
|
||||
# Load environment variables
|
||||
[ -r "env-polkadot-zombienet" ] && . ./env-polkadot-zombienet
|
||||
|
||||
# Check if required tools are available
|
||||
command -v curl >/dev/null 2>&1 || { echo "curl is required but not installed." >&2; exit 1; }
|
||||
|
||||
# Validate configuration
|
||||
if [ -z "$ZOMBIENET_VERSION" ]; then
|
||||
echo "ZOMBIENET_VERSION must be set" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate provider
|
||||
case "${ZOMBIENET_PROVIDER:-native}" in
|
||||
"native"|"kubernetes"|"podman")
|
||||
echo "Provider: ${ZOMBIENET_PROVIDER}"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid provider: ${ZOMBIENET_PROVIDER}" >&2
|
||||
echo "Supported providers: native, kubernetes, podman" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check provider-specific requirements
|
||||
case "${ZOMBIENET_PROVIDER:-native}" in
|
||||
"kubernetes")
|
||||
if ! command -v kubectl >/dev/null 2>&1; then
|
||||
echo "kubectl is required for Kubernetes provider but not installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if kubectl can connect to cluster
|
||||
if ! kubectl cluster-info >/dev/null 2>&1; then
|
||||
echo "Warning: kubectl cannot connect to Kubernetes cluster"
|
||||
echo "Make sure you have a valid kubeconfig and cluster access"
|
||||
else
|
||||
echo "✅ Kubernetes cluster access verified"
|
||||
fi
|
||||
;;
|
||||
"podman")
|
||||
if ! command -v podman >/dev/null 2>&1; then
|
||||
echo "podman is required for Podman provider but not installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check podman version (Zombienet supports v2 or older)
|
||||
PODMAN_VERSION=$(podman --version | awk '{print $3}' | cut -d. -f1)
|
||||
if [ "$PODMAN_VERSION" -gt 2 ]; then
|
||||
echo "Warning: Zombienet currently supports Podman v2 or older"
|
||||
echo "You have Podman v$PODMAN_VERSION - you may need to apply patches"
|
||||
fi
|
||||
|
||||
# Test podman functionality
|
||||
if ! podman info >/dev/null 2>&1; then
|
||||
echo "Warning: podman info failed - check podman configuration"
|
||||
else
|
||||
echo "✅ Podman is working"
|
||||
fi
|
||||
;;
|
||||
"native")
|
||||
echo "Native provider selected - binaries will be downloaded automatically"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check available disk space
|
||||
AVAILABLE_SPACE=$(df "${ZOMBIENET_WORK_PATH:-/var/lib/zombienet}" 2>/dev/null | awk 'NR==2 {print $4}' || echo "0")
|
||||
REQUIRED_SPACE=5000000 # 5GB for binaries and network data
|
||||
if [ "$AVAILABLE_SPACE" -ne "0" ] && [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then
|
||||
echo "Warning: Low disk space for Zombienet"
|
||||
echo "Available: $(($AVAILABLE_SPACE / 1024))MB, Recommended: $(($REQUIRED_SPACE / 1024))MB"
|
||||
fi
|
||||
|
||||
# Check memory requirements
|
||||
if command -v free >/dev/null 2>&1; then
|
||||
FREE_MEMORY=$(free -m | awk '/^Mem:/{print $7}')
|
||||
MIN_MEMORY=4096 # Zombienet networks can be memory intensive
|
||||
|
||||
if [ "$FREE_MEMORY" -lt "$MIN_MEMORY" ]; then
|
||||
echo "Warning: Low memory for Zombienet networks"
|
||||
echo "Available: ${FREE_MEMORY}MB, Recommended: ${MIN_MEMORY}MB"
|
||||
echo "Consider starting with simple networks or reducing node count"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Validate relay chain configuration
|
||||
RELAYCHAIN_NODES=${ZOMBIENET_RELAYCHAIN_NODES:-2}
|
||||
if [ "$RELAYCHAIN_NODES" -lt 2 ]; then
|
||||
echo "Error: At least 2 relay chain nodes are required" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for common port conflicts
|
||||
COMMON_PORTS=(30333 9944 9933 9615)
|
||||
for port in "${COMMON_PORTS[@]}"; do
|
||||
if command -v netstat >/dev/null 2>&1; then
|
||||
if netstat -tuln | grep -q ":$port "; then
|
||||
echo "Warning: Port $port appears to be in use (common Polkadot port)"
|
||||
fi
|
||||
elif command -v ss >/dev/null 2>&1; then
|
||||
if ss -tuln | grep -q ":$port "; then
|
||||
echo "Warning: Port $port appears to be in use (common Polkadot port)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Check Docker/Podman for image availability (if not native)
|
||||
if [ "${ZOMBIENET_PROVIDER:-native}" != "native" ]; then
|
||||
if [ "${ZOMBIENET_PROVIDER}" = "podman" ] && command -v podman >/dev/null 2>&1; then
|
||||
echo "Checking for required container images..."
|
||||
if ! podman image exists parity/polkadot:latest >/dev/null 2>&1; then
|
||||
echo "Info: parity/polkadot:latest image not found locally - will be pulled during network spawn"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Validate timeout settings
|
||||
TIMEOUT=${ZOMBIENET_TIMEOUT:-1000}
|
||||
if [ "$TIMEOUT" -lt 100 ]; then
|
||||
echo "Warning: Timeout seems very low ($TIMEOUT seconds)"
|
||||
echo "Network startup may fail with insufficient timeout"
|
||||
fi
|
||||
|
||||
# Check for jq (useful for network info parsing)
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
echo "Info: jq not found - JSON network info parsing will be limited"
|
||||
fi
|
||||
|
||||
echo "Preparation completed successfully."
|
||||
echo ""
|
||||
echo "Zombienet configuration:"
|
||||
echo "- Version: ${ZOMBIENET_VERSION}"
|
||||
echo "- Provider: ${ZOMBIENET_PROVIDER:-native}"
|
||||
echo "- Relay chain nodes: ${ZOMBIENET_RELAYCHAIN_NODES:-2}"
|
||||
echo "- Parachains: ${ZOMBIENET_PARACHAINS_COUNT:-0}"
|
||||
echo "- Timeout: ${ZOMBIENET_TIMEOUT:-1000}s"
|
||||
echo "- Work path: ${ZOMBIENET_WORK_PATH:-/var/lib/zombienet}"
|
||||
|
||||
case "${ZOMBIENET_PROVIDER:-native}" in
|
||||
"kubernetes")
|
||||
echo "- Kubernetes namespace: ${ZOMBIENET_K8S_NAMESPACE:-zombienet}"
|
||||
;;
|
||||
"podman")
|
||||
echo "- Podman monitoring: ${ZOMBIENET_PODMAN_MONITORING:-true}"
|
||||
;;
|
||||
"native")
|
||||
echo "- Binaries path: ${ZOMBIENET_BINARIES_PATH:-/var/lib/zombienet/binaries}"
|
||||
;;
|
||||
esac
|
||||
2
taskservs/polkadot/zombienet/default/provisioning.toml
Normal file
2
taskservs/polkadot/zombienet/default/provisioning.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
info = "polkadot-zombienet"
|
||||
release = "1.0"
|
||||
17
taskservs/polkadot/zombienet/default/simple-network.toml
Normal file
17
taskservs/polkadot/zombienet/default/simple-network.toml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Simple Zombienet Network Template
|
||||
# Minimal 2-node relay chain configuration
|
||||
|
||||
[settings]
|
||||
timeout = 1000
|
||||
|
||||
[relaychain]
|
||||
default_image = "parity/polkadot:latest"
|
||||
chain = "rococo-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
validator = true
|
||||
21
taskservs/polkadot/zombienet/default/test-basic.zndsl
Normal file
21
taskservs/polkadot/zombienet/default/test-basic.zndsl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Basic Zombienet Test Script
|
||||
# Tests basic network functionality
|
||||
|
||||
Description: Basic network test
|
||||
Network: ./simple-network.toml
|
||||
Creds: config
|
||||
|
||||
# Test that nodes are running
|
||||
alice: is up
|
||||
bob: is up
|
||||
|
||||
# Test that nodes are producing blocks
|
||||
alice: parachain 0 block height is at least 1 within 60 seconds
|
||||
bob: parachain 0 block height is at least 1 within 60 seconds
|
||||
|
||||
# Test connectivity between nodes
|
||||
alice: count of peers is at least 1 within 30 seconds
|
||||
bob: count of peers is at least 1 within 30 seconds
|
||||
|
||||
# Test basic RPC functionality
|
||||
alice: js-script ./test-scripts/check-runtime.js with "rococo" return is 0 within 30 seconds
|
||||
26
taskservs/polkadot/zombienet/default/test-parachain.zndsl
Normal file
26
taskservs/polkadot/zombienet/default/test-parachain.zndsl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Parachain Zombienet Test Script
|
||||
# Tests parachain functionality
|
||||
|
||||
Description: Parachain functionality test
|
||||
Network: ./parachain-network.toml
|
||||
Creds: config
|
||||
|
||||
# Test that relay chain nodes are running
|
||||
alice: is up
|
||||
bob: is up
|
||||
charlie: is up
|
||||
|
||||
# Test that collator is running
|
||||
collator01: is up
|
||||
|
||||
# Test that parachain is registered
|
||||
alice: parachain 2000 is registered within 225 seconds
|
||||
|
||||
# Test that parachain is producing blocks
|
||||
collator01: parachain 2000 block height is at least 10 within 200 seconds
|
||||
|
||||
# Test that relay chain is producing blocks
|
||||
alice: parachain 0 block height is at least 5 within 120 seconds
|
||||
|
||||
# Test parachain block finalization
|
||||
alice: parachain 2000 block height is at least 3 within 400 seconds
|
||||
164
taskservs/polkadot/zombienet/default/zombienet-service.sh.j2
Normal file
164
taskservs/polkadot/zombienet/default/zombienet-service.sh.j2
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
#!/bin/bash
|
||||
# Info: Zombienet service management script
|
||||
# Author: Provisioning System
|
||||
|
||||
ZOMBIENET_BIN="{{ polkadot_zombienet.bin_path }}/{{ polkadot_zombienet.zombienet_binary }}"
|
||||
NETWORKS_PATH="{{ polkadot_zombienet.networks_path }}"
|
||||
LOGS_PATH="{{ polkadot_zombienet.logs_path }}"
|
||||
CONFIG_PATH="{{ polkadot_zombienet.config_path }}"
|
||||
PROVIDER="{{ polkadot_zombienet.settings.provider }}"
|
||||
RUN_USER="{{ polkadot_zombienet.run_user.name }}"
|
||||
|
||||
# Default network configuration
|
||||
DEFAULT_NETWORK="$NETWORKS_PATH/simple-network.toml"
|
||||
CURRENT_NETWORK_FILE="$CONFIG_PATH/current-network.toml"
|
||||
PID_FILE="$CONFIG_PATH/zombienet.pid"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
NETWORK_FILE="${2:-$DEFAULT_NETWORK}"
|
||||
|
||||
if [ ! -f "$NETWORK_FILE" ]; then
|
||||
echo "Network file not found: $NETWORK_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
echo "Zombienet is already running (PID: $PID)"
|
||||
exit 1
|
||||
else
|
||||
rm -f "$PID_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Starting Zombienet with network: $NETWORK_FILE"
|
||||
echo "Provider: $PROVIDER"
|
||||
echo "Logs will be written to: $LOGS_PATH"
|
||||
|
||||
# Copy network file to current
|
||||
cp "$NETWORK_FILE" "$CURRENT_NETWORK_FILE"
|
||||
|
||||
# Start zombienet in background
|
||||
nohup sudo -u "$RUN_USER" "$ZOMBIENET_BIN" spawn \
|
||||
--provider "$PROVIDER" \
|
||||
"$CURRENT_NETWORK_FILE" \
|
||||
> "$LOGS_PATH/zombienet.log" 2>&1 &
|
||||
|
||||
echo $! > "$PID_FILE"
|
||||
echo "Zombienet started with PID: $(cat $PID_FILE)"
|
||||
echo "Monitor logs with: tail -f $LOGS_PATH/zombienet.log"
|
||||
;;
|
||||
|
||||
stop)
|
||||
if [ ! -f "$PID_FILE" ]; then
|
||||
echo "Zombienet is not running (no PID file)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PID=$(cat "$PID_FILE")
|
||||
if ! kill -0 "$PID" 2>/dev/null; then
|
||||
echo "Zombienet process not found (stale PID file)"
|
||||
rm -f "$PID_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Stopping Zombienet (PID: $PID)..."
|
||||
|
||||
# Kill the process tree
|
||||
pkill -P "$PID" 2>/dev/null || true
|
||||
kill "$PID" 2>/dev/null || true
|
||||
|
||||
# Wait for graceful shutdown
|
||||
for i in {1..30}; do
|
||||
if ! kill -0 "$PID" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Force kill if still running
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
echo "Force killing Zombienet..."
|
||||
kill -9 "$PID" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
rm -f "$PID_FILE"
|
||||
echo "Zombienet stopped"
|
||||
;;
|
||||
|
||||
restart)
|
||||
$0 stop
|
||||
sleep 2
|
||||
$0 start "$2"
|
||||
;;
|
||||
|
||||
status)
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
echo "Zombienet is running (PID: $PID)"
|
||||
if [ -f "$CURRENT_NETWORK_FILE" ]; then
|
||||
echo "Current network: $CURRENT_NETWORK_FILE"
|
||||
fi
|
||||
|
||||
# Show some network info
|
||||
echo ""
|
||||
echo "Network processes:"
|
||||
pgrep -f "polkadot\|zombienet" | head -10
|
||||
|
||||
exit 0
|
||||
else
|
||||
echo "Zombienet is not running (stale PID file)"
|
||||
rm -f "$PID_FILE"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Zombienet is not running"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
logs)
|
||||
if [ -f "$LOGS_PATH/zombienet.log" ]; then
|
||||
tail -f "$LOGS_PATH/zombienet.log"
|
||||
else
|
||||
echo "No logs found at $LOGS_PATH/zombienet.log"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
test)
|
||||
TEST_FILE="$2"
|
||||
if [ -z "$TEST_FILE" ]; then
|
||||
echo "Usage: $0 test <test-file.zndsl>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$TEST_FILE" ]; then
|
||||
echo "Test file not found: $TEST_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Running test: $TEST_FILE"
|
||||
sudo -u "$RUN_USER" "$ZOMBIENET_BIN" test --provider "$PROVIDER" "$TEST_FILE"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Zombienet Service Management"
|
||||
echo "Usage: $0 {start|stop|restart|status|logs|test} [options]"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " start [network.toml] Start Zombienet with specified network"
|
||||
echo " stop Stop running Zombienet"
|
||||
echo " restart [network.toml] Restart Zombienet"
|
||||
echo " status Show Zombienet status"
|
||||
echo " logs Follow Zombienet logs"
|
||||
echo " test <file.zndsl> Run a test file"
|
||||
echo ""
|
||||
echo "Provider: $PROVIDER"
|
||||
echo "Default network: $DEFAULT_NETWORK"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Loading…
Add table
Add a link
Reference in a new issue