testzeus-environments
Manage TestZeus environments (dev, staging, production configurations).
Category: data · Version: 1.0.0 · Requires: testzeus-auth
Triggers: environment, create environment, manage environment, upload to environment, staging, production, dev environment, environment config, environment file, environment variables
Overview
Environments in TestZeus store configuration data and files that tests use during execution. They represent different deployment targets (dev, staging, production) with their specific settings.
Quick Reference
# List environments
testzeus environments list
# Create environment
testzeus environments create --name "Staging" \
--data-file ./staging-config.json
# Get environment
testzeus environments get env_id
# Upload file
testzeus environments upload-file env_id ./config.yaml
# Upload a mobile app file (APK/ZIP) to a mobile environment
testzeus environments upload-mobile-file env_id ./app.apk
# Update
testzeus environments update env_id --name "New Name"
# Delete
testzeus environments delete env_idEnvironment Structure
Configuration Data
{
"base_url": "https://staging.example.com",
"api_url": "https://api.staging.example.com",
"database": {
"host": "db.staging.example.com",
"port": 5432
},
"features": {
"new_checkout": true,
"beta_features": false
}
}File Attachments
Environments can have files attached:
- Configuration files (yaml, json, env)
- Certificates and keys
- Test fixtures
Create Environment
Basic Creation
# From inline JSON
testzeus environments create \
--name "Development" \
--data '{
"base_url": "http://localhost:3000",
"debug": true
}'
# From file
testzeus environments create \
--name "Staging" \
--data-file ./staging-config.json
# From a config file
testzeus environments create \
--name "Production" \
--data-file ./prod-config.jsonWith Tags
testzeus environments create \
--name "QA" \
--data '{}' \
--tags qa \
--tags automatedManage Environments
List Environments
# List all
testzeus environments list
# Filter by status
testzeus environments list --filters status=ready
# Filter by name
testzeus environments list --filters name~"staging"
# Get with details
testzeus environments get env_id
testzeus environments get env_id --expand related_entitiesUpdate Environment
# Update name
testzeus environments update env_id --name "New Name"
# Update
testzeus environments update env_id --name "Updated name"
# Update data
testzeus environments update env_id \
--data '{"updated": true}'
# Update from file
testzeus environments update env_id \
--data-file ./new-config.jsonDelete Environment
# Delete all files first (recommended)
testzeus environments delete-all-files env_id
# Then delete
testzeus environments delete env_idFile Management
Upload Files
# Upload single file
testzeus environments upload-file env_id ./config.yaml
# Upload multiple files
testzeus environments upload-file env_id ./app-config.yaml
testzeus environments upload-file env_id ./database.yaml
testzeus environments upload-file env_id ./secrets.env
# Upload certificates
testzeus environments upload-file env_id ./server.crt
testzeus environments upload-file env_id ./server.key
# Upload a mobile app build (APK/ZIP) to a mobile environment
testzeus environments upload-mobile-file env_id ./app-release.apkRemove Files
# Remove specific file
testzeus environments remove-file env_id ./old-config.yaml
# Remove all files
testzeus environments delete-all-files env_idList Files
Files are accessible via the API or can be viewed in the TestZeus UI.
Environment Examples
Development
testzeus environments create \
--name "Development" \
--data '{
"base_url": "http://localhost:3000",
"api_url": "http://localhost:8080",
"debug": true,
"mock_external_services": true,
"database": {
"host": "localhost",
"port": 5432,
"name": "testdb"
}
}'Staging
testzeus environments create \
--name "Staging" \
--tags staging \
--data '{
"base_url": "https://staging.example.com",
"api_url": "https://api.staging.example.com",
"debug": false,
"mock_external_services": false,
"database": {
"host": "db.staging.example.com",
"port": 5432,
"name": "staging_db"
},
"features": {
"new_checkout": true,
"beta_ui": true
}
}'Production
testzeus environments create \
--name "Production" \
--tags production \
--data '{
"base_url": "https://www.example.com",
"api_url": "https://api.example.com",
"debug": false,
"mock_external_services": false,
"features": {
"new_checkout": false,
"beta_ui": false
}
}'Connected Environments
Connected environments track integration status with external systems.
Check Connection Status
# Via SDK
connected = await client.connected_environments.get_one("conn_env_id")
# Check if connected
if connected.has_connection():
print(f"Connected to: {connected.connection}")
print(f"Status: {connected.connection_status}")Create Connected Environment
# Via SDK
connected = await client.connected_environments.create({
"name": "AWS Staging",
"type": "aws",
"config": {
"region": "us-west-2",
"account_id": "123456789"
}
})Connected Environment Properties
connected = await client.connected_environments.get_one("conn_env_id")
# Properties
connected.id # UUID
connected.name # "AWS Staging"
connected.type # "aws", "azure", "gcp", "custom"
connected.config # Connection config
connected.status # Connection status
# Methods
connected.has_connection() # Is connected?
connected.get_connection_info() # Connection detailsSDK Usage
from testzeus_sdk import TestZeusClient
async def main():
async with TestZeusClient() as client:
# Create environment
env = await client.environments.create({
"name": "E2E Tests",
"data": {
"base_url": "https://e2e.example.com",
"timeout": 30000
},
"status": "ready"
})
# Upload config file
await client.environments.upload_file(
env.id,
"./e2e-config.yaml"
)
# Upload certificates
await client.environments.upload_file(
env.id,
"./client.crt"
)
# List environments
all_envs = await client.environments.get_list()
# Use with tests
test = await client.tests.create(
name="E2E Test",
test_feature="...",
environment=env.id
)Environment Variables
Best Practices
-
Separate sensitive data
- Use environments for non-sensitive config
- Use secrets management for API keys/passwords
- Don't commit credentials to git
-
Environment-specific settings
{ "debug": true, // Dev only "log_level": "debug", // Dev only "cache_ttl": 300 } -
Feature flags
{ "features": { "new_ui": false, // Disabled in prod initially "beta_api": true // Enabled for testing } }
Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
Env not found |
Wrong ID | List environments first |
File too large |
Exceeds limit | Compress or split files |
Invalid JSON |
Malformed config | Validate JSON/YAML |
Status conflict |
Can't update archived | Restore or create new |
Validation
Always validate your config before creating:
# Validate JSON
cat config.json | python -m json.tool > /dev/null && echo "Valid JSON"
# Validate YAML
python -c "import yaml; yaml.safe_load(open('config.yaml'))"Component Schema
Use EnvironmentCard component:
{
"component": "EnvironmentCard",
"props": {
"name": "Staging",
"status": "ready",
"type": "staging",
"tags": ["staging", "automated"],
"data": {
"base_url": "https://staging.example.com"
}
}
}Related Skills
- testzeus-test-data - Test data management
- testzeus-test-operations - Running tests with environments
- testzeus-test-authoring - Creating tests with environments