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
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"context"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func TestRunManifestReproducibility(t *testing.T) {
|
|||
MaxWorkers: 4,
|
||||
SandboxNetworkMode: "none",
|
||||
SandboxNoNewPrivs: true,
|
||||
ComplianceMode: "standard",
|
||||
ComplianceMode: "standard",
|
||||
}
|
||||
|
||||
m2 := manifest.NewRunManifest("run-2", "task-2", "job-2", created)
|
||||
|
|
@ -74,7 +74,7 @@ func TestRunManifestReproducibility(t *testing.T) {
|
|||
MaxWorkers: 4,
|
||||
SandboxNetworkMode: "none",
|
||||
SandboxNoNewPrivs: true,
|
||||
ComplianceMode: "standard",
|
||||
ComplianceMode: "standard",
|
||||
}
|
||||
|
||||
// Write manifests
|
||||
|
|
|
|||
|
|
@ -147,28 +147,28 @@ func TestSecretsRotation(t *testing.T) {
|
|||
// TestSecretsPatternDetection validates specific secret pattern detection
|
||||
func TestSecretsPatternDetection(t *testing.T) {
|
||||
patterns := []struct {
|
||||
value string
|
||||
value string
|
||||
shouldMatch bool
|
||||
pattern string
|
||||
pattern string
|
||||
}{
|
||||
// AWS patterns
|
||||
{"AKIAIOSFODNN7EXAMPLE", true, "AWS Access Key"},
|
||||
{"ASIAIOSFODNN7EXAMPLE", true, "AWS Session Key"},
|
||||
{"AKIA1234567890", true, "AWS Access Key short"},
|
||||
|
||||
// GitHub patterns
|
||||
|
||||
// GitHub patterns
|
||||
{"ghp_xxxxxxxxxxxxxxxxxxxx", true, "GitHub Personal Token"},
|
||||
{"gho_xxxxxxxxxxxxxxxxxxxx", true, "GitHub OAuth"},
|
||||
{"github_pat_xxxxxxxxxx", true, "GitHub App Token"},
|
||||
|
||||
|
||||
// GitLab patterns
|
||||
{"glpat-xxxxxxxxxxxxxxxx", true, "GitLab Token"},
|
||||
|
||||
|
||||
// OpenAI/Stripe patterns
|
||||
{"sk-xxxxxxxxxxxxxxxxxxxxxxxx", true, "OpenAI/Stripe Secret"},
|
||||
{"sk_test_xxxxxxxxxxxxxx", true, "Stripe Test Key"},
|
||||
{"sk_live_xxxxxxxxxxxxxx", true, "Stripe Live Key"},
|
||||
|
||||
|
||||
// Non-secrets that should NOT match
|
||||
{"not-a-secret", false, "Plain text"},
|
||||
{"password123", false, "Simple password"},
|
||||
|
|
@ -181,7 +181,7 @@ func TestSecretsPatternDetection(t *testing.T) {
|
|||
t.Run(p.pattern, func(t *testing.T) {
|
||||
// Check if the value looks like a secret
|
||||
looksLikeSecret := looksLikeSecretHelper(p.value)
|
||||
|
||||
|
||||
if p.shouldMatch && !looksLikeSecret {
|
||||
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
|
||||
patterns := []string{
|
||||
"AKIA", // AWS Access Key
|
||||
"ASIA", // AWS Session Key
|
||||
"ghp_", // GitHub personal
|
||||
"gho_", // GitHub OAuth
|
||||
"AKIA", // AWS Access Key
|
||||
"ASIA", // AWS Session Key
|
||||
"ghp_", // GitHub personal
|
||||
"gho_", // GitHub OAuth
|
||||
"github_pat_", // GitHub app
|
||||
"glpat-", // GitLab
|
||||
"sk-", // OpenAI/Stripe
|
||||
"glpat-", // GitLab
|
||||
"sk-", // OpenAI/Stripe
|
||||
}
|
||||
|
||||
for _, pattern := range patterns {
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ func TestStorageRedisMetricsIntegration(t *testing.T) {
|
|||
// Record system metrics in Redis
|
||||
ctx := context.Background()
|
||||
systemMetricsKey := "ml:metrics:system"
|
||||
metricsData := map[string]interface{}{
|
||||
metricsData := map[string]any{
|
||||
"timestamp": time.Now().Unix(),
|
||||
"cpu_total": 85.2,
|
||||
"memory_total": 4096.0,
|
||||
|
|
|
|||
|
|
@ -557,9 +557,9 @@ func (ltr *LoadTestRunner) generatePayload(workerID int) []byte {
|
|||
return nil
|
||||
}
|
||||
|
||||
payload := map[string]interface{}{
|
||||
payload := map[string]any{
|
||||
"job_name": fmt.Sprintf("load-test-job-%d-%d", workerID, time.Now().UnixNano()),
|
||||
"args": map[string]interface{}{
|
||||
"args": map[string]any{
|
||||
"model": "test-model",
|
||||
"data": generateRandomData(ltr.Config.PayloadSize),
|
||||
"worker_id": workerID,
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ func TestParseResourceRequest(t *testing.T) {
|
|||
func TestMarshalJSONOrEmpty(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
data interface{}
|
||||
data any
|
||||
want []byte
|
||||
}{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ func TestConfigHashPostDefaults(t *testing.T) {
|
|||
MaxWorkers: 4,
|
||||
GPUVendor: "nvidia",
|
||||
Sandbox: worker.SandboxConfig{
|
||||
NetworkMode: "none",
|
||||
SeccompProfile: "default-hardened",
|
||||
NetworkMode: "none",
|
||||
SeccompProfile: "default-hardened",
|
||||
NoNewPrivileges: true,
|
||||
},
|
||||
ComplianceMode: "standard",
|
||||
|
|
@ -115,8 +115,8 @@ func TestConfigHashPostDefaults(t *testing.T) {
|
|||
MaxWorkers: 4,
|
||||
GPUVendor: "nvidia",
|
||||
Sandbox: worker.SandboxConfig{
|
||||
NetworkMode: "none",
|
||||
SeccompProfile: "default-hardened",
|
||||
NetworkMode: "none",
|
||||
SeccompProfile: "default-hardened",
|
||||
NoNewPrivileges: true,
|
||||
},
|
||||
ComplianceMode: "standard",
|
||||
|
|
|
|||
|
|
@ -12,69 +12,69 @@ func TestValidateFileType_AllowedTypes(t *testing.T) {
|
|||
tempDir := t.TempDir()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
content []byte
|
||||
ext string
|
||||
wantType string
|
||||
wantErr bool
|
||||
name string
|
||||
content []byte
|
||||
ext string
|
||||
wantType string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "valid safetensors (ZIP magic)",
|
||||
content: []byte{0x50, 0x4B, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00},
|
||||
ext: ".safetensors",
|
||||
ext: ".safetensors",
|
||||
wantType: "safetensors",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "valid GGUF",
|
||||
content: []byte{0x47, 0x47, 0x55, 0x46, 0x00, 0x00, 0x00, 0x00},
|
||||
ext: ".gguf",
|
||||
ext: ".gguf",
|
||||
wantType: "gguf",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "valid JSON",
|
||||
content: []byte(`{"key": "value"}`),
|
||||
ext: ".json",
|
||||
ext: ".json",
|
||||
wantType: "json",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "valid text file",
|
||||
content: []byte("Hello, World!"),
|
||||
ext: ".txt",
|
||||
ext: ".txt",
|
||||
wantType: "text",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "dangerous pickle extension",
|
||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||
name: "dangerous pickle extension",
|
||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||
ext: ".pkl",
|
||||
wantErr: true,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "dangerous pytorch extension",
|
||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||
name: "dangerous pytorch extension",
|
||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||
ext: ".pt",
|
||||
wantErr: true,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "executable extension",
|
||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||
name: "executable extension",
|
||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||
ext: ".exe",
|
||||
wantErr: true,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "script extension",
|
||||
content: []byte("#!/bin/bash"),
|
||||
name: "script extension",
|
||||
content: []byte("#!/bin/bash"),
|
||||
ext: ".sh",
|
||||
wantErr: true,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "archive extension",
|
||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||
name: "archive extension",
|
||||
content: []byte{0x00, 0x00, 0x00, 0x00},
|
||||
ext: ".zip",
|
||||
wantErr: true,
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -107,10 +107,10 @@ func TestValidateModelFile(t *testing.T) {
|
|||
tempDir := t.TempDir()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
content []byte
|
||||
ext string
|
||||
wantErr bool
|
||||
name string
|
||||
content []byte
|
||||
ext string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "valid model - safetensors",
|
||||
|
|
|
|||
Loading…
Reference in a new issue