2023-04-07 14:28:21 +00:00
|
|
|
//go:build dump_metrics
|
|
|
|
|
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"flag"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2023-04-10 08:40:58 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool"
|
2023-04-07 14:28:21 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2023-04-10 08:40:58 +00:00
|
|
|
"go.uber.org/zap/zaptest"
|
2023-04-07 14:28:21 +00:00
|
|
|
)
|
|
|
|
|
2023-04-10 08:40:58 +00:00
|
|
|
type mock struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m mock) Statistic() pool.Statistic {
|
|
|
|
return pool.Statistic{}
|
|
|
|
}
|
|
|
|
|
2023-04-07 14:28:21 +00:00
|
|
|
var metricsPath = flag.String("out", "", "File to export s3 gateway metrics to.")
|
|
|
|
|
|
|
|
func TestDescribeAll(t *testing.T) {
|
2023-04-10 08:40:58 +00:00
|
|
|
// to check correct metrics type mapping
|
2024-02-26 13:18:34 +00:00
|
|
|
cfg := AppMetricsConfig{
|
|
|
|
Logger: zaptest.NewLogger(t),
|
|
|
|
PoolStatistics: mock{},
|
|
|
|
Enabled: true,
|
|
|
|
}
|
|
|
|
_ = NewAppMetrics(cfg)
|
2023-04-10 08:40:58 +00:00
|
|
|
|
2023-04-07 14:28:21 +00:00
|
|
|
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)
|
|
|
|
}
|