|
| 1 | +# Test Scripts |
| 2 | + |
| 3 | +## test-demo.sh |
| 4 | + |
| 5 | +Test script for the `nfctl demo` command. Can be run locally or in GitHub Actions. |
| 6 | + |
| 7 | +### Usage |
| 8 | + |
| 9 | +**In GitHub Actions:** |
| 10 | + |
| 11 | +```yaml |
| 12 | +- name: Run demo test |
| 13 | + env: |
| 14 | + NETFOUNDRY_CLIENT_ID: ${{ secrets.NETFOUNDRY_CLIENT_ID }} |
| 15 | + NETFOUNDRY_PASSWORD: ${{ secrets.NETFOUNDRY_PASSWORD }} |
| 16 | + NETFOUNDRY_OAUTH_URL: ${{ secrets.NETFOUNDRY_OAUTH_URL }} |
| 17 | + run: ./scripts/test-demo.sh |
| 18 | +``` |
| 19 | +
|
| 20 | +The script automatically detects GitHub Actions via `GITHUB_RUN_ID` and uses it in the network name prefix. |
| 21 | + |
| 22 | +**Locally:** |
| 23 | + |
| 24 | +```bash |
| 25 | +# Use default prefix (local-<timestamp>) |
| 26 | +./scripts/test-demo.sh |
| 27 | +
|
| 28 | +# Use custom prefix |
| 29 | +DEMO_PREFIX=mytest ./scripts/test-demo.sh |
| 30 | +
|
| 31 | +# Specify organization and network group |
| 32 | +NETFOUNDRY_ORGANIZATION=acme \ |
| 33 | +NETFOUNDRY_NETWORK_GROUP=testing \ |
| 34 | +DEMO_PREFIX=mytest \ |
| 35 | +./scripts/test-demo.sh |
| 36 | +``` |
| 37 | + |
| 38 | +### What it does |
| 39 | + |
| 40 | +1. Creates a temporary directory and config file (cleaned up on exit) |
| 41 | +2. Generates a unique network name using `--echo-name` |
| 42 | +3. Configures nfctl with all settings in the temp config: |
| 43 | + - Network name (generated) |
| 44 | + - Organization (from `NETFOUNDRY_ORGANIZATION` if set) |
| 45 | + - Network group (from `NETFOUNDRY_NETWORK_GROUP` if set) |
| 46 | + - Auto-confirm and verbose flags |
| 47 | +4. Runs the demo with medium size, AWS provider, us-west-2 and us-east-1 regions |
| 48 | +5. Tests service operations (list, get, delete, create) |
| 49 | +6. Cleans up by deleting the network and removing temp directory |
| 50 | + |
| 51 | +### Environment Variables |
| 52 | + |
| 53 | +**Script Configuration:** |
| 54 | + |
| 55 | +- `GITHUB_RUN_ID` - Auto-detected in GitHub Actions, used for network prefix |
| 56 | +- `DEMO_PREFIX` - Custom prefix for local runs (default: `local-<timestamp>`) |
| 57 | +- `NETFOUNDRY_PROFILE` - Profile name for token cache isolation (default: `default`) |
| 58 | + |
| 59 | +**Standard NetFoundry Environment Variables:** |
| 60 | + |
| 61 | +- `NETFOUNDRY_ORGANIZATION` - Optional organization name (omitted if unset) |
| 62 | +- `NETFOUNDRY_NETWORK_GROUP` - Optional network group name (omitted if unset) |
| 63 | +- `NETFOUNDRY_CLIENT_ID` - NetFoundry API credentials |
| 64 | +- `NETFOUNDRY_PASSWORD` - NetFoundry API credentials |
| 65 | +- `NETFOUNDRY_OAUTH_URL` - NetFoundry OAuth URL |
| 66 | +- `NETFOUNDRY_API_ACCOUNT` - Path to API credentials JSON file |
| 67 | + |
| 68 | +These standard variables match those used by `nfctl login --eval` for consistency. |
| 69 | + |
| 70 | +**Profile Usage:** |
| 71 | + |
| 72 | +The `NETFOUNDRY_PROFILE` variable allows you to isolate token caches for different accounts. Each profile uses a separate cache file (`~/.cache/netfoundry/<profile>.json`), preventing conflicts when working with multiple NetFoundry accounts. |
| 73 | + |
| 74 | +```bash |
| 75 | +# Use a specific profile |
| 76 | +NETFOUNDRY_PROFILE=advdev \ |
| 77 | +NETFOUNDRY_API_ACCOUNT=~/.config/netfoundry/advdev.json \ |
| 78 | +./scripts/test-demo.sh |
| 79 | +``` |
| 80 | + |
| 81 | +### Features |
| 82 | + |
| 83 | +- **Isolated config**: Each run uses a temporary config file that doesn't interfere with your existing nfctl configuration |
| 84 | +- **Auto-cleanup**: Temporary directory is automatically removed on exit (success or failure) |
| 85 | +- **Config-based scoping**: Organization and network group are set in the config file (from environment variables) rather than passed as CLI options on every command |
0 commit comments