refactor: rename hive to spinifex in all shell scripts

- Update scripts/: start-dev, stop-dev, dev-setup, setup, setup-ovn, etc.
- Update tests/e2e/: all E2E test scripts
- Update scripts/iac/: rename hive-test.sh → spinifex-test.sh, update TF files
- Update config/: rename hive.service and install script
- Binary refs use spx, env vars use SPINIFEX_, paths use spinifex
This commit is contained in:
Ben Duncan
2026-03-18 01:04:12 +00:00
parent b97a98e2b7
commit 5d93786995
26 changed files with 682 additions and 682 deletions
-49
View File
@@ -1,49 +0,0 @@
[Unit]
Description=Hive Services
Documentation=https://github.com/mulgadc/hive
After=network.target
Wants=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
User=root
Group=root
WorkingDirectory=/opt/hive
Environment=PATH=/opt/hive/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Start NATS service
ExecStart=/opt/hive/bin/hive service nats start
ExecStartPost=/bin/sleep 3
# Start Predastore service
ExecStart=/opt/hive/bin/hive service predastore start
ExecStartPost=/bin/sleep 2
# Start Viperblock service
ExecStart=/opt/hive/bin/hive service viperblock start
# Stop services in reverse order
ExecStop=/opt/hive/bin/hive service viperblock stop
ExecStopPost=/bin/sleep 2
ExecStop=/opt/hive/bin/hive service predastore stop
ExecStopPost=/bin/sleep 2
ExecStop=/opt/hive/bin/hive service nats stop
# Restart policy
Restart=on-failure
RestartSec=10
# Security settings
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/hive /var/log /var/run
# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=hive
[Install]
WantedBy=multi-user.target
@@ -1,7 +1,7 @@
#!/bin/bash
# Hive Service Installation Script
# This script installs the hive systemd service on Ubuntu/Debian systems
# Spinifex Service Installation Script
# This script installs the spinifex systemd service on Ubuntu/Debian systems
set -e
@@ -38,7 +38,7 @@ fi
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SERVICE_FILE="$SCRIPT_DIR/hive.service"
SERVICE_FILE="$SCRIPT_DIR/spinifex.service"
# Check if service file exists
if [[ ! -f "$SERVICE_FILE" ]]; then
@@ -46,7 +46,7 @@ if [[ ! -f "$SERVICE_FILE" ]]; then
exit 1
fi
print_status "Installing Hive systemd service..."
print_status "Installing Spinifex systemd service..."
# Copy service file to systemd directory
cp "$SERVICE_FILE" /etc/systemd/system/
@@ -55,20 +55,20 @@ cp "$SERVICE_FILE" /etc/systemd/system/
systemctl daemon-reload
# Enable the service to start on boot
systemctl enable hive.service
systemctl enable spinifex.service
print_status "Service installed successfully!"
print_status "You can now use the following commands:"
echo " systemctl start hive # Start the service"
echo " systemctl stop hive # Stop the service"
echo " systemctl status hive # Check service status"
echo " systemctl restart hive # Restart the service"
echo " journalctl -u hive -f # View service logs"
echo " systemctl start spinifex # Start the service"
echo " systemctl stop spinifex # Stop the service"
echo " systemctl status spinifex # Check service status"
echo " systemctl restart spinifex # Restart the service"
echo " journalctl -u spinifex -f # View service logs"
# Check if hive binary exists
if [[ ! -f "/opt/hive/bin/hive" ]]; then
print_warning "Hive binary not found at /opt/hive/bin/hive"
print_warning "Please ensure hive is installed in /opt/hive before starting the service"
# Check if spinifex binary exists
if [[ ! -f "/opt/spinifex/bin/spinifex" ]]; then
print_warning "Spinifex binary not found at /opt/spinifex/bin/spinifex"
print_warning "Please ensure spinifex is installed in /opt/spinifex before starting the service"
fi
print_status "Installation complete!"
+49
View File
@@ -0,0 +1,49 @@
[Unit]
Description=Spinifex Services
Documentation=https://github.com/mulgadc/spinifex
After=network.target
Wants=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
User=root
Group=root
WorkingDirectory=/opt/spinifex
Environment=PATH=/opt/spinifex/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Start NATS service
ExecStart=/opt/spinifex/bin/spinifex service nats start
ExecStartPost=/bin/sleep 3
# Start Predastore service
ExecStart=/opt/spinifex/bin/spinifex service predastore start
ExecStartPost=/bin/sleep 2
# Start Viperblock service
ExecStart=/opt/spinifex/bin/spinifex service viperblock start
# Stop services in reverse order
ExecStop=/opt/spinifex/bin/spinifex service viperblock stop
ExecStopPost=/bin/sleep 2
ExecStop=/opt/spinifex/bin/spinifex service predastore stop
ExecStopPost=/bin/sleep 2
ExecStop=/opt/spinifex/bin/spinifex service nats stop
# Restart policy
Restart=on-failure
RestartSec=10
# Security settings
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/spinifex /var/log /var/run
# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=spinifex
[Install]
WantedBy=multi-user.target
+4 -4
View File
@@ -1,6 +1,6 @@
#!/bin/bash
# Hive Development Dependencies Setup Script
# Spinifex Development Dependencies Setup Script
# This script clones Viperblock and Predastore repositories for cross-repo development
# TODO: Improve, remove CLAUDE readme reference, simplify next-steps
@@ -10,13 +10,13 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
MULGA_ROOT="$(cd "$PROJECT_ROOT/.." && pwd)"
echo "🏗️ Setting up Hive development environment..."
echo "🏗️ Setting up Spinifex development environment..."
echo "Project root: $PROJECT_ROOT"
echo "Mulga root: $MULGA_ROOT"
# Check if we're in the correct directory structure
if [[ ! -f "$PROJECT_ROOT/go.mod" ]]; then
echo "❌ Error: Cannot find go.mod. Please run this script from the hive repository."
echo "❌ Error: Cannot find go.mod. Please run this script from the spinifex repository."
exit 1
fi
@@ -70,7 +70,7 @@ fi
# Verify directory structure
echo ""
echo "📁 Directory structure:"
ls -la "$MULGA_ROOT" | grep -E "(hive|viperblock|predastore)" || true
ls -la "$MULGA_ROOT" | grep -E "(spinifex|viperblock|predastore)" || true
echo ""
echo "🎉 Development environment setup complete!"
+2 -2
View File
@@ -3,12 +3,12 @@ set -euo pipefail
# Run Go tests with coverage and report total code coverage.
COVERPROFILE=$(mktemp /tmp/hive-coverage-XXXXXX.out)
COVERPROFILE=$(mktemp /tmp/spinifex-coverage-XXXXXX.out)
trap 'rm -f "$COVERPROFILE"' EXIT
echo "Running tests with coverage..."
echo ""
LOG_IGNORE=1 go test -timeout 120s -coverprofile="$COVERPROFILE" -covermode=atomic ./hive/... 2>&1
LOG_IGNORE=1 go test -timeout 120s -coverprofile="$COVERPROFILE" -covermode=atomic ./spinifex/... 2>&1
if [[ ! -s "$COVERPROFILE" ]]; then
echo "No coverage data collected."
+4 -4
View File
@@ -26,13 +26,13 @@ echo "========================="
echo "Starting init node (127.0.0.1) and joining nodes (127.0.0.2, 127.0.0.3)..."
# Init blocks until all nodes join, so run in background
./bin/hive admin init \
./bin/spx admin init \
--node node1 \
--nodes 3 \
--bind 127.0.0.1 \
--cluster-bind 127.0.0.1 \
--port 4432 \
--hive-dir ~/node1/ \
--spinifex-dir ~/node1/ \
--config-dir ~/node1/config/ \
--region ap-southeast-2 \
--az ap-southeast-2a &
@@ -42,7 +42,7 @@ INIT_PID=$!
sleep 2
# Join nodes concurrently
./bin/hive admin join \
./bin/spx admin join \
--node node2 \
--bind 127.0.0.2 \
--cluster-bind 127.0.0.2 \
@@ -53,7 +53,7 @@ sleep 2
--az ap-southeast-2a &
JOIN2_PID=$!
./bin/hive admin join \
./bin/spx admin join \
--node node3 \
--bind 127.0.0.3 \
--cluster-bind 127.0.0.3 \
+24 -24
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# Hive Platform Development Environment Setup
# This script sets up a complete development environment for the Hive platform
# Spinifex Platform Development Environment Setup
# This script sets up a complete development environment for the Spinifex platform
set -e
@@ -12,17 +12,17 @@ MULGA_ROOT="$(cd "$PROJECT_ROOT/.." && pwd)"
# Default configuration
NATS_PORT=4222
PREDASTORE_PORT=8443
HIVE_GATEWAY_PORT=9999
DATA_DIR="$HOME/hive"
# Use CONFIG_DIR environment variable if set, otherwise default to ~/hive/config
CONFIG_DIR="${CONFIG_DIR:-$HOME/hive/config}"
SPINIFEX_GATEWAY_PORT=9999
DATA_DIR="$HOME/spinifex"
# Use CONFIG_DIR environment variable if set, otherwise default to ~/spinifex/config
CONFIG_DIR="${CONFIG_DIR:-$HOME/spinifex/config}"
echo "🚀 Setting up Hive development environment..."
echo "🚀 Setting up Spinifex development environment..."
echo "Project root: $PROJECT_ROOT"
echo "Data directory: $DATA_DIR"
# Create necessary directories
mkdir -p "$DATA_DIR"/{nats,predastore,viperblock,logs,hive}
mkdir -p "$DATA_DIR"/{nats,predastore,viperblock,logs,spinifex}
mkdir -p "$CONFIG_DIR"
# Function to check if command exists
@@ -124,7 +124,7 @@ done
echo ""
echo "🔌 Checking port availability..."
ports=("$NATS_PORT:NATS" "$PREDASTORE_PORT:Predastore" "$HIVE_GATEWAY_PORT:Hive Gateway")
ports=("$NATS_PORT:NATS" "$PREDASTORE_PORT:Predastore" "$SPINIFEX_GATEWAY_PORT:Spinifex Gateway")
for port_info in "${ports[@]}"; do
port="${port_info%:*}"
service="${port_info#*:}"
@@ -135,24 +135,24 @@ for port_info in "${ports[@]}"; do
fi
done
# Build Hive first (needed for admin init)
# Build Spinifex first (needed for admin init)
echo ""
echo "🔨 Building Hive..."
echo "🔨 Building Spinifex..."
cd "$PROJECT_ROOT"
make build
echo "✅ Hive built successfully"
echo "✅ Spinifex built successfully"
# Initialize Hive configuration using admin init
# Initialize Spinifex configuration using admin init
#echo ""
#echo "🔐 Initializing Hive configuration..."
#echo "🔐 Initializing Spinifex configuration..."
#if [[ ! -f "$CONFIG_DIR/hive.toml" ]]; then
# echo "📋 Running hive admin init..."
# ./bin/hive admin init --config-dir "$CONFIG_DIR"
# echo "✅ Hive configuration initialized"
#if [[ ! -f "$CONFIG_DIR/spinifex.toml" ]]; then
# echo "📋 Running spx admin init..."
# ./bin/spx admin init --config-dir "$CONFIG_DIR"
# echo "✅ Spinifex configuration initialized"
#else
# echo "✅ Hive configuration already exists"
# echo " To re-initialize, run: ./bin/hive admin init --force"
# echo "✅ Spinifex configuration already exists"
# echo " To re-initialize, run: ./bin/spx admin init --force"
#fi
# Build components
@@ -182,9 +182,9 @@ fi
echo ""
echo "🎉 Development environment setup complete!"
echo ""
echo "When running Hive for the first time, run the init function to create the"
echo "When running Spinifex for the first time, run the init function to create the"
echo "default directories for data, config files and layout required."
echo "./bin/hive admin init"
echo "./bin/spx admin init"
echo ""
echo "🚀 To start the development environment:"
echo " ./scripts/start-dev.sh"
@@ -193,7 +193,7 @@ echo "🛑 To stop the development environment:"
echo " ./scripts/stop-dev.sh"
echo ""
echo "🔧 Development endpoints:"
echo " - Hive Gateway: https://localhost:$HIVE_GATEWAY_PORT"
echo " - Spinifex Gateway: https://localhost:$SPINIFEX_GATEWAY_PORT"
echo " - Predastore S3: https://localhost:$PREDASTORE_PORT"
echo " - NATS: nats://localhost:$NATS_PORT"
echo ""
@@ -201,4 +201,4 @@ echo "📊 Monitor logs:"
echo " tail -f $DATA_DIR/logs/*.log"
echo ""
echo "🧪 Test with AWS CLI:"
echo " aws --endpoint-url https://localhost:$HIVE_GATEWAY_PORT --no-verify-ssl ec2 describe-instances"
echo " aws --endpoint-url https://localhost:$SPINIFEX_GATEWAY_PORT --no-verify-ssl ec2 describe-instances"
+12 -12
View File
@@ -79,19 +79,19 @@ data "aws_ami" "debian12" {
}
}
# Keypair: hive-test
# Keypair: spinifex-test
resource "tls_private_key" "hive_test" {
algorithm = "ED25519"
}
resource "aws_key_pair" "hive_test" {
key_name = "hive-test"
key_name = "spinifex-test"
public_key = tls_private_key.hive_test.public_key_openssh
}
# Save private key locally for SSH
resource "local_file" "hive_test_pem" {
filename = "${path.module}/hive-test.pem"
filename = "${path.module}/spinifex-test.pem"
content = tls_private_key.hive_test.private_key_openssh
file_permission = "0600"
}
@@ -103,7 +103,7 @@ resource "aws_vpc" "main" {
enable_dns_support = true
tags = {
Name = "hive-test-vpc"
Name = "spinifex-test-vpc"
}
}
@@ -112,7 +112,7 @@ resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.main.id
tags = {
Name = "hive-test-igw"
Name = "spinifex-test-igw"
}
}
@@ -124,7 +124,7 @@ resource "aws_subnet" "public" {
map_public_ip_on_launch = true
tags = {
Name = "hive-test-public-subnet"
Name = "spinifex-test-public-subnet"
}
}
@@ -137,7 +137,7 @@ resource "aws_route_table" "public" {
}
tags = {
Name = "hive-test-public-rt"
Name = "spinifex-test-public-rt"
}
}
@@ -148,7 +148,7 @@ resource "aws_route_table_association" "public" {
# 3: Security group
resource "aws_security_group" "web_ssh" {
name = "hive-test-sg"
name = "spinifex-test-sg"
description = "Allow inbound 22,80,443; allow all outbound"
vpc_id = aws_vpc.main.id
@@ -185,13 +185,13 @@ resource "aws_security_group" "web_ssh" {
}
tags = {
Name = "hive-test-sg"
Name = "spinifex-test-sg"
}
}
# 4: Ensure 3 servers on different underlying hardware (spread placement group)
resource "aws_placement_group" "spread" {
name = "hive-test-spread"
name = "spinifex-test-spread"
strategy = "spread"
}
@@ -208,7 +208,7 @@ resource "aws_instance" "vm" {
placement_group = aws_placement_group.spread.name
tags = {
Name = "hive-test-vm-${count.index + 1}"
Name = "spinifex-test-vm-${count.index + 1}"
}
}
@@ -219,6 +219,6 @@ output "instance_public_ips" {
output "ssh_commands" {
value = [
for ip in aws_instance.vm[*].public_ip :
"ssh -i hive-test.pem admin@${ip}"
"ssh -i spinifex-test.pem admin@${ip}"
]
}
+7 -7
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
# Configure a provisioned Hive cluster: clone repo, build, form cluster, start services.
# Configure a provisioned Spinifex cluster: clone repo, build, form cluster, start services.
# Usage: configure-cluster.sh <cluster_name> <state_file>
CLUSTER_NAME="${1:?Usage: configure-cluster.sh <cluster_name> <state_file>}"
@@ -93,7 +93,7 @@ NODE1_IP="${MGMT_IPS[0]}"
# Node 1: init
echo " Starting init on node1 ($NODE1_IP)..."
remote_bg "$NODE1_IP" "export PATH=\$PATH:/usr/local/go/bin && cd ~/Development/mulga/hive && ./bin/hive admin init \
remote_bg "$NODE1_IP" "export PATH=\$PATH:/usr/local/go/bin && cd ~/Development/mulga/hive && ./bin/spx admin init \
--node node1 \
--bind $NODE1_IP \
--cluster-bind $NODE1_IP \
@@ -103,8 +103,8 @@ remote_bg "$NODE1_IP" "export PATH=\$PATH:/usr/local/go/bin && cd ~/Development/
--nodes $NODE_COUNT \
--region $REGION \
--az $AZ \
--hive-dir ~/hive/ \
--config-dir ~/hive/config/"
--hive-dir ~/spinifex/ \
--config-dir ~/spinifex/config/"
INIT_PID=$!
# Wait for formation server to be ready
@@ -128,14 +128,14 @@ if [ "$NODE_COUNT" -gt 1 ]; then
ip="${MGMT_IPS[$i]}"
node_num=$((i + 1))
echo " Starting join on node$node_num ($ip)..."
remote_bg "$ip" "export PATH=\$PATH:/usr/local/go/bin && cd ~/Development/mulga/hive && ./bin/hive admin join \
remote_bg "$ip" "export PATH=\$PATH:/usr/local/go/bin && cd ~/Development/mulga/hive && ./bin/spx admin join \
--node node$node_num \
--bind $ip \
--cluster-bind $ip \
--cluster-routes $NODE1_IP:4248 \
--host $NODE1_IP:4432 \
--data-dir ~/hive/ \
--config-dir ~/hive/config/ \
--data-dir ~/spinifex/ \
--config-dir ~/spinifex/config/ \
--region $REGION \
--az $AZ"
JOIN_PIDS+=($!)
+2 -2
View File
@@ -62,7 +62,7 @@ variable "nodes" {
variable "cluster_name" {
type = string
description = "Name for the Hive cluster (used in VM names and tags)"
description = "Name for the Spinifex cluster (used in VM names and tags)"
validation {
condition = can(regex("^[a-z0-9-]+$", var.cluster_name))
@@ -72,7 +72,7 @@ variable "cluster_name" {
variable "node_count" {
type = number
description = "Number of Hive VMs to create"
description = "Number of Spinifex VMs to create"
default = 3
validation {
+1 -1
View File
@@ -3,7 +3,7 @@ resource "proxmox_virtual_environment_vm" "hive_node" {
name = "${var.cluster_name}-${count.index + 1}"
description = "Managed by Terraform"
tags = ["terraform", "hive", var.cluster_name]
tags = ["terraform", "spinifex", var.cluster_name]
node_name = var.nodes[count.index % length(var.nodes)].name
initialization {
@@ -7,7 +7,7 @@ CLUSTERS_DIR="$TOFU_DIR/clusters"
usage() {
cat <<'USAGE'
Usage: hive-test.sh <command> <cluster_name> [options]
Usage: spinifex-test.sh <command> <cluster_name> [options]
Commands:
up Provision VMs with OpenTofu
@@ -25,13 +25,13 @@ Options:
--disk-size-gb=N Disk size per VM in GB (default: 32)
Examples:
./scripts/iac/hive-test.sh up hive-test1
./scripts/iac/hive-test.sh configure hive-test1
./scripts/iac/hive-test.sh test hive-test1
./scripts/iac/hive-test.sh status hive-test1
./scripts/iac/hive-test.sh ssh hive-test1 2
./scripts/iac/hive-test.sh down hive-test1
./scripts/iac/hive-test.sh full hive-test1 --node-count=3
./scripts/iac/spinifex-test.sh up spinifex-test1
./scripts/iac/spinifex-test.sh configure spinifex-test1
./scripts/iac/spinifex-test.sh test spinifex-test1
./scripts/iac/spinifex-test.sh status spinifex-test1
./scripts/iac/spinifex-test.sh ssh spinifex-test1 2
./scripts/iac/spinifex-test.sh down spinifex-test1
./scripts/iac/spinifex-test.sh full spinifex-test1 --node-count=3
USAGE
exit 1
}
@@ -195,7 +195,7 @@ cmd_status() {
cmd_ssh() {
if [ -z "$SSH_NODE" ]; then
echo "Usage: hive-test.sh ssh <cluster_name> <node_number>"
echo "Usage: spinifex-test.sh ssh <cluster_name> <node_number>"
exit 1
fi
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
# Run smoke tests against a configured Hive cluster.
# Run smoke tests against a configured Spinifex cluster.
# Usage: test-cluster.sh <cluster_name> <state_file>
CLUSTER_NAME="${1:?Usage: test-cluster.sh <cluster_name> <state_file>}"
+9 -9
View File
@@ -8,26 +8,26 @@ echo "Shutting down services"
echo "Removing data"
rm -rf ~/hive/predastore/
rm -rf ~/spinifex/predastore/
rm -rf ~/hive/hive/*
rm -rf ~/spinifex/hive/*
rm -rf ~/hive/viperblock/*
rm -rf ~/spinifex/viperblock/*
rm -rf ~/hive/nats/*
rm -rf ~/spinifex/nats/*
rm -rf ~/hive/images/*
rm -rf ~/spinifex/images/*
# Enable pprof for development
PPROF_ENABLED=1 PPROF_OUTPUT=/tmp/hive-vm.prof ./scripts/start-dev.sh --build
PPROF_ENABLED=1 PPROF_OUTPUT=/tmp/spinifex-vm.prof ./scripts/start-dev.sh --build
# Follow INSTALL.md steps
echo "Importing AMI"
export AWS_PROFILE=hive
export AWS_PROFILE=spinifex
# Step 1 SSH key
aws ec2 import-key-pair --key-name "hive-key" --public-key-material fileb://~/.ssh/hive-key.pub
aws ec2 import-key-pair --key-name "spinifex-key" --public-key-material fileb://~/.ssh/spinifex-key.pub
echo "Validating key pair imported"
@@ -45,7 +45,7 @@ else
fi
echo "Detected architecture: $ARCH, using image: $IMAGE_NAME"
./bin/hive admin images import --name "$IMAGE_NAME"
./bin/spx admin images import --name "$IMAGE_NAME"
aws ec2 describe-images
+25 -25
View File
@@ -1,15 +1,15 @@
#!/bin/sh
# List running instances using ubuntu image and run disk performance benchmark
export AWS_PROFILE=hive
export AWS_PROFILE=spinifex
# Initialize perf tracking variables
PERF_PID=""
NBDKIT_PID=""
# Check HIVE_AMI set, if not try to detect it
if [ -z "$HIVE_AMI" ]; then
echo "HIVE_AMI not set, attempting to detect..."
# Check SPINIFEX_AMI set, if not try to detect it
if [ -z "$SPINIFEX_AMI" ]; then
echo "SPINIFEX_AMI not set, attempting to detect..."
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
IMAGE_NAME="ami-ubuntu-24.04-x86_64"
@@ -18,23 +18,23 @@ if [ -z "$HIVE_AMI" ]; then
else
IMAGE_NAME="ami-ubuntu-24.04-x86_64"
fi
HIVE_AMI=$(aws ec2 describe-images --query "Images[?Name=='$IMAGE_NAME'].ImageId" --output text)
if [ -z "$HIVE_AMI" ]; then
SPINIFEX_AMI=$(aws ec2 describe-images --query "Images[?Name=='$IMAGE_NAME'].ImageId" --output text)
if [ -z "$SPINIFEX_AMI" ]; then
echo "Error: Could not find image with Name '$IMAGE_NAME'"
exit 1
fi
echo "Detected HIVE_AMI: $HIVE_AMI"
echo "Detected SPINIFEX_AMI: $SPINIFEX_AMI"
fi
# Get running instances matching the AMI
# Retry loop: wait for instance to come online (up to 120 seconds)
echo "Finding running instances with ImageId: $HIVE_AMI"
echo "Finding running instances with ImageId: $SPINIFEX_AMI"
MAX_ATTEMPTS=120
ATTEMPT=0
INSTANCE_ID=""
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
INSTANCE_JSON=$(aws ec2 describe-instances --filters "Name=image-id,Values=$HIVE_AMI" "Name=instance-state-name,Values=running" --output json 2>/dev/null)
INSTANCE_JSON=$(aws ec2 describe-instances --filters "Name=image-id,Values=$SPINIFEX_AMI" "Name=instance-state-name,Values=running" --output json 2>/dev/null)
# Extract InstanceId using jq (handle nested structure)
INSTANCE_ID=$(echo "$INSTANCE_JSON" | jq -r '.Reservations[0].Instances[0].InstanceId // empty' 2>/dev/null)
@@ -52,7 +52,7 @@ while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
done
if [ -z "$INSTANCE_ID" ] || [ "$INSTANCE_ID" = "null" ]; then
echo "Error: No running instances found with ImageId $HIVE_AMI after $MAX_ATTEMPTS attempts"
echo "Error: No running instances found with ImageId $SPINIFEX_AMI after $MAX_ATTEMPTS attempts"
echo "Available instances:"
aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId,ImageId,State.Name]" --output table
exit 1
@@ -113,7 +113,7 @@ else
# Start perf record in the background (will run until interrupted)
echo "Starting perf profiling for nbdkit process (PID: $NBDKIT_PID)..."
sudo perf record -g -p "$NBDKIT_PID" -o /tmp/hive-nbdkit-perf.data > /tmp/perf.log 2>&1 &
sudo perf record -g -p "$NBDKIT_PID" -o /tmp/spinifex-nbdkit-perf.data > /tmp/perf.log 2>&1 &
PERF_PID=$!
echo "Perf profiling started (PID: $PERF_PID), will record during benchmark execution"
fi
@@ -137,7 +137,7 @@ SSH_READY=false
while [ $SSH_ATTEMPTS -lt $MAX_SSH_ATTEMPTS ]; do
ssh-keyscan -p "$SSH_PORT" 127.0.0.1 >> ~/.ssh/known_hosts 2>/dev/null
if ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=2 -p "$SSH_PORT" -i ~/.ssh/hive-key ec2-user@127.0.0.1 'echo ready' >/dev/null 2>&1; then
if ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=2 -p "$SSH_PORT" -i ~/.ssh/spinifex-key ec2-user@127.0.0.1 'echo ready' >/dev/null 2>&1; then
SSH_READY=true
echo "SSH is ready!"
break
@@ -156,7 +156,7 @@ if [ "$SSH_READY" != "true" ]; then
fi
echo "Copying benchmark script to instance..."
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P "$SSH_PORT" -i ~/.ssh/hive-key "$BENCH_SCRIPT" ec2-user@127.0.0.1:~/disk-performance.sh
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P "$SSH_PORT" -i ~/.ssh/spinifex-key "$BENCH_SCRIPT" ec2-user@127.0.0.1:~/disk-performance.sh
if [ $? -ne 0 ]; then
echo "Error: Failed to copy benchmark script to instance"
@@ -165,19 +165,19 @@ fi
# Execute benchmark script
echo "Running benchmark on instance..."
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p "$SSH_PORT" -i ~/.ssh/hive-key ec2-user@127.0.0.1 'chmod +x ~/disk-performance.sh && ~/disk-performance.sh' > /tmp/hive-vm-disk.log 2>&1
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p "$SSH_PORT" -i ~/.ssh/spinifex-key ec2-user@127.0.0.1 'chmod +x ~/disk-performance.sh && ~/disk-performance.sh' > /tmp/spinifex-vm-disk.log 2>&1
if [ $? -ne 0 ]; then
echo "Error: Benchmark execution failed, check /tmp/hive-vm-disk.log for details"
echo "Error: Benchmark execution failed, check /tmp/spinifex-vm-disk.log for details"
# Stop perf if it was running
if [ -n "$PERF_PID" ]; then
echo "Stopping perf profiling..."
sudo kill -INT "$PERF_PID" 2>/dev/null || true
# Wait for perf to finish writing
sleep 3
if [ -f /tmp/hive-nbdkit-perf.data ]; then
sudo chmod 644 /tmp/hive-nbdkit-perf.data
echo "Perf data saved to /tmp/hive-nbdkit-perf.data"
if [ -f /tmp/spinifex-nbdkit-perf.data ]; then
sudo chmod 644 /tmp/spinifex-nbdkit-perf.data
echo "Perf data saved to /tmp/spinifex-nbdkit-perf.data"
fi
fi
exit 1
@@ -191,19 +191,19 @@ if [ -n "$PERF_PID" ]; then
# Wait for perf to finish writing data
sleep 3
if [ -f /tmp/hive-nbdkit-perf.data ]; then
sudo chmod 644 /tmp/hive-nbdkit-perf.data
echo "Perf benchmarks saved to /tmp/hive-nbdkit-perf.data"
echo "To view: sudo perf report -i /tmp/hive-nbdkit-perf.data"
if [ -f /tmp/spinifex-nbdkit-perf.data ]; then
sudo chmod 644 /tmp/spinifex-nbdkit-perf.data
echo "Perf benchmarks saved to /tmp/spinifex-nbdkit-perf.data"
echo "To view: sudo perf report -i /tmp/spinifex-nbdkit-perf.data"
else
echo "Warning: Perf data file not found at /tmp/hive-nbdkit-perf.data"
echo "Warning: Perf data file not found at /tmp/spinifex-nbdkit-perf.data"
fi
fi
# Display results
echo ""
echo "Benchmark completed successfully!"
echo "Results saved to /tmp/hive-vm-disk.log"
echo "Results saved to /tmp/spinifex-vm-disk.log"
echo ""
echo "=== Benchmark Results ==="
cat /tmp/hive-vm-disk.log
cat /tmp/spinifex-vm-disk.log
+9 -9
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Query images, get Ubuntu image
export AWS_PROFILE=hive
export AWS_PROFILE=spinifex
# Detect architecture
ARCH=$(uname -m)
@@ -14,7 +14,7 @@ else
IMAGE_NAME="ami-ubuntu-24.04-x86_64"
fi
# Query available instance types from Hive and pick the first micro type
# Query available instance types from Spinifex and pick the first micro type
INSTANCE_TYPE=$(aws ec2 describe-instance-types --query "InstanceTypes[?contains(InstanceType, '.micro')].InstanceType | [0]" --output text)
if [ -z "$INSTANCE_TYPE" ] || [ "$INSTANCE_TYPE" = "None" ]; then
echo "Error: Could not find available micro instance type"
@@ -28,27 +28,27 @@ echo "Detected architecture: $ARCH"
echo "Looking for image with Name: $IMAGE_NAME"
# Query images and extract ImageId matching the IMAGE_NAME
HIVE_AMI=$(aws ec2 describe-images --query "Images[?Name=='$IMAGE_NAME'].ImageId" --output text)
SPINIFEX_AMI=$(aws ec2 describe-images --query "Images[?Name=='$IMAGE_NAME'].ImageId" --output text)
if [ -z "$HIVE_AMI" ]; then
if [ -z "$SPINIFEX_AMI" ]; then
echo "Error: Could not find image with Name '$IMAGE_NAME'"
echo "Available images:"
aws ec2 describe-images --query "Images[*].[Name,ImageId]" --output table
exit 1
fi
export HIVE_AMI=$HIVE_AMI
export SPINIFEX_AMI=$SPINIFEX_AMI
echo "Found ImageId: $HIVE_AMI"
export HIVE_AMI
echo "Found ImageId: $SPINIFEX_AMI"
export SPINIFEX_AMI
echo "Launching instance"
# Launch instance
aws ec2 run-instances \
--image-id "$HIVE_AMI" \
--image-id "$SPINIFEX_AMI" \
--instance-type "$INSTANCE_TYPE" \
--key-name hive-key \
--key-name spinifex-key \
--security-group-ids sg-0123456789abcdef0 \
--subnet-id subnet-6e7f829e \
--count 1
+10 -10
View File
@@ -1,6 +1,6 @@
#!/bin/bash
# OVN Compute Node Setup for Hive VPC Networking
# OVN Compute Node Setup for Spinifex VPC Networking
#
# This script bootstraps a compute node for OVN-based VPC networking:
# 1. Installs OVN/OVS packages (if not present)
@@ -71,7 +71,7 @@ if [ -z "$CHASSIS_ID" ]; then
echo "Auto-detected chassis ID: $CHASSIS_ID"
fi
echo "=== Hive OVN Compute Node Setup ==="
echo "=== Spinifex OVN Compute Node Setup ==="
echo " Management node: $MANAGEMENT"
echo " OVN Remote (SB): $OVN_REMOTE"
echo " Encap IP: $ENCAP_IP"
@@ -161,8 +161,8 @@ echo " ovn-controller: started"
echo ""
echo "Step 6: Applying sysctl for overlay networking..."
sudo tee /etc/sysctl.d/99-hive-vpc.conf >/dev/null <<'SYSCTL'
# Hive VPC networking: enable IP forwarding and disable rp_filter
sudo tee /etc/sysctl.d/99-spinifex-vpc.conf >/dev/null <<'SYSCTL'
# Spinifex VPC networking: enable IP forwarding and disable rp_filter
# for Geneve overlay traffic on OVS bridges.
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
@@ -226,9 +226,9 @@ fi
# Create persistent systemd override so permissions survive OVS restarts
OVERRIDE_DIR="/etc/systemd/system/openvswitch-switch.service.d"
if [ ! -f "$OVERRIDE_DIR/hive-perms.conf" ]; then
if [ ! -f "$OVERRIDE_DIR/spinifex-perms.conf" ]; then
sudo mkdir -p "$OVERRIDE_DIR"
sudo tee "$OVERRIDE_DIR/hive-perms.conf" >/dev/null <<'OVERRIDE'
sudo tee "$OVERRIDE_DIR/spinifex-perms.conf" >/dev/null <<'OVERRIDE'
[Service]
ExecStartPost=/bin/chmod 0666 /var/run/openvswitch/db.sock
OVERRIDE
@@ -240,11 +240,11 @@ fi
# Create sudoers rule for network commands that always need root
# (ip tuntap, ip link set — NET_ADMIN operations)
SUDOERS_FILE="/etc/sudoers.d/hive-network"
SUDOERS_FILE="/etc/sudoers.d/spinifex-network"
if [ ! -f "$SUDOERS_FILE" ]; then
CURRENT_USER=$(whoami)
sudo tee "$SUDOERS_FILE" >/dev/null <<EOF
# Hive VPC networking: allow non-root daemon to manage tap devices and OVS
# Spinifex VPC networking: allow non-root daemon to manage tap devices and OVS
$CURRENT_USER ALL=(root) NOPASSWD: /sbin/ip, /usr/sbin/ip
$CURRENT_USER ALL=(root) NOPASSWD: /usr/bin/ovs-vsctl, /usr/bin/ovs-appctl
$CURRENT_USER ALL=(root) NOPASSWD: /usr/bin/ovn-nbctl, /usr/bin/ovn-sbctl
@@ -269,7 +269,7 @@ if ls /var/log/ovn/*.log.log* 1>/dev/null 2>&1; then
echo " cleaned up stale .log.log files"
fi
LOGROTATE_FILE="/etc/logrotate.d/ovn-hive"
LOGROTATE_FILE="/etc/logrotate.d/ovn-spinifex"
sudo tee "$LOGROTATE_FILE" >/dev/null <<'LOGROTATE'
/var/log/ovn/ovn-controller.log
/var/log/ovn/ovn-northd.log
@@ -288,7 +288,7 @@ LOGROTATE
echo " logrotate config: $LOGROTATE_FILE (daily, 100M max, 3 rotations, explicit filenames)"
# --- Step 10: Disable auto-start on boot ---
# start-dev.sh / stop-dev.sh manage the OVN lifecycle. Without hive services
# start-dev.sh / stop-dev.sh manage the OVN lifecycle. Without spinifex services
# running, ovn-controller spins in a tight reconnect loop burning CPU.
echo ""
echo "Step 10: Disabling OVN auto-start on boot (start-dev.sh will manage lifecycle)..."
+94 -94
View File
@@ -1,17 +1,17 @@
#!/bin/bash
# Hive binary installer
# Spinifex binary installer
# Usage: curl -sfL https://install.mulgadc.com | bash
#
# Environment variables:
# INSTALL_HIVE_CHANNEL Release channel: latest (default), dev
# INSTALL_HIVE_VERSION Pin to specific version (overrides channel)
# INSTALL_HIVE_TARBALL Path to local tarball (skips download, for testing/air-gapped)
# INSTALL_HIVE_SKIP_APT Set to 1 to skip apt dependency install
# INSTALL_HIVE_SKIP_AWS Set to 1 to skip AWS CLI install
# INSTALL_SPINIFEX_CHANNEL Release channel: latest (default), dev
# INSTALL_SPINIFEX_VERSION Pin to specific version (overrides channel)
# INSTALL_SPINIFEX_TARBALL Path to local tarball (skips download, for testing/air-gapped)
# INSTALL_SPINIFEX_SKIP_APT Set to 1 to skip apt dependency install
# INSTALL_SPINIFEX_SKIP_AWS Set to 1 to skip AWS CLI install
set -e
INSTALL_HIVE_CHANNEL="${INSTALL_HIVE_CHANNEL:-latest}"
INSTALL_SPINIFEX_CHANNEL="${INSTALL_SPINIFEX_CHANNEL:-latest}"
INSTALL_BASE_URL="${INSTALL_BASE_URL:-https://install.mulgadc.com}"
# --- Colors ---
@@ -60,7 +60,7 @@ detect_os() {
fi
;;
*)
fatal "Unsupported OS: $ID $VERSION_ID. Hive requires Debian 12+ or Ubuntu 22.04+"
fatal "Unsupported OS: $ID $VERSION_ID. Spinifex requires Debian 12+ or Ubuntu 22.04+"
;;
esac
@@ -82,7 +82,7 @@ detect_arch() {
AWS_ARCH="aarch64"
;;
*)
fatal "Unsupported architecture: $MACHINE. Hive requires x86_64 or aarch64"
fatal "Unsupported architecture: $MACHINE. Spinifex requires x86_64 or aarch64"
;;
esac
@@ -92,30 +92,30 @@ detect_arch() {
# --- Detect service user ---
detect_service_user() {
# Use the real user — either the current user, or SUDO_USER if running via sudo
HIVE_USER="${SUDO_USER:-$(whoami)}"
HIVE_GROUP="$(id -gn "$HIVE_USER")"
SPINIFEX_USER="${SUDO_USER:-$(whoami)}"
SPINIFEX_GROUP="$(id -gn "$SPINIFEX_USER")"
if [ "$HIVE_USER" = "root" ]; then
if [ "$SPINIFEX_USER" = "root" ]; then
fatal "Cannot determine service user. Do not run as root directly — use: curl ... | bash (as a normal user)"
fi
info "Services will run as: $HIVE_USER:$HIVE_GROUP"
info "Services will run as: $SPINIFEX_USER:$SPINIFEX_GROUP"
# Allow the service user to manage OVN/OVS and tap devices
$SUDO tee /etc/sudoers.d/hive-network > /dev/null << SUDOERS
# Hive VPC networking: allow service user to manage tap devices, OVS, and OVN
${HIVE_USER} ALL=(root) NOPASSWD: /sbin/ip, /usr/sbin/ip
${HIVE_USER} ALL=(root) NOPASSWD: /usr/bin/ovs-vsctl, /usr/bin/ovs-appctl
${HIVE_USER} ALL=(root) NOPASSWD: /usr/bin/ovn-nbctl, /usr/bin/ovn-sbctl
$SUDO tee /etc/sudoers.d/spinifex-network > /dev/null << SUDOERS
# Spinifex VPC networking: allow service user to manage tap devices, OVS, and OVN
${SPINIFEX_USER} ALL=(root) NOPASSWD: /sbin/ip, /usr/sbin/ip
${SPINIFEX_USER} ALL=(root) NOPASSWD: /usr/bin/ovs-vsctl, /usr/bin/ovs-appctl
${SPINIFEX_USER} ALL=(root) NOPASSWD: /usr/bin/ovn-nbctl, /usr/bin/ovn-sbctl
SUDOERS
$SUDO chmod 0440 /etc/sudoers.d/hive-network
info "Sudoers rules installed for $HIVE_USER"
$SUDO chmod 0440 /etc/sudoers.d/spinifex-network
info "Sudoers rules installed for $SPINIFEX_USER"
}
# --- Install apt dependencies ---
install_apt_deps() {
if [ "${INSTALL_HIVE_SKIP_APT}" = "1" ]; then
info "Skipping apt dependencies (INSTALL_HIVE_SKIP_APT=1)"
if [ "${INSTALL_SPINIFEX_SKIP_APT}" = "1" ]; then
info "Skipping apt dependencies (INSTALL_SPINIFEX_SKIP_APT=1)"
return
fi
@@ -135,8 +135,8 @@ install_apt_deps() {
# --- Install AWS CLI ---
install_aws_cli() {
if [ "${INSTALL_HIVE_SKIP_AWS}" = "1" ]; then
info "Skipping AWS CLI (INSTALL_HIVE_SKIP_AWS=1)"
if [ "${INSTALL_SPINIFEX_SKIP_AWS}" = "1" ]; then
info "Skipping AWS CLI (INSTALL_SPINIFEX_SKIP_AWS=1)"
return
fi
@@ -156,42 +156,42 @@ install_aws_cli() {
}
# --- Download tarball ---
download_hive() {
HIVE_TMPDIR=$(mktemp -d)
TARBALL="$HIVE_TMPDIR/hive.tar.gz"
download_spinifex() {
SPINIFEX_TMPDIR=$(mktemp -d)
TARBALL="$SPINIFEX_TMPDIR/hive.tar.gz"
# Local tarball override — skip download (for testing and air-gapped installs)
if [ -n "$INSTALL_HIVE_TARBALL" ]; then
info "Using local tarball: $INSTALL_HIVE_TARBALL"
cp "$INSTALL_HIVE_TARBALL" "$TARBALL"
if [ -n "$INSTALL_SPINIFEX_TARBALL" ]; then
info "Using local tarball: $INSTALL_SPINIFEX_TARBALL"
cp "$INSTALL_SPINIFEX_TARBALL" "$TARBALL"
info "Extracting..."
tar -xzf "$TARBALL" -C "$HIVE_TMPDIR"
EXTRACT_DIR="$HIVE_TMPDIR"
tar -xzf "$TARBALL" -C "$SPINIFEX_TMPDIR"
EXTRACT_DIR="$SPINIFEX_TMPDIR"
return
fi
if [ -n "$INSTALL_HIVE_VERSION" ]; then
DOWNLOAD_URL="${INSTALL_BASE_URL}/download/${INSTALL_HIVE_VERSION}/${ARCH}"
info "Downloading Hive $INSTALL_HIVE_VERSION ($ARCH)..."
if [ -n "$INSTALL_SPINIFEX_VERSION" ]; then
DOWNLOAD_URL="${INSTALL_BASE_URL}/download/${INSTALL_SPINIFEX_VERSION}/${ARCH}"
info "Downloading Spinifex $INSTALL_SPINIFEX_VERSION ($ARCH)..."
else
DOWNLOAD_URL="${INSTALL_BASE_URL}/download/${INSTALL_HIVE_CHANNEL}/${ARCH}"
info "Downloading Hive ($INSTALL_HIVE_CHANNEL channel, $ARCH)..."
DOWNLOAD_URL="${INSTALL_BASE_URL}/download/${INSTALL_SPINIFEX_CHANNEL}/${ARCH}"
info "Downloading Spinifex ($INSTALL_SPINIFEX_CHANNEL channel, $ARCH)..."
fi
HTTP_CODE=$(curl -fsSL -w '%{http_code}' -o "$TARBALL" "$DOWNLOAD_URL" 2>/dev/null) || true
if [ ! -f "$TARBALL" ] || [ "$HTTP_CODE" -ge 400 ] 2>/dev/null; then
rm -rf "$HIVE_TMPDIR"
fatal "Failed to download Hive from $DOWNLOAD_URL (HTTP $HTTP_CODE)"
rm -rf "$SPINIFEX_TMPDIR"
fatal "Failed to download Spinifex from $DOWNLOAD_URL (HTTP $HTTP_CODE)"
fi
# Verify checksum if available
CHECKSUM_URL="${DOWNLOAD_URL}.sha256"
if curl -fsSL -o "$HIVE_TMPDIR/checksum.sha256" "$CHECKSUM_URL" 2>/dev/null; then
if curl -fsSL -o "$SPINIFEX_TMPDIR/checksum.sha256" "$CHECKSUM_URL" 2>/dev/null; then
info "Verifying checksum..."
EXPECTED=$(awk '{print $1}' "$HIVE_TMPDIR/checksum.sha256")
EXPECTED=$(awk '{print $1}' "$SPINIFEX_TMPDIR/checksum.sha256")
ACTUAL=$(sha256sum "$TARBALL" | awk '{print $1}')
if [ "$EXPECTED" != "$ACTUAL" ]; then
rm -rf "$HIVE_TMPDIR"
rm -rf "$SPINIFEX_TMPDIR"
fatal "Checksum verification failed. Expected: $EXPECTED, Got: $ACTUAL"
fi
info "Checksum verified"
@@ -201,8 +201,8 @@ download_hive() {
# Extract
info "Extracting..."
tar -xzf "$TARBALL" -C "$HIVE_TMPDIR"
EXTRACT_DIR="$HIVE_TMPDIR"
tar -xzf "$TARBALL" -C "$SPINIFEX_TMPDIR"
EXTRACT_DIR="$SPINIFEX_TMPDIR"
}
# --- Place files ---
@@ -210,8 +210,8 @@ install_files() {
info "Installing files..."
# Binary
$SUDO install -m 0755 "$EXTRACT_DIR/hive" /usr/local/bin/hive
info " /usr/local/bin/hive"
$SUDO install -m 0755 "$EXTRACT_DIR/spx" /usr/local/bin/spx
info " /usr/local/bin/spx"
# nbdkit plugin
PLUGINDIR=$(nbdkit --dump-config 2>/dev/null | grep ^plugindir= | cut -d= -f2)
@@ -228,10 +228,10 @@ install_files() {
info " $PLUGINDIR/nbdkit-viperblock-plugin.so"
# Setup scripts
$SUDO mkdir -p /usr/local/share/hive
$SUDO mkdir -p /usr/local/share/spinifex
if [ -f "$EXTRACT_DIR/setup-ovn.sh" ]; then
$SUDO install -m 0755 "$EXTRACT_DIR/setup-ovn.sh" /usr/local/share/hive/setup-ovn.sh
info " /usr/local/share/hive/setup-ovn.sh"
$SUDO install -m 0755 "$EXTRACT_DIR/setup-ovn.sh" /usr/local/share/spinifex/setup-ovn.sh
info " /usr/local/share/spinifex/setup-ovn.sh"
fi
}
@@ -239,39 +239,39 @@ install_files() {
create_directories() {
info "Creating directories..."
$SUDO mkdir -p /etc/hive
$SUDO chmod 0700 /etc/hive
$SUDO chown "$HIVE_USER:$HIVE_GROUP" /etc/hive
$SUDO mkdir -p /etc/spinifex
$SUDO chmod 0700 /etc/spinifex
$SUDO chown "$SPINIFEX_USER:$SPINIFEX_GROUP" /etc/spinifex
$SUDO mkdir -p /var/lib/hive
$SUDO chown "$HIVE_USER:$HIVE_GROUP" /var/lib/hive
$SUDO mkdir -p /var/lib/spinifex
$SUDO chown "$SPINIFEX_USER:$SPINIFEX_GROUP" /var/lib/spinifex
# Symlink so services that expect BaseDir/config/ can find /etc/hive/
if [ ! -e /var/lib/hive/config ]; then
$SUDO ln -s /etc/hive /var/lib/hive/config
# Symlink so services that expect BaseDir/config/ can find /etc/spinifex/
if [ ! -e /var/lib/spinifex/config ]; then
$SUDO ln -s /etc/spinifex /var/lib/spinifex/config
fi
# Symlink so services that write logs to BaseDir/logs/ use /var/log/hive/
if [ ! -e /var/lib/hive/logs ]; then
$SUDO ln -s /var/log/hive /var/lib/hive/logs
# Symlink so services that write logs to BaseDir/logs/ use /var/log/spinifex/
if [ ! -e /var/lib/spinifex/logs ]; then
$SUDO ln -s /var/log/spinifex /var/lib/spinifex/logs
fi
$SUDO mkdir -p /var/log/hive
$SUDO chown "$HIVE_USER:$HIVE_GROUP" /var/log/hive
$SUDO mkdir -p /var/log/spinifex
$SUDO chown "$SPINIFEX_USER:$SPINIFEX_GROUP" /var/log/spinifex
$SUDO mkdir -p /run/hive
$SUDO chown "$HIVE_USER:$HIVE_GROUP" /run/hive
$SUDO mkdir -p /run/spinifex
$SUDO chown "$SPINIFEX_USER:$SPINIFEX_GROUP" /run/spinifex
$SUDO mkdir -p /var/lib/hive/viperblock
$SUDO chown "$HIVE_USER:$HIVE_GROUP" /var/lib/hive/viperblock
$SUDO mkdir -p /var/lib/spinifex/viperblock
$SUDO chown "$SPINIFEX_USER:$SPINIFEX_GROUP" /var/lib/spinifex/viperblock
# Generate environment file with install-specific values (e.g. arch-dependent paths)
$SUDO tee /etc/hive/systemd.env > /dev/null << EOF
$SUDO tee /etc/spinifex/systemd.env > /dev/null << EOF
# Generated by setup.sh — install-specific environment variables
HIVE_VIPERBLOCK_PLUGIN_PATH=${PLUGINDIR}/nbdkit-viperblock-plugin.so
SPINIFEX_VIPERBLOCK_PLUGIN_PATH=${PLUGINDIR}/nbdkit-viperblock-plugin.so
EOF
$SUDO chown "$HIVE_USER:$HIVE_GROUP" /etc/hive/systemd.env
info "Generated /etc/hive/systemd.env"
$SUDO chown "$SPINIFEX_USER:$SPINIFEX_GROUP" /etc/spinifex/systemd.env
info "Generated /etc/spinifex/systemd.env"
}
# --- Install systemd units ---
@@ -284,20 +284,20 @@ install_systemd() {
for unit in "$EXTRACT_DIR"/systemd/*; do
# Substitute User= and Group= with the detected service user
sed "s/^User=hive$/User=$HIVE_USER/;s/^Group=hive$/Group=$HIVE_GROUP/" \
sed "s/^User=hive$/User=$SPINIFEX_USER/;s/^Group=hive$/Group=$SPINIFEX_GROUP/" \
"$unit" | $SUDO tee "/etc/systemd/system/$(basename "$unit")" > /dev/null
$SUDO chmod 0644 "/etc/systemd/system/$(basename "$unit")"
info " /etc/systemd/system/$(basename "$unit")"
done
$SUDO systemctl daemon-reload
info "Systemd units installed (running as $HIVE_USER:$HIVE_GROUP)"
info "Systemd units installed (running as $SPINIFEX_USER:$SPINIFEX_GROUP)"
}
# --- Install logrotate ---
install_logrotate() {
if [ -f "$EXTRACT_DIR/logrotate-hive" ]; then
$SUDO install -m 0644 "$EXTRACT_DIR/logrotate-hive" /etc/logrotate.d/hive
if [ -f "$EXTRACT_DIR/logrotate-spinifex" ]; then
$SUDO install -m 0644 "$EXTRACT_DIR/logrotate-spinifex" /etc/logrotate.d/hive
else
warn "Logrotate config not found in tarball, skipping"
return
@@ -307,61 +307,61 @@ install_logrotate() {
# --- Upgrade handling ---
handle_upgrade() {
if $SUDO systemctl is-active --quiet hive.target 2>/dev/null; then
warn "Hive services are running. Stopping for upgrade..."
$SUDO systemctl stop hive.target
if $SUDO systemctl is-active --quiet spinifex.target 2>/dev/null; then
warn "Spinifex services are running. Stopping for upgrade..."
$SUDO systemctl stop spinifex.target
RESTART_AFTER=true
fi
}
restart_if_needed() {
if [ "${RESTART_AFTER}" = "true" ]; then
info "Restarting Hive services..."
$SUDO systemctl start hive.target
info "Restarting Spinifex services..."
$SUDO systemctl start spinifex.target
fi
}
# --- Print summary ---
print_summary() {
INSTALLED_VERSION=$(/usr/local/bin/hive version 2>/dev/null || echo "unknown")
INSTALLED_VERSION=$(/usr/local/bin/spx version 2>/dev/null || echo "unknown")
echo ""
echo "============================================"
echo " Hive installed successfully"
echo " Spinifex installed successfully"
echo "============================================"
echo ""
echo " Version: $INSTALLED_VERSION"
echo " Architecture: $ARCH"
echo " Service user: $HIVE_USER"
echo " Binary: /usr/local/bin/hive"
echo " Config: /etc/hive/"
echo " Data: /var/lib/hive/"
echo " Logs: /var/log/hive/"
echo " Service user: $SPINIFEX_USER"
echo " Binary: /usr/local/bin/spx"
echo " Config: /etc/spinifex/"
echo " Data: /var/lib/spinifex/"
echo " Logs: /var/log/spinifex/"
echo ""
echo " Next steps:"
echo ""
echo " 1. Setup OVN networking:"
echo " sudo /usr/local/share/hive/setup-ovn.sh --management"
echo " sudo /usr/local/share/spinifex/setup-ovn.sh --management"
echo ""
echo " 2. Initialize a region:"
echo " sudo hive admin init --region <region> --az <az> --node node1 --nodes 1"
echo " sudo spx admin init --region <region> --az <az> --node node1 --nodes 1"
echo ""
echo " 3. Trust the CA certificate:"
echo " sudo cp /etc/hive/ca.pem /usr/local/share/ca-certificates/hive-ca.crt"
echo " sudo cp /etc/spinifex/ca.pem /usr/local/share/ca-certificates/hive-ca.crt"
echo " sudo update-ca-certificates"
echo ""
echo " 4. Start services:"
echo " sudo systemctl start hive.target"
echo " sudo systemctl start spinifex.target"
echo ""
echo " 5. Verify:"
echo " export AWS_PROFILE=hive"
echo " export AWS_PROFILE=spinifex"
echo " aws ec2 describe-instance-types"
echo ""
}
# --- Main ---
main() {
info "Hive installer"
info "Spinifex installer"
echo ""
setup_sudo
@@ -371,12 +371,12 @@ main() {
install_apt_deps
install_aws_cli
detect_service_user
download_hive
download_spinifex
install_files
create_directories
install_systemd
install_logrotate
rm -rf "$HIVE_TMPDIR"
rm -rf "$SPINIFEX_TMPDIR"
restart_if_needed
print_summary
}
+73 -73
View File
@@ -1,13 +1,13 @@
#!/bin/bash
# Start Hive development environment
# This script starts all required services in the correct order using Hive service commands
# Start Spinifex development environment
# This script starts all required services in the correct order using Spinifex service commands
# Usage: ./scripts/start-dev.sh [--build] [data-dir]
# --build: Rebuild all binaries before starting (default: skip build)
# data-dir: Optional data directory path (default: ~/hive)
# data-dir: Optional data directory path (default: ~/spinifex)
#
# Environment variables:
# UI=false Skip starting Hive UI (e.g., UI=false ./scripts/start-dev.sh)
# UI=false Skip starting Spinifex UI (e.g., UI=false ./scripts/start-dev.sh)
set -e
@@ -17,7 +17,7 @@ MULGA_ROOT="$(cd "$PROJECT_ROOT/.." && pwd)"
# Parse arguments
BUILD=false
DATA_DIR="$HOME/hive"
DATA_DIR="$HOME/spinifex"
for arg in "$@"; do
case "$arg" in
--build) BUILD=true ;;
@@ -31,15 +31,15 @@ CONFIG_DIR="${CONFIG_DIR:-$DATA_DIR/config}"
echo "Using data directory: $DATA_DIR"
echo "Using configuration directory: $CONFIG_DIR"
LOGS_DIR="$DATA_DIR/logs"
WAL_DIR="$DATA_DIR/hive"
WAL_DIR="$DATA_DIR/spinifex"
echo "🚀 Starting Hive development environment..."
echo "🚀 Starting Spinifex development environment..."
echo "Project root: $PROJECT_ROOT"
echo "Data directory: $DATA_DIR"
# Parse services from hive.toml — defaults to all if not set
# Parse services from spinifex.toml — defaults to all if not set
parse_services() {
local config_file="$CONFIG_DIR/hive.toml"
local config_file="$CONFIG_DIR/spinifex.toml"
if [ -f "$config_file" ]; then
local svc_line=$(grep -m1 '^services' "$config_file" | sed 's/.*\[//;s/\].*//;s/"//g;s/,/ /g')
if [ -n "$svc_line" ]; then
@@ -59,7 +59,7 @@ echo "Services: $SERVICES"
# Detect multi-node cluster from config
is_multinode() {
local config_file="$CONFIG_DIR/hive.toml"
local config_file="$CONFIG_DIR/spinifex.toml"
if [ -f "$config_file" ]; then
local node_count=$(grep -c '^\[nodes\.' "$config_file")
[ "$node_count" -gt 1 ]
@@ -71,8 +71,8 @@ is_multinode() {
# Confirm configuration directory exists
if [ ! -d "$CONFIG_DIR" ]; then
echo "⚠️ Configuration directory $CONFIG_DIR does not exist."
echo "Please init the hive environment using the CLI."
echo "hive admin init"
echo "Please init the spinifex environment using the CLI."
echo "spx admin init"
exit 1
fi
@@ -177,7 +177,7 @@ check_service() {
if [ "$BUILD" = "true" ]; then
echo "✈️ Pre-flight, compiling latest..."
echo " Building hive..."
echo " Building spinifex..."
make build
echo " Building predastore..."
@@ -231,14 +231,14 @@ if has_service "nats"; then
echo "1️⃣ Starting NATS server..."
if [ -f "$CONFIG_DIR/nats/nats.conf" ]; then
export HIVE_CONFIG_PATH=$CONFIG_DIR/nats/nats.conf
export SPINIFEX_CONFIG_PATH=$CONFIG_DIR/nats/nats.conf
echo " Using NATS config file: $CONFIG_DIR/nats/nats.conf"
else
echo " ⚠️ NATS config file not found at $CONFIG_DIR/nats/nats.conf, using defaults"
export HIVE_NATS_HOST=0.0.0.0
export HIVE_NATS_PORT=4222
export HIVE_NATS_DATA_DIR=$DATA_DIR/nats/
export HIVE_NATS_JETSTREAM=false
export SPINIFEX_NATS_HOST=0.0.0.0
export SPINIFEX_NATS_PORT=4222
export SPINIFEX_NATS_DATA_DIR=$DATA_DIR/nats/
export SPINIFEX_NATS_JETSTREAM=false
fi
# Extract NATS listen address from config (multi-node binds to specific IP, not 127.0.0.1)
@@ -250,14 +250,14 @@ if has_service "nats"; then
fi
fi
NATS_CMD="./bin/hive service nats start"
NATS_CMD="./bin/spx service nats start"
start_service "nats" "$NATS_CMD"
set_oom_score "nats" "-500"
check_service "NATS" "$NATS_CHECK_HOST" "4222"
# Wait for NATS JetStream to be ready before Predastore starts.
# Predastore lazily opens IAM KV buckets — it starts with config-only auth
# and activates IAM auth once the hive daemon creates the KV buckets.
# and activates IAM auth once the spinifex daemon creates the KV buckets.
echo "🔍 Waiting for NATS JetStream..."
NATS_JS_READY=false
for i in $(seq 1 15); do
@@ -280,43 +280,43 @@ fi
echo ""
if has_service "predastore"; then
echo "2️⃣ Starting Predastore..."
unset HIVE_CONFIG_PATH
unset SPINIFEX_CONFIG_PATH
export HIVE_PREDASTORE_BASE_PATH=$DATA_DIR/predastore/
export HIVE_PREDASTORE_CONFIG_PATH=$CONFIG_DIR/predastore/predastore.toml
export HIVE_PREDASTORE_TLS_CERT=$CONFIG_DIR/server.pem
export HIVE_PREDASTORE_TLS_KEY=$CONFIG_DIR/server.key
export SPINIFEX_PREDASTORE_BASE_PATH=$DATA_DIR/predastore/
export SPINIFEX_PREDASTORE_CONFIG_PATH=$CONFIG_DIR/predastore/predastore.toml
export SPINIFEX_PREDASTORE_TLS_CERT=$CONFIG_DIR/server.pem
export SPINIFEX_PREDASTORE_TLS_KEY=$CONFIG_DIR/server.key
# Auto-detect Predastore host:port from hive.toml [nodes.<name>.predastore] section
# Auto-detect Predastore host:port from spinifex.toml [nodes.<name>.predastore] section
PREDASTORE_BIND="0.0.0.0:8443"
if [ -f "$CONFIG_DIR/hive.toml" ]; then
DETECTED_PREDASTORE_HOST=$(awk -F'"' '/\[nodes\..*\.predastore\]/{found=1} found && /^host/{print $2; exit}' "$CONFIG_DIR/hive.toml")
if [ -f "$CONFIG_DIR/spinifex.toml" ]; then
DETECTED_PREDASTORE_HOST=$(awk -F'"' '/\[nodes\..*\.predastore\]/{found=1} found && /^host/{print $2; exit}' "$CONFIG_DIR/spinifex.toml")
if [ -n "$DETECTED_PREDASTORE_HOST" ]; then
PREDASTORE_BIND="$DETECTED_PREDASTORE_HOST"
echo " Auto-detected Predastore bind=$PREDASTORE_BIND from hive.toml"
echo " Auto-detected Predastore bind=$PREDASTORE_BIND from spinifex.toml"
fi
fi
export HIVE_PREDASTORE_HOST="${PREDASTORE_BIND%%:*}"
export HIVE_PREDASTORE_PORT="${PREDASTORE_BIND##*:}"
export SPINIFEX_PREDASTORE_HOST="${PREDASTORE_BIND%%:*}"
export SPINIFEX_PREDASTORE_PORT="${PREDASTORE_BIND##*:}"
export HIVE_PREDASTORE_BACKEND=distributed
export SPINIFEX_PREDASTORE_BACKEND=distributed
# Auto-detect Predastore NODE_ID from hive.toml if not already set
if [ -z "$HIVE_PREDASTORE_NODE_ID" ]; then
if [ -f "$CONFIG_DIR/hive.toml" ]; then
DETECTED_NODE_ID=$(awk -F'= *' '/node_id/{gsub(/ /,"",$2); print $2; exit}' "$CONFIG_DIR/hive.toml")
# Auto-detect Predastore NODE_ID from spinifex.toml if not already set
if [ -z "$SPINIFEX_PREDASTORE_NODE_ID" ]; then
if [ -f "$CONFIG_DIR/spinifex.toml" ]; then
DETECTED_NODE_ID=$(awk -F'= *' '/node_id/{gsub(/ /,"",$2); print $2; exit}' "$CONFIG_DIR/spinifex.toml")
if [ -n "$DETECTED_NODE_ID" ] && [ "$DETECTED_NODE_ID" != "0" ]; then
export HIVE_PREDASTORE_NODE_ID="$DETECTED_NODE_ID"
echo " Auto-detected Predastore NODE_ID=$DETECTED_NODE_ID from hive.toml"
export SPINIFEX_PREDASTORE_NODE_ID="$DETECTED_NODE_ID"
echo " Auto-detected Predastore NODE_ID=$DETECTED_NODE_ID from spinifex.toml"
fi
fi
fi
export HIVE_PREDASTORE_NODE_ID="${HIVE_PREDASTORE_NODE_ID:-}"
export SPINIFEX_PREDASTORE_NODE_ID="${SPINIFEX_PREDASTORE_NODE_ID:-}"
PREDASTORE_CMD="./bin/hive service predastore start"
PREDASTORE_CMD="./bin/spx service predastore start"
start_service "predastore" "$PREDASTORE_CMD"
set_oom_score "predastore" "-500"
check_service "Predastore" "$HIVE_PREDASTORE_HOST" "$HIVE_PREDASTORE_PORT"
check_service "Predastore" "$SPINIFEX_PREDASTORE_HOST" "$SPINIFEX_PREDASTORE_PORT"
else
echo "2️⃣ Skipping Predastore (not a local service)"
fi
@@ -344,31 +344,31 @@ if has_service "viperblock"; then
cd "$PROJECT_ROOT"
fi
export HIVE_CONFIG_PATH=$CONFIG_DIR/hive.toml
export HIVE_VIPERBLOCK_PLUGIN_PATH=$NBD_PLUGIN_PATH
export HIVE_BASE_DIR=$VB_BASE_DIR
export SPINIFEX_CONFIG_PATH=$CONFIG_DIR/spinifex.toml
export SPINIFEX_VIPERBLOCK_PLUGIN_PATH=$NBD_PLUGIN_PATH
export SPINIFEX_BASE_DIR=$VB_BASE_DIR
VIPERBLOCK_CMD="./bin/hive service viperblock start"
VIPERBLOCK_CMD="./bin/spx service viperblock start"
start_service "viperblock" "$VIPERBLOCK_CMD"
set_oom_score "viperblock" "-500"
else
echo "3️⃣ Skipping Viperblock (not a local service)"
fi
# 4️⃣ Start Hive Gateway/Daemon
# 4️⃣ Start Spinifex Gateway/Daemon
echo ""
if has_service "daemon"; then
echo "4️⃣. Starting Hive Gateway..."
echo "4️⃣. Starting Spinifex Gateway..."
export HIVE_CONFIG_PATH=$CONFIG_DIR/hive.toml
export HIVE_BASE_DIR=$DATA_DIR/hive/
export HIVE_WAL_DIR=$WAL_DIR
export SPINIFEX_CONFIG_PATH=$CONFIG_DIR/spinifex.toml
export SPINIFEX_BASE_DIR=$DATA_DIR/spinifex/
export SPINIFEX_WAL_DIR=$WAL_DIR
HIVE_CMD="./bin/hive service hive start"
start_service "hive" "$HIVE_CMD"
set_oom_score "hive" "-500"
SPINIFEX_CMD="./bin/spx service hive start"
start_service "spinifex" "$SPINIFEX_CMD"
set_oom_score "spinifex" "-500"
else
echo "4️⃣. Skipping Hive Gateway (not a local service)"
echo "4️⃣. Skipping Spinifex Gateway (not a local service)"
fi
@@ -377,14 +377,14 @@ echo ""
if has_service "awsgw"; then
echo "5️⃣. Starting AWS Gateway..."
unset HIVE_NATS_HOST
unset HIVE_PREDASTORE_HOST
export HIVE_BASE_DIR=$DATA_DIR
export HIVE_CONFIG_PATH=$CONFIG_DIR/hive.toml
export HIVE_AWSGW_TLS_CERT=$CONFIG_DIR/server.pem
export HIVE_AWSGW_TLS_KEY=$CONFIG_DIR/server.key
unset SPINIFEX_NATS_HOST
unset SPINIFEX_PREDASTORE_HOST
export SPINIFEX_BASE_DIR=$DATA_DIR
export SPINIFEX_CONFIG_PATH=$CONFIG_DIR/spinifex.toml
export SPINIFEX_AWSGW_TLS_CERT=$CONFIG_DIR/server.pem
export SPINIFEX_AWSGW_TLS_KEY=$CONFIG_DIR/server.key
AWSGW_CMD="./bin/hive service awsgw start"
AWSGW_CMD="./bin/spx service awsgw start"
start_service "awsgw" "$AWSGW_CMD"
set_oom_score "awsgw" "-500"
else
@@ -397,33 +397,33 @@ echo ""
if has_service "vpcd"; then
echo "6️⃣. Starting vpcd (VPC daemon)..."
export HIVE_CONFIG_PATH=$CONFIG_DIR/hive.toml
export SPINIFEX_CONFIG_PATH=$CONFIG_DIR/spinifex.toml
VPCD_CMD="./bin/hive service vpcd start"
VPCD_CMD="./bin/spx service vpcd start"
start_service "vpcd" "$VPCD_CMD"
set_oom_score "vpcd" "-500"
else
echo "6️⃣. Skipping vpcd (not a local service)"
fi
# 7️⃣ Start Hive UI (skip with UI=false or if not a local service)
# 7️⃣ Start Spinifex UI (skip with UI=false or if not a local service)
if [ "${UI}" != "false" ] && has_service "ui"; then
echo ""
echo "7️⃣. Starting Hive UI..."
echo "7️⃣. Starting Spinifex UI..."
HIVEUI_CMD="./bin/hive service hive-ui start"
start_service "hive-ui" "$HIVEUI_CMD"
set_oom_score "hive-ui" "-500"
HIVEUI_CMD="./bin/spx service spinifex-ui start"
start_service "spinifex-ui" "$HIVEUI_CMD"
set_oom_score "spinifex-ui" "-500"
else
echo ""
echo "7️⃣. Skipping Hive UI"
echo "7️⃣. Skipping Spinifex UI"
fi
echo ""
echo "🔗 Service endpoints will be:"
if [ "${UI}" != "false" ]; then
echo " - Hive UI: https://localhost:3000"
echo " - Spinifex UI: https://localhost:3000"
fi
echo " - NATS: nats://localhost:4222"
echo " - Predastore: https://localhost:8443"
@@ -433,7 +433,7 @@ echo "📊 Monitor background service logs:"
echo " tail -f $LOGS_DIR/*.log"
echo ""
echo "🧪 Test with AWS CLI (once daemon is running):"
echo " export AWS_PROFILE=hive"
echo " export AWS_PROFILE=spinifex"
echo " aws ec2 describe-instances"
echo ""
@@ -445,7 +445,7 @@ if is_multinode; then
/^\[nodes\./ { node=1; daemon=0 }
node && /^\[.*\.daemon\]/ { daemon=1 }
daemon && /^host/ { gsub(/[" ]/, "", $3); print $3; daemon=0 }
' "$CONFIG_DIR/hive.toml")
' "$CONFIG_DIR/spinifex.toml")
for peer in $peer_hosts; do
attempts=0
@@ -469,4 +469,4 @@ fi
# This will only be reached if air/daemon exits normally
#echo ""
#echo "🛑 Hive development environment stopped"
#echo "🛑 Spinifex development environment stopped"
+1 -1
View File
@@ -1,3 +1,3 @@
#!/bin/sh
HIVE_CONFIG_PATH=~/node1/config/nats/nats.conf ./bin/hive service nats start
SPINIFEX_CONFIG_PATH=~/node1/config/nats/nats.conf ./bin/spx service nats start
+22 -22
View File
@@ -1,12 +1,12 @@
#!/bin/bash
# Stop Hive development environment
# Stop Spinifex development environment
# This script stops all services started by start-dev.sh
# Usage: ./scripts/stop-dev.sh
# Note: Services are stopped using PID files, so data-dir is not required
# Accept optional data directory argument
DATA_DIR="${1:-$HOME/hive}"
DATA_DIR="${1:-$HOME/spinifex}"
# Always use the logs directory for PID files — start-dev.sh writes shell PIDs
# there, and Go services write PIDs to their own data dirs. This ensures
@@ -20,16 +20,16 @@ LOGS_DIR="$PROJECT_ROOT/data/logs"
# Check if /mnt/ramdisk is mounted
#if mountpoint -q /mnt/ramdisk; then
#echo "🛑 Stopping Hive development environment..."
#echo "🛑 Stopping Spinifex development environment..."
#sudo umount /mnt/ramdisk
#fi
echo "Stopping Hive development environment..."
echo "Stopping Spinifex development environment..."
# Parse services from hive.toml — defaults to all if not set
# Parse services from spinifex.toml — defaults to all if not set
CONFIG_DIR="${CONFIG_DIR:-$DATA_DIR/config}"
parse_services() {
local config_file="$CONFIG_DIR/hive.toml"
local config_file="$CONFIG_DIR/spinifex.toml"
if [ -f "$config_file" ]; then
local svc_line=$(grep -m1 '^services' "$config_file" | sed 's/.*\[//;s/\].*//;s/"//g;s/,/ /g')
if [ -n "$svc_line" ]; then
@@ -44,15 +44,15 @@ SERVICES=$(parse_services)
has_service() {
local svc="$1"
case "$svc" in
hive) svc="daemon" ;;
hive-ui) svc="ui" ;;
spinifex) svc="daemon" ;;
spinifex-ui) svc="ui" ;;
esac
echo "$SERVICES" | grep -qw "$svc"
}
# Detect multi-node cluster from config
is_multinode() {
local config_file="$CONFIG_DIR/hive.toml"
local config_file="$CONFIG_DIR/spinifex.toml"
if [ -f "$config_file" ]; then
# Count only top-level node sections [nodes.X], not subsections [nodes.X.Y]
local node_count=$(grep -cE '^\[nodes\.[^.]+\]' "$config_file")
@@ -65,10 +65,10 @@ is_multinode() {
# For multi-node clusters, delegate to coordinated shutdown via NATS.
# Only when called without arguments (default path). When a data-dir is
# explicitly provided (e.g., E2E per-node cleanup), use per-service stop.
if is_multinode && [ -z "$HIVE_FORCE_LOCAL_STOP" ] && [ -z "$1" ]; then
if is_multinode && [ -z "$SPINIFEX_FORCE_LOCAL_STOP" ] && [ -z "$1" ]; then
echo "Multi-node cluster detected. Using coordinated shutdown..."
echo " (Set HIVE_FORCE_LOCAL_STOP=1 to force per-service stop)"
exec $PROJECT_ROOT/bin/hive admin cluster shutdown
echo " (Set SPINIFEX_FORCE_LOCAL_STOP=1 to force per-service stop)"
exec $PROJECT_ROOT/bin/spx admin cluster shutdown
fi
# Function to stop service by PID file
@@ -84,8 +84,8 @@ stop_service() {
kill -SIGTERM $(cat "$pidpath/$name.pid" 2>/dev/null) 2>/dev/null || rc=$?
sleep 1
else
# Correct graceful shutdown via hive binary, waits for clean exit
$PROJECT_ROOT/bin/hive service $name stop || rc=$?
# Correct graceful shutdown via spx binary, waits for clean exit
$PROJECT_ROOT/bin/spx service $name stop || rc=$?
fi
if [[ $rc -ne 0 ]]; then
@@ -101,11 +101,11 @@ stop_service() {
# Stop services in reverse order
echo "Stopping services..."
echo ""
# Stop Hive UI first (last to start)
has_service "hive-ui" && stop_service "hive-ui" "$PID_DIR"
# Stop Spinifex UI first (last to start)
has_service "spinifex-ui" && stop_service "spinifex-ui" "$PID_DIR"
# Stop Hive daemon/gateway (it will terminate running instances, unmount nbd devices)
has_service "hive" && stop_service "hive" "$PID_DIR"
# Stop Spinifex daemon/gateway (it will terminate running instances, unmount nbd devices)
has_service "spinifex" && stop_service "spinifex" "$PID_DIR"
# Wait for all QEMU instances to exit before stopping infrastructure services.
# The daemon sends system_powerdown to VMs during shutdown, but may be killed
@@ -143,7 +143,7 @@ has_service "predastore" && stop_service "predastore" "$PID_DIR"
# Stop NATS
has_service "nats" && stop_service "nats" "$PID_DIR"
# Stop OVN networking (prevents idle CPU burn when hive isn't running)
# Stop OVN networking (prevents idle CPU burn when spinifex isn't running)
if pidof systemd >/dev/null 2>&1; then
echo "🛑 Stopping OVN networking..."
sudo systemctl stop ovn-controller 2>/dev/null && echo "✅ ovn-controller stopped" || true
@@ -154,10 +154,10 @@ if pidof systemd >/dev/null 2>&1; then
fi
echo ""
echo "✅ Hive development environment stopped"
echo "✅ Spinifex development environment stopped"
# Show any remaining hive-related processes
remaining=$(pgrep -af '(bin/hive|hive-ui|nats-server|predastore|viperblock|vpcd|qemu-system)' | grep -v "stop-dev.sh" || true)
# Show any remaining spinifex-related processes
remaining=$(pgrep -af '(bin/spx|spinifex-ui|nats-server|predastore|viperblock|vpcd|qemu-system)' | grep -v "stop-dev.sh" || true)
if [[ -n "$remaining" ]]; then
echo ""
echo "⚠️ Some related processes may still be running:"
+7 -7
View File
@@ -348,7 +348,7 @@ get_instance_node() {
for i in 1 2 3; do
local data_dir="$HOME/node$i"
local instances_file="$data_dir/hive/instances.json"
local instances_file="$data_dir/spinifex/instances.json"
if [ -f "$instances_file" ]; then
if jq -e ".[\"$instance_id\"]" "$instances_file" > /dev/null 2>&1; then
@@ -506,7 +506,7 @@ dump_all_node_logs() {
echo ""
echo "=== Node$i Logs ==="
for log in nats predastore viperblock hive awsgw; do
for log in nats predastore viperblock spinifex awsgw; do
if [ -f "$logs_dir/$log.log" ]; then
echo ""
echo "--- $log.log (last 50 lines) ---"
@@ -631,7 +631,7 @@ force_cleanup_all_nodes() {
local logs_dir="$data_dir/logs"
if [ -d "$logs_dir" ]; then
for svc in hive-ui hive awsgw viperblock predastore nats; do
for svc in spinifex-ui spinifex awsgw viperblock predastore nats; do
local pidfile="$logs_dir/$svc.pid"
if [ -f "$pidfile" ]; then
local pid
@@ -654,7 +654,7 @@ force_cleanup_all_nodes() {
local logs_dir="$data_dir/logs"
if [ -d "$logs_dir" ]; then
for svc in hive-ui hive awsgw viperblock predastore nats; do
for svc in spinifex-ui spinifex awsgw viperblock predastore nats; do
local pidfile="$logs_dir/$svc.pid"
if [ -f "$pidfile" ]; then
local pid
@@ -722,7 +722,7 @@ init_leader_node() {
rm -rf "$HOME/node1/"
# Start init in background — formation server will wait for joins
./bin/hive admin init \
./bin/spinifex admin init \
--node node1 \
--bind "${NODE1_IP}" \
--cluster-bind "${NODE1_IP}" \
@@ -731,7 +731,7 @@ init_leader_node() {
--port ${CLUSTER_PORT} \
--region ap-southeast-2 \
--az ap-southeast-2a \
--hive-dir "$HOME/node1/" \
--spinifex-dir "$HOME/node1/" \
--config-dir "$HOME/node1/config/" &
LEADER_INIT_PID=$!
@@ -762,7 +762,7 @@ join_follower_node() {
rm -rf "$data_dir/"
# Route to node1 (seed node) - other nodes discovered via NATS gossip
./bin/hive admin join \
./bin/spinifex admin join \
--node "node$node_num" \
--bind "$node_ip" \
--cluster-bind "$node_ip" \
+52 -52
View File
@@ -16,28 +16,28 @@ cleanup() {
if [ $EXIT_CODE -ne 0 ]; then
echo ""
echo "=== NATS Service Log ==="
if [ -f ~/hive/logs/nats.log ]; then
tail -100 ~/hive/logs/nats.log 2>/dev/null
if [ -f ~/spinifex/logs/nats.log ]; then
tail -100 ~/spinifex/logs/nats.log 2>/dev/null
fi
echo ""
echo "=== Predastore Service Log ==="
if [ -f ~/hive/logs/predastore.log ]; then
tail -100 ~/hive/logs/predastore.log 2>/dev/null
if [ -f ~/spinifex/logs/predastore.log ]; then
tail -100 ~/spinifex/logs/predastore.log 2>/dev/null
fi
echo ""
echo "=== Viperblock Service Log ==="
if [ -f ~/hive/logs/viperblock.log ]; then
tail -100 ~/hive/logs/viperblock.log 2>/dev/null
if [ -f ~/spinifex/logs/viperblock.log ]; then
tail -100 ~/spinifex/logs/viperblock.log 2>/dev/null
fi
echo ""
echo "=== Hive Daemon Log ==="
if [ -f ~/hive/logs/hive.log ]; then
tail -200 ~/hive/logs/hive.log 2>/dev/null
echo "=== Spinifex Daemon Log ==="
if [ -f ~/spinifex/logs/hive.log ]; then
tail -200 ~/spinifex/logs/hive.log 2>/dev/null
fi
echo ""
echo "=== AWS Gateway Log ==="
if [ -f ~/hive/logs/awsgw.log ]; then
tail -200 ~/hive/logs/awsgw.log 2>/dev/null
if [ -f ~/spinifex/logs/awsgw.log ]; then
tail -200 ~/spinifex/logs/awsgw.log 2>/dev/null
fi
fi
# Only stop services if we started them (not when bootstrapped)
@@ -48,15 +48,15 @@ cleanup() {
}
trap cleanup EXIT
# Use Hive profile (hive admin init sets endpoint_url, ca_bundle, region in ~/.aws/config)
export AWS_PROFILE=hive
# Use Spinifex profile (spx admin init sets endpoint_url, ca_bundle, region in ~/.aws/config)
export AWS_PROFILE=spinifex
# Detect bootstrapped environment from hive.toml config
# Detect bootstrapped environment from spinifex.toml config
BOOTSTRAPPED="false"
GATEWAY_HOST="localhost"
PREDASTORE_HOST="localhost"
if [ -f ~/hive/config/hive.toml ]; then
# Resolve gateway host from AWS profile endpoint_url (set by hive admin init)
if [ -f ~/spinifex/config/spinifex.toml ]; then
# Resolve gateway host from AWS profile endpoint_url (set by spx admin init)
ENDPOINT_URL=$(aws configure get endpoint_url 2>/dev/null || true)
if [ -n "$ENDPOINT_URL" ]; then
DETECTED_GW_HOST=$(echo "$ENDPOINT_URL" | sed 's|https\?://||;s|:.*||')
@@ -64,8 +64,8 @@ if [ -f ~/hive/config/hive.toml ]; then
GATEWAY_HOST="$DETECTED_GW_HOST"
fi
fi
# Resolve predastore host from hive.toml
DETECTED_PS_HOST=$(awk -F'"' '/\[nodes\..*\.predastore\]/{found=1} found && /^host/{print $2; exit}' ~/hive/config/hive.toml)
# Resolve predastore host from spinifex.toml
DETECTED_PS_HOST=$(awk -F'"' '/\[nodes\..*\.predastore\]/{found=1} found && /^host/{print $2; exit}' ~/spinifex/config/spinifex.toml)
if [ -n "$DETECTED_PS_HOST" ]; then
PREDASTORE_HOST="${DETECTED_PS_HOST%%:*}"
fi
@@ -78,7 +78,7 @@ if [ -f ~/hive/config/hive.toml ]; then
fi
fi
# Helper: set up an AWS CLI profile with credentials + endpoint/CA config from the hive profile
# Helper: set up an AWS CLI profile with credentials + endpoint/CA config from the spinifex profile
setup_test_profile() {
local profile="$1" key_id="$2" secret="$3"
aws configure set aws_access_key_id "$key_id" --profile "$profile"
@@ -107,16 +107,16 @@ else
fi
if [ "$BOOTSTRAPPED" != "true" ]; then
./bin/hive admin init --region ap-southeast-2 --az ap-southeast-2a --node node1 --nodes 1
./bin/spx admin init --region ap-southeast-2 --az ap-southeast-2a --node node1 --nodes 1
# Trust the Hive CA certificate for AWS CLI SSL verification
echo "Adding Hive CA certificate to system trust store..."
sudo cp ~/hive/config/ca.pem /usr/local/share/ca-certificates/hive-ca.crt
# Trust the Spinifex CA certificate for AWS CLI SSL verification
echo "Adding Spinifex CA certificate to system trust store..."
sudo cp ~/spinifex/config/ca.pem /usr/local/share/ca-certificates/hive-ca.crt
sudo update-ca-certificates
# Start all services
# Ensure logs directory exists for start-dev.sh
mkdir -p ~/hive/logs
mkdir -p ~/spinifex/logs
./scripts/start-dev.sh
fi
@@ -140,28 +140,28 @@ fi
wait_for_daemon_ready "https://${GATEWAY_HOST}:9999"
# Discover the cluster's availability zone and region dynamically
HIVE_AZ=$(aws ec2 describe-availability-zones --query 'AvailabilityZones[0].ZoneName' --output text)
HIVE_REGION=$(aws ec2 describe-availability-zones --query 'AvailabilityZones[0].RegionName' --output text)
echo "Discovered AZ: $HIVE_AZ, Region: $HIVE_REGION"
SPINIFEX_AZ=$(aws ec2 describe-availability-zones --query 'AvailabilityZones[0].ZoneName' --output text)
SPINIFEX_REGION=$(aws ec2 describe-availability-zones --query 'AvailabilityZones[0].RegionName' --output text)
echo "Discovered AZ: $SPINIFEX_AZ, Region: $SPINIFEX_REGION"
# No need for AWS_EC2/AWS_IAM vars — endpoint_url and ca_bundle are in the profile config
# Phase 1b: Cluster Stats CLI
echo "Phase 1b: Cluster Stats CLI"
# Test hive get nodes — should show node1 as Ready
echo "Testing hive get nodes..."
GET_NODES_OUTPUT=$(./bin/hive get nodes --config ~/hive/config/hive.toml --timeout 5s 2>/dev/null)
# Test spx get nodes — should show node1 as Ready
echo "Testing spx get nodes..."
GET_NODES_OUTPUT=$(./bin/spx get nodes --config ~/spinifex/config/spinifex.toml --timeout 5s 2>/dev/null)
echo "$GET_NODES_OUTPUT"
if ! echo "$GET_NODES_OUTPUT" | grep -q "Ready"; then
echo "hive get nodes did not show any Ready nodes"
echo "spx get nodes did not show any Ready nodes"
exit 1
fi
echo "hive get nodes passed"
echo "spx get nodes passed"
# Test hive top nodes — should show CPU/MEM stats
echo "Testing hive top nodes..."
TOP_NODES_OUTPUT=$(./bin/hive top nodes --config ~/hive/config/hive.toml --timeout 5s 2>/dev/null)
TOP_NODES_OUTPUT=$(./bin/spx top nodes --config ~/spinifex/config/spinifex.toml --timeout 5s 2>/dev/null)
echo "$TOP_NODES_OUTPUT"
if ! echo "$TOP_NODES_OUTPUT" | grep -q "0/"; then
echo "hive top nodes did not show resource stats"
@@ -169,15 +169,15 @@ if ! echo "$TOP_NODES_OUTPUT" | grep -q "0/"; then
fi
echo "hive top nodes passed"
# Test hive get vms — should show no VMs yet
echo "Testing hive get vms (empty)..."
GET_VMS_OUTPUT=$(./bin/hive get vms --config ~/hive/config/hive.toml --timeout 5s 2>/dev/null)
# Test spx get vms — should show no VMs yet
echo "Testing spx get vms (empty)..."
GET_VMS_OUTPUT=$(./bin/spx get vms --config ~/spinifex/config/spinifex.toml --timeout 5s 2>/dev/null)
echo "$GET_VMS_OUTPUT"
if ! echo "$GET_VMS_OUTPUT" | grep -q "No VMs found"; then
echo "hive get vms should show 'No VMs found' before any launches"
echo "spx get vms should show 'No VMs found' before any launches"
exit 1
fi
echo "hive get vms (empty) passed"
echo "spx get vms (empty) passed"
# Phase 2: Discovery & Metadata
echo "Phase 2: Discovery & Metadata"
@@ -196,8 +196,8 @@ if [ "$AZ_STATE" != "available" ]; then
fi
echo "DescribeAvailabilityZones verified (Zone=$AZ_NAME, State=$AZ_STATE)"
# Discover available instance types from Hive
# Hive generates these based on the host CPU (e.g., m7i.micro, m8g.small, etc.)
# Discover available instance types from Spinifex
# Spinifex generates these based on the host CPU (e.g., m7i.micro, m8g.small, etc.)
echo "Discovering available instance types..."
AVAILABLE_TYPES=$(aws ec2 describe-instance-types --query 'InstanceTypes[*].InstanceType' --output text)
echo "Available instance types: $AVAILABLE_TYPES"
@@ -301,7 +301,7 @@ if [ "$BOOTSTRAPPED" = "true" ]; then
AMI_ID=$(aws ec2 describe-images --query 'Images[0].ImageId' --output text)
else
echo "Importing pre-cached Ubuntu image..."
IMPORT_LOG=$(./bin/hive admin images import \
IMPORT_LOG=$(./bin/spx admin images import \
--file ~/images/ubuntu-24.04.img \
--arch "$ARCH" \
--distro ubuntu \
@@ -384,15 +384,15 @@ if [ "$STATE" != "running" ]; then
exit 1
fi
# Phase 5a-pre: Verify hive get vms shows running instance
# Phase 5a-pre: Verify spx get vms shows running instance
echo "Phase 5a-pre: Cluster Stats CLI (with running VM)"
GET_VMS_OUTPUT=$(./bin/hive get vms --config ~/hive/config/hive.toml --timeout 5s 2>/dev/null)
GET_VMS_OUTPUT=$(./bin/spx get vms --config ~/spinifex/config/spinifex.toml --timeout 5s 2>/dev/null)
echo "$GET_VMS_OUTPUT"
if ! echo "$GET_VMS_OUTPUT" | grep -q "$INSTANCE_ID"; then
echo "hive get vms did not show running instance $INSTANCE_ID"
echo "spx get vms did not show running instance $INSTANCE_ID"
exit 1
fi
echo "hive get vms shows running instance"
echo "spx get vms shows running instance"
# Phase 5a: Validate instance metadata fields
echo "Phase 5a: Instance Metadata Validation"
@@ -518,8 +518,8 @@ echo "Phase 5b: Volume Lifecycle (Attach/Detach)"
echo "Testing volume create -> resize -> attach -> detach -> delete..."
# Create a test volume
echo "Creating 10GB volume in ${HIVE_AZ}..."
CREATE_OUTPUT=$(aws ec2 create-volume --size 10 --availability-zone "$HIVE_AZ")
echo "Creating 10GB volume in ${SPINIFEX_AZ}..."
CREATE_OUTPUT=$(aws ec2 create-volume --size 10 --availability-zone "$SPINIFEX_AZ")
TEST_VOLUME_ID=$(echo "$CREATE_OUTPUT" | jq -r '.VolumeId')
if [ -z "$TEST_VOLUME_ID" ] || [ "$TEST_VOLUME_ID" == "null" ]; then
@@ -735,7 +735,7 @@ echo "Describe snapshot verified (VolumeId=$DESC_VOL_ID, Size=$DESC_SIZE, Descri
# Copy the snapshot
echo "Copying snapshot $SNAPSHOT_ID..."
COPY_OUTPUT=$(aws ec2 copy-snapshot --source-snapshot-id "$SNAPSHOT_ID" --source-region "$HIVE_REGION" --description "e2e-copy")
COPY_OUTPUT=$(aws ec2 copy-snapshot --source-snapshot-id "$SNAPSHOT_ID" --source-region "$SPINIFEX_REGION" --description "e2e-copy")
COPY_SNAPSHOT_ID=$(echo "$COPY_OUTPUT" | jq -r '.SnapshotId')
if [ -z "$COPY_SNAPSHOT_ID" ] || [ "$COPY_SNAPSHOT_ID" == "null" ]; then
@@ -1014,7 +1014,7 @@ echo "Reboot-stopped correctly rejected"
# Phase 7a: Attach volume to stopped instance (should fail)
echo "Phase 7a: Attach Volume to Stopped Instance (Error Path)"
echo "Creating a volume to test attach-to-stopped..."
STOPPED_VOL_OUTPUT=$(aws ec2 create-volume --size 10 --availability-zone "$HIVE_AZ")
STOPPED_VOL_OUTPUT=$(aws ec2 create-volume --size 10 --availability-zone "$SPINIFEX_AZ")
STOPPED_VOL_ID=$(echo "$STOPPED_VOL_OUTPUT" | jq -r '.VolumeId')
echo "Created volume: $STOPPED_VOL_ID"
@@ -1867,7 +1867,7 @@ echo "Phase 8 Step 1: Account Setup"
echo "----------------------------------------"
echo " Creating Team Alpha account..."
ALPHA_OUTPUT=$(./bin/hive admin account create --name "Team Alpha" 2>&1)
ALPHA_OUTPUT=$(./bin/spx admin account create --name "Team Alpha" 2>&1)
echo "$ALPHA_OUTPUT"
ALPHA_ACCOUNT=$(echo "$ALPHA_OUTPUT" | grep "Account ID:" | awk '{print $NF}')
ALPHA_KEY_ID=$(echo "$ALPHA_OUTPUT" | grep "Access Key ID:" | awk '{print $NF}')
@@ -1881,7 +1881,7 @@ echo " Team Alpha: account=$ALPHA_ACCOUNT key=$ALPHA_KEY_ID"
setup_test_profile hive-team-alpha "$ALPHA_KEY_ID" "$ALPHA_SECRET"
echo " Creating Team Beta account..."
BETA_OUTPUT=$(./bin/hive admin account create --name "Team Beta" 2>&1)
BETA_OUTPUT=$(./bin/spx admin account create --name "Team Beta" 2>&1)
echo "$BETA_OUTPUT"
BETA_ACCOUNT=$(echo "$BETA_OUTPUT" | grep "Account ID:" | awk '{print $NF}')
BETA_KEY_ID=$(echo "$BETA_OUTPUT" | grep "Access Key ID:" | awk '{print $NF}')
@@ -2416,7 +2416,7 @@ echo "----------------------------------------"
# Empty account (Gamma)
echo " Creating empty Gamma account..."
GAMMA_OUTPUT=$(./bin/hive admin account create --name "Team Gamma" 2>&1)
GAMMA_OUTPUT=$(./bin/spx admin account create --name "Team Gamma" 2>&1)
GAMMA_KEY_ID=$(echo "$GAMMA_OUTPUT" | grep "Access Key ID:" | awk '{print $NF}')
GAMMA_SECRET=$(echo "$GAMMA_OUTPUT" | grep "Secret Access Key:" | awk '{print $NF}')
setup_test_profile hive-team-gamma "$GAMMA_KEY_ID" "$GAMMA_SECRET"
+40 -40
View File
@@ -3,7 +3,7 @@ set -euo pipefail
# Multi-Node E2E Test Suite (real 3-node cluster)
# Runs inside node1 of a 3-node cluster provisioned by tofu (env2).
# Bootstrap has already: built hive, set up OVN, run init/join, started services,
# Bootstrap has already: built spinifex, set up OVN, run init/join, started services,
# installed CA certs, imported SSH key + AMI, created VPC + subnet.
#
# Usage: run-multinode-e2e.sh <node1_ip> <node2_ip> <node3_ip>
@@ -11,7 +11,7 @@ set -euo pipefail
# Ensure Go is on PATH (SSH non-interactive shells don't source .bashrc)
export PATH="/usr/local/go/bin:$HOME/go/bin:$PATH"
# Ensure we are in the hive project root
# Ensure we are in the spinifex project root
cd "$(dirname "$0")/../.."
# ==========================================================================
@@ -36,14 +36,14 @@ NATS_MONITOR_PORT=8222
PREDASTORE_PORT=8443
AWSGW_PORT=9999
SSH_KEY_PATH="$HOME/.ssh/tf-user-ap-southeast-2"
HIVE_DATA_DIR="$HOME/hive"
HIVE_CONFIG="$HIVE_DATA_DIR/config/hive.toml"
HIVE_BIN="./bin/hive"
SPINIFEX_DATA_DIR="$HOME/spinifex"
SPINIFEX_CONFIG="$SPINIFEX_DATA_DIR/config/spinifex.toml"
SPINIFEX_BIN="./bin/spx"
# Use Hive profile for AWS CLI
export AWS_PROFILE=hive
# Trust Hive CA for AWS CLI v2 (bundles its own Python/certifi, ignores system CA store)
export AWS_CA_BUNDLE="$HIVE_DATA_DIR/config/ca.pem"
# Use Spinifex profile for AWS CLI
export AWS_PROFILE=spinifex
# Trust Spinifex CA for AWS CLI v2 (bundles its own Python/certifi, ignores system CA store)
export AWS_CA_BUNDLE="$SPINIFEX_DATA_DIR/config/ca.pem"
# Track test results
TESTS_PASSED=0
@@ -107,13 +107,13 @@ dump_all_node_logs() {
echo ""
echo "=== Node $((i+1)) ($ip) ==="
if [ "$ip" = "$LOCAL_IP" ]; then
for f in "$HIVE_DATA_DIR/logs/"*.log; do
for f in "$SPINIFEX_DATA_DIR/logs/"*.log; do
[ -f "$f" ] || continue
echo "--- $(basename "$f") (last 50 lines) ---"
tail -50 "$f" 2>/dev/null || echo "(not found)"
done
else
peer_ssh "$ip" 'for f in ~/hive/logs/*.log; do
peer_ssh "$ip" 'for f in ~/spinifex/logs/*.log; do
[ -f "$f" ] || continue
echo "--- $(basename "$f") (last 50 lines) ---"
tail -50 "$f" 2>/dev/null || echo "(not found)"
@@ -401,23 +401,23 @@ if [ -z "$TYPES" ] || [ "$TYPES" == "None" ]; then
fi
pass_test "Daemon readiness"
# Hive CLI: get nodes
echo "Checking hive get nodes..."
GET_NODES_OUTPUT=$($HIVE_BIN get nodes --config "$HIVE_CONFIG" --timeout 5s 2>/dev/null)
# Spinifex CLI: get nodes
echo "Checking spx get nodes..."
GET_NODES_OUTPUT=$($SPINIFEX_BIN get nodes --config "$SPINIFEX_CONFIG" --timeout 5s 2>/dev/null)
echo "$GET_NODES_OUTPUT"
READY_COUNT=$(echo "$GET_NODES_OUTPUT" | grep -c "Ready" || true)
if [ "$READY_COUNT" -ge 3 ]; then
pass_test "hive get nodes ($READY_COUNT Ready)"
pass_test "spx get nodes ($READY_COUNT Ready)"
else
echo " WARNING: hive get nodes shows $READY_COUNT Ready nodes (expected 3)"
fail_test "hive get nodes"
echo " WARNING: spx get nodes shows $READY_COUNT Ready nodes (expected 3)"
fail_test "spx get nodes"
fi
# Hive CLI: get vms (should be empty)
echo "Checking hive get vms (empty)..."
GET_VMS_OUTPUT=$($HIVE_BIN get vms --config "$HIVE_CONFIG" --timeout 5s 2>/dev/null)
# Spinifex CLI: get vms (should be empty)
echo "Checking spx get vms (empty)..."
GET_VMS_OUTPUT=$($SPINIFEX_BIN get vms --config "$SPINIFEX_CONFIG" --timeout 5s 2>/dev/null)
echo "$GET_VMS_OUTPUT"
pass_test "hive get vms (empty)"
pass_test "spx get vms (empty)"
echo ""
@@ -450,7 +450,7 @@ for i in 1 2 3; do
RUN_OUTPUT=$($AWS_EC2 run-instances \
--image-id "$AMI_ID" \
--instance-type "$INSTANCE_TYPE" \
--key-name hive-key)
--key-name spinifex-key)
INSTANCE_ID=$(echo "$RUN_OUTPUT" | jq -r '.Instances[0].InstanceId')
if [ -z "$INSTANCE_ID" ] || [ "$INSTANCE_ID" == "null" ]; then
@@ -475,7 +475,7 @@ for instance_id in "${INSTANCE_IDS[@]}"; do
}
done
# Check distribution via hive get vms or QEMU process check
# Check distribution via spx get vms or QEMU process check
echo ""
echo "Checking instance distribution across nodes..."
declare -A NODE_INSTANCE_COUNT
@@ -497,17 +497,17 @@ else
pass_test "Instance distribution (non-deterministic)"
fi
# Verify hive get vms shows all instances
# Verify spx get vms shows all instances
echo ""
echo "Verifying hive get vms..."
GET_VMS_OUTPUT=$($HIVE_BIN get vms --config "$HIVE_CONFIG" --timeout 5s 2>/dev/null)
echo "Verifying spx get vms..."
GET_VMS_OUTPUT=$($SPINIFEX_BIN get vms --config "$SPINIFEX_CONFIG" --timeout 5s 2>/dev/null)
echo "$GET_VMS_OUTPUT"
for instance_id in "${INSTANCE_IDS[@]}"; do
if ! echo "$GET_VMS_OUTPUT" | grep -q "$instance_id"; then
echo " WARNING: hive get vms did not show $instance_id"
echo " WARNING: spx get vms did not show $instance_id"
fi
done
pass_test "hive get vms (with instances)"
pass_test "spx get vms (with instances)"
echo ""
@@ -543,7 +543,7 @@ for idx in "${!INSTANCE_IDS[@]}"; do
-o BatchMode=yes \
-o LogLevel=ERROR \
-p "$SSH_PORT" \
-i "$HOME/.ssh/hive-key" \
-i "$HOME/.ssh/spinifex-key" \
ec2-user@"$host_ip" 'echo ready' > /dev/null 2>&1; then
SSH_READY=true
break
@@ -566,7 +566,7 @@ for idx in "${!INSTANCE_IDS[@]}"; do
-o BatchMode=yes \
-o LogLevel=ERROR \
-p "$SSH_PORT" \
-i "$HOME/.ssh/hive-key" \
-i "$HOME/.ssh/spinifex-key" \
ec2-user@"$host_ip" 'id' 2>&1) || {
echo " ERROR: SSH 'id' command failed"
fail_test "Guest SSH ($instance_id)"
@@ -589,7 +589,7 @@ for idx in "${!INSTANCE_IDS[@]}"; do
-o BatchMode=yes \
-o LogLevel=ERROR \
-p "$SSH_PORT" \
-i "$HOME/.ssh/hive-key" \
-i "$HOME/.ssh/spinifex-key" \
ec2-user@"$host_ip" 'lsblk' 2>&1) || true
echo " lsblk: $(echo "$LSBLK_OUTPUT" | head -5)"
@@ -605,12 +605,12 @@ echo "Phase 5: Volume Lifecycle"
echo "========================================"
# Discover AZ
HIVE_AZ=$($AWS_EC2 describe-availability-zones --query 'AvailabilityZones[0].ZoneName' --output text)
echo "AZ: $HIVE_AZ"
SPINIFEX_AZ=$($AWS_EC2 describe-availability-zones --query 'AvailabilityZones[0].ZoneName' --output text)
echo "AZ: $SPINIFEX_AZ"
# Create volume
echo "Creating 10GB test volume..."
CREATE_OUTPUT=$($AWS_EC2 create-volume --size 10 --availability-zone "$HIVE_AZ")
CREATE_OUTPUT=$($AWS_EC2 create-volume --size 10 --availability-zone "$SPINIFEX_AZ")
TEST_VOLUME_ID=$(echo "$CREATE_OUTPUT" | jq -r '.VolumeId')
if [ -z "$TEST_VOLUME_ID" ] || [ "$TEST_VOLUME_ID" == "null" ]; then
echo " ERROR: Failed to create volume"
@@ -772,9 +772,9 @@ echo "Phase 8: Node Failure"
echo "========================================"
echo "Stopping services on node2 ($NODE2_IP) to simulate node failure..."
# Stop services on node2 only — HIVE_FORCE_LOCAL_STOP prevents coordinated
# Stop services on node2 only — SPINIFEX_FORCE_LOCAL_STOP prevents coordinated
# cluster shutdown which would kill all nodes via NATS
peer_ssh "$NODE2_IP" "cd ~/Development/mulga/hive && HIVE_FORCE_LOCAL_STOP=1 ./scripts/stop-dev.sh" || {
peer_ssh "$NODE2_IP" "cd ~/Development/mulga/spinifex && SPINIFEX_FORCE_LOCAL_STOP=1 ./scripts/stop-dev.sh" || {
echo " WARNING: stop-dev.sh returned non-zero (may be expected)"
}
@@ -835,7 +835,7 @@ echo "Phase 9: Node Recovery"
echo "========================================"
echo "Restarting services on node2 ($NODE2_IP)..."
peer_ssh "$NODE2_IP" "cd ~/Development/mulga/hive && ./scripts/start-dev.sh" || {
peer_ssh "$NODE2_IP" "cd ~/Development/mulga/spinifex && ./scripts/start-dev.sh" || {
echo " ERROR: Failed to restart services on node2"
fail_test "Node2 restart"
}
@@ -884,9 +884,9 @@ else
fail_test "Node2 gateway recovery"
fi
# Verify hive get nodes shows 3 Ready again
echo " Checking hive get nodes after recovery..."
GET_NODES_RECOVER=$($HIVE_BIN get nodes --config "$HIVE_CONFIG" --timeout 10s 2>/dev/null || echo "")
# Verify spx get nodes shows 3 Ready again
echo " Checking spx get nodes after recovery..."
GET_NODES_RECOVER=$($SPINIFEX_BIN get nodes --config "$SPINIFEX_CONFIG" --timeout 10s 2>/dev/null || echo "")
echo "$GET_NODES_RECOVER"
READY_RECOVER=$(echo "$GET_NODES_RECOVER" | grep -c "Ready" || true)
if [ "$READY_RECOVER" -ge 3 ]; then
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -2,7 +2,7 @@
set -e
# VPC E2E Test Suite
# Tests VPC networking operations via the AWS CLI against a running Hive cluster.
# Tests VPC networking operations via the AWS CLI against a running Spinifex cluster.
# Can run with or without OVN — skips network-level tests when OVN is unavailable.
#
# Usage:
@@ -12,7 +12,7 @@ set -e
cd "$(dirname "$0")/../.."
ENDPOINT="${ENDPOINT:-https://127.0.0.1:9999}"
export AWS_PROFILE=hive
export AWS_PROFILE=spinifex
AWS_EC2="aws --endpoint-url ${ENDPOINT} ec2"
PASSED=0