mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-13 21:56:32 +00:00
virtcontainers: Reduce cc_proxy mock test noise
We don't need that many logs, especially for the positive path. Fixes: #1211 Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
79ed0886c6
commit
2093fe6bfd
@ -9,6 +9,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
@ -109,10 +110,9 @@ func connectShimHandler(data []byte, userData interface{}, response *handlerResp
|
|||||||
|
|
||||||
if payload.Token != proxy.token {
|
if payload.Token != proxy.token {
|
||||||
response.SetErrorMsg("Invalid Token")
|
response.SetErrorMsg("Invalid Token")
|
||||||
|
proxy.logF("Invalid Token (token=%s)", payload.Token)
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy.logF("ConnectShim(token=%s)", payload.Token)
|
|
||||||
|
|
||||||
response.AddResult("version", api.Version)
|
response.AddResult("version", api.Version)
|
||||||
proxy.ShimConnected <- true
|
proxy.ShimConnected <- true
|
||||||
}
|
}
|
||||||
@ -125,8 +125,6 @@ func signalShimHandler(data []byte, userData interface{}, response *handlerRespo
|
|||||||
err := json.Unmarshal(data, &signalPayload)
|
err := json.Unmarshal(data, &signalPayload)
|
||||||
assert.Nil(proxy.t, err)
|
assert.Nil(proxy.t, err)
|
||||||
|
|
||||||
proxy.logF("CCProxyMock received signal: %v", signalPayload)
|
|
||||||
|
|
||||||
proxy.Signal <- signalPayload
|
proxy.Signal <- signalPayload
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +132,6 @@ func disconnectShimHandler(data []byte, userData interface{}, response *handlerR
|
|||||||
client := userData.(*client)
|
client := userData.(*client)
|
||||||
proxy := client.proxy
|
proxy := client.proxy
|
||||||
|
|
||||||
proxy.log("Client sent DisconnectShim Command")
|
|
||||||
proxy.ShimDisconnected <- true
|
proxy.ShimDisconnected <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,10 +147,9 @@ func registerVMHandler(data []byte, userData interface{}, response *handlerRespo
|
|||||||
client := userData.(*client)
|
client := userData.(*client)
|
||||||
proxy := client.proxy
|
proxy := client.proxy
|
||||||
|
|
||||||
proxy.log("Register VM")
|
|
||||||
|
|
||||||
payload := api.RegisterVM{}
|
payload := api.RegisterVM{}
|
||||||
if err := json.Unmarshal(data, &payload); err != nil {
|
if err := json.Unmarshal(data, &payload); err != nil {
|
||||||
|
proxy.logF("Register VM failed (%s)", err)
|
||||||
response.SetError(err)
|
response.SetError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -172,20 +168,15 @@ func registerVMHandler(data []byte, userData interface{}, response *handlerRespo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func unregisterVMHandler(data []byte, userData interface{}, response *handlerResponse) {
|
func unregisterVMHandler(data []byte, userData interface{}, response *handlerResponse) {
|
||||||
client := userData.(*client)
|
|
||||||
proxy := client.proxy
|
|
||||||
|
|
||||||
proxy.log("Unregister VM")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func attachVMHandler(data []byte, userData interface{}, response *handlerResponse) {
|
func attachVMHandler(data []byte, userData interface{}, response *handlerResponse) {
|
||||||
client := userData.(*client)
|
client := userData.(*client)
|
||||||
proxy := client.proxy
|
proxy := client.proxy
|
||||||
|
|
||||||
proxy.log("Attach VM")
|
|
||||||
|
|
||||||
payload := api.AttachVM{}
|
payload := api.AttachVM{}
|
||||||
if err := json.Unmarshal(data, &payload); err != nil {
|
if err := json.Unmarshal(data, &payload); err != nil {
|
||||||
|
proxy.logF("Attach VM failed (%s)", err)
|
||||||
response.SetError(err)
|
response.SetError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -204,11 +195,6 @@ func attachVMHandler(data []byte, userData interface{}, response *handlerRespons
|
|||||||
}
|
}
|
||||||
|
|
||||||
func hyperCmdHandler(data []byte, userData interface{}, response *handlerResponse) {
|
func hyperCmdHandler(data []byte, userData interface{}, response *handlerResponse) {
|
||||||
client := userData.(*client)
|
|
||||||
proxy := client.proxy
|
|
||||||
|
|
||||||
proxy.log("Hyper command")
|
|
||||||
|
|
||||||
response.SetData([]byte{})
|
response.SetData([]byte{})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,8 +221,6 @@ func (proxy *CCProxyMock) startListening() {
|
|||||||
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: proxy.connectionPath, Net: "unix"})
|
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: proxy.connectionPath, Net: "unix"})
|
||||||
assert.Nil(proxy.t, err)
|
assert.Nil(proxy.t, err)
|
||||||
|
|
||||||
proxy.logF("listening on %s", proxy.connectionPath)
|
|
||||||
|
|
||||||
proxy.listener = l
|
proxy.listener = l
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,11 +229,11 @@ func (proxy *CCProxyMock) serveClient(proto *ccProxyProtocol, newConn net.Conn)
|
|||||||
proxy: proxy,
|
proxy: proxy,
|
||||||
conn: newConn,
|
conn: newConn,
|
||||||
}
|
}
|
||||||
err := proto.Serve(newConn, newClient)
|
if err := proto.Serve(newConn, newClient); err != nil && err != io.EOF {
|
||||||
proxy.logF("Error serving client : %v\n", err)
|
proxy.logF("Error serving client : %v\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
newConn.Close()
|
newConn.Close()
|
||||||
proxy.log("Client closed connection")
|
|
||||||
|
|
||||||
proxy.wg.Done()
|
proxy.wg.Done()
|
||||||
}
|
}
|
||||||
@ -281,7 +265,6 @@ func (proxy *CCProxyMock) serve() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.NotNil(proxy.t, conn)
|
assert.NotNil(proxy.t, conn)
|
||||||
proxy.log("Client connected")
|
|
||||||
|
|
||||||
proxy.wg.Add(1)
|
proxy.wg.Add(1)
|
||||||
|
|
||||||
@ -319,7 +302,6 @@ func (proxy *CCProxyMock) Stop() {
|
|||||||
proxy.listener.Close()
|
proxy.listener.Close()
|
||||||
|
|
||||||
if proxy.cl != nil {
|
if proxy.cl != nil {
|
||||||
proxy.log("Closing client connection")
|
|
||||||
proxy.cl.Close()
|
proxy.cl.Close()
|
||||||
proxy.cl = nil
|
proxy.cl = nil
|
||||||
} else {
|
} else {
|
||||||
@ -332,7 +314,6 @@ func (proxy *CCProxyMock) Stop() {
|
|||||||
close(proxy.ShimDisconnected)
|
close(proxy.ShimDisconnected)
|
||||||
close(proxy.StdinReceived)
|
close(proxy.StdinReceived)
|
||||||
os.Remove(proxy.connectionPath)
|
os.Remove(proxy.connectionPath)
|
||||||
proxy.log("Stopped")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: could do with its own package to remove that ugly namespacing
|
// XXX: could do with its own package to remove that ugly namespacing
|
||||||
|
Loading…
Reference in New Issue
Block a user