-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce VPP integration tests (#75)
- Loading branch information
1 parent
c01d6b8
commit 3ed0937
Showing
17 changed files
with
1,093 additions
and
184 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: Test | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
# Allows running this workflow manually | ||
workflow_dispatch: | ||
|
||
jobs: | ||
integration: | ||
name: "VPP Integration ${{ matrix.version }}" | ||
runs-on: ubuntu-latest | ||
env: | ||
VPP_REPO: ${{ matrix.version }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: [ '2210', '2206', '2202' ] | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v3 | ||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
- name: "Run Tests" | ||
run: | | ||
make test-integration |
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
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
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,58 @@ | ||
FROM ubuntu:20.04 | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
gnupg \ | ||
iproute2 \ | ||
iputils-ping \ | ||
make \ | ||
nano \ | ||
sudo \ | ||
wget \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ARG GOTESTSUM_VERSION=1.8.2 | ||
RUN 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.18.3 | ||
|
||
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 mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" | ||
|
||
ARG VPP_REPO=release | ||
|
||
# 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,39 @@ | ||
// 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 integration | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"go.fd.io/govpp/binapi/vpe" | ||
"go.fd.io/govpp/test/vpptesting" | ||
) | ||
|
||
func TestVersion(t *testing.T) { | ||
test := vpptesting.SetupVPP(t) | ||
|
||
vpeRPC := vpe.NewServiceClient(test.Conn) | ||
|
||
versionInfo, err := vpeRPC.ShowVersion(context.Background(), &vpe.ShowVersion{}) | ||
if err != nil { | ||
t.Fatalf("getting version failed: %v", err) | ||
} | ||
|
||
t.Logf("VPP version: %v", versionInfo.Version) | ||
if versionInfo.Version == "" { | ||
t.Fatal("expected VPP version to not be empty") | ||
} | ||
} |
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,50 @@ | ||
// 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 integration | ||
|
||
import ( | ||
"io/fs" | ||
"os/exec" | ||
"path/filepath" | ||
"testing" | ||
|
||
"go.fd.io/govpp/test/vpptesting" | ||
) | ||
|
||
func TestExamples(t *testing.T) { | ||
if err := filepath.WalkDir("./examples", func(path string, d fs.DirEntry, err error) error { | ||
if !d.IsDir() || filepath.Base(d.Name()) == "examples" { | ||
return nil | ||
} | ||
example := filepath.Base(d.Name()) | ||
t.Run(example, func(tt *testing.T) { | ||
testExample(tt, example) | ||
}) | ||
return nil | ||
}); err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func testExample(t *testing.T, example string) { | ||
vpptesting.SetupVPP(t) | ||
|
||
cmd := exec.Command("go", "run", "./examples/"+example) | ||
out, err := cmd.CombinedOutput() | ||
if err != nil { | ||
t.Fatalf("%s command failed: %+v\n%s", cmd, err, out) | ||
} | ||
t.Logf("out: %s", out) | ||
} |
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,28 @@ | ||
// 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 integration contains tests against running VPP instance. | ||
// The test cases are only executed if env contains TEST=integration. | ||
package integration | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
if os.Getenv("TEST") == "integration" { | ||
os.Exit(m.Run()) | ||
} | ||
} |
Oops, something went wrong.