-
Notifications
You must be signed in to change notification settings - Fork 1
feat(orchestrator): add AWS S3 seed objects to LocalStack init #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
010edd6
feat(orchestrator): add AWS S3 seed objects to LocalStack init
erenaslandev 51126d6
refactor(runner): make generic mid delivery action method
erenaslandev 00d90b5
fix(runner): add missing container cleanup, correct function comment and
erenaslandev fc4fbb4
feat(runner): aggregate resource metrics for crash/restart
erenaslandev 5210813
fix(results): skip only truly idle containers in aggregation, not
erenaslandev ff5c920
fix: support multi-container metric collection
erenaslandev fb36f09
fix(collector): floor CPU idle at 0 when summed usage exceeds 100%
erenaslandev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| package results | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| func writeMetricsCSV(t *testing.T, rows string) string { | ||
| t.Helper() | ||
| path := filepath.Join(t.TempDir(), "metrics.csv") | ||
| header := "epoch,cpu_usr,mem_used,net_recv,net_send,dsk_read,dsk_writ,load_avg1,load_avg5,load_avg15\n" | ||
| if err := os.WriteFile(path, []byte(header+rows), 0o644); err != nil { | ||
| t.Fatalf("writing csv: %v", err) | ||
| } | ||
| return path | ||
| } | ||
|
|
||
| func TestAggregateAllMetricsFromCSV(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| // Stopped-container samples (cpu 0 AND mem 0) are dropped so the | ||
| // crash/restart down window doesn't dilute the averages. | ||
| t.Run("all-zero rows skipped", func(t *testing.T) { | ||
| t.Parallel() | ||
| csv := writeMetricsCSV(t, | ||
| "100,0,0,0,0,0,0,0,0,0\n"+ | ||
| "101,10,104857600,0,0,0,0,0,0,0\n"+ | ||
| "102,0,0,0,0,0,0,0,0,0\n"+ | ||
| "103,20,209715200,0,0,0,0,0,0,0\n") | ||
| m, err := AggregateAllMetricsFromCSV(csv) | ||
| if err != nil { | ||
| t.Fatalf("aggregate: %v", err) | ||
| } | ||
| if m.Samples != 2 { | ||
| t.Fatalf("Samples = %d, want 2", m.Samples) | ||
| } | ||
| if m.CPUAvg != 15 || m.CPUMax != 20 { | ||
| t.Fatalf("cpu avg/max = %v/%v, want 15/20", m.CPUAvg, m.CPUMax) | ||
| } | ||
| if m.MemAvgMB != 150 || m.MemMaxMB != 200 { | ||
| t.Fatalf("mem avg/max = %v/%v, want 150/200", m.MemAvgMB, m.MemMaxMB) | ||
| } | ||
| }) | ||
|
|
||
| // A running-but-idle sample (cpu 0, mem > 0) is a real sample and stays. | ||
| t.Run("idle row kept", func(t *testing.T) { | ||
| t.Parallel() | ||
| csv := writeMetricsCSV(t, | ||
| "100,0,104857600,0,0,0,0,0,0,0\n"+ | ||
| "101,10,104857600,0,0,0,0,0,0,0\n") | ||
| m, err := AggregateAllMetricsFromCSV(csv) | ||
| if err != nil { | ||
| t.Fatalf("aggregate: %v", err) | ||
| } | ||
| if m.Samples != 2 { | ||
| t.Fatalf("Samples = %d, want 2", m.Samples) | ||
| } | ||
| if m.CPUAvg != 5 { | ||
| t.Fatalf("CPUAvg = %v, want 5", m.CPUAvg) | ||
| } | ||
| }) | ||
|
|
||
| // Net/disk totals accumulate only over surviving rows. | ||
| t.Run("io totals over kept rows", func(t *testing.T) { | ||
| t.Parallel() | ||
| csv := writeMetricsCSV(t, | ||
| "100,0,0,999,999,999,999,0,0,0\n"+ | ||
| "101,10,104857600,100,200,300,400,0,0,0\n") | ||
| m, err := AggregateAllMetricsFromCSV(csv) | ||
| if err != nil { | ||
| t.Fatalf("aggregate: %v", err) | ||
| } | ||
| if m.NetRecv != 100 || m.NetSend != 200 || m.DiskRead != 300 || m.DiskWrite != 400 { | ||
| t.Fatalf("io = net %d/%d disk %d/%d, want 100/200 300/400", | ||
| m.NetRecv, m.NetSend, m.DiskRead, m.DiskWrite) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| func TestAggregateAllMetricsFromCSVWindow(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| // The epoch window filter still applies alongside the zero-row skip. | ||
| csv := writeMetricsCSV(t, | ||
| "100,10,104857600,0,0,0,0,0,0,0\n"+ | ||
| "200,0,0,0,0,0,0,0,0,0\n"+ | ||
| "201,30,314572800,0,0,0,0,0,0,0\n"+ | ||
| "300,50,524288000,0,0,0,0,0,0,0\n") | ||
| startNs := int64(200) * int64(time.Second) | ||
| endNs := int64(250) * int64(time.Second) | ||
| m, err := AggregateAllMetricsFromCSVWindow(csv, startNs, endNs) | ||
| if err != nil { | ||
| t.Fatalf("aggregate: %v", err) | ||
| } | ||
| if m.Samples != 1 { | ||
| t.Fatalf("Samples = %d, want 1 (window keeps 200-201, zero row dropped)", m.Samples) | ||
| } | ||
| if m.CPUAvg != 30 || m.MemMaxMB != 300 { | ||
| t.Fatalf("cpu/mem = %v/%v, want 30/300", m.CPUAvg, m.MemMaxMB) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.