Files
nupst/test/manualdocker
Juergen Kunz fb4d776bdd
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 8s
Release / build-and-release (push) Successful in 48s
CI / Build All Platforms (push) Successful in 51s
fix(migration): properly transform v3 flat structure to v4 nested snmp config
The v3→v4 migration was only renaming upsList to upsDevices without
transforming the device structure. V3 had a flat structure with SNMP
fields directly on the device object, while v4 expects a nested 'snmp'
object.

This commit fixes the migration to:
- Move host, port, community, version, etc. into nested snmp object
- Convert version from string to number
- Add default timeout (5000ms)
- Create thresholds object with defaults
- Preserve all SNMPv1, v2c, and v3 authentication fields

Also includes install.sh fix for better non-interactive handling.
2025-10-19 21:32:55 +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