aboutsummaryrefslogtreecommitdiffstats
path: root/GPL
diff options
context:
space:
mode:
authorJuraj Linkeš <juraj.linkes@pantheon.tech>2021-01-07 16:25:31 +0100
committerJuraj Linke? <juraj.linkes@pantheon.tech>2021-01-11 15:37:32 +0000
commit9d510d595f73d26e3f7c6646fa6530e8f252f790 (patch)
tree6a619859dccae3f368ade61dc85a2c68849df82f /GPL
parent2f4b14bc83437afcc242190a121ba47a6d10bd09 (diff)
tests: add 2n1l l2 acl tests, update 2n-tx2 specs
Modify initialize L2BD ACL keywords to be usable for both 2-node and 3-node topologies and update testsuites accordingly. Add the missing macip T-rex profile. Add classifier tests to 2n-tx2 job specs. Change-Id: I17b84b8fc18ef9a6f275ae0238a0665ac2017f01 Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Diffstat (limited to 'GPL')
-rw-r--r--GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc10kip4src10k.py170
1 files changed, 170 insertions, 0 deletions
diff --git a/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc10kip4src10k.py b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc10kip4src10k.py
new file mode 100644
index 0000000000..a644e99953
--- /dev/null
+++ b/GPL/traffic_profiles/trex/trex-stl-2n-ethip4-macsrc10kip4src10k.py
@@ -0,0 +1,170 @@
+# Copyright (c) 2021 Cisco and/or its affiliates.
+#
+# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+#
+# Licensed under the Apache License 2.0 or
+# GNU General Public License v2.0 or later; you may not use this file
+# except in compliance with one of these Licenses. You
+# may obtain a copy of the Licenses at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
+#
+# Note: If this file is linked with Scapy, which is GPLv2+, your use of it
+# must be under GPLv2+. If at any point in the future it is no longer linked
+# with Scapy (or other GPLv2+ licensed software), you are free to choose Apache 2.
+#
+# 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.
+
+"""Stream profile for T-rex traffic generator.
+
+Stream profile:
+ - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time.
+ - Packet: | ETH | IP |
+ - Direction 0 --> 1:
+ - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:27:0f
+ - Source IP address range: 10.0.0.2 - 10.0.39.17
+ - Destination IP address range: 20.0.0.1
+ - Direction 1 --> 0:
+ - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:27:0f
+ - Source IP address range: 20.0.0.2 - 20.0.39.17
+ - Destination IP address range: 10.0.0.1
+"""
+
+from trex.stl.api import *
+from profile_trex_stateless_base_class import TrafficStreamsBaseClass
+
+
+class TrafficStreams(TrafficStreamsBaseClass):
+ """Stream profile."""
+
+ def __init__(self):
+ """Initialization and setting of streams' parameters."""
+
+ super(TrafficStreamsBaseClass, self).__init__()
+
+ self.clients = 10000
+
+ # MACs used in packet headers.
+ self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF
+
+ self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF
+
+ # IPs used in packet headers.
+ self.p1_src_start_ip = u"10.0.0.2"
+ self.p1_src_end_ip = u"10.0.39.17"
+ self.p1_dst_start_ip = u"20.0.0.1"
+
+ self.p2_src_start_ip = u"20.0.0.2"
+ self.p2_src_end_ip = u"20.0.39.17"
+ self.p2_dst_start_ip = u"10.0.0.1"
+
+ def define_packets(self):
+ """Defines the packets to be sent from the traffic generator.
+
+ Packet definition: | ETH | IP |
+
+ :returns: Packets to be sent from the traffic generator.
+ :rtype: tuple
+ """
+
+ # Direction 0 --> 1
+ base_pkt_a = (
+ Ether(
+ src=self.p1_src_start_mac
+ ) /
+ IP(
+ src=self.p1_src_start_ip,
+ dst=self.p1_dst_start_ip,
+ proto=61
+ )
+ )
+ # Direction 1 --> 0
+ base_pkt_b = (
+ Ether(
+ src=self.p2_src_start_mac
+ ) /
+ IP(
+ src=self.p2_src_start_ip,
+ dst=self.p2_dst_start_ip,
+ proto=61
+ )
+ )
+
+ # Direction 0 --> 1
+ vm1 = STLScVmRaw(
+ [
+ STLVmFlowVar(
+ name=u"mac_src",
+ min_value=0,
+ max_value=self.clients-1,
+ size=4,
+ op=u"inc"
+ ),
+ STLVmWrFlowVar(
+ fv_name=u"mac_src",
+ pkt_offset=8
+ ),
+ STLVmFlowVar(
+ name=u"src",
+ min_value=self.p1_src_start_ip,
+ max_value=self.p1_src_end_ip,
+ size=4,
+ op=u"inc"
+ ),
+ STLVmWrFlowVar(
+ fv_name=u"src",
+ pkt_offset=u"IP.src"
+ ),
+ STLVmFixIpv4(
+ offset=u"IP"
+ )
+ ]
+ )
+ # Direction 1 --> 0
+ vm2 = STLScVmRaw(
+ [
+ STLVmFlowVar(
+ name=u"mac_src",
+ min_value=0,
+ max_value=self.clients-1,
+ size=4,
+ op=u"inc"
+ ),
+ STLVmWrFlowVar(
+ fv_name=u"mac_src",
+ pkt_offset=8
+ ),
+ STLVmFlowVar(
+ name=u"src",
+ min_value=self.p2_src_start_ip,
+ max_value=self.p2_src_end_ip,
+ size=4,
+ op=u"inc"
+ ),
+ STLVmWrFlowVar(
+ fv_name=u"src",
+ pkt_offset=u"IP.src"
+ ),
+ STLVmFixIpv4(
+ offset=u"IP"
+ )
+ ]
+ )
+
+ return base_pkt_a, base_pkt_b, vm1, vm2
+
+
+def register():
+ """Register this traffic profile to T-rex.
+
+ Do not change this function.
+
+ :returns: Traffic streams.
+ :rtype: Object
+ """
+ return TrafficStreams()
n class="n">i is None: i = "" return str(o), f, c, i # Returns version of the installed Go def get_go_version(go_root): p = subprocess.Popen(["./go", "version"], cwd=go_root + "/bin", stdout=subprocess.PIPE, universal_newlines=True, ) output, _ = p.communicate() output_fmt = output.replace("go version go", "", 1) return output_fmt.rstrip("\n") # Returns version of the installed binary API generator def get_binapi_gen_version(go_path): p = subprocess.Popen(["./binapi-generator", "-version"], cwd=go_path + "/bin", stdout=subprocess.PIPE, universal_newlines=True, ) output, _ = p.communicate() output_fmt = output.replace("govpp", "", 1) return output_fmt.rstrip("\n") # Verifies local Go installation and installs the latest # one if missing def install_golang(go_root): go_bin = go_root + "/bin/go" if os.path.exists(go_bin) and os.path.isfile(go_bin): print('Go ' + get_go_version(go_root) + ' is already installed') return print("Go binary not found, installing the latest version...") go_folders = ['src', 'pkg', 'bin'] for f in go_folders: if not os.path.exists(os.path.join(go_root, f)): os.makedirs(os.path.join(go_root, f)) filename = requests.get('https://golang.org/VERSION?m=text').text + ".linux-amd64.tar.gz" url = "https://dl.google.com/go/" + filename r = requests.get(url) with open("/tmp/" + filename, 'wb') as f: f.write(r.content) go_tf = tarfile.open("/tmp/" + filename) # Strip /go dir from the go_root path as it will # be created while extracting the tar file go_root_head, _ = os.path.split(go_root) go_tf.extractall(path=go_root_head) go_tf.close() os.remove("/tmp/" + filename) print('Go ' + get_go_version(go_root) + ' was installed') # Installs latest binary API generator def install_binapi_gen(c, go_root, go_path): os.environ['GO111MODULE'] = "on" if os.path.exists(go_root + "/bin/go") & os.path.isfile(go_root + "/bin/go"): p = subprocess.Popen(["./go", "get", "git.fd.io/govpp.git/cmd/binapi-generator@" + c], cwd=go_root + "/bin", stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, ) _, error = p.communicate() if p.returncode != 0: print("binapi generator installation failed: %d %s" % (p.returncode, error)) sys.exit(1) bg_ver = get_binapi_gen_version(go_path) print('Installed binary API generator ' + bg_ver) # Creates generated bindings using GoVPP binapigen to the target folder def generate_api(output_dir, vpp_dir, api_list, import_prefix, no_source, go_path): output_binapi = output_dir + "binapi" if output_dir[-1] == "/" else output_dir + "/binapi" json_dir = vpp_dir + "/build-root/install-vpp-native/vpp/share/vpp/api" if not os.path.exists(json_dir): print("Missing JSON api definitions") sys.exit(1) print("Generating API") cmd = ["./binapi-generator", "--output-dir=" + output_binapi, "--input-dir=" + json_dir] if len(api_list): print("Following API files were requested by 'GO_API_FILES': " + str(api_list)) print("Note that dependency requirements may generate additional API files") cmd.append(api_list) if not import_prefix == "": cmd.append("-import-prefix=" + import_prefix) if no_source: cmd.append("-no-source-path-info") p = subprocess.Popen(cmd, cwd=go_path + "/bin", stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, ) out = p.communicate()[1] if p.returncode != 0: print("go api generate failed: %d %s" % (p.returncode, out)) sys.exit(1) # Print nice output of the binapi generator for msg in out.split(): if "=" in msg: print() print(msg, end=" ") print("\n") print("Go API bindings were generated to " + output_binapi) def main(): # project root directory root = pathlib.Path(os.path.dirname(os.path.abspath(__file__))) vpp_dir: str = root.parent.parent.parent o, f, c, i = validate_args(vpp_dir, args.output_dir, args.api_files, args.govpp_commit, args.import_prefix) # go specific environment variables if "GOROOT" in os.environ: go_root = os.environ['GOROOT'] else: go_root = os.environ['HOME'] + "/.go" if "GOPATH" in os.environ: go_path = os.environ['GOPATH'] else: go_path = os.environ['HOME'] + "/go" install_golang(go_root) install_binapi_gen(c, go_root, go_path) generate_api(o, str(vpp_dir), f, i, args.no_source_path_info, go_path) if __name__ == "__main__": main()