This document describes the validation testing framework for cloud provider implementations.
Validation tests verify that cloud provider implementations correctly implement the SDK interfaces by making real API calls to cloud providers. These tests are separate from unit tests and require actual cloud credentials.
# Skip validation tests (default)
make test
# Run validation tests
make test-validation
# Run all tests
make test-allEach provider requires specific environment variables:
- LambdaLabs:
LAMBDALABS_API_KEY
Validation tests run automatically:
- Daily via scheduled workflows
- On pull requests when labeled with
run-validation - Manually via workflow dispatch
- Create validation test file:
internal/{provider}/v1/validation_test.go - Use the shared validation package with provider-specific configuration:
func TestValidationFunctions(t *testing.T) {
apiKey := os.Getenv("YOUR_PROVIDER_API_KEY")
if apiKey == "" {
t.Skip("YOUR_PROVIDER_API_KEY not set, skipping YourProvider validation tests")
}
config := validation.ProviderConfig{
Credential: NewYourProviderCredential("validation-test", apiKey),
}
validation.RunValidationSuite(t, config)
}- Create CI workflow:
.github/workflows/validation-{provider}.yml - Add environment variables to CI secrets
- Update this documentation
The validation tests use a shared package at internal/validation/ that provides:
RunValidationSuite()- Tests all validation functions from pkg/v1/RunInstanceLifecycleValidation()- Tests instance lifecycle operationsProviderConfig- Configuration for provider-specific setup using CloudCredential
The ProviderConfig uses the existing CloudCredential interface which acts as a factory for CloudClient instances. The provider name is automatically obtained from the credential's GetCloudProviderID() method. This approach eliminates code duplication and ensures consistent validation testing across all providers while leveraging the existing credential abstraction.
Validation tests use testing.Short() guards:
func TestValidation(t *testing.T) {
if testing.Short() {
t.Skip("Skipping validation tests in short mode")
}
// ... validation logic
}This ensures validation tests only run when explicitly requested.
The framework tests all validation functions from the SDK:
ValidateCreateInstance- Tests instance creation with timing and attribute validationValidateListCreatedInstance- Tests instance listing and filteringValidateTerminateInstance- Tests instance terminationValidateMergeInstanceForUpdate- Tests instance update merging logic
ValidateGetInstanceTypes- Tests instance type retrieval and filteringValidateRegionalInstanceTypes- Tests regional instance type filteringValidateStableInstanceTypeIDs- Tests instance type ID stability
ValidateGetLocations- Tests location retrieval and availability
- Validation tests use real cloud credentials stored as GitHub secrets
- Tests create and destroy real cloud resources
- Proper cleanup is implemented to avoid resource leaks
- Tests are designed to be cost-effective and use minimal resources
- Missing credentials: Ensure environment variables are set
- Quota limits: Tests may skip if quota is exceeded
- Resource availability: Tests adapt to available instance types and locations
- Network timeouts: Tests use appropriate timeouts for cloud operations
# Run specific validation test
go test -v -short=false -run TestValidationFunctions ./internal/lambdalabs/v1/
# Run with verbose output
go test -v -short=false -timeout=20m ./internal/lambdalabs/v1/When adding new validation functions:
- Add the validation function to the appropriate
pkg/v1/*.gofile - Add corresponding test in
internal/{provider}/v1/validation_test.go - Ensure proper cleanup and error handling
- Update this documentation