feat: add runtime interface and fake implementation#59
feat: add runtime interface and fake implementation#59feloy merged 2 commits intokortex-hub:mainfrom
Conversation
📝 WalkthroughWalkthroughA new runtime package is introduced with a pluggable Runtime interface defining lifecycle methods, data structures for creation parameters and runtime metadata, and standard error definitions. A fake in-memory runtime implementation and a thread-safe registry system for managing runtime instances complete the foundation. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Signed-off-by: Philippe Martin <phmartin@redhat.com> Co-Authored-By: Claude Code (Claude Sonnet 4.5) <noreply@anthropic.com>
Signed-off-by: Philippe Martin <phmartin@redhat.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/runtime/fake/fake_test.go (1)
255-262: Addt.Parallel()to subtests for parallel execution.Per coding guidelines, subtests should also call
t.Parallel(). Since subtests share thertinstance, each subtest should create its own runtime to enable safe parallel execution.♻️ Suggested fix
for _, tt := range tests { + tt := tt // capture range variable for parallel subtests t.Run(tt.name, func(t *testing.T) { + t.Parallel() + rt := New() + ctx := context.Background() _, err := rt.Create(ctx, tt.params) if !errors.Is(err, runtime.ErrInvalidParams) { t.Errorf("Expected ErrInvalidParams, got %v", err) } }) }As per coding guidelines: "All Go test functions must call
t.Parallel()as the first line of the test function".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/runtime/fake/fake_test.go` around lines 255 - 262, The subtests need to call t.Parallel() and must not share the parent rt instance: inside the t.Run callback for each loop iteration, add t.Parallel() as the first statement and initialize a fresh runtime (instead of using the outer shared rt) so each subtest uses its own runtime before calling rt.Create(ctx, tt.params); ensure the parent test also calls t.Parallel() at its start if applicable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/runtime/fake/fake_test.go`:
- Around line 255-262: The subtests need to call t.Parallel() and must not share
the parent rt instance: inside the t.Run callback for each loop iteration, add
t.Parallel() as the first statement and initialize a fresh runtime (instead of
using the outer shared rt) so each subtest uses its own runtime before calling
rt.Create(ctx, tt.params); ensure the parent test also calls t.Parallel() at its
start if applicable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8af42093-654b-47f8-afbb-a0405ecdca0a
📒 Files selected for processing (6)
pkg/runtime/errors.gopkg/runtime/fake/fake.gopkg/runtime/fake/fake_test.gopkg/runtime/registry.gopkg/runtime/registry_test.gopkg/runtime/runtime.go
fixes #46
fixes #52