Marina Biryukova
2981a47e99
All checks were successful
/ DCO (pull_request) Successful in 1m20s
/ Vulncheck (pull_request) Successful in 1m54s
/ Builds (1.20) (pull_request) Successful in 2m22s
/ Builds (1.21) (pull_request) Successful in 2m8s
/ Lint (pull_request) Successful in 4m32s
/ Tests (1.20) (pull_request) Successful in 2m27s
/ Tests (1.21) (pull_request) Successful in 2m13s
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
43 lines
865 B
Go
43 lines
865 B
Go
//go:build dump_metrics
|
|
|
|
package metrics
|
|
|
|
import (
|
|
"encoding/json"
|
|
"flag"
|
|
"os"
|
|
"testing"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool"
|
|
"github.com/stretchr/testify/require"
|
|
"go.uber.org/zap/zaptest"
|
|
)
|
|
|
|
type mock struct {
|
|
}
|
|
|
|
func (m mock) Statistic() pool.Statistic {
|
|
return pool.Statistic{}
|
|
}
|
|
|
|
var metricsPath = flag.String("out", "", "File to export s3 gateway metrics to.")
|
|
|
|
func TestDescribeAll(t *testing.T) {
|
|
// to check correct metrics type mapping
|
|
cfg := AppMetricsConfig{
|
|
Logger: zaptest.NewLogger(t),
|
|
PoolStatistics: mock{},
|
|
Enabled: true,
|
|
}
|
|
_ = NewAppMetrics(cfg)
|
|
|
|
flag.Parse()
|
|
|
|
require.NotEmpty(t, metricsPath, "flag 'out' must be provided to dump metrics description")
|
|
|
|
data, err := json.Marshal(DescribeAll())
|
|
require.NoError(t, err)
|
|
|
|
err = os.WriteFile(*metricsPath, data, 0644)
|
|
require.NoError(t, err)
|
|
}
|