Files
nupst/test/manualdocker
Juergen Kunz 016681b77b feat(migrations): add migration system for v3→v4 config format
- Create abstract BaseMigration class with order, shouldRun(), migrate()
- Add MigrationRunner to execute migrations in order
- Add Migration v1→v2 (snmp → upsDevices)
- Add Migration v3→v4 (upsList → upsDevices)
- Update INupstConfig with version field
- Update loadConfig() to run migrations automatically
- Update saveConfig() to ensure version field and remove legacy fields
- Update Docker test scripts to use real UPS data from .nogit/env.json
- Remove colors.bright (not available in @std/fmt/colors)

Config migrations allow users to jump versions (e.g., v1→v4) with all
intermediate migrations running automatically. Version field tracks
config format for future migrations.
2025-10-19 20:41:09 +00:00
..

Manual Docker Testing Scripts

This directory contains scripts for manually testing NUPST installation and migration in Docker containers with systemd support.

Prerequisites

  • Docker installed and running
  • Privileged access (for systemd in container)
  • Linux host (systemd container requirements)

Test Scripts

1. 01-setup-v3-container.sh

Creates a Docker container with systemd and installs NUPST v3.

What it does:

  • Creates Ubuntu 22.04 container with systemd enabled
  • Installs NUPST v3 from commit 806f81c6 (last v3 version)
  • Enables and starts the systemd service
  • Leaves container running for testing

Usage:

chmod +x 01-setup-v3-container.sh
./01-setup-v3-container.sh

Container name: nupst-test-v3

2. 02-test-v3-to-v4-migration.sh

Tests the migration from v3 to v4.

What it does:

  • Checks current v3 installation
  • Pulls v4 code from migration/deno-v4 branch
  • Runs install.sh (should auto-detect and migrate)
  • Verifies service is running with v4
  • Tests basic commands

Usage:

chmod +x 02-test-v3-to-v4-migration.sh
./02-test-v3-to-v4-migration.sh

Prerequisites: Must run 01-setup-v3-container.sh first

3. 03-cleanup.sh

Removes the test container.

Usage:

chmod +x 03-cleanup.sh
./03-cleanup.sh

Manual Testing Workflow

Full Migration Test

  1. Set up v3 environment:

    ./01-setup-v3-container.sh
    
  2. Verify v3 is working:

    docker exec nupst-test-v3 nupst --version
    docker exec nupst-test-v3 systemctl status nupst
    
  3. Test migration to v4:

    ./02-test-v3-to-v4-migration.sh
    
  4. Manual verification:

    # Enter container
    docker exec -it nupst-test-v3 bash
    
    # Inside container:
    nupst --version                    # Should show v4.0.0
    nupst service status               # Should show running service
    cat /etc/nupst/config.json         # Config should be preserved
    systemctl status nupst             # Service should be active
    
  5. Cleanup:

    ./03-cleanup.sh
    

Useful Docker Commands

# Enter container shell
docker exec -it nupst-test-v3 bash

# Check service status
docker exec nupst-test-v3 systemctl status nupst

# View service logs
docker exec nupst-test-v3 journalctl -u nupst -n 50

# Check NUPST version
docker exec nupst-test-v3 nupst --version

# Run NUPST commands
docker exec nupst-test-v3 nupst service status
docker exec nupst-test-v3 nupst ups list

# Stop container
docker stop nupst-test-v3

# Start container
docker start nupst-test-v3

# Remove container
docker rm -f nupst-test-v3

Notes

  • The container runs with --privileged flag for systemd support
  • Container uses Ubuntu 22.04 as base image
  • v3 installation is from commit 806f81c6a057a2a5da586b96a231d391f12eb1bb
  • v4 migration pulls from migration/deno-v4 branch
  • All scripts are designed to be idempotent where possible

Troubleshooting

Container won't start

  • Ensure Docker daemon is running
  • Check you have privileged access
  • Try: docker logs nupst-test-v3

Systemd not working in container

  • Requires Linux host (not macOS/Windows)
  • Needs --privileged and cgroup volume mounts
  • Check: docker exec nupst-test-v3 systemctl --version

Migration fails

  • Check logs: docker exec nupst-test-v3 journalctl -xe
  • Verify install.sh ran: docker exec nupst-test-v3 ls -la /opt/nupst/
  • Check service: docker exec nupst-test-v3 systemctl status nupst