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:
@@ -2,11 +2,14 @@ package runner
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewRunner_InitializesFields(t *testing.T) {
|
||||
r := New("http://localhost:8080", "runner-a", "host-a", false)
|
||||
r := New("http://localhost:8080", "runner-a", "host-a", false, false, 0)
|
||||
if r == nil {
|
||||
t.Fatal("New should return a runner")
|
||||
}
|
||||
@@ -16,15 +19,26 @@ func TestNewRunner_InitializesFields(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRunner_GPUFlagsSetters(t *testing.T) {
|
||||
r := New("http://localhost:8080", "runner-a", "host-a", false)
|
||||
r.SetGPULockedOut(true)
|
||||
r := New("http://localhost:8080", "runner-a", "host-a", false, false, 0)
|
||||
if newly := r.SetGPULockedOut(true); !newly {
|
||||
t.Fatal("expected first SetGPULockedOut(true) to report newly enabled")
|
||||
}
|
||||
if !r.IsGPULockedOut() {
|
||||
t.Fatal("expected GPU lockout to be true")
|
||||
}
|
||||
if newly := r.SetGPULockedOut(true); newly {
|
||||
t.Fatal("expected second SetGPULockedOut(true) to be a no-op transition")
|
||||
}
|
||||
if newly := r.SetGPULockedOut(false); newly {
|
||||
t.Fatal("clearing lockout should not report newly enabled")
|
||||
}
|
||||
if r.IsGPULockedOut() {
|
||||
t.Fatal("expected GPU lockout cleared")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateFingerprint_PopulatesValue(t *testing.T) {
|
||||
r := New("http://localhost:8080", "runner-a", "host-a", false)
|
||||
r := New("http://localhost:8080", "runner-a", "host-a", false, false, 0)
|
||||
r.generateFingerprint()
|
||||
fp := r.GetFingerprint()
|
||||
if fp == "" {
|
||||
@@ -38,3 +52,45 @@ func TestGenerateFingerprint_PopulatesValue(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUploadOutputFiles_FailsWhenUploadErrors(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(dir, "frame_0001.exr"), []byte("x"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err := uploadOutputFiles(dir, func(filePath, fileName string) error {
|
||||
return errors.New("upload denied")
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected error when upload fails")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUploadOutputFiles_FailsWhenEmpty(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
err := uploadOutputFiles(dir, func(filePath, fileName string) error {
|
||||
t.Fatal("upload should not be called")
|
||||
return nil
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected error for empty output dir")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUploadOutputFiles_Success(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(dir, "frame_0001.exr"), []byte("x"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var seen string
|
||||
err := uploadOutputFiles(dir, func(filePath, fileName string) error {
|
||||
seen = fileName
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("uploadOutputFiles: %v", err)
|
||||
}
|
||||
if seen != "frame_0001.exr" {
|
||||
t.Fatalf("got %q", seen)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user