diff --git a/acceptance/common/docker.py b/acceptance/common/docker.py index 0af9a69bc4..c6f56fb2c8 100644 --- a/acceptance/common/docker.py +++ b/acceptance/common/docker.py @@ -197,7 +197,7 @@ def assert_no_networks(writer=None): writer.write("Docker networking assertions are OFF\n") return - allowed_nets = ['bridge', 'host', 'none'] + allowed_nets = ['bridge', 'host', 'none', 'benchmark'] unexpected_nets = [] for net in _get_networks(): if net.name not in allowed_nets: diff --git a/acceptance/router_benchmark/test.py b/acceptance/router_benchmark/test.py index 2049d9eea3..428b58f71e 100755 --- a/acceptance/router_benchmark/test.py +++ b/acceptance/router_benchmark/test.py @@ -141,7 +141,7 @@ def _run(self): "-name", "router_benchmark", "-cmd", "./bin/end2endblast", "-attempts", 1500000, - "-timeout", "120s", # Timeout is for all attempts together + "-timeout", "180s", # Timeout is for all attempts together "-parallelism", 100, "-subset", "noncore#core#remoteISD" ].run_tee() diff --git a/acceptance/router_newbenchmark/BUILD.bazel b/acceptance/router_newbenchmark/BUILD.bazel new file mode 100644 index 0000000000..1a93da0376 --- /dev/null +++ b/acceptance/router_newbenchmark/BUILD.bazel @@ -0,0 +1,28 @@ +load("//acceptance/common:raw.bzl", "raw_test") + +exports_files([ + "conf", + "test.py", +]) + +args = [ + "--executable", + "brload:$(location //acceptance/router_newbenchmark/brload:brload)", + "--container-loader=posix-router:latest#$(location //docker:posix_router)", +] + +data = [ + ":conf", + "//docker:posix_router", + "//acceptance/router_newbenchmark/brload:brload", +] + +raw_test( + name = "test", + src = "test.py", + args = args, + data = data, + homedir = "$(rootpath //docker:posix_router)", + # This test uses sudo and accesses /var/run/netns. + local = True, +) diff --git a/acceptance/router_newbenchmark/brload/BUILD.bazel b/acceptance/router_newbenchmark/brload/BUILD.bazel new file mode 100644 index 0000000000..e475b8b68a --- /dev/null +++ b/acceptance/router_newbenchmark/brload/BUILD.bazel @@ -0,0 +1,27 @@ +load("//tools/lint:go.bzl", "go_library") +load("//:scion.bzl", "scion_go_binary") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "github.com/scionproto/scion/acceptance/router_newbenchmark/brload", + visibility = ["//visibility:private"], + deps = [ + "//acceptance/router_newbenchmark/cases:go_default_library", + "//pkg/log:go_default_library", + "//pkg/private/serrors:go_default_library", + "//pkg/scrypto:go_default_library", + "//pkg/slayers:go_default_library", + "//private/keyconf:go_default_library", + "@com_github_google_gopacket//:go_default_library", + "@com_github_google_gopacket//afpacket:go_default_library", + "@com_github_google_gopacket//layers:go_default_library", + "@com_github_spf13_cobra//:go_default_library", + ], +) + +scion_go_binary( + name = "brload", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) diff --git a/acceptance/router_newbenchmark/brload/main.go b/acceptance/router_newbenchmark/brload/main.go new file mode 100644 index 0000000000..40e50cfbf6 --- /dev/null +++ b/acceptance/router_newbenchmark/brload/main.go @@ -0,0 +1,316 @@ +// Copyright 2023 SCION Association +// +// 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 main + +import ( + "errors" + "fmt" + "hash" + "net" + "os" + "path/filepath" + "reflect" + "strings" + "time" + + "github.com/google/gopacket" + "github.com/google/gopacket/afpacket" + "github.com/google/gopacket/layers" + "github.com/spf13/cobra" + + "github.com/scionproto/scion/acceptance/router_newbenchmark/cases" + "github.com/scionproto/scion/pkg/log" + "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/scrypto" + "github.com/scionproto/scion/pkg/slayers" + "github.com/scionproto/scion/private/keyconf" +) + +type Case func(payload string, mac hash.Hash, numDistinct int) (string, string, [][]byte) + +type caseChoice string + +func (c *caseChoice) String() string { + return string(*c) +} + +func (c *caseChoice) Set(v string) error { + _, ok := allCases[v] + if !ok { + return errors.New("No such case") + } + *c = caseChoice(v) + return nil +} + +func (c *caseChoice) Type() string { + return "string enum" +} + +func (c *caseChoice) Allowed() string { + return fmt.Sprintf("One of: %v", reflect.ValueOf(allCases).MapKeys()) +} + +var ( + allCases = map[string]Case{ + "in": cases.In, + "out": cases.Out, + "in_transit": cases.InTransit, + "out_transit": cases.OutTransit, + "br_transit": cases.BrTransit, + } + logConsole string + dir string + numPackets int + numStreams int + caseToRun caseChoice + interfaces []string +) + +func main() { + rootCmd := &cobra.Command{ + Use: "brload", + Short: "Generates traffic into a specific router of a specific topology", + } + intfCmd := &cobra.Command{ + Use: "show-interfaces", + Short: "Provides a terse list of the interfaces that this test requires", + Run: func(cmd *cobra.Command, args []string) { + os.Exit(showInterfaces(cmd)) + }, + } + runCmd := &cobra.Command{ + Use: "run", + Short: "Executes the test", + Run: func(cmd *cobra.Command, args []string) { + os.Exit(run(cmd)) + }, + } + runCmd.Flags().IntVar(&numPackets, "num-packets", 10, "Number of packets to send") + runCmd.Flags().IntVar(&numStreams, "num-streams", 4, + "Number of independent streams (flowID) to use") + runCmd.Flags().StringVar(&logConsole, "log.console", "error", + "Console logging level: debug|info|error|etc.") + runCmd.Flags().StringVar(&dir, "artifacts", "", "Artifacts directory") + runCmd.Flags().Var(&caseToRun, "case", "Case to run. "+caseToRun.Allowed()) + runCmd.Flags().StringArrayVar(&interfaces, "interface", []string{}, + `label=host_interface,mac,peer_mac where: + host_interface: use this to exchange traffic with interface