Some checks failed
go: build dev binaries / cleanup (push) Successful in 4s
Codespell / Check for spelling errors (push) Failing after 3s
docker: build dev containers / build-rust-binaries (amd64, x86_64-unknown-linux-musl) (push) Failing after 3s
docker: build dev containers / build-dev-containers (push) Has been skipped
docker: build dev containers / build-rust-binaries (arm64, true, aarch64-unknown-linux-musl) (push) Failing after 3s
End to End / FUSE Mount (push) Failing after 2s
EC Integration Tests / EC Integration Tests (push) Failing after 30s
FUSE DLM Integration Tests / FUSE DLM Integration Tests (push) Failing after 3s
FUSE Volume Server Failover Tests / FUSE Volume Server Failover (push) Failing after 3s
FUSE Integration Tests / FUSE Integration Testing (push) Failing after 2s
FUSE P2P Peer Chunk Sharing Integration Tests / FUSE P2P Peer Chunk Sharing (push) Failing after 3s
go: build binary / Go Vet (push) Failing after 2s
go: build binary / Go Vet 32-bit (push) Failing after 3s
go: build binary / Build (push) Failing after 4s
go: build binary / Build cross-platform (freebsd/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (darwin/arm64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/arm64) (push) Failing after 3s
go: build binary / Test (push) Failing after 2s
go: build binary / Test 32-bit (push) Failing after 3s
helm: lint and test charts / lint-test (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (11) (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (17) (push) Failing after 3s
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Failing after 2s
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Failing after 3s
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been skipped
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been skipped
Java Client Unit Tests / Java Unit Tests (11) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (17) (push) Failing after 2s
Java Client Unit Tests / Java Unit Tests (21) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (8) (push) Failing after 3s
Kafka Quick Test (Load Test with Schema Registry) / Kafka Client Load Test (Quick) (push) Failing after 3s
Kafka Gateway Tests / Kafka Unit Tests (unit-tests-1) (push) Failing after 11s
Kafka Gateway Tests / Kafka Integration Tests (Critical) (integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka End-to-End Tests (with SMQ) (e2e-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Consumer Group Tests (Highly Isolated) (consumer-group-1) (push) Failing after 2s
Kafka Gateway Tests / Kafka Client Compatibility (with SMQ) (client-compat-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka SMQ Integration Tests (Full Stack) (smq-integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Protocol Tests (Isolated) (protocol-1) (push) Failing after 3s
KMS Tests / KMS Provider Integration Tests (push) Failing after 2s
KMS Tests / S3 KMS End-to-End Tests (push) Failing after 3s
Master Cold Start Tests / Master Cold Start Tests (push) Failing after 4s
Metadata Subscribe Integration Tests / Metadata Subscribe Integration Tests (push) Failing after 3s
Multi-Master Tests / Multi-Master Failover Tests (push) Failing after 3s
Performance / CPU and Heap Profile (push) Failing after 2s
Performance / S3 Read/Write Benchmark (rust volume) (push) Failing after 3s
pjdfstest POSIX Compliance / pjdfstest (push) Failing after 2s
Plugin Worker Integration Tests / Plugin Worker: erasure_coding (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: vacuum (push) Failing after 3s
Rust Volume Server Tests / Rust Integration Tests (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 1) (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 1) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 3) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Distributed Tests (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Performance Tests (push) Failing after 3s
Performance / Throughput Benchmark (go volume) (push) Failing after 3s
Performance / Throughput Benchmark (rust volume) (push) Failing after 2s
Performance / S3 Read/Write Benchmark (go volume) (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: volume_balance (push) Failing after 3s
PostgreSQL Gateway Tests / PostgreSQL Basic Tests (push) Failing after 3s
Rust Volume Server Tests / Rust Unit Tests (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 3) (push) Failing after 3s
Rust Plugin Worker Tests / Rust Plugin Worker Build and Unit Tests (push) Failing after 3s
rust: build dev volume server binaries / cleanup (push) Successful in 3s
S3 ETag and ACL Tests / S3 ETag + ACL Integration Tests (push) Failing after 3s
S3 IAM Integration Tests / IAM Unit Tests (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (advanced) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (basic) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (group) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (policy-enforcement) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (sts) (push) Failing after 4s
S3 Keycloak Integration Tests / S3 Keycloak Integration Tests (push) Failing after 3s
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.11) (push) Failing after 3s
S3 PyArrow Parquet Tests / Go Unit Tests (Implicit Directory) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.12) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-amd64, x86_64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-arm64, aarch64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-linux (linux-amd64, x86_64-unknown-linux-gnu) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.9) (push) Has been cancelled
S3 Proxy Signature Tests / S3 Proxy Signature Verification Tests (push) Has been cancelled
S3 SDK V2 Route Disambiguation Tests / S3 SDK V2 Routing Tests (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (quick) (push) Has been cancelled
S3 SSE Tests / S3 SSE Compatibility Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Metadata Persistence Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Copy Operations Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Multipart Upload Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Performance Test (push) Has been cancelled
S3 SSE Tests / S3 Volume Encryption Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (comprehensive) (push) Has been cancelled
Spark Integration Tests / Spark Integration Tests (push) Failing after 2s
Telemetry Integration Tests / telemetry-integration-test (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 1) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 1) (push) Failing after 3s
Ceph S3 tests / Basic S3 tests (KV store) (push) Has been cancelled
Ceph S3 tests / S3 Versioning & Object Lock tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Unit Tests (push) Failing after 3s
Ceph S3 tests / S3 CORS tests (push) Has been cancelled
Ceph S3 tests / SeaweedFS Custom S3 Copy tests (push) Has been cancelled
Ceph S3 tests / Basic S3 tests (SQL store) (push) Has been cancelled
test s3 over https using aws-cli / awscli-tests (push) Has been cancelled
TLS Rotation Integration Tests / TLS Rotation Integration Tests (push) Has been cancelled
Vacuum Integration Tests / Vacuum Integration Tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Variables Integration Tests (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (advanced-policy) (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (basic-policy) (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (contextual-policy) (push) Failing after 4s
S3 Policy Integration Tests / Trusted Proxy Detection Tests (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Shell Integration Tests (push) Failing after 3s
Samba on FUSE Integration / samba-integration (push) Failing after 2s
SFTP Integration Tests / SFTP Integration Testing (push) Failing after 3s
terraform: validate and test modules / fmt, validate, plan-level tests (push) Failing after 3s
terraform: validate and test modules / local cluster smoke test (real weed) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 3) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 2) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 2) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 3) (push) Failing after 5s
mount: windows conformance / WinFsp conformance (push) Has been cancelled
mount: windows / Mount on Windows (push) Has been cancelled
632 lines
17 KiB
Go
632 lines
17 KiB
Go
package plugin
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/plugin_pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/worker_pb"
|
|
"google.golang.org/protobuf/proto"
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
func TestPluginLoadsPersistedMonitorStateOnStart(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
dataDir := t.TempDir()
|
|
store, err := NewConfigStore(dataDir)
|
|
if err != nil {
|
|
t.Fatalf("NewConfigStore: %v", err)
|
|
}
|
|
|
|
seedJobs := []TrackedJob{
|
|
{
|
|
JobID: "job-seeded",
|
|
JobType: "vacuum",
|
|
State: "running",
|
|
CreatedAt: timeToPtr(time.Now().UTC().Add(-2 * time.Minute)),
|
|
UpdatedAt: timeToPtr(time.Now().UTC().Add(-1 * time.Minute)),
|
|
},
|
|
}
|
|
seedActivities := []JobActivity{
|
|
{
|
|
JobID: "job-seeded",
|
|
JobType: "vacuum",
|
|
Source: "worker_progress",
|
|
Message: "seeded",
|
|
OccurredAt: timeToPtr(time.Now().UTC().Add(-30 * time.Second)),
|
|
},
|
|
}
|
|
|
|
if err := store.SaveTrackedJobs(seedJobs); err != nil {
|
|
t.Fatalf("SaveTrackedJobs: %v", err)
|
|
}
|
|
if err := store.SaveActivities(seedActivities); err != nil {
|
|
t.Fatalf("SaveActivities: %v", err)
|
|
}
|
|
|
|
pluginSvc, err := New(Options{DataDir: dataDir})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
gotJobs := pluginSvc.ListTrackedJobs("", "", 0)
|
|
if len(gotJobs) != 1 || gotJobs[0].JobID != "job-seeded" {
|
|
t.Fatalf("unexpected loaded jobs: %+v", gotJobs)
|
|
}
|
|
|
|
gotActivities := pluginSvc.ListActivities("", 0)
|
|
if len(gotActivities) != 1 || gotActivities[0].Message != "seeded" {
|
|
t.Fatalf("unexpected loaded activities: %+v", gotActivities)
|
|
}
|
|
}
|
|
|
|
func TestPluginPersistsMonitorStateAfterJobUpdates(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
dataDir := t.TempDir()
|
|
pluginSvc, err := New(Options{DataDir: dataDir})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
job := &plugin_pb.JobSpec{
|
|
JobId: "job-persist",
|
|
JobType: "vacuum",
|
|
Summary: "persist test",
|
|
}
|
|
pluginSvc.trackExecutionStart("req-persist", "worker-a", job, 1)
|
|
|
|
pluginSvc.trackExecutionCompletion(&plugin_pb.JobCompleted{
|
|
RequestId: "req-persist",
|
|
JobId: "job-persist",
|
|
JobType: "vacuum",
|
|
Success: true,
|
|
Result: &plugin_pb.JobResult{Summary: "done"},
|
|
CompletedAt: timestamppb.New(time.Now().UTC()),
|
|
})
|
|
pluginSvc.Shutdown()
|
|
|
|
store, err := NewConfigStore(dataDir)
|
|
if err != nil {
|
|
t.Fatalf("NewConfigStore: %v", err)
|
|
}
|
|
|
|
trackedJobs, err := store.LoadTrackedJobs()
|
|
if err != nil {
|
|
t.Fatalf("LoadTrackedJobs: %v", err)
|
|
}
|
|
if len(trackedJobs) == 0 {
|
|
t.Fatalf("expected persisted tracked jobs")
|
|
}
|
|
|
|
found := false
|
|
for _, tracked := range trackedJobs {
|
|
if tracked.JobID == "job-persist" {
|
|
found = true
|
|
if tracked.State == "" {
|
|
t.Fatalf("persisted job state should not be empty")
|
|
}
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatalf("persisted tracked jobs missing job-persist")
|
|
}
|
|
|
|
activities, err := store.LoadActivities()
|
|
if err != nil {
|
|
t.Fatalf("LoadActivities: %v", err)
|
|
}
|
|
if len(activities) == 0 {
|
|
t.Fatalf("expected persisted activities")
|
|
}
|
|
}
|
|
|
|
func TestTrackExecutionQueuedMarksPendingState(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
pluginSvc, err := New(Options{})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
pluginSvc.trackExecutionQueued(&plugin_pb.JobSpec{
|
|
JobId: "job-pending-1",
|
|
JobType: "vacuum",
|
|
DedupeKey: "vacuum:1",
|
|
Summary: "pending queue item",
|
|
})
|
|
|
|
jobs := pluginSvc.ListTrackedJobs("vacuum", "", 10)
|
|
if len(jobs) != 1 {
|
|
t.Fatalf("expected one tracked pending job, got=%d", len(jobs))
|
|
}
|
|
job := jobs[0]
|
|
if job.JobID != "job-pending-1" {
|
|
t.Fatalf("unexpected pending job id: %s", job.JobID)
|
|
}
|
|
if job.State != "job_state_pending" {
|
|
t.Fatalf("unexpected pending job state: %s", job.State)
|
|
}
|
|
if job.Stage != "queued" {
|
|
t.Fatalf("unexpected pending job stage: %s", job.Stage)
|
|
}
|
|
|
|
activities := pluginSvc.ListActivities("vacuum", 50)
|
|
found := false
|
|
for _, activity := range activities {
|
|
if activity.JobID == "job-pending-1" && activity.Stage == "queued" && activity.Source == "admin_scheduler" {
|
|
found = true
|
|
break
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatalf("expected queued activity for pending job")
|
|
}
|
|
}
|
|
|
|
func TestHandleJobProgressUpdateCarriesWorkerIDInActivities(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
pluginSvc, err := New(Options{})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
job := &plugin_pb.JobSpec{
|
|
JobId: "job-progress-worker",
|
|
JobType: "vacuum",
|
|
}
|
|
pluginSvc.trackExecutionStart("req-progress-worker", "worker-a", job, 1)
|
|
|
|
pluginSvc.handleJobProgressUpdate("worker-a", &plugin_pb.JobProgressUpdate{
|
|
RequestId: "req-progress-worker",
|
|
JobId: "job-progress-worker",
|
|
JobType: "vacuum",
|
|
State: plugin_pb.JobState_JOB_STATE_RUNNING,
|
|
ProgressPercent: 42.0,
|
|
Stage: "scan",
|
|
Message: "in progress",
|
|
Activities: []*plugin_pb.ActivityEvent{
|
|
{
|
|
Source: plugin_pb.ActivitySource_ACTIVITY_SOURCE_EXECUTOR,
|
|
Message: "volume scanned",
|
|
Stage: "scan",
|
|
},
|
|
},
|
|
})
|
|
|
|
activities := pluginSvc.ListActivities("vacuum", 0)
|
|
if len(activities) == 0 {
|
|
t.Fatalf("expected activity entries")
|
|
}
|
|
|
|
foundProgress := false
|
|
foundEvent := false
|
|
for _, activity := range activities {
|
|
if activity.Source == "worker_progress" && activity.Message == "in progress" {
|
|
foundProgress = true
|
|
if activity.WorkerID != "worker-a" {
|
|
t.Fatalf("worker_progress activity worker mismatch: got=%q want=%q", activity.WorkerID, "worker-a")
|
|
}
|
|
}
|
|
if activity.Message == "volume scanned" {
|
|
foundEvent = true
|
|
if activity.WorkerID != "worker-a" {
|
|
t.Fatalf("worker event worker mismatch: got=%q want=%q", activity.WorkerID, "worker-a")
|
|
}
|
|
}
|
|
}
|
|
|
|
if !foundProgress {
|
|
t.Fatalf("expected worker_progress activity")
|
|
}
|
|
if !foundEvent {
|
|
t.Fatalf("expected worker activity event")
|
|
}
|
|
}
|
|
|
|
func TestHandleJobProgressUpdateWithoutJobIDTracksDetectionActivities(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
pluginSvc, err := New(Options{})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
pluginSvc.handleJobProgressUpdate("worker-detector", &plugin_pb.JobProgressUpdate{
|
|
RequestId: "detect-req-1",
|
|
JobType: "vacuum",
|
|
State: plugin_pb.JobState_JOB_STATE_RUNNING,
|
|
Stage: "decision_summary",
|
|
Message: "VACUUM: No tasks created for 3 volumes",
|
|
Activities: []*plugin_pb.ActivityEvent{
|
|
{
|
|
Source: plugin_pb.ActivitySource_ACTIVITY_SOURCE_DETECTOR,
|
|
Stage: "decision_summary",
|
|
Message: "VACUUM: No tasks created for 3 volumes",
|
|
},
|
|
},
|
|
})
|
|
|
|
activities := pluginSvc.ListActivities("vacuum", 0)
|
|
if len(activities) == 0 {
|
|
t.Fatalf("expected activity entries")
|
|
}
|
|
|
|
foundDetectionProgress := false
|
|
foundDetectorEvent := false
|
|
for _, activity := range activities {
|
|
if activity.RequestID != "detect-req-1" {
|
|
continue
|
|
}
|
|
if activity.Source == "worker_detection" {
|
|
foundDetectionProgress = true
|
|
if activity.WorkerID != "worker-detector" {
|
|
t.Fatalf("worker_detection worker mismatch: got=%q want=%q", activity.WorkerID, "worker-detector")
|
|
}
|
|
}
|
|
if activity.Source == "activity_source_detector" {
|
|
foundDetectorEvent = true
|
|
if activity.WorkerID != "worker-detector" {
|
|
t.Fatalf("detector event worker mismatch: got=%q want=%q", activity.WorkerID, "worker-detector")
|
|
}
|
|
}
|
|
}
|
|
|
|
if !foundDetectionProgress {
|
|
t.Fatalf("expected worker_detection activity")
|
|
}
|
|
if !foundDetectorEvent {
|
|
t.Fatalf("expected detector activity event")
|
|
}
|
|
}
|
|
|
|
func TestHandleJobCompletedCarriesWorkerIDInActivitiesAndRunHistory(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
pluginSvc, err := New(Options{})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
job := &plugin_pb.JobSpec{
|
|
JobId: "job-complete-worker",
|
|
JobType: "vacuum",
|
|
}
|
|
pluginSvc.trackExecutionStart("req-complete-worker", "worker-b", job, 1)
|
|
|
|
pluginSvc.handleJobCompleted(&plugin_pb.JobCompleted{
|
|
RequestId: "req-complete-worker",
|
|
JobId: "job-complete-worker",
|
|
JobType: "vacuum",
|
|
Success: true,
|
|
Activities: []*plugin_pb.ActivityEvent{
|
|
{
|
|
Source: plugin_pb.ActivitySource_ACTIVITY_SOURCE_EXECUTOR,
|
|
Message: "finalizer done",
|
|
Stage: "finalize",
|
|
},
|
|
},
|
|
CompletedAt: timestamppb.Now(),
|
|
})
|
|
pluginSvc.Shutdown()
|
|
|
|
activities := pluginSvc.ListActivities("vacuum", 0)
|
|
foundWorkerEvent := false
|
|
for _, activity := range activities {
|
|
if activity.Message == "finalizer done" {
|
|
foundWorkerEvent = true
|
|
if activity.WorkerID != "worker-b" {
|
|
t.Fatalf("worker completion event worker mismatch: got=%q want=%q", activity.WorkerID, "worker-b")
|
|
}
|
|
}
|
|
}
|
|
if !foundWorkerEvent {
|
|
t.Fatalf("expected completion worker event activity")
|
|
}
|
|
|
|
history, err := pluginSvc.LoadRunHistory("vacuum")
|
|
if err != nil {
|
|
t.Fatalf("LoadRunHistory: %v", err)
|
|
}
|
|
if history == nil || len(history.SuccessfulRuns) == 0 {
|
|
t.Fatalf("expected successful run history entry")
|
|
}
|
|
if history.SuccessfulRuns[0].WorkerID != "worker-b" {
|
|
t.Fatalf("run history worker mismatch: got=%q want=%q", history.SuccessfulRuns[0].WorkerID, "worker-b")
|
|
}
|
|
}
|
|
|
|
func TestTrackExecutionStartStoresJobPayloadDetails(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
pluginSvc, err := New(Options{DataDir: t.TempDir()})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
pluginSvc.trackExecutionStart("req-payload", "worker-c", &plugin_pb.JobSpec{
|
|
JobId: "job-payload",
|
|
JobType: "vacuum",
|
|
Summary: "payload summary",
|
|
Detail: "payload detail",
|
|
Parameters: map[string]*plugin_pb.ConfigValue{
|
|
"volume_id": {
|
|
Kind: &plugin_pb.ConfigValue_Int64Value{Int64Value: 9},
|
|
},
|
|
},
|
|
Labels: map[string]string{
|
|
"source": "detector",
|
|
},
|
|
}, 2)
|
|
pluginSvc.Shutdown()
|
|
|
|
job, found := pluginSvc.GetTrackedJob("job-payload")
|
|
if !found || job == nil {
|
|
t.Fatalf("expected tracked job")
|
|
}
|
|
if job.Detail != "" {
|
|
t.Fatalf("expected in-memory tracked job detail to be stripped, got=%q", job.Detail)
|
|
}
|
|
if job.Attempt != 2 {
|
|
t.Fatalf("unexpected attempt: %d", job.Attempt)
|
|
}
|
|
if len(job.Labels) != 0 {
|
|
t.Fatalf("expected in-memory labels to be stripped, got=%+v", job.Labels)
|
|
}
|
|
if len(job.Parameters) != 0 {
|
|
t.Fatalf("expected in-memory parameters to be stripped, got=%+v", job.Parameters)
|
|
}
|
|
|
|
detail, found, err := pluginSvc.BuildJobDetail("job-payload", 100, 0)
|
|
if err != nil {
|
|
t.Fatalf("BuildJobDetail: %v", err)
|
|
}
|
|
if !found || detail == nil || detail.Job == nil {
|
|
t.Fatalf("expected disk-backed job detail")
|
|
}
|
|
if detail.Job.Detail != "payload detail" {
|
|
t.Fatalf("unexpected disk-backed detail: %q", detail.Job.Detail)
|
|
}
|
|
if got := detail.Job.Labels["source"]; got != "detector" {
|
|
t.Fatalf("unexpected disk-backed label source: %q", got)
|
|
}
|
|
if got, ok := detail.Job.Parameters["volume_id"].(map[string]interface{}); !ok || got["int64_value"] != "9" {
|
|
t.Fatalf("unexpected disk-backed parameters payload: %#v", detail.Job.Parameters["volume_id"])
|
|
}
|
|
}
|
|
|
|
func TestTrackExecutionStartStoresErasureCodingExecutionPlan(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
pluginSvc, err := New(Options{DataDir: t.TempDir()})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
taskParams := &worker_pb.TaskParams{
|
|
TaskId: "task-ec-1",
|
|
VolumeId: 29,
|
|
Collection: "photos",
|
|
Sources: []*worker_pb.TaskSource{
|
|
{
|
|
Node: "source-a:8080",
|
|
DataCenter: "dc1",
|
|
Rack: "rack1",
|
|
VolumeId: 29,
|
|
DiskId: 5,
|
|
},
|
|
},
|
|
Targets: []*worker_pb.TaskTarget{
|
|
{
|
|
Node: "target-a:8080",
|
|
DataCenter: "dc1",
|
|
Rack: "rack2",
|
|
VolumeId: 29,
|
|
DiskId: 2,
|
|
ShardIds: []uint32{0, 10},
|
|
},
|
|
{
|
|
Node: "target-b:8080",
|
|
DataCenter: "dc2",
|
|
Rack: "rack3",
|
|
VolumeId: 29,
|
|
DiskId: 3,
|
|
ShardIds: []uint32{1, 11},
|
|
},
|
|
},
|
|
TaskParams: &worker_pb.TaskParams_ErasureCodingParams{
|
|
ErasureCodingParams: &worker_pb.ErasureCodingTaskParams{
|
|
DataShards: 10,
|
|
ParityShards: 4,
|
|
},
|
|
},
|
|
}
|
|
payload, err := proto.Marshal(taskParams)
|
|
if err != nil {
|
|
t.Fatalf("Marshal task params: %v", err)
|
|
}
|
|
|
|
pluginSvc.trackExecutionStart("req-ec-plan", "worker-ec", &plugin_pb.JobSpec{
|
|
JobId: "job-ec-plan",
|
|
JobType: "erasure_coding",
|
|
Parameters: map[string]*plugin_pb.ConfigValue{
|
|
"task_params_pb": {
|
|
Kind: &plugin_pb.ConfigValue_BytesValue{BytesValue: payload},
|
|
},
|
|
},
|
|
}, 1)
|
|
pluginSvc.Shutdown()
|
|
|
|
detail, found, err := pluginSvc.BuildJobDetail("job-ec-plan", 100, 0)
|
|
if err != nil {
|
|
t.Fatalf("BuildJobDetail: %v", err)
|
|
}
|
|
if !found || detail == nil || detail.Job == nil {
|
|
t.Fatalf("expected disk-backed detail")
|
|
}
|
|
|
|
rawPlan, ok := detail.Job.Parameters["execution_plan"]
|
|
if !ok {
|
|
t.Fatalf("expected execution_plan in parameters, got=%+v", detail.Job.Parameters)
|
|
}
|
|
plan, ok := rawPlan.(map[string]interface{})
|
|
if !ok {
|
|
t.Fatalf("unexpected execution_plan type: %T", rawPlan)
|
|
}
|
|
if plan["job_type"] != "erasure_coding" {
|
|
t.Fatalf("unexpected execution plan job type: %+v", plan["job_type"])
|
|
}
|
|
if plan["volume_id"] != float64(29) {
|
|
t.Fatalf("unexpected execution plan volume id: %+v", plan["volume_id"])
|
|
}
|
|
sourcesRaw, ok := plan["sources"].([]interface{})
|
|
if !ok || len(sourcesRaw) != 1 {
|
|
t.Fatalf("unexpected sources in execution plan: %+v", plan["sources"])
|
|
}
|
|
firstSource, ok := sourcesRaw[0].(map[string]interface{})
|
|
if !ok {
|
|
t.Fatalf("unexpected source payload: %+v", sourcesRaw[0])
|
|
}
|
|
if firstSource["disk_id"] != float64(5) {
|
|
t.Fatalf("unexpected source disk_id: %+v", firstSource["disk_id"])
|
|
}
|
|
targets, ok := plan["targets"].([]interface{})
|
|
if !ok || len(targets) != 2 {
|
|
t.Fatalf("unexpected targets in execution plan: %+v", plan["targets"])
|
|
}
|
|
firstTarget, ok := targets[0].(map[string]interface{})
|
|
if !ok {
|
|
t.Fatalf("unexpected target payload: %+v", targets[0])
|
|
}
|
|
if firstTarget["disk_id"] != float64(2) {
|
|
t.Fatalf("unexpected target disk_id: %+v", firstTarget["disk_id"])
|
|
}
|
|
assignments, ok := plan["shard_assignments"].([]interface{})
|
|
if !ok || len(assignments) != 4 {
|
|
t.Fatalf("unexpected shard assignments in execution plan: %+v", plan["shard_assignments"])
|
|
}
|
|
firstAssignment, ok := assignments[0].(map[string]interface{})
|
|
if !ok {
|
|
t.Fatalf("unexpected first assignment payload: %+v", assignments[0])
|
|
}
|
|
if firstAssignment["shard_id"] != float64(0) || firstAssignment["kind"] != "data" {
|
|
t.Fatalf("unexpected first assignment: %+v", firstAssignment)
|
|
}
|
|
if firstAssignment["target_disk_id"] != float64(2) {
|
|
t.Fatalf("unexpected first assignment target_disk_id: %+v", firstAssignment["target_disk_id"])
|
|
}
|
|
secondAssignment, ok := assignments[1].(map[string]interface{})
|
|
if !ok {
|
|
t.Fatalf("unexpected second assignment payload: %+v", assignments[1])
|
|
}
|
|
if secondAssignment["shard_id"] != float64(1) || secondAssignment["target_disk_id"] != float64(3) {
|
|
t.Fatalf("unexpected second assignment: %+v", secondAssignment)
|
|
}
|
|
}
|
|
|
|
func TestBuildJobDetailIncludesActivitiesAndRunRecord(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
pluginSvc, err := New(Options{DataDir: t.TempDir()})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
pluginSvc.trackExecutionStart("req-detail", "worker-z", &plugin_pb.JobSpec{
|
|
JobId: "job-detail",
|
|
JobType: "vacuum",
|
|
Summary: "detail summary",
|
|
}, 1)
|
|
pluginSvc.handleJobProgressUpdate("worker-z", &plugin_pb.JobProgressUpdate{
|
|
RequestId: "req-detail",
|
|
JobId: "job-detail",
|
|
JobType: "vacuum",
|
|
State: plugin_pb.JobState_JOB_STATE_RUNNING,
|
|
Stage: "scan",
|
|
Message: "scanning volume",
|
|
})
|
|
pluginSvc.handleJobCompleted(&plugin_pb.JobCompleted{
|
|
RequestId: "req-detail",
|
|
JobId: "job-detail",
|
|
JobType: "vacuum",
|
|
Success: true,
|
|
Result: &plugin_pb.JobResult{
|
|
Summary: "done",
|
|
OutputValues: map[string]*plugin_pb.ConfigValue{
|
|
"affected": {
|
|
Kind: &plugin_pb.ConfigValue_Int64Value{Int64Value: 1},
|
|
},
|
|
},
|
|
},
|
|
CompletedAt: timestamppb.Now(),
|
|
})
|
|
pluginSvc.Shutdown()
|
|
|
|
detail, found, err := pluginSvc.BuildJobDetail("job-detail", 100, 5)
|
|
if err != nil {
|
|
t.Fatalf("BuildJobDetail error: %v", err)
|
|
}
|
|
if !found || detail == nil {
|
|
t.Fatalf("expected job detail")
|
|
}
|
|
if detail.Job == nil || detail.Job.JobID != "job-detail" {
|
|
t.Fatalf("unexpected job detail payload: %+v", detail.Job)
|
|
}
|
|
if detail.RunRecord == nil || detail.RunRecord.JobID != "job-detail" {
|
|
t.Fatalf("expected run record for job-detail, got=%+v", detail.RunRecord)
|
|
}
|
|
if len(detail.Activities) == 0 {
|
|
t.Fatalf("expected activity timeline entries")
|
|
}
|
|
if detail.Job.ResultOutputValues == nil {
|
|
t.Fatalf("expected result output values")
|
|
}
|
|
}
|
|
|
|
func TestBuildJobDetailLoadsFromDiskWhenMemoryCleared(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
pluginSvc, err := New(Options{DataDir: t.TempDir()})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
defer pluginSvc.Shutdown()
|
|
|
|
pluginSvc.trackExecutionStart("req-disk", "worker-d", &plugin_pb.JobSpec{
|
|
JobId: "job-disk",
|
|
JobType: "vacuum",
|
|
Summary: "disk summary",
|
|
Detail: "disk detail payload",
|
|
}, 1)
|
|
pluginSvc.Shutdown()
|
|
|
|
pluginSvc.jobsMu.Lock()
|
|
pluginSvc.jobs = map[string]*TrackedJob{}
|
|
pluginSvc.jobsMu.Unlock()
|
|
pluginSvc.activitiesMu.Lock()
|
|
pluginSvc.activities = nil
|
|
pluginSvc.activitiesMu.Unlock()
|
|
|
|
detail, found, err := pluginSvc.BuildJobDetail("job-disk", 100, 0)
|
|
if err != nil {
|
|
t.Fatalf("BuildJobDetail: %v", err)
|
|
}
|
|
if !found || detail == nil || detail.Job == nil {
|
|
t.Fatalf("expected detail from disk")
|
|
}
|
|
if detail.Job.Detail != "disk detail payload" {
|
|
t.Fatalf("unexpected disk detail payload: %q", detail.Job.Detail)
|
|
}
|
|
}
|