mirror of
https://github.com/logos-messaging/logos-messaging-go-bindings.git
synced 2026-01-02 14:03:10 +00:00
Adding changes for creating multi iteration job
This commit is contained in:
parent
c20129ed9c
commit
ddc9290370
42
.github/workflows/endurancce_test.yml
vendored
Normal file
42
.github/workflows/endurancce_test.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: Repeated Test Suite
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
repeated-tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: "1.21"
|
||||
|
||||
- name: Clean environment
|
||||
run: go clean -cache
|
||||
|
||||
- name: Initialize CSV
|
||||
run: echo "TestName,Iteration,Phase,HeapAlloc(KB),RSS(KB),Timestamp" > memory_metrics.csv
|
||||
|
||||
- name: Repeated test runs
|
||||
run: |
|
||||
for i in {1..10}; do
|
||||
echo "Iteration $i: measuring memory BEFORE the tests..."
|
||||
go run waku/memory_utils.go --iteration $i --phase start
|
||||
echo "Running tests (iteration $i)..."
|
||||
go test -v -tags '!stress' ./...
|
||||
echo "Iteration $i: measuring memory AFTER the tests..."
|
||||
go run waku/memory_utils.go --iteration $i --phase end
|
||||
done
|
||||
|
||||
- name: Upload memory_metrics.csv
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: memory_metrics
|
||||
path: memory_metrics.csv
|
||||
77
waku/memory_utils.go
Normal file
77
waku/memory_utils.go
Normal file
@ -0,0 +1,77 @@
|
||||
package waku
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
testName string
|
||||
iteration int
|
||||
phase string
|
||||
mu sync.Mutex
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.StringVar(&testName, "testName", "FullTestSuite", "Name of the test ")
|
||||
flag.IntVar(&iteration, "iteration", 0, "Iteration number")
|
||||
flag.StringVar(&phase, "phase", "", "'start' or 'end')")
|
||||
flag.Parse()
|
||||
|
||||
var memStats runtime.MemStats
|
||||
runtime.ReadMemStats(&memStats)
|
||||
heapKB := memStats.HeapAlloc / 1024
|
||||
|
||||
rssKB, err := getRSSKB()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Failed to get RSS:", err)
|
||||
rssKB = 0
|
||||
}
|
||||
|
||||
if err := recordMemoryMetricsCSV(testName, iteration, phase, heapKB, rssKB); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Error recording metrics:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func recordMemoryMetricsCSV(testName string, iter int, phase string, heapKB, rssKB uint64) error {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
f, err := os.OpenFile("memory_metrics.csv", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
w := csv.NewWriter(f)
|
||||
defer w.Flush()
|
||||
|
||||
stat, err := f.Stat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if stat.Size() == 0 {
|
||||
header := []string{"TestName", "Iteration", "Phase", "HeapAlloc(KB)", "RSS(KB)", "Timestamp"}
|
||||
if err := w.Write(header); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
row := []string{
|
||||
testName,
|
||||
strconv.Itoa(iter),
|
||||
phase,
|
||||
strconv.FormatUint(heapKB, 10),
|
||||
strconv.FormatUint(rssKB, 10),
|
||||
time.Now().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
return w.Write(row)
|
||||
}
|
||||
@ -1,3 +1,6 @@
|
||||
|
||||
// +build !stress
|
||||
|
||||
package waku
|
||||
|
||||
import (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user