Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ generate-api-docs: $(CRD_REF_DOCS)
.PHONY: test-unit
test-unit:
@echo "> Running tests for operator/api"
@cd operator/api && go test ./...
@make --directory=operator/api test-unit
@echo "> Running tests for operator"
@make --directory=operator test-unit
@echo "> Running tests for operator/client"
Expand All @@ -109,12 +109,16 @@ test-unit:

.PHONY: test-cover
test-cover:
@echo "> Running tests with coverage for operator/api"
@make --directory=operator/api test-cover
@echo "> Running tests with coverage for operator"
@make --directory=operator test-cover

# Generates HTML coverage reports for the entire codebase (all modules)
.PHONY: cover-html
cover-html:
@echo "> Generating HTML coverage report for operator/api"
@make --directory=operator/api cover-html
@echo "> Generating HTML coverage report for operator"
@make --directory=operator cover-html

Expand Down
19 changes: 19 additions & 0 deletions operator/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,22 @@ generate: $(CONTROLLER_GEN)
.PHONY: lint
lint: $(GOLANGCI_LINT)
@$(GOLANGCI_LINT) run -c $(REPO_ROOT)/.golangci.yaml ./...

# Make targets for tests
# -------------------------------------------------------------

# Run all unit tests
.PHONY: test-unit
test-unit:
@go test ./...

# Run all unit tests with code coverage
.PHONY: test-cover
test-cover:
@go test ./... -coverprofile=coverage.out

# Generate HTML coverage report
.PHONY: cover-html
cover-html: test-cover
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated at coverage.html"
2 changes: 2 additions & 0 deletions operator/api/common/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const (
// AnnotationDisableManagedResourceProtection is an annotation set by an operator on a PodCliqueSet to explicitly
// disable protection of managed resources for a PodCliqueSet.
AnnotationDisableManagedResourceProtection = "grove.io/disable-managed-resource-protection"
// AnnotationReconcileTrigger is an annotation set on a PodCliqueSet to explicitly trigger a reconcile without changing its spec.
AnnotationReconcileTrigger = "grove.io/reconcile-trigger"
// AnnotationTopologyName is an annotation set on PodGang to allow KAI scheduler to discover which topology to use.
AnnotationTopologyName = "grove.io/topology-name"
)
Expand Down
3 changes: 3 additions & 0 deletions operator/e2e/diagnostics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ func createDiagnosticsFile(testName, diagDir string) (*os.File, string, error) {

if diagDir != "" {
filename := filepath.Join(diagDir, baseFilename)
if err := os.MkdirAll(diagDir, 0755); err != nil {
return nil, "", fmt.Errorf("failed to create diagnostics directory %s: %w", diagDir, err)
}
file, err := os.Create(filename)
if err != nil {
return nil, "", fmt.Errorf("failed to create diagnostics file in %s: %w", diagDir, err)
Expand Down
3 changes: 2 additions & 1 deletion operator/e2e/grove/workload/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"time"

"github.com/ai-dynamo/grove/operator/api/common/constants"
grovecorev1alpha1 "github.com/ai-dynamo/grove/operator/api/core/v1alpha1"
"github.com/ai-dynamo/grove/operator/e2e/grove/gvk"
"github.com/ai-dynamo/grove/operator/e2e/k8s/k8sclient"
Expand Down Expand Up @@ -79,7 +80,7 @@ func (wm *WorkloadManager) TriggerPCSReconcile(ctx context.Context, namespace, n
Namespace: namespace,
},
}
patch := []byte(fmt.Sprintf(`{"metadata":{"annotations":{"grove.io/reconcile-trigger":%q}}}`, triggerID))
patch := []byte(fmt.Sprintf(`{"metadata":{"annotations":{%q:%q}}}`, constants.AnnotationReconcileTrigger, triggerID))
if err := wm.cl.Patch(ctx, pcs, client.RawPatch(types.MergePatchType, patch)); err != nil {
return fmt.Errorf("trigger PCS reconcile %s/%s: %w", namespace, name, err)
}
Expand Down
7 changes: 6 additions & 1 deletion operator/e2e/testctx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ func (tc *TestContext) GetLabelSelector() string {

// ListPods lists pods matching the current workload's label selector.
func (tc *TestContext) ListPods() (*v1.PodList, error) {
return tc.newPodManager().List(tc.Ctx, tc.Namespace, tc.GetLabelSelector())
return tc.ListPodsWithContext(tc.Ctx)
}

// ListPodsWithContext lists pods matching the current workload's label selector using ctx.
func (tc *TestContext) ListPodsWithContext(ctx context.Context) (*v1.PodList, error) {
return tc.newPodManager().List(ctx, tc.Namespace, tc.GetLabelSelector())
}

// WaitForPods waits for the expected pod count to be ready.
Expand Down
Loading
Loading