test(cli): add tests for provision and validate commands#613
test(cli): add tests for provision and validate commands#613ArangoGutierrez wants to merge 3 commits intoNVIDIA:mainfrom
Conversation
Adds a new `holodeck validate -f env.yaml` command that checks: - Environment file is valid YAML - Required fields are present (provider, keyName, region, etc.) - SSH private/public keys are readable - AWS credentials are configured (for AWS provider) - Component dependencies (runtime required for toolkit/k8s) Refs: NVIDIA#563 Task: 1/2 Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
Adds a new `holodeck provision` command with two modes: 1. Instance mode: Provision/re-provision an existing instance by ID `holodeck provision abc123` 2. SSH mode: Provision a remote host directly without an instance `holodeck provision --ssh --host 1.2.3.4 --key ~/.ssh/id_rsa -f env.yaml` Features: - Re-runs idempotent provisioning scripts safely - Supports kubeconfig download with -k flag - Works with both single-node and multinode clusters Refs: NVIDIA#563 Task: 2/2 Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
Pull Request Test Coverage Report for Build 21680290137Details
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive unit tests for the new provision and validate CLI commands, significantly improving test coverage for these features. However, the PR includes critical issues in main.go that will prevent the code from compiling, as it references multiple command packages that don't exist in the codebase.
Changes:
- Added unit tests for the
provisionCLI command (8 test functions, 41.5% coverage) - Added unit tests for the
validateCLI command (10 test functions, 67.4% coverage) - Updated main.go to register new commands (some of which don't exist)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/cli/validate/validate_test.go | New comprehensive test file with 10 test functions covering command structure, flags, environment file validation, required fields, SSH keys, components, and path expansion |
| cmd/cli/validate/validate.go | New validate command implementation that provides environment file validation before instance creation |
| cmd/cli/provision/provision_test.go | New comprehensive test file with 8 test functions covering command structure, instance mode, SSH mode, host URL resolution, and kubeconfig path generation |
| cmd/cli/provision/provision.go | New provision command implementation for provisioning/re-provisioning instances in both instance and SSH modes |
| cmd/cli/main.go | Updated to register new commands including provision and validate, but also references several non-existent commands |
|
|
||
| err := app.Run([]string{"holodeck", "validate", "-f", "/nonexistent/file.yaml"}) | ||
| require.Error(t, err) | ||
| require.Error(t, err) |
There was a problem hiding this comment.
Duplicate require.Error call. This line is redundant as line 83 already checks for an error.
| require.Error(t, err) |
| @@ -0,0 +1,578 @@ | |||
| /* | |||
| * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | |||
There was a problem hiding this comment.
Copyright year should be 2026 to match the convention used in other test files in this directory (see list_test.go, status_test.go, delete_test.go, etc.). The current year is 2026.
| @@ -0,0 +1,474 @@ | |||
| /* | |||
| * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | |||
There was a problem hiding this comment.
Copyright year should be 2026 to match the convention used in other files in cmd/cli (see cmd/cli/os/os.go, cmd/cli/list/list_test.go, cmd/cli/status/status_test.go). The current year is 2026.
| @@ -0,0 +1,373 @@ | |||
| /* | |||
| * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | |||
There was a problem hiding this comment.
Copyright year should be 2026 to match the convention used in other test files in this directory (see cmd/cli/list/list_test.go, cmd/cli/status/status_test.go). The current year is 2026.
| @@ -0,0 +1,320 @@ | |||
| /* | |||
| * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | |||
There was a problem hiding this comment.
Copyright year should be 2026 to match the convention used in other files in cmd/cli (see cmd/cli/os/os.go, cmd/cli/list/list_test.go). The current year is 2026.
| "github.com/NVIDIA/holodeck/cmd/cli/list" | ||
| oscmd "github.com/NVIDIA/holodeck/cmd/cli/os" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/provision" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/scp" |
There was a problem hiding this comment.
This import references a package "github.com/NVIDIA/holodeck/cmd/cli/scp" that does not appear to exist in the codebase. The command is registered on line 122 but the package is missing.
| "github.com/NVIDIA/holodeck/cmd/cli/scp" |
| "github.com/NVIDIA/holodeck/cmd/cli/scp" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/ssh" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/status" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/update" |
There was a problem hiding this comment.
This import references a package "github.com/NVIDIA/holodeck/cmd/cli/update" that does not appear to exist in the codebase. The command is registered on line 125 but the package is missing.
| "github.com/NVIDIA/holodeck/cmd/cli/update" |
| "github.com/NVIDIA/holodeck/cmd/cli/delete" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/describe" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/dryrun" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/get" |
There was a problem hiding this comment.
This import references a package "github.com/NVIDIA/holodeck/cmd/cli/get" that does not appear to exist in the codebase. The command is registered on line 118 but the package is missing.
| "github.com/NVIDIA/holodeck/cmd/cli/get" |
| oscmd "github.com/NVIDIA/holodeck/cmd/cli/os" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/provision" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/scp" | ||
| "github.com/NVIDIA/holodeck/cmd/cli/ssh" |
There was a problem hiding this comment.
This import references a package "github.com/NVIDIA/holodeck/cmd/cli/ssh" that does not appear to exist in the codebase. The command is registered on line 123 but the package is missing.
| "github.com/NVIDIA/holodeck/cmd/cli/ssh" |
| Spec: v1alpha1.EnvironmentSpec{ | ||
| Provider: v1alpha1.ProviderSSH, | ||
| Instance: v1alpha1.Instance{ | ||
| HostUrl: "192.168.1.100"}, |
There was a problem hiding this comment.
Inconsistent formatting: the closing brace should be on a new line to match Go formatting conventions and the style used elsewhere in the struct literal.
| HostUrl: "192.168.1.100"}, | |
| HostUrl: "192.168.1.100", | |
| }, |
|
Closing: these tests target This PR can be reopened if/when provision and validate commands are added in a future PR. |
Summary
Add comprehensive unit tests for the new
provisionandvalidateCLI commands.Changes
New Test Files
cmd/cli/provision/provision_test.go(8 test functions)cmd/cli/validate/validate_test.go(10 test functions)Test Coverage
provisionvalidateResults
Test plan
go test ./cmd/cli/provision/... ./cmd/cli/validate/... -v