Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: Reduce cc_proxy mock test noise
Browse files Browse the repository at this point in the history
We don't need that many logs, especially for the positive path.

Fixes: #1211

Signed-off-by: Samuel Ortiz <[email protected]>
  • Loading branch information
Samuel Ortiz committed Feb 5, 2019
1 parent 79ed088 commit 2093fe6
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions virtcontainers/pkg/mock/cc_proxy_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"net"
"os"
"sync"
Expand Down Expand Up @@ -109,10 +110,9 @@ func connectShimHandler(data []byte, userData interface{}, response *handlerResp

if payload.Token != proxy.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)
proxy.ShimConnected <- true
}
Expand All @@ -125,16 +125,13 @@ func signalShimHandler(data []byte, userData interface{}, response *handlerRespo
err := json.Unmarshal(data, &signalPayload)
assert.Nil(proxy.t, err)

proxy.logF("CCProxyMock received signal: %v", signalPayload)

proxy.Signal <- signalPayload
}

func disconnectShimHandler(data []byte, userData interface{}, response *handlerResponse) {
client := userData.(*client)
proxy := client.proxy

proxy.log("Client sent DisconnectShim Command")
proxy.ShimDisconnected <- true
}

Expand All @@ -150,10 +147,9 @@ func registerVMHandler(data []byte, userData interface{}, response *handlerRespo
client := userData.(*client)
proxy := client.proxy

proxy.log("Register VM")

payload := api.RegisterVM{}
if err := json.Unmarshal(data, &payload); err != nil {
proxy.logF("Register VM failed (%s)", err)
response.SetError(err)
return
}
Expand All @@ -172,20 +168,15 @@ func registerVMHandler(data []byte, userData interface{}, response *handlerRespo
}

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) {
client := userData.(*client)
proxy := client.proxy

proxy.log("Attach VM")

payload := api.AttachVM{}
if err := json.Unmarshal(data, &payload); err != nil {
proxy.logF("Attach VM failed (%s)", err)
response.SetError(err)
return
}
Expand All @@ -204,11 +195,6 @@ func attachVMHandler(data []byte, userData interface{}, response *handlerRespons
}

func hyperCmdHandler(data []byte, userData interface{}, response *handlerResponse) {
client := userData.(*client)
proxy := client.proxy

proxy.log("Hyper command")

response.SetData([]byte{})
}

Expand All @@ -235,8 +221,6 @@ func (proxy *CCProxyMock) startListening() {
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: proxy.connectionPath, Net: "unix"})
assert.Nil(proxy.t, err)

proxy.logF("listening on %s", proxy.connectionPath)

proxy.listener = l
}

Expand All @@ -245,11 +229,11 @@ func (proxy *CCProxyMock) serveClient(proto *ccProxyProtocol, newConn net.Conn)
proxy: proxy,
conn: newConn,
}
err := proto.Serve(newConn, newClient)
proxy.logF("Error serving client : %v\n", err)
if err := proto.Serve(newConn, newClient); err != nil && err != io.EOF {
proxy.logF("Error serving client : %v\n", err)
}

newConn.Close()
proxy.log("Client closed connection")

proxy.wg.Done()
}
Expand Down Expand Up @@ -281,7 +265,6 @@ func (proxy *CCProxyMock) serve() {
}

assert.NotNil(proxy.t, conn)
proxy.log("Client connected")

proxy.wg.Add(1)

Expand Down Expand Up @@ -319,7 +302,6 @@ func (proxy *CCProxyMock) Stop() {
proxy.listener.Close()

if proxy.cl != nil {
proxy.log("Closing client connection")
proxy.cl.Close()
proxy.cl = nil
} else {
Expand All @@ -332,7 +314,6 @@ func (proxy *CCProxyMock) Stop() {
close(proxy.ShimDisconnected)
close(proxy.StdinReceived)
os.Remove(proxy.connectionPath)
proxy.log("Stopped")
}

// XXX: could do with its own package to remove that ugly namespacing
Expand Down

0 comments on commit 2093fe6

Please sign in to comment.