diff options
Diffstat (limited to 'extras/hs-test/vppinstance.go')
-rw-r--r-- | extras/hs-test/vppinstance.go | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/extras/hs-test/vppinstance.go b/extras/hs-test/vppinstance.go index 1a058c8e0e3..9b400cfcb77 100644 --- a/extras/hs-test/vppinstance.go +++ b/extras/hs-test/vppinstance.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "io" "os" "os/exec" "os/signal" @@ -10,7 +11,9 @@ import ( "syscall" "time" + "github.com/sirupsen/logrus" "github.com/edwarnicke/exechelper" + . "github.com/onsi/ginkgo/v2" "go.fd.io/govpp" "go.fd.io/govpp/api" @@ -59,6 +62,8 @@ plugins { plugin http_static_plugin.so { enable } plugin prom_plugin.so { enable } plugin tlsopenssl_plugin.so { enable } + plugin ping_plugin.so { enable } + plugin nsim_plugin.so { enable } } logging { @@ -103,6 +108,10 @@ func (vpp *VppInstance) getEtcDir() string { } func (vpp *VppInstance) start() error { + // Replace default logger in govpp with our own + govppLogger := logrus.New() + govppLogger.SetOutput(io.MultiWriter(vpp.getSuite().logger.Writer(), GinkgoWriter)) + core.SetLogger(govppLogger) // Create folders containerWorkDir := vpp.container.getContainerWorkDir() @@ -131,9 +140,10 @@ func (vpp *VppInstance) start() error { vpp.container.createFile(vppcliFileName, cliContent) vpp.container.exec("chmod 0755 " + vppcliFileName) + vpp.getSuite().log("starting vpp") if *isVppDebug { sig := make(chan os.Signal, 1) - signal.Notify(sig, syscall.SIGINT) + signal.Notify(sig, syscall.SIGQUIT) cont := make(chan bool, 1) go func() { <-sig @@ -143,7 +153,7 @@ func (vpp *VppInstance) start() error { vpp.container.execServer("su -c \"vpp -c " + startupFileName + " &> /proc/1/fd/1\"") fmt.Println("run following command in different terminal:") fmt.Println("docker exec -it " + vpp.container.name + " gdb -ex \"attach $(docker exec " + vpp.container.name + " pidof vpp)\"") - fmt.Println("Afterwards press CTRL+C to continue") + fmt.Println("Afterwards press CTRL+\\ to continue") <-cont fmt.Println("continuing...") } else { @@ -151,6 +161,7 @@ func (vpp *VppInstance) start() error { vpp.container.execServer("su -c \"vpp -c " + startupFileName + " &> /proc/1/fd/1\"") } + vpp.getSuite().log("connecting to vpp") // Connect to VPP and store the connection sockAddress := vpp.container.getHostWorkDir() + defaultApiSocketFilePath conn, connEv, err := govpp.AsyncConnect( @@ -207,7 +218,7 @@ func (vpp *VppInstance) GetSessionStat(stat string) int { tokens := strings.Split(strings.TrimSpace(line), " ") val, err := strconv.Atoi(tokens[0]) if err != nil { - vpp.getSuite().FailNow("failed to parse stat value %s", err) + Fail("failed to parse stat value %s" + fmt.Sprint(err)) return 0 } return val @@ -217,6 +228,7 @@ func (vpp *VppInstance) GetSessionStat(stat string) int { } func (vpp *VppInstance) waitForApp(appName string, timeout int) { + vpp.getSuite().log("waiting for app " + appName) for i := 0; i < timeout; i++ { o := vpp.vppctl("show app") if strings.Contains(o, appName) { @@ -240,6 +252,7 @@ func (vpp *VppInstance) createAfPacket( } createReply := &af_packet.AfPacketCreateV2Reply{} + vpp.getSuite().log("create af-packet interface " + veth.Name()) if err := vpp.apiChannel.SendRequest(createReq).ReceiveReply(createReply); err != nil { return 0, err } @@ -252,6 +265,7 @@ func (vpp *VppInstance) createAfPacket( } upReply := &interfaces.SwInterfaceSetFlagsReply{} + vpp.getSuite().log("set af-packet interface " + veth.Name() + " up") if err := vpp.apiChannel.SendRequest(upReq).ReceiveReply(upReply); err != nil { return 0, err } @@ -273,6 +287,7 @@ func (vpp *VppInstance) createAfPacket( } addressReply := &interfaces.SwInterfaceAddDelAddressReply{} + vpp.getSuite().log("af-packet interface " + veth.Name() + " add address " + veth.ip4Address) if err := vpp.apiChannel.SendRequest(addressReq).ReceiveReply(addressReply); err != nil { return 0, err } @@ -292,6 +307,7 @@ func (vpp *VppInstance) addAppNamespace( } reply := &session.AppNamespaceAddDelV2Reply{} + vpp.getSuite().log("add app namespace " + namespaceId) if err := vpp.apiChannel.SendRequest(req).ReceiveReply(reply); err != nil { return err } @@ -301,6 +317,7 @@ func (vpp *VppInstance) addAppNamespace( } sessionReply := &session.SessionEnableDisableReply{} + vpp.getSuite().log("enable app namespace " + namespaceId) if err := vpp.apiChannel.SendRequest(sessionReq).ReceiveReply(sessionReply); err != nil { return err } @@ -325,6 +342,7 @@ func (vpp *VppInstance) createTap( } createTapReply := &tapv2.TapCreateV2Reply{} + vpp.getSuite().log("create tap interface " + tap.Name()) // Create tap interface if err := vpp.apiChannel.SendRequest(createTapReq).ReceiveReply(createTapReply); err != nil { return err @@ -338,6 +356,7 @@ func (vpp *VppInstance) createTap( } addAddressReply := &interfaces.SwInterfaceAddDelAddressReply{} + vpp.getSuite().log("tap interface " + tap.Name() + " add address " + tap.peer.ip4Address) if err := vpp.apiChannel.SendRequest(addAddressReq).ReceiveReply(addAddressReply); err != nil { return err } @@ -349,6 +368,7 @@ func (vpp *VppInstance) createTap( } upReply := &interfaces.SwInterfaceSetFlagsReply{} + vpp.getSuite().log("set tap interface " + tap.Name() + " up") if err := vpp.apiChannel.SendRequest(upReq).ReceiveReply(upReply); err != nil { return err } @@ -360,7 +380,6 @@ func (vpp *VppInstance) saveLogs() { logTarget := vpp.container.getLogDirPath() + "vppinstance-" + vpp.container.name + ".log" logSource := vpp.container.getHostWorkDir() + defaultLogFilePath cmd := exec.Command("cp", logSource, logTarget) - vpp.getSuite().T().Helper() vpp.getSuite().log(cmd.String()) cmd.Run() } |