Refactor installation and runner scripts for enhanced usability and security
- Updated the installation script to clarify that production wrappers do not include fixed test secrets, improving user guidance for local testing. - Modified the jiggablend-manager and jiggablend-runner scripts to remove fixed test configurations, emphasizing the use of local test credentials via `make init-test`. - Enhanced error handling in the runner script to ensure that an API key is provided, improving security and user feedback. - Added new flags and options for the runner, including sandboxing capabilities and GPU ray tracing control, enhancing flexibility for users. - Improved README documentation to reflect changes in usage and configuration, ensuring users have clear instructions for setup and execution.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package api
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseBlenderFrame(t *testing.T) {
|
||||
frame, ok := parseBlenderFrame("Info Fra:2470 Mem:12.00M")
|
||||
@@ -19,3 +22,79 @@ func TestJobTaskCounts_Progress(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseWSTaskUpdate_LegacyErrorObject(t *testing.T) {
|
||||
// Simulates older runners that JSON-marshaled an error interface as {}
|
||||
raw := json.RawMessage(`{"task_id":99,"success":false,"error":{}}`)
|
||||
update, err := parseWSTaskUpdate(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("parseWSTaskUpdate: %v", err)
|
||||
}
|
||||
if update.TaskID != 99 {
|
||||
t.Fatalf("TaskID = %d, want 99", update.TaskID)
|
||||
}
|
||||
if update.Success {
|
||||
t.Fatal("Success = true, want false")
|
||||
}
|
||||
if update.Error != "" {
|
||||
t.Fatalf("Error = %q, want empty (legacy object)", update.Error)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseWSTaskUpdate_StringError(t *testing.T) {
|
||||
raw := json.RawMessage(`{"task_id":7,"success":false,"error":"blender failed: signal: segmentation fault (core dumped)","free_requeue":true}`)
|
||||
update, err := parseWSTaskUpdate(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("parseWSTaskUpdate: %v", err)
|
||||
}
|
||||
if update.TaskID != 7 || update.Success {
|
||||
t.Fatalf("unexpected update: %+v", update)
|
||||
}
|
||||
if update.Error != "blender failed: signal: segmentation fault (core dumped)" {
|
||||
t.Fatalf("Error = %q", update.Error)
|
||||
}
|
||||
if !update.FreeRequeue {
|
||||
t.Fatal("expected FreeRequeue true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatInferredTaskFailure(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
in string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "task failed segfault prefix",
|
||||
in: "Task failed: blender failed: signal: segmentation fault (core dumped)",
|
||||
want: "blender failed: signal: segmentation fault (core dumped)",
|
||||
},
|
||||
{
|
||||
name: "blender render failed prefix",
|
||||
in: "Blender render failed: blender failed: signal: segmentation fault (core dumped)",
|
||||
want: "blender failed: signal: segmentation fault (core dumped)",
|
||||
},
|
||||
{
|
||||
name: "double prefix",
|
||||
in: "Task failed: Blender render failed: blender failed: signal: segmentation fault (core dumped)",
|
||||
want: "blender failed: signal: segmentation fault (core dumped)",
|
||||
},
|
||||
{
|
||||
name: "plain message",
|
||||
in: "blender failed: exit status 1",
|
||||
want: "blender failed: exit status 1",
|
||||
},
|
||||
{
|
||||
name: "empty falls back",
|
||||
in: " ",
|
||||
want: defaultUnexpectedDisconnectError,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := formatInferredTaskFailure(tt.in); got != tt.want {
|
||||
t.Fatalf("formatInferredTaskFailure(%q) = %q, want %q", tt.in, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user