test-perf: .deps.ok .build.ok
@bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \
--test=$(TEST) --vppsrc=$(VPPSRC) --repeat=$(REPEAT) \
- --skip=$(SKIP) --no_color=$(NO_COLOR) --perf=true; \
+ --skip=$(SKIP) --no_color=$(NO_COLOR) --perf=true --timeout=$(TIMEOUT); \
./script/compress.sh $$?
.PHONY: setup-cluster
-setup-cluster:
+setup-cluster: .kind_deps.ok
@bash ./kubernetes/setupCluster.sh
.PHONY: build-go
.deps.ok:
@$(MAKE) install-deps
+.kind_deps.ok:
+ @$(MAKE) install-kind-deps
+
+.PHONY: install-kind-deps
+install-kind-deps: .deps.ok
+ -@if which kind > /dev/null 2>&1; then \
+ sudo ln -s $$(which kind) /usr/bin/kind; \
+ fi
+ @if ! command -v kubectl >/dev/null 2>&1; then \
+ echo "kubectl not found. Installing kubectl..."; \
+ sudo -E apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl gnupg; \
+ curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.33/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg; \
+ sudo -E chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg; \
+ echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list; \
+ sudo -E chmod 644 /etc/apt/sources.list.d/kubernetes.list; \
+ sudo apt-get update && sudo apt-get install -y kubectl; \
+ else \
+ echo "kubectl is already installed. Skipping installation."; \
+ fi
+ @touch .kind_deps.ok
+
.PHONY: install-deps
install-deps:
@rm -f .deps.ok
+ @if [ -d "/usr/local/go" ]; then \
+ echo "Go is already installed. You may have to update it manually if version < 1.22"; \
+ go version; \
+ else \
+ echo "Installing Go 1.22"; \
+ wget https://go.dev/dl/go1.22.12.linux-amd64.tar.gz -O /tmp/go1.22.12.linux-amd64.tar.gz && sudo tar -C /usr/local -xzf /tmp/go1.22.12.linux-amd64.tar.gz; \
+ sudo ln -s /usr/local/go/bin/go /usr/bin/go ; \
+ fi
@sudo -E apt-get update
@sudo -E apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
bridge-utils gpg
func TestHst(t *testing.T) {
// if we're debugging/running a coverage build and timeout isn't overridden,
// set test timeout to 30 minutes. Also impacts AssertChannelClosed()
- if (*IsVppDebug || *IsCoverage) && *Timeout == 5 {
+ if (*IsVppDebug || *IsCoverage || *PerfTesting) && *Timeout == 5 {
TestTimeout = time.Minute * 30
fmt.Printf("[Debugging or coverage build, TestTimeout is set to %s]\n", TestTimeout.String())
} else {
;;
--perf=*)
perf="${i#*=}"
+ args="$args -perf"
;;
--timeout=*)
args="$args -timeout ${i#*=}"
var IsVppDebug = flag.Bool("debug", false, "attach gdb to vpp")
var DryRun = flag.Bool("dryrun", false, "set up containers but don't run tests")
var Timeout = flag.Int("timeout", 5, "test timeout override (in minutes)")
+var PerfTesting = flag.Bool("perf", false, "perf test flag")
var NumaAwareCpuAlloc bool
var TestTimeout time.Duration
var RunningInCi bool
// Coverage builds take longer to finish -> assert timeout is set to 'TestTimeout - 30 seconds' to let the test finish properly
func (s *HstCommon) AssertChannelClosed(timeout time.Duration, channel chan error) {
if *IsCoverage && timeout > time.Second*30 {
- s.Log("Coverage build, assert timeout is set to %s", timeout.String())
timeout = TestTimeout - time.Second*30
+ s.Log("Coverage build, assert timeout is set to %s", timeout.String())
}
EventuallyWithOffset(2, channel).WithTimeout(timeout).Should(BeClosed())
}
package hst_kind
import (
+ "fmt"
"os"
"reflect"
+ "regexp"
"runtime"
"strings"
"text/template"
}
func (s *KindSuite) TeardownSuite() {
+ s.HstCommon.TeardownSuite()
s.Log(" %s", s.Namespace)
s.AssertNil(s.deleteNamespace(s.Namespace))
}
+// Quick and dirty fix for now. Runs 'ldd /usr/lib/libvcl_ldpreload.so'
+// and searches for the first version string, then creates symlinks.
+func (s *KindSuite) FixVersionNumber(pods ...*Pod) {
+ regex := regexp.MustCompile(`lib.*\.so\.([0-9]+\.[0-9]+)`)
+ o, _ := s.Exec(s.Pods.ServerGeneric, []string{"/bin/bash", "-c",
+ "ldd /usr/lib/libvcl_ldpreload.so"})
+ match := regex.FindStringSubmatch(o)
+
+ if len(match) > 1 {
+ version := match[1]
+ s.Log("Found version: %s", version)
+ cmd := fmt.Sprintf("for file in /usr/lib/*.so; do\n"+
+ "if [ -e \"$file\" ]; then\n"+
+ "base=$(basename \"$file\")\n"+
+ "newlink=\"/usr/lib/${base}.%s\"\n"+
+ "ln -s \"$file\" \"$newlink\"\n"+
+ "fi\n"+
+ "done", version)
+ for _, pod := range pods {
+ s.Exec(pod, []string{"/bin/bash", "-c", cmd})
+ }
+
+ } else {
+ s.Log("Couldn't find version.")
+ }
+}
+
func (s *KindSuite) CreateConfigFromTemplate(targetConfigName string, templateName string, values any) {
template := template.Must(template.ParseFiles(templateName))
func (s *KindSuite) CreateNginxConfig() {
values := struct {
Workers uint8
+ Port uint16
}{
Workers: 1,
+ Port: 8081,
}
s.CreateConfigFromTemplate(
"/nginx.conf",
RegisterKindTests(KindIperfVclTest, NginxRpsTest)
}
+const vcl string = "VCL_CONFIG=/vcl.conf"
+const ldp string = "LD_PRELOAD=/usr/lib/libvcl_ldpreload.so"
+
func KindIperfVclTest(s *KindSuite) {
s.DeployPod(s.Pods.ClientGeneric)
s.DeployPod(s.Pods.ServerGeneric)
- vclPath := "/vcl.conf"
- ldpPath := "/usr/lib/libvcl_ldpreload.so"
-
- // temporary workaround
- symLink := "for file in /usr/lib/*.so; do\n" +
- "if [ -e \"$file\" ]; then\n" +
- "base=$(basename \"$file\")\n" +
- "newlink=\"/usr/lib/${base}.25.06\"\n" +
- "ln -s \"$file\" \"$newlink\"\n" +
- "fi\n" +
- "done"
-
vclConf := "echo \"vcl {\n" +
"rx-fifo-size 4000000\n" +
"tx-fifo-size 4000000\n" +
"app-socket-api abstract:vpp/session\n" +
"}\" > /vcl.conf"
- s.Exec(s.Pods.ClientGeneric, []string{"/bin/bash", "-c", symLink})
- s.Exec(s.Pods.ServerGeneric, []string{"/bin/bash", "-c", symLink})
-
_, err := s.Exec(s.Pods.ClientGeneric, []string{"/bin/bash", "-c", vclConf})
s.AssertNil(err)
_, err = s.Exec(s.Pods.ServerGeneric, []string{"/bin/bash", "-c", vclConf})
s.AssertNil(err)
- _, err = s.Exec(s.Pods.ServerGeneric, []string{"/bin/bash", "-c",
- "VCL_CONFIG=" + vclPath + " LD_PRELOAD=" + ldpPath + " iperf3 -s -D -4"})
- s.AssertNil(err)
+ s.FixVersionNumber(s.Pods.ClientGeneric, s.Pods.ServerGeneric)
+
+ o, err := s.Exec(s.Pods.ServerGeneric, []string{"/bin/bash", "-c",
+ vcl + " " + ldp + " iperf3 -s -D -4"})
+ s.AssertNil(err, o)
output, err := s.Exec(s.Pods.ClientGeneric, []string{"/bin/bash", "-c",
- "VCL_CONFIG=" + vclPath + " LD_PRELOAD=" + ldpPath + " iperf3 -c " + s.Pods.ServerGeneric.IpAddress})
+ vcl + " " + ldp + " iperf3 -c " + s.Pods.ServerGeneric.IpAddress})
s.Log(output)
s.AssertNil(err)
}
s.DeployPod(s.Pods.Nginx)
s.DeployPod(s.Pods.Ab)
s.CreateNginxConfig()
- vcl := "VCL_CONFIG=/vcl.conf"
- ldp := "LD_PRELOAD=/usr/lib/libvcl_ldpreload.so"
-
- // temporary workaround
- symLink := "for file in /usr/lib/*.so; do\n" +
- "if [ -e \"$file\" ]; then\n" +
- "base=$(basename \"$file\")\n" +
- "newlink=\"/usr/lib/${base}.25.06\"\n" +
- "ln -s \"$file\" \"$newlink\"\n" +
- "fi\n" +
- "done"
vclConf := "echo \"vcl {\n" +
"heapsize 64M\n" +
"app-socket-api abstract:vpp/session\n" +
"}\" > /vcl.conf"
- out, err := s.Exec(s.Pods.Nginx, []string{"/bin/bash", "-c", symLink})
- s.AssertNil(err, out)
-
- out, err = s.Exec(s.Pods.Nginx, []string{"/bin/bash", "-c", vclConf})
+ out, err := s.Exec(s.Pods.Nginx, []string{"/bin/bash", "-c", vclConf})
s.AssertNil(err, out)
go func() {
// wait for nginx to start up
time.Sleep(time.Second * 2)
- out, err = s.Exec(s.Pods.Ab, []string{"ab", "-k", "-r", "-n", "1000000", "-c", "1000", "http://" + s.Pods.Nginx.IpAddress + ":80/64B.json"})
+ out, err = s.Exec(s.Pods.Ab, []string{"ab", "-k", "-r", "-n", "1000000", "-c", "1000", "http://" + s.Pods.Nginx.IpAddress + ":8081/64B.json"})
s.Log(out)
s.AssertNil(err)
}
#!/usr/bin/env bash
set -e
-if [ "$EUID" -eq 0 ]; then
- echo "********"
- echo "Do not run as root. Exiting."
- echo "********"
- exit 1
-fi
-
echo "********"
echo "Performance tests only work on Ubuntu 22.04 for now."
-echo "Do not run as root (untested) and make sure you have KinD and Kubectl installed!"
-echo "https://kind.sigs.k8s.io/"
-echo "https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management"
echo "********"
kind create cluster --config kubernetes/kind-config.yaml