test(integration,unit): update test suites for new features and APIs
Integration test updates: - jupyter_experiment_test.go: update for new workspace handling - run_manifest_test.go: reproducibility manifest validation - secrets_integration_test.go: KMS and secret provider tests - storage_redis_integration_test.go: Redis-backed storage tests Unit test updates: - response_helpers_test.go: API response helper tests - config_hash_test.go: configuration hashing for reproducibility - filetype_test.go: security file type detection tests Load testing: - load_test.go: scheduler load and stress tests
This commit is contained in:
parent
2b1ef10514
commit
2bd7f97ae2
8 changed files with 53 additions and 53 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"slices"
|
|
||||||
"context"
|
"context"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ func TestRunManifestReproducibility(t *testing.T) {
|
||||||
MaxWorkers: 4,
|
MaxWorkers: 4,
|
||||||
SandboxNetworkMode: "none",
|
SandboxNetworkMode: "none",
|
||||||
SandboxNoNewPrivs: true,
|
SandboxNoNewPrivs: true,
|
||||||
ComplianceMode: "standard",
|
ComplianceMode: "standard",
|
||||||
}
|
}
|
||||||
|
|
||||||
m2 := manifest.NewRunManifest("run-2", "task-2", "job-2", created)
|
m2 := manifest.NewRunManifest("run-2", "task-2", "job-2", created)
|
||||||
|
|
@ -74,7 +74,7 @@ func TestRunManifestReproducibility(t *testing.T) {
|
||||||
MaxWorkers: 4,
|
MaxWorkers: 4,
|
||||||
SandboxNetworkMode: "none",
|
SandboxNetworkMode: "none",
|
||||||
SandboxNoNewPrivs: true,
|
SandboxNoNewPrivs: true,
|
||||||
ComplianceMode: "standard",
|
ComplianceMode: "standard",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write manifests
|
// Write manifests
|
||||||
|
|
|
||||||
|
|
@ -147,28 +147,28 @@ func TestSecretsRotation(t *testing.T) {
|
||||||
// TestSecretsPatternDetection validates specific secret pattern detection
|
// TestSecretsPatternDetection validates specific secret pattern detection
|
||||||
func TestSecretsPatternDetection(t *testing.T) {
|
func TestSecretsPatternDetection(t *testing.T) {
|
||||||
patterns := []struct {
|
patterns := []struct {
|
||||||
value string
|
value string
|
||||||
shouldMatch bool
|
shouldMatch bool
|
||||||
pattern string
|
pattern string
|
||||||
}{
|
}{
|
||||||
// AWS patterns
|
// AWS patterns
|
||||||
{"AKIAIOSFODNN7EXAMPLE", true, "AWS Access Key"},
|
{"AKIAIOSFODNN7EXAMPLE", true, "AWS Access Key"},
|
||||||
{"ASIAIOSFODNN7EXAMPLE", true, "AWS Session Key"},
|
{"ASIAIOSFODNN7EXAMPLE", true, "AWS Session Key"},
|
||||||
{"AKIA1234567890", true, "AWS Access Key short"},
|
{"AKIA1234567890", true, "AWS Access Key short"},
|
||||||
|
|
||||||
// GitHub patterns
|
// GitHub patterns
|
||||||
{"ghp_xxxxxxxxxxxxxxxxxxxx", true, "GitHub Personal Token"},
|
{"ghp_xxxxxxxxxxxxxxxxxxxx", true, "GitHub Personal Token"},
|
||||||
{"gho_xxxxxxxxxxxxxxxxxxxx", true, "GitHub OAuth"},
|
{"gho_xxxxxxxxxxxxxxxxxxxx", true, "GitHub OAuth"},
|
||||||
{"github_pat_xxxxxxxxxx", true, "GitHub App Token"},
|
{"github_pat_xxxxxxxxxx", true, "GitHub App Token"},
|
||||||
|
|
||||||
// GitLab patterns
|
// GitLab patterns
|
||||||
{"glpat-xxxxxxxxxxxxxxxx", true, "GitLab Token"},
|
{"glpat-xxxxxxxxxxxxxxxx", true, "GitLab Token"},
|
||||||
|
|
||||||
// OpenAI/Stripe patterns
|
// OpenAI/Stripe patterns
|
||||||
{"sk-xxxxxxxxxxxxxxxxxxxxxxxx", true, "OpenAI/Stripe Secret"},
|
{"sk-xxxxxxxxxxxxxxxxxxxxxxxx", true, "OpenAI/Stripe Secret"},
|
||||||
{"sk_test_xxxxxxxxxxxxxx", true, "Stripe Test Key"},
|
{"sk_test_xxxxxxxxxxxxxx", true, "Stripe Test Key"},
|
||||||
{"sk_live_xxxxxxxxxxxxxx", true, "Stripe Live Key"},
|
{"sk_live_xxxxxxxxxxxxxx", true, "Stripe Live Key"},
|
||||||
|
|
||||||
// Non-secrets that should NOT match
|
// Non-secrets that should NOT match
|
||||||
{"not-a-secret", false, "Plain text"},
|
{"not-a-secret", false, "Plain text"},
|
||||||
{"password123", false, "Simple password"},
|
{"password123", false, "Simple password"},
|
||||||
|
|
@ -181,7 +181,7 @@ func TestSecretsPatternDetection(t *testing.T) {
|
||||||
t.Run(p.pattern, func(t *testing.T) {
|
t.Run(p.pattern, func(t *testing.T) {
|
||||||
// Check if the value looks like a secret
|
// Check if the value looks like a secret
|
||||||
looksLikeSecret := looksLikeSecretHelper(p.value)
|
looksLikeSecret := looksLikeSecretHelper(p.value)
|
||||||
|
|
||||||
if p.shouldMatch && !looksLikeSecret {
|
if p.shouldMatch && !looksLikeSecret {
|
||||||
t.Errorf("Expected '%s' to be detected as secret but wasn't", p.value)
|
t.Errorf("Expected '%s' to be detected as secret but wasn't", p.value)
|
||||||
}
|
}
|
||||||
|
|
@ -200,13 +200,13 @@ func looksLikeSecretHelper(value string) bool {
|
||||||
|
|
||||||
// Check for known secret patterns
|
// Check for known secret patterns
|
||||||
patterns := []string{
|
patterns := []string{
|
||||||
"AKIA", // AWS Access Key
|
"AKIA", // AWS Access Key
|
||||||
"ASIA", // AWS Session Key
|
"ASIA", // AWS Session Key
|
||||||
"ghp_", // GitHub personal
|
"ghp_", // GitHub personal
|
||||||
"gho_", // GitHub OAuth
|
"gho_", // GitHub OAuth
|
||||||
"github_pat_", // GitHub app
|
"github_pat_", // GitHub app
|
||||||
"glpat-", // GitLab
|
"glpat-", // GitLab
|
||||||
"sk-", // OpenAI/Stripe
|
"sk-", // OpenAI/Stripe
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pattern := range patterns {
|
for _, pattern := range patterns {
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ func TestStorageRedisMetricsIntegration(t *testing.T) {
|
||||||
// Record system metrics in Redis
|
// Record system metrics in Redis
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
systemMetricsKey := "ml:metrics:system"
|
systemMetricsKey := "ml:metrics:system"
|
||||||
metricsData := map[string]interface{}{
|
metricsData := map[string]any{
|
||||||
"timestamp": time.Now().Unix(),
|
"timestamp": time.Now().Unix(),
|
||||||
"cpu_total": 85.2,
|
"cpu_total": 85.2,
|
||||||
"memory_total": 4096.0,
|
"memory_total": 4096.0,
|
||||||
|
|
|
||||||
|
|
@ -557,9 +557,9 @@ func (ltr *LoadTestRunner) generatePayload(workerID int) []byte {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
payload := map[string]interface{}{
|
payload := map[string]any{
|
||||||
"job_name": fmt.Sprintf("load-test-job-%d-%d", workerID, time.Now().UnixNano()),
|
"job_name": fmt.Sprintf("load-test-job-%d-%d", workerID, time.Now().UnixNano()),
|
||||||
"args": map[string]interface{}{
|
"args": map[string]any{
|
||||||
"model": "test-model",
|
"model": "test-model",
|
||||||
"data": generateRandomData(ltr.Config.PayloadSize),
|
"data": generateRandomData(ltr.Config.PayloadSize),
|
||||||
"worker_id": workerID,
|
"worker_id": workerID,
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ func TestParseResourceRequest(t *testing.T) {
|
||||||
func TestMarshalJSONOrEmpty(t *testing.T) {
|
func TestMarshalJSONOrEmpty(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
data interface{}
|
data any
|
||||||
want []byte
|
want []byte
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,8 @@ func TestConfigHashPostDefaults(t *testing.T) {
|
||||||
MaxWorkers: 4,
|
MaxWorkers: 4,
|
||||||
GPUVendor: "nvidia",
|
GPUVendor: "nvidia",
|
||||||
Sandbox: worker.SandboxConfig{
|
Sandbox: worker.SandboxConfig{
|
||||||
NetworkMode: "none",
|
NetworkMode: "none",
|
||||||
SeccompProfile: "default-hardened",
|
SeccompProfile: "default-hardened",
|
||||||
NoNewPrivileges: true,
|
NoNewPrivileges: true,
|
||||||
},
|
},
|
||||||
ComplianceMode: "standard",
|
ComplianceMode: "standard",
|
||||||
|
|
@ -115,8 +115,8 @@ func TestConfigHashPostDefaults(t *testing.T) {
|
||||||
MaxWorkers: 4,
|
MaxWorkers: 4,
|
||||||
GPUVendor: "nvidia",
|
GPUVendor: "nvidia",
|
||||||
Sandbox: worker.SandboxConfig{
|
Sandbox: worker.SandboxConfig{
|
||||||
NetworkMode: "none",
|
NetworkMode: "none",
|
||||||
SeccompProfile: "default-hardened",
|
SeccompProfile: "default-hardened",
|
||||||
NoNewPrivileges: true,
|
NoNewPrivileges: true,
|
||||||
},
|
},
|
||||||
ComplianceMode: "standard",
|
ComplianceMode: "standard",
|
||||||
|
|
|
||||||
|
|
@ -12,69 +12,69 @@ func TestValidateFileType_AllowedTypes(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
content []byte
|
content []byte
|
||||||
ext string
|
ext string
|
||||||
wantType string
|
wantType string
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "valid safetensors (ZIP magic)",
|
name: "valid safetensors (ZIP magic)",
|
||||||
content: []byte{0x50, 0x4B, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00},
|
content: []byte{0x50, 0x4B, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00},
|
||||||
ext: ".safetensors",
|
ext: ".safetensors",
|
||||||
wantType: "safetensors",
|
wantType: "safetensors",
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid GGUF",
|
name: "valid GGUF",
|
||||||
content: []byte{0x47, 0x47, 0x55, 0x46, 0x00, 0x00, 0x00, 0x00},
|
content: []byte{0x47, 0x47, 0x55, 0x46, 0x00, 0x00, 0x00, 0x00},
|
||||||
ext: ".gguf",
|
ext: ".gguf",
|
||||||
wantType: "gguf",
|
wantType: "gguf",
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid JSON",
|
name: "valid JSON",
|
||||||
content: []byte(`{"key": "value"}`),
|
content: []byte(`{"key": "value"}`),
|
||||||
ext: ".json",
|
ext: ".json",
|
||||||
wantType: "json",
|
wantType: "json",
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid text file",
|
name: "valid text file",
|
||||||
content: []byte("Hello, World!"),
|
content: []byte("Hello, World!"),
|
||||||
ext: ".txt",
|
ext: ".txt",
|
||||||
wantType: "text",
|
wantType: "text",
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "dangerous pickle extension",
|
name: "dangerous pickle extension",
|
||||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||||
ext: ".pkl",
|
ext: ".pkl",
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "dangerous pytorch extension",
|
name: "dangerous pytorch extension",
|
||||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||||
ext: ".pt",
|
ext: ".pt",
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "executable extension",
|
name: "executable extension",
|
||||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||||
ext: ".exe",
|
ext: ".exe",
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "script extension",
|
name: "script extension",
|
||||||
content: []byte("#!/bin/bash"),
|
content: []byte("#!/bin/bash"),
|
||||||
ext: ".sh",
|
ext: ".sh",
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "archive extension",
|
name: "archive extension",
|
||||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||||
ext: ".zip",
|
ext: ".zip",
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,10 +107,10 @@ func TestValidateModelFile(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
content []byte
|
content []byte
|
||||||
ext string
|
ext string
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "valid model - safetensors",
|
name: "valid model - safetensors",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue