Skip to content

test(cli): add tests for provision and validate commands#613

Closed
ArangoGutierrez wants to merge 3 commits intoNVIDIA:mainfrom
ArangoGutierrez:feat/provision-validate-tests
Closed

test(cli): add tests for provision and validate commands#613
ArangoGutierrez wants to merge 3 commits intoNVIDIA:mainfrom
ArangoGutierrez:feat/provision-validate-tests

Conversation

@ArangoGutierrez
Copy link
Collaborator

Summary

Add comprehensive unit tests for the new provision and validate CLI commands.

Changes

New Test Files

  1. cmd/cli/provision/provision_test.go (8 test functions)

    • Command structure and flag validation
    • Instance mode (missing/valid instance ID)
    • SSH mode validation (missing host, key, env file)
    • Host URL resolution
    • Kubeconfig path generation
  2. cmd/cli/validate/validate_test.go (10 test functions)

    • Command structure and flags
    • Environment file validation
    • Required fields validation
    • SSH key validation
    • Component validation
    • Path expansion

Test Coverage

Package Coverage
provision 41.5%
validate 67.4%

Results

  • 73 test cases executed (including subtests)
  • All tests passing

Test plan

  • go test ./cmd/cli/provision/... ./cmd/cli/validate/... -v

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>
Copilot AI review requested due to automatic review settings February 4, 2026 16:50
@coveralls
Copy link

Pull Request Test Coverage Report for Build 21680290137

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 44.937%

Totals Coverage Status
Change from base Build 21674359722: 0.0%
Covered Lines: 2006
Relevant Lines: 4464

💛 - Coveralls

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 provision CLI command (8 test functions, 41.5% coverage)
  • Added unit tests for the validate CLI 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)
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate require.Error call. This line is redundant as line 83 already checks for an error.

Suggested change
require.Error(t, err)

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,578 @@
/*
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,474 @@
/*
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,373 @@
/*
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,320 @@
/*
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
"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"
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"github.com/NVIDIA/holodeck/cmd/cli/scp"

Copilot uses AI. Check for mistakes.
"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"
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"github.com/NVIDIA/holodeck/cmd/cli/update"

Copilot uses AI. Check for mistakes.
"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"
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"github.com/NVIDIA/holodeck/cmd/cli/get"

Copilot uses AI. Check for mistakes.
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"
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"github.com/NVIDIA/holodeck/cmd/cli/ssh"

Copilot uses AI. Check for mistakes.
Spec: v1alpha1.EnvironmentSpec{
Provider: v1alpha1.ProviderSSH,
Instance: v1alpha1.Instance{
HostUrl: "192.168.1.100"},
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
HostUrl: "192.168.1.100"},
HostUrl: "192.168.1.100",
},

Copilot uses AI. Check for mistakes.
@ArangoGutierrez
Copy link
Collaborator Author

Closing: these tests target provision.go and validate.go which are not on main. PR #621 merged the CLI CRUD operations without these commands.

This PR can be reopened if/when provision and validate commands are added in a future PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants