[#1656] qos: Add test for SetCriticalIOTag Interceptor
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m21s
Tests and linters / Run gofumpt (push) Successful in 1m52s
Build / Build Components (push) Successful in 2m26s
Pre-commit hooks / Pre-commit (push) Successful in 2m27s
Tests and linters / Tests (push) Successful in 2m58s
Tests and linters / Staticcheck (push) Successful in 2m59s
Tests and linters / Lint (push) Successful in 3m42s
Tests and linters / Tests with -race (push) Successful in 4m36s
Tests and linters / gopls check (push) Successful in 4m43s
OCI image / Build container images (push) Successful in 5m33s

Change-Id: I4a55fcb84e6f65408a1c0120ac917e49e23354a1
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
Ekaterina Lebedeva 2025-03-22 16:36:55 +03:00
parent 115aae7c34
commit dcb2b23a7d

View file

@ -19,6 +19,7 @@ const (
var (
errTest = errors.New("mock")
errWrongTag = errors.New("wrong tag")
errResExhausted *apistatus.ResourceExhausted
)
@ -119,3 +120,18 @@ func Test_MaxActiveRPCLimiter(t *testing.T) {
require.True(t, lim.released)
})
}
func TestSetCriticalIOTagUnaryServerInterceptor_Pass(t *testing.T) {
interceptor := qos.NewSetCriticalIOTagUnaryServerInterceptor()
called := false
handler := func(ctx context.Context, req any) (any, error) {
called = true
if tag, ok := tagging.IOTagFromContext(ctx); ok && tag == qos.IOTagCritical.String() {
return nil, nil
}
return nil, errWrongTag
}
_, err := interceptor(context.Background(), nil, nil, handler)
require.NoError(t, err)
require.True(t, called)
}