runtime: fix agnet ut

We should not use a plain unix socket reader to act as grpc
server. Place a really mock grpc server instead.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2020-04-24 02:46:29 -07:00
parent e540648950
commit 426a9cab6e

View File

@ -10,7 +10,6 @@ import (
"context"
"fmt"
"io/ioutil"
"net"
"os"
"path"
"path/filepath"
@ -45,11 +44,6 @@ var (
testPCIAddr = "04/02"
)
func proxyHandlerDiscard(c net.Conn) {
buf := make([]byte, 1024)
c.Read(buf)
}
func testGenerateKataProxySockDir() (string, error) {
dir, err := ioutil.TempDir("", "kata-proxy-test")
if err != nil {
@ -61,8 +55,9 @@ func testGenerateKataProxySockDir() (string, error) {
func TestKataAgentConnect(t *testing.T) {
assert := assert.New(t)
proxy := mock.ProxyUnixMock{
ClientHandler: proxyHandlerDiscard,
proxy := mock.ProxyGRPCMock{
GRPCImplementer: &gRPCProxy{},
GRPCRegister: gRPCRegister,
}
sockDir, err := testGenerateKataProxySockDir()
@ -88,8 +83,9 @@ func TestKataAgentConnect(t *testing.T) {
func TestKataAgentDisconnect(t *testing.T) {
assert := assert.New(t)
proxy := mock.ProxyUnixMock{
ClientHandler: proxyHandlerDiscard,
proxy := mock.ProxyGRPCMock{
GRPCImplementer: &gRPCProxy{},
GRPCRegister: gRPCRegister,
}
sockDir, err := testGenerateKataProxySockDir()