-
Notifications
You must be signed in to change notification settings - Fork 4
STAC-22609: Adding stackpack test command #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Stackpack Test CLI Command - Testing Results ReportPrerequisites ✅ PASSED
Command Output: $ export STS_EXPERIMENTAL_STACKPACK=1 && echo "Experimental flag set: $STS_EXPERIMENTAL_STACKPACK"
Experimental flag set: 1Test Environment Setup ✅ PASSEDCreating Test Stackpacks
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack scaffold --name test-stackpack-001
✓ Validating arguments...
✓ Checking destination directory...
✓ Fetching template from github:StackVista/stackpack-templates@main:templates
✓ Rendering templates...
✓ Validating rendered templates...
✓ Copying files to destination...
Files copied:
README.md
provisioning/metricbindings.sty
provisioning/monitors.sty
provisioning/remediation-hints/node-memory-pressure.md.hbs
provisioning/stackpack.sty
resources/deprovisioning.md
resources/error.md
resources/installed.md
resources/logo.png
resources/notinstalled.md
resources/overview.md
resources/provisioning.md
resources/waitingfordata.md
stackpack.conf
✅ ✓ Scaffold complete!
Next steps:
1. Review the generated files in: /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-001
2. Check the /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-001/README.md for instructions on what to do next.
Commands & Outputs: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack scaffold --name test-stackpack-002
# [Same successful output as above, creating test-stackpack-002]
$ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack scaffold --name test-stackpack-003
# [Same successful output as above, creating test-stackpack-003]
Command & Output: $ ls -la test-stackpack-001
total 24
drwxr-xr-x@ 6 viliakov staff 192 Aug 29 09:09 .
drwxr-xr-x 42 viliakov staff 1344 Aug 29 09:09 ..
-rw-r--r--@ 1 viliakov staff 4336 Aug 29 09:09 README.md
drwxr-xr-x@ 6 viliakov staff 192 Aug 29 09:09 provisioning
drwxr-xr-x@ 10 viliakov staff 320 Aug 29 09:09 resources
-rw-r--r--@ 1 viliakov staff 1823 Aug 29 09:09 stackpack.conf
Checking Existing Stackpacks
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack list
NAME | DISPLAY NA | INSTALLED | NEXT VERSI | LATEST VER | INSTANCE C
| ME | VERSION | ON | SION | OUNT
aad-v2 | Autonomous | 1.0.1-mast | - | 1.0.1-mast | 0
| Anomaly D | er-10924-9 | | er-10924-9 |
| etector | 8ca6654-SN | | 8ca6654-SN |
| | APSHOT | | APSHOT |
# [Additional stackpacks listed...]
my-awesome | my-awesome | 0.0.7-cli- | - | 0.0.7-cli- | 1
-stackpack | -stackpack | test.1 | | test.1 | 1. Basic Test Command Functionality ✅ PASSEDDefault Functionality (Current Directory)
Command & Output: $ cd test-stackpack-001 && STS_EXPERIMENTAL_STACKPACK=1 go run ../main.go stackpack test --yes
✅ Starting stackpack test sequence...
Stackpack: test-stackpack-001 (current version: 0.0.1)
Step 1/5: Checking installed version...
Step 2/5: Creating temporary copy for testing...
✅ ✓ Temporary copy created
Step 3/5: Bumping version for testing...
✅ ✓ Version bumped to: 0.0.1-cli-test.10000
Step 4/5: Packaging stackpack...
✅ ✓ Stackpack packaged successfully!
Stackpack: test-stackpack-001 (v0.0.1-cli-test.10000)
Zip file: /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-001/test-stackpack-001-0.0.1-cli-test.10000.zip
✅ ✓ Stackpack packaged successfully
Step 5/5: Uploading and installing/upgrading stackpack...
✅ Uploaded StackPack: /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-001/test-stackpack-001-0.0.1-cli-test.10000.zip
NAME | DISPLAY NAME | VERSION
test-stackpack-001 | test-stackpack-001 | 0.0.1-cli-test.10000
✅ ✓ Stackpack uploaded successfully
✅ StackPack instance installed
ID | NAME | STATUS | VERSION | LAST UPDATED
274027256960772 | - | PROVISIONING | 0.0.1-cli-test.1 | Fri Aug 29 09:10
| | | 0000 | :26 2025 CEST
✅ ✓ Stackpack installed successfully
✅ 🎉 Test sequence completed successfully!
Test Specific Directory
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d ./test-stackpack-002 --yes
✅ Starting stackpack test sequence...
Stackpack: test-stackpack-002 (current version: 0.0.1)
Step 1/5: Checking installed version...
Step 2/5: Creating temporary copy for testing...
✅ ✓ Temporary copy created
Step 3/5: Bumping version for testing...
✅ ✓ Version bumped to: 0.0.1-cli-test.10000
Step 4/5: Packaging stackpack...
✅ ✓ Stackpack packaged successfully!
Stackpack: test-stackpack-002 (v0.0.1-cli-test.10000)
Zip file: /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-002-0.0.1-cli-test.10000.zip
✅ ✓ Stackpack packaged successfully
Step 5/5: Uploading and installing/upgrading stackpack...
✅ Uploaded StackPack: /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-002-0.0.1-cli-test.10000.zip
NAME | DISPLAY NAME | VERSION
test-stackpack-002 | test-stackpack-002 | 0.0.1-cli-test.10000
✅ ✓ Stackpack uploaded successfully
✅ StackPack instance installed
ID | NAME | STATUS | VERSION | LAST UPDATED
129974028780148 | - | PROVISIONING | 0.0.1-cli-test.1 | Fri Aug 29 09:11
| | | 0000 | :16 2025 CEST
✅ ✓ Stackpack installed successfully
✅ 🎉 Test sequence completed successfully!
Interactive Confirmation (No --yes Flag)
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d ./test-stackpack-003
✅ Starting stackpack test sequence...
Stackpack: test-stackpack-003 (current version: 0.0.1)
Step 1/5: Checking installed version...
Step 2/5: Creating temporary copy for testing...
✅ ✓ Temporary copy created
Step 3/5: Bumping version for testing...
✅ ✓ Version bumped to: 0.0.1-cli-test.10000
Step 4/5: Packaging stackpack...
✅ ✓ Stackpack packaged successfully!
Stackpack: test-stackpack-003 (v0.0.1-cli-test.10000)
Zip file: /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-003-0.0.1-cli-test.10000.zip
✅ ✓ Stackpack packaged successfully
⚠️ This will upload 'test-stackpack-003-0.0.1-cli-test.10000.zip' to SUSE Observability server:
Server: https://stac-22609.sandbox-main.sandbox.stackstate.io
Continue? (y/N):
❌ Upload cancelled by user
exit status 9
2. Version Selection Logic Tests ✅ PASSEDTest Case 1: Higher Local Minor Version vs Installed VersionSetup:
Expected Behavior:
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d ./test-stackpack-006 --yes
✅ Starting stackpack test sequence...
Stackpack: test-stackpack-006 (current version: 1.3.0)
Step 1/5: Checking installed version...
Found installed version: 1.2.0-cli-test.10000
Using local version as base (higher than installed): 1.3.0
Step 2/5: Creating temporary copy for testing...
✅ ✓ Temporary copy created
Step 3/5: Bumping version for testing...
✅ ✓ Version bumped to: 1.3.0-cli-test.10000
Step 4/5: Packaging stackpack...
✅ ✓ Stackpack packaged successfully!
Step 5/5: Uploading and installing/upgrading stackpack...
✅ Uploaded StackPack: /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-006-1.3.0-cli-test.10000.zip
NAME | DISPLAY NAME | VERSION
test-stackpack-006 | test-stackpack-006 | 1.3.0-cli-test.10000
✅ ✓ Stackpack uploaded successfully
✅ Successfully triggered upgrade from 1.2.0-cli-test.10000 to 1.3.0-cli-test.10000
✅ ✓ Stackpack upgraded successfully
✅ 🎉 Test sequence completed successfully!
Test Case 2: First Time Installation (No Existing Stackpack)Setup:
Expected Behavior:
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d ./test-stackpack-003 --yes
✅ Starting stackpack test sequence...
Stackpack: test-stackpack-003 (current version: 0.0.1)
Step 1/5: Checking installed version...
Step 2/5: Creating temporary copy for testing...
✅ ✓ Temporary copy created
Step 3/5: Bumping version for testing...
✅ ✓ Version bumped to: 0.0.1-cli-test.10000
Step 4/5: Packaging stackpack...
✅ ✓ Stackpack packaged successfully!
# [Upload and installation successful]
✅ 🎉 Test sequence completed successfully!
Test Case 3: Higher Local Version vs Installed VersionSetup:
Expected Behavior:
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d ./test-stackpack-001 --yes
✅ Starting stackpack test sequence...
Stackpack: test-stackpack-001 (current version: 2.0.0)
Step 1/5: Checking installed version...
Found installed version: 0.0.1-cli-test.10000
Using local version as base (higher than installed): 2.0.0
Step 2/5: Creating temporary copy for testing...
✅ ✓ Temporary copy created
Step 3/5: Bumping version for testing...
✅ ✓ Version bumped to: 2.0.0-cli-test.10000
Step 4/5: Packaging stackpack...
✅ ✓ Stackpack packaged successfully!
Step 5/5: Uploading and installing/upgrading stackpack...
✅ Uploaded StackPack: /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-001-2.0.0-cli-test.10000.zip
NAME | DISPLAY NAME | VERSION
test-stackpack-001 | test-stackpack-001 | 2.0.0-cli-test.10000
✅ ✓ Stackpack uploaded successfully
❌ Stackpack test-stackpack-001 cannot be upgraded at this moment
exit status 9
Test Case 4: Equal Base Versions with Existing CLI-TestSetup:
Expected Behavior:
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d ./test-stackpack-002 --yes
✅ Starting stackpack test sequence...
Stackpack: test-stackpack-002 (current version: 0.0.1)
Step 1/5: Checking installed version...
Found installed version: 0.0.1-cli-test.10000
Using installed version as base: 0.0.1-cli-test.10000
Step 2/5: Creating temporary copy for testing...
✅ ✓ Temporary copy created
Step 3/5: Bumping version for testing...
✅ ✓ Version bumped to: 0.0.1-cli-test.10001
Step 4/5: Packaging stackpack...
✅ ✓ Stackpack packaged successfully!
Step 5/5: Uploading and installing/upgrading stackpack...
✅ Uploaded StackPack: /Users/viliakov/Workspace/src/github/stackstate-cli/test-stackpack-002-0.0.1-cli-test.10001.zip
NAME | DISPLAY NAME | VERSION
test-stackpack-002 | test-stackpack-002 | 0.0.1-cli-test.10001
✅ ✓ Stackpack uploaded successfully
✅ Successfully triggered upgrade from 0.0.1-cli-test.10000 to 0.0.1-cli-test.10001
✅ ✓ Stackpack upgraded successfully
✅ 🎉 Test sequence completed successfully!
3. File Operations and Safety ✅ PASSEDTemporary Directory Operations
Command & Output: $ ls -la /tmp/ | grep stackpack
# No output - temporary directories properly cleaned up
HOCON Configuration Handling
Command & Output: $ cat test-stackpack-002/stackpack.conf | grep version
# schemaVersion -- Stackpack specification version.
# version -- Semantic version of the StackPack. StackPacks with the same major version are considered compatible.
version = "0.0.1"
# isNew -- This specifies whether the StackPack is new, as in the StackPack version is the first publicly available version. The values can be yes/no/true/false.
Archive Creation and Cleanup
Command & Output: $ ls -la *.zip
-rw-r--r--@ 1 viliakov staff 23852 Aug 28 13:32 my-awesome-stackpack-0.0.3-cli-test.10.zip
-rw-r--r--@ 1 viliakov staff 23851 Aug 28 13:35 my-awesome-stackpack-0.0.4-cli-test.1.zip
-rw-r--r--@ 1 viliakov staff 23852 Aug 28 16:32 my-awesome-stackpack-0.0.4-cli-test.10.zip
-rw-r--r--@ 1 viliakov staff 23852 Aug 28 14:20 my-awesome-stackpack-0.0.4-cli-test.8.zip
4. Error Handling and Validation ✅ PASSEDInvalid Stackpack Directory
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d ./nonexistent-stackpack --yes
❌ Failed to parse stackpack.conf: failed to read file: open nonexistent-stackpack/stackpack.conf: no such file or directory
exit status 9
Missing Required Files
Setup & Command: $ mkdir incomplete-stackpack && echo "name = \"incomplete\"" > incomplete-stackpack/stackpack.conf
$ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d ./incomplete-stackpack --yes
❌ Failed to parse stackpack.conf: version not found in stackpack.conf
exit status 9
Malformed stackpack.conf
Setup & Command: $ mkdir malformed-stackpack && echo "name = incomplete" > malformed-stackpack/stackpack.conf
$ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d ./malformed-stackpack --yes
❌ Failed to parse stackpack.conf: version not found in stackpack.conf
exit status 9
6. Command Help and Usage ✅ PASSEDCommand Help
Command & Output: $ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test --help
Test a stackpack by running package, upload, and install/upgrade commands in sequence.
This command will:
1. Read the stackpack name and version from stackpack.conf
2. Create a temporary copy of the stackpack directory
3. Update the version in the temporary copy with -cli-test.N suffix
4. Package the stackpack from the temporary copy into a zip file
5. Upload the zip file to the server (with confirmation)
6. Install the stackpack (if not installed) or upgrade it (if already installed)
The original stackpack directory is left untouched. The version is automatically incremented for each test run.
The stackpack name is read from stackpack.conf, so no --name flag is required.
Minimum supported StackState version: 5.0.0
Usage:
sts stackpack test [flags]
Examples:
# Test stackpack with confirmation
sts stackpack test -p "param1=value1"
# Skip confirmation prompt
sts stackpack test --yes
# Test stackpack in specific directory with unlocked strategy
sts stackpack test -d ./my-stackpack --yes --unlocked-strategy force
# Test with custom unlocked strategy
sts stackpack test --unlocked-strategy skip --yes
Flags:
-h, --help help for test
-p, --parameter stringToString List of parameters of the form "key=value" (default [])
-d, --stackpack-directory string Path to stackpack directory (defaults to current directory)
--unlocked-strategy string Strategy for dealing with unlocked StackPacks. Valid options are: fail, force, skip (default "fail")
-y, --yes Skip confirmation prompt before upload
Global Flags:
--api-token string Specify the API token of the StackState server
--ca-cert-base64-data string Base64-encoded private CA or self-signed certificate data to use for SSL verification. Ignored if skip-ssl or ca-cert-path is set
--ca-cert-path string Path to a private CA or self-signed certificate file. Ignored if skip-ssl is set
--config string Override the path to the config file
-c, --context string Override the context to use
--k8s-sa-token string Specify the Kubernetes Service Account Token
--k8s-sa-token-path string Specify the path to the Kubernetes Service Account Token
--no-color Disable color when printing to the terminal
-o, --output enum Specify the output format (must be { json | text }) (default text)
--service-token string Specify the Service token of the StackState server
--skip-ssl Whether to skip SSL certificate verification when connecting to StackState
--url string Specify the URL of the StackState server
-v, --verbose count Print verbose logging to the terminal to track what the CLI is doing (use multiple times to increase verbosity)
Without Experimental Flag
Command & Output: $ go run main.go stackpack --help
Manage and upload StackPacks.
Usage:
sts stackpack [command]
Available Commands:
confirm-manual-steps Confirm manual steps of StackPack
describe Describe a StackPack
install Install a StackPack
list List stackpacks
list-instances List installed instances of a StackPack
list-parameters List all parameters
uninstall Uninstall instances of a StackPack
upgrade Upgrade a StackPack
upload Upload a stackpack
Use "sts stackpack [command] --help" for more information about a command.
|
deontaljaard
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Test Case: Installation with incorrect resource definitions.❯ STS_EXPERIMENTAL_STACKPACK=1 go run main.go stackpack test -d test-stackpack-005 Step 1/5: Checking installed version... Step 2/5: Creating temporary copy for testing... Step 3/5: Bumping version for testing... Step 4/5: Packaging stackpack... Stackpack: test-stackpack-005 (v0.0.1-cli-test.10000)
Step 5/5: Uploading and installing/upgrading stackpack... Test Case: Upgrade with incorrect resource definitions.` Step 1/5: Checking installed version... Step 2/5: Creating temporary copy for testing... Step 3/5: Bumping version for testing... Step 4/5: Packaging stackpack... Stackpack: test-stackpack-004 (v0.0.1-cli-test.10002) Step 5/5: Uploading and installing/upgrading stackpack... |
Status: Draft - Experimental Feature
Summary
Adds a new
stackpack testcommand that streamlines the stackpack development workflow by automating the package → upload → install/upgrade sequence with automatic version management for testing iterations.What's Changed
New Command:
stackpack testSTS_EXPERIMENTAL_STACKPACKfeature flagKey Features
Automatic Test Versioning
-cli-test.Nsuffix to versions for testing iterations1.0.0→1.0.0-cli-test.1→1.0.0-cli-test.2Smart Base Version Selection
0.0.6+ Installed0.0.4-cli-test.9→0.0.6-cli-test.1Safe File Operations
Comprehensive Error Handling
Command Usage
Technical Implementation