mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-28 19:44:21 +01:00
containerd checks for the grpc error code to determine correct recover action upon grpc errors. We need to provide them properly. Unfortunately ttrpc doesn't support grpc interceptor so we have to modify every service function for it. Fixes: #1527 Signed-off-by: Peng Tao <bergwolf@hyper.sh>
30 lines
674 B
Go
30 lines
674 B
Go
// Copyright (c) 2019 hyper.sh
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package containerdshim
|
|
|
|
import (
|
|
"syscall"
|
|
"testing"
|
|
|
|
vc "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestToGRPC(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
for _, err := range []error{vc.ErrNeedSandbox, vc.ErrNeedSandboxID,
|
|
vc.ErrNeedContainerID, vc.ErrNeedState, syscall.EINVAL, vc.ErrNoSuchContainer, syscall.ENOENT} {
|
|
assert.False(isGRPCError(err))
|
|
err = toGRPC(err)
|
|
assert.True(isGRPCError(err))
|
|
err = toGRPC(err)
|
|
assert.True(isGRPCError(err))
|
|
err = toGRPCf(err, "appending")
|
|
assert.True(isGRPCError(err))
|
|
}
|
|
}
|