-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* gomemif: fix the icmp responder polling example Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> * extras: add support for extras integration test This patch adds extras integration testing support. It tests the gomemif integration for poll mode and interrupt mode. Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> --------- Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Co-authored-by: Ondrej Fabry <ondrej@fabry.dev>
- Loading branch information
1 parent
4bf9957
commit 026c565
Showing
8 changed files
with
337 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
module go.fd.io/govpp/extras | ||
|
||
go 1.18 | ||
go 1.22 | ||
|
||
require ( | ||
github.com/google/gopacket v1.1.17 | ||
github.com/pkg/profile v1.6.0 | ||
github.com/sirupsen/logrus v1.4.2 | ||
github.com/pkg/profile v1.7.0 | ||
github.com/sirupsen/logrus v1.9.3 | ||
go.fd.io/govpp v0.10.0 | ||
) | ||
|
||
require ( | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect | ||
golang.org/x/sys v0.1.0 // indirect | ||
github.com/felixge/fgprof v0.9.3 // indirect | ||
github.com/fsnotify/fsnotify v1.7.0 // indirect | ||
github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff // indirect | ||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect | ||
github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe // indirect | ||
github.com/mitchellh/go-ps v1.0.0 // indirect | ||
golang.org/x/sys v0.16.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,56 @@ | ||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= | ||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= | ||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g= | ||
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= | ||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= | ||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= | ||
github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff h1:zk1wwii7uXmI0znwU+lqg+wFL9G5+vm5I+9rv2let60= | ||
github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff/go.mod h1:yUhRXHewUVJ1k89wHKP68xfzk7kwXUx/DV1nx4EBMbw= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/google/gopacket v1.1.17 h1:rMrlX2ZY2UbvT+sdz3+6J+pp2z+msCq9MxTU6ymxbBY= | ||
github.com/google/gopacket v1.1.17/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||
github.com/pkg/profile v1.6.0 h1:hUDfIISABYI59DyeB3OTay/HxSRwTQ8rB/H83k6r5dM= | ||
github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= | ||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y= | ||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= | ||
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= | ||
github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe h1:ewr1srjRCmcQogPQ/NCx6XCk6LGVmsVCc9Y3vvPZj+Y= | ||
github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= | ||
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= | ||
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= | ||
github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= | ||
github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= | ||
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA= | ||
github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= | ||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= | ||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= | ||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= | ||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||
go.fd.io/govpp v0.10.0 h1:lL93SbqOILjON2pMvazrlHRekGYTRy0Qmj57RuAkxR0= | ||
go.fd.io/govpp v0.10.0/go.mod h1:5m3bZM9ck+2EGC2O3ASmSSJAaoouyOlVWtiwj5BdCv0= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= | ||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= | ||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= | ||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= | ||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
FROM buildpack-deps:22.04-scm | ||
|
||
# Install gotestsum | ||
ARG GOTESTSUM_VERSION=1.12.0 | ||
RUN set -eux; \ | ||
curl -fsSL https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz -o gotestsum.tar.gz; \ | ||
tar -xf gotestsum.tar.gz gotestsum; \ | ||
mv gotestsum /usr/local/bin/gotestsum; \ | ||
rm gotestsum.tar.gz; | ||
|
||
# Install Go | ||
ENV GOLANG_VERSION=1.22.4 | ||
|
||
RUN set -eux; \ | ||
dpkgArch="$(dpkg --print-architecture)"; \ | ||
case "${dpkgArch##*-}" in \ | ||
amd64) goRelArch='linux-amd64'; ;; \ | ||
armhf) goRelArch='linux-armv6l'; ;; \ | ||
arm64) goRelArch='linux-arm64'; ;; \ | ||
esac; \ | ||
wget -nv -O go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ | ||
tar -C /usr/local -xzf go.tgz; \ | ||
rm go.tgz; | ||
|
||
ENV GOPATH=/go | ||
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH | ||
|
||
RUN set -eux; \ | ||
mkdir -p "$GOPATH/src" "$GOPATH/bin"; \ | ||
chmod -R 777 "$GOPATH"; | ||
|
||
ARG VPP_REPO=master | ||
|
||
# Install VPP | ||
RUN set -eux; \ | ||
apt-get update; \ | ||
curl -fsSL https://packagecloud.io/install/repositories/fdio/${VPP_REPO}/script.deb.sh | bash; \ | ||
apt-get update && apt-get install -V -y \ | ||
vpp \ | ||
vpp-plugin-core \ | ||
; \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY vpp.conf /etc/vpp/vpp.conf | ||
|
||
WORKDIR /src | ||
|
||
CMD ["/usr/bin/vpp", "-c", "/etc/vpp/vpp.conf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
unix { | ||
nodaemon | ||
log /var/log/vpp.log | ||
cli-listen /run/vpp/cli.sock | ||
cli-no-pager | ||
full-coredump | ||
pidfile /run/vpp/vpp.pid | ||
} | ||
api-trace { | ||
on | ||
} | ||
socksvr { | ||
socket-name /run/vpp/api.sock | ||
} | ||
statseg { | ||
socket-name /run/vpp/stats.sock | ||
per-node-counters on | ||
} | ||
plugins { | ||
plugin dpdk_plugin.so { disable } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// Copyright (c) 2022 Cisco and/or its affiliates. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at: | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package extras | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os/exec" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"go.fd.io/govpp/test/vpptesting" | ||
) | ||
|
||
func TestGoMemifPoll(t *testing.T) { | ||
test := "/icmp_responder_poll/icmp_responder_poll" | ||
runGoMemif(t, test) | ||
} | ||
|
||
func TestGoMemifCb(t *testing.T) { | ||
test := "/icmp_responder_cb/icmp_responder_cb" | ||
runGoMemif(t, test) | ||
} | ||
|
||
func runGoMemif(t *testing.T, test string) { | ||
_, err := exec.LookPath("go") | ||
if err != nil { | ||
t.Skipf("`go` command is not available, skipping test") | ||
} | ||
|
||
// Start VPP | ||
tc := vpptesting.SetupVPP(t) | ||
|
||
// create memif interface, assign ip address and set it up | ||
tc.RunCli("create interface memif id 0 master") | ||
tc.RunCli("set int ip addr memif0/0 192.168.1.2/24") | ||
tc.RunCli("set int state memif0/0 up") | ||
|
||
cmd := exec.Command("./gomemif/examples" + test) | ||
t.Logf("executing command '%v'", cmd) | ||
|
||
stdin, err := cmd.StdinPipe() | ||
if err != nil { | ||
t.Fatalf("Error creating stdin pipe: %v", err) | ||
return | ||
} | ||
|
||
stdout, err := cmd.StdoutPipe() | ||
if err != nil { | ||
t.Fatalf("Error creating stdout pipe: %v", err) | ||
return | ||
} | ||
|
||
// Start the command | ||
err = cmd.Start() | ||
if err != nil { | ||
t.Fatalf("Error starting command: %v", err) | ||
return | ||
} | ||
|
||
// Create a scanner to read the output from the command | ||
scanner := bufio.NewScanner(stdout) | ||
go func() { | ||
for scanner.Scan() { | ||
// Print each line of output | ||
fmt.Println(scanner.Text()) | ||
} | ||
}() | ||
|
||
// Send the "start" command to the gomemif application | ||
_, err = stdin.Write([]byte("start\n")) | ||
if err != nil { | ||
t.Fatalf("Error writing to stdin: %v", err) | ||
return | ||
} | ||
|
||
time.Sleep(1 * time.Second) | ||
// Send the "show" command to the gomemif application | ||
_, err = stdin.Write([]byte("show\n")) | ||
if err != nil { | ||
t.Fatalf("Error writing to stdin: %v", err) | ||
return | ||
} | ||
|
||
vppout, err := tc.RunCli("ping 192.168.1.1") | ||
if err != nil { | ||
t.Fatalf("Error running ping command: %v", err) | ||
return | ||
} else { | ||
ouput_split := strings.Split(vppout, "received")[0] | ||
output_field := strings.Fields(ouput_split) | ||
received, _ := strconv.Atoi(output_field[len(output_field)-1]) | ||
if received < 1 { | ||
t.Fatalf("No packets received") | ||
return | ||
} | ||
} | ||
|
||
_, err = stdin.Write([]byte("exit\n")) | ||
if err != nil { | ||
t.Fatalf("Error writing to stdin: %v", err) | ||
return | ||
} | ||
|
||
err = stdin.Close() | ||
if err != nil { | ||
t.Fatalf("Error closing stdin: %v", err) | ||
return | ||
} | ||
|
||
t.Logf("test %s output: %s", test, stdout) | ||
} |
Oops, something went wrong.