Add validation testing framework with testing.Short() guards#9
Add validation testing framework with testing.Short() guards#9
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
all these tests should be the same for all providers. Can we make a set of tests that we can run against all providers vs implement on a cloud per cloud basis? Maybe we make a validation package in internal that shares common logic.
internal/validation/suite.go
Outdated
| type ProviderConfig struct { | ||
| ProviderName string | ||
| EnvVarName string | ||
| ClientFactory func(apiKey string) v1.CloudClient |
There was a problem hiding this comment.
this should just take in a cloud credential which is a factory for cloud client
| with: | ||
| name: lambdalabs-validation-results | ||
| path: | | ||
| internal/lambdalabs/test-results.xml |
internal/validation/suite.go
Outdated
|
|
||
| client, err := config.Credential.MakeClient(ctx, "") | ||
| if err != nil { | ||
| t.Skipf("Failed to create client for %s: %v", config.ProviderName, err) |
There was a problem hiding this comment.
we should fail here instead of skip
internal/validation/suite.go
Outdated
|
|
||
| client, err := config.Credential.MakeClient(ctx, "") | ||
| if err != nil { | ||
| t.Skipf("Failed to create client for %s: %v", config.ProviderName, err) |
There was a problem hiding this comment.
we should fail here instead of skip
internal/validation/suite.go
Outdated
| ProviderName string | ||
| EnvVarName string | ||
| ClientFactory func(apiKey string) v1.CloudClient | ||
| ProviderName string |
There was a problem hiding this comment.
I don't think we need provider name since we can get provider id from the credential. Lets still keep the ProviderConfig in case we need to add test suit specific attributes,
- Create validation_test.go for LambdaLabs provider with comprehensive validation function tests - Add testing.Short() guards to skip validation tests during normal test runs - Update Makefile with test-validation and test-all targets - Create provider-specific CI workflow for LambdaLabs validation tests - Add documentation for validation testing framework - Update main CI workflow with validation testing notes The framework allows running validation functions as part of testing coverage while keeping them separate from unit tests using testing.Short() pattern. Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- Create internal/validation package with shared test logic - Refactor LambdaLabs validation tests to use ProviderConfig pattern - Eliminate code duplication across providers - Update documentation to reflect shared validation approach - Maintain testing.Short() guards and existing functionality Addresses GitHub PR feedback to make validation tests provider-agnostic instead of duplicating logic per provider. Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- Refactor ProviderConfig to use CloudCredential interface instead of custom function - Move environment variable handling to test files where credentials are created - Update documentation to reflect CloudCredential approach - Maintain all existing functionality including testing.Short() guards - Commit go.mod/go.sum changes from dependency updates Addresses GitHub comment from @theFong on internal/validation/suite.go Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- Address GitHub comment from @theFong about test-results.xml file - Standard Go tests don't generate XML output without additional tooling - Keep coverage.out path for potential future coverage reporting - Verified no XML files are generated during test runs Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- Remove ProviderName field from ProviderConfig struct - Use config.Credential.GetCloudProviderID() for provider identification - Change from t.Skipf() to t.Fatalf() when MakeClient fails in both validation functions - Update LambdaLabs tests to use simplified ProviderConfig - Update documentation to reflect ProviderName removal Addresses GitHub comments from @theFong on internal/validation/suite.go Co-Authored-By: Alec Fong <alecsanf@usc.edu>
cdc6a10 to
96503c9
Compare
Add validation testing framework with shared provider-agnostic package
Summary
This PR creates a shared validation testing framework to eliminate code duplication across cloud providers. The implementation addresses GitHub feedback to use provider-agnostic validation tests instead of duplicating logic for each provider.
Key Changes:
internal/validation/suite.gowith shared validation test logic that works with any CloudClient implementationProviderConfigpattern (reduced from 125 lines to 33 lines)ClientFactory func(apiKey string) CloudClienttoCloudCredentialinterface for better architectural alignmentProviderNamefield fromProviderConfig(now usesGetCloudProviderID()from credential)t.Skip()tot.Fatalf()when client creation failstest-results.xmlartifact from CI workflowBenefits:
ProviderConfig)CloudCredentialinterface for better architectureReview & Testing Checklist for Human
internal/validation/suite.gopackage contains complex timeout handling, context management, and error scenarios that affect all providers. This code has no unit tests and relies entirely on integration testing. Verify it handles edge cases correctly, especially around context timeouts and client creation failures.ClientFactoryfunction toCloudCredentialinterface changes core behavior. Test credential creation, client instantiation, and error handling paths. EnsureGetCloudProviderID()returns appropriate values for error messages.t.Skip()tot.Fatalf()whenMakeClient()fails. This is a significant behavioral change that will cause tests to fail hard instead of skipping. Verify this is the intended behavior and won't cause issues in CI environments.coverage.out). Test that the workflow runs without errors even when artifacts are missing, and verify the workflow triggers correctly on the specified conditions.Recommended Test Plan:
make testand verify validation tests are skipped in short modemake test-validationand verify validation tests attempt to run but skip without credentialsLAMBDALABS_API_KEYset to verify actual validation execution (if credentials available)ProviderConfigpattern for extensibility to future providersDiagram
%%{ init : { "theme" : "default" }}%% graph TD validation_suite["internal/validation/suite.go<br/>Shared validation logic"]:::major-edit lambdalabs_tests["internal/lambdalabs/v1/validation_test.go<br/>LambdaLabs wrapper"]:::major-edit ci_workflow[".github/workflows/validation-lambdalabs.yml<br/>CI validation workflow"]:::major-edit validation_docs["docs/VALIDATION_TESTING.md<br/>Updated documentation"]:::minor-edit makefile["Makefile<br/>Test targets"]:::minor-edit pkg_v1["pkg/v1/<br/>Validation functions"]:::context validation_suite --> lambdalabs_tests validation_suite -.-> future_provider["Future providers<br/>(easy to add)"]:::context lambdalabs_tests --> ci_workflow validation_docs --> validation_suite makefile --> validation_suite pkg_v1 --> validation_suite subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
This refactor was specifically requested by @theFong in GitHub comments pointing out that validation tests should be shared across providers since the validation functions in
pkg/v1/already work with interface types. The implementation went through multiple iterations to address architectural feedback:The
ProviderConfigpattern makes it trivial to add validation tests for new providers - they just need to create a minimal wrapper file with their specific credential setup. This approach is extensible and follows established patterns in the codebase.Important: The shared validation package doesn't have its own unit tests and relies entirely on integration testing through provider implementations. The complex timeout and context handling should be thoroughly tested. The error handling change from skip to fatal is significant and affects test behavior across all providers.
Session: https://app.devin.ai/sessions/6b1b6f102fa141e8b82300d301394302
Requested by: @theFong