github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/tests/integration/monitoring_test.go (about) 1 //go:build integration 2 // +build integration 3 4 package integration 5 6 import ( 7 "context" 8 "os" 9 "testing" 10 11 "github.com/stretchr/testify/require" 12 "github.com/ydb-platform/ydb-go-genproto/Ydb_Monitoring_V1" 13 "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Monitoring" 14 15 "github.com/ydb-platform/ydb-go-sdk/v3" 16 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest" 17 "github.com/ydb-platform/ydb-go-sdk/v3/retry" 18 ) 19 20 func TestMonitoring(t *testing.T) { 21 ctx := xtest.Context(t) 22 23 db, err := ydb.Open(ctx, 24 "", // corner case for check replacement of endpoint+database+secure 25 ydb.WithConnectionString(os.Getenv("YDB_CONNECTION_STRING")), 26 ) 27 if err != nil { 28 t.Fatal(err) 29 } 30 defer func() { 31 // cleanup connection 32 if e := db.Close(ctx); e != nil { 33 t.Fatalf("close failed: %+v", e) 34 } 35 }() 36 t.Run("monitoring.SelfCheck", func(t *testing.T) { 37 err = retry.Retry(ctx, func(ctx context.Context) (err error) { 38 client := Ydb_Monitoring_V1.NewMonitoringServiceClient(ydb.GRPCConn(db)) 39 response, err := client.SelfCheck(ctx, &Ydb_Monitoring.SelfCheckRequest{ 40 OperationParams: nil, 41 ReturnVerboseStatus: false, 42 MinimumStatus: 0, 43 MaximumLevel: 0, 44 }) 45 if err != nil { 46 return err 47 } 48 var result Ydb_Monitoring.SelfCheckResult 49 err = response.Operation.Result.UnmarshalTo(&result) 50 if err != nil { 51 return err 52 } 53 t.Logf("%+v\n", &result) 54 return nil 55 }, retry.WithIdempotent(true)) 56 require.NoError(t, err) 57 }) 58 }