aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/k8s/cluster-deployment/uscni/Dockerfile25
-rwxr-xr-xtools/k8s/cluster-deployment/uscni/entrypoint.sh18
-rw-r--r--tools/k8s/cluster-deployment/uscni/userspace-cni-daemonset.yml45
-rw-r--r--tools/pkt_gen/trex/trex_client.py86
4 files changed, 167 insertions, 7 deletions
diff --git a/tools/k8s/cluster-deployment/uscni/Dockerfile b/tools/k8s/cluster-deployment/uscni/Dockerfile
new file mode 100644
index 00000000..ddfa3674
--- /dev/null
+++ b/tools/k8s/cluster-deployment/uscni/Dockerfile
@@ -0,0 +1,25 @@
+# docker build --rm -t uscni
+FROM centos:7
+SHELL ["/bin/bash", "-o", "pipefail", "-c"]
+RUN yum install -y epel-release wget; yum clean all
+RUN wget --no-check-certificate https://golang.org/dl/go1.16.6.linux-amd64.tar.gz
+RUN tar -C /usr/local -xzf go1.16.6.linux-amd64.tar.gz
+ENV PATH /usr/local/go/bin:$PATH
+RUN yum install -y git make sudo; yum clean all
+ENV GOPATH /root/go
+RUN mkdir -p "/root/go" "$GOPATH/bin" "$GOPATH/src" "$GOPATH/src" && chmod -R 777 "$GOPATH"
+WORKDIR /root/go/src/
+ENV GO111MODULE off
+RUN go get github.com/intel/userspace-cni-network-plugin > /tmp/UserspaceDockerBuild.log 2>&1 || echo "Can ignore no GO files."
+WORKDIR /root/go/src/github.com/intel/userspace-cni-network-plugin
+ENV GO111MODULE on
+ENV GOROOT /usr/local/go
+ENV GOPATH /root/go
+RUN make clean && make install-dep && make install && make
+RUN cp userspace/userspace /usr/bin/userspace
+
+FROM alpine:latest
+COPY --from=0 /usr/bin/userspace /userspace
+
+ADD entrypoint.sh /
+ENTRYPOINT ["/entrypoint.sh"]
diff --git a/tools/k8s/cluster-deployment/uscni/entrypoint.sh b/tools/k8s/cluster-deployment/uscni/entrypoint.sh
new file mode 100755
index 00000000..0658f150
--- /dev/null
+++ b/tools/k8s/cluster-deployment/uscni/entrypoint.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Always exit on errors.
+set -e
+
+# Check if /opt/cni/bin directory exists
+if [ ! -d "/host/opt/cni/bin" ]
+then
+ echo "Directory /opt/cni/bin/ does not exists."
+ exit 1;
+fi
+
+# Copy cni-plugin on host machine
+cp -f /userspace /host/opt/cni/bin/
+
+# Sleep for 50 years.
+# sleep infinity is not available in alpine;
+sleep 2147483647
diff --git a/tools/k8s/cluster-deployment/uscni/userspace-cni-daemonset.yml b/tools/k8s/cluster-deployment/uscni/userspace-cni-daemonset.yml
new file mode 100644
index 00000000..d598fc6d
--- /dev/null
+++ b/tools/k8s/cluster-deployment/uscni/userspace-cni-daemonset.yml
@@ -0,0 +1,45 @@
+apiVersion: apps/v1
+kind: DaemonSet
+metadata:
+ name: userspace-cni-amd64
+ namespace: kube-system
+ labels:
+ tier: node
+ app: userspace-cni
+spec:
+ selector:
+ matchLabels:
+ app: userspace-cni
+ template:
+ metadata:
+ labels:
+ tier: node
+ app: userspace-cni
+ spec:
+ hostNetwork: true
+ nodeSelector:
+ beta.kubernetes.io/arch: amd64
+ tolerations:
+ - key: node-role.kubernetes.io/master
+ operator: Exists
+ effect: NoSchedule
+ containers:
+ - name: userspace-cni-plugin
+ image: uscni:latest
+ imagePullPolicy: Never
+ resources:
+ requests:
+ cpu: "100m"
+ memory: "50Mi"
+ limits:
+ cpu: "100m"
+ memory: "50Mi"
+ securityContext:
+ privileged: true
+ volumeMounts:
+ - name: cnibin
+ mountPath: /host/opt/cni/bin
+ volumes:
+ - name: cnibin
+ hostPath:
+ path: /opt/cni/bin
diff --git a/tools/pkt_gen/trex/trex_client.py b/tools/pkt_gen/trex/trex_client.py
index 3d6836d8..680497ec 100644
--- a/tools/pkt_gen/trex/trex_client.py
+++ b/tools/pkt_gen/trex/trex_client.py
@@ -85,6 +85,11 @@ _SCAPY_FRAME = {
'{IP_PROTO}(sport={IP_PROTO_dport}, dport={IP_PROTO_sport})',
}
+def cast_integer(value):
+ """
+ force 0 value if NaN value from TRex to avoid error in JSON result parsing
+ """
+ return int(value) if not isnan(value) else 0
class Trex(ITrafficGenerator):
"""Trex Traffic generator wrapper."""
@@ -103,6 +108,7 @@ class Trex(ITrafficGenerator):
self._stlclient = None
self._verification_params = None
self._show_packet_data = False
+ self.trial_results = []
def show_packet_info(self, packet_a, packet_b):
"""
@@ -130,7 +136,15 @@ class Trex(ITrafficGenerator):
else:
raise RuntimeError('T-Rex: Trex host not defined')
- ping = subprocess.Popen(cmd_ping, shell=True, stderr=subprocess.PIPE)
+ if settings.getValue('CLEAN_OUTPUT'):
+ ping = subprocess.Popen(cmd_ping,
+ shell=True,
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.PIPE)
+ else:
+ ping = subprocess.Popen(cmd_ping,
+ shell=True,
+ stderr=subprocess.PIPE)
output, error = ping.communicate()
if ping.returncode:
@@ -146,9 +160,16 @@ class Trex(ITrafficGenerator):
self._trex_base_dir + "t-rex-64"
- find_trex = subprocess.Popen(cmd_find_trex,
- shell=True,
- stderr=subprocess.PIPE)
+ if settings.getValue('CLEAN_OUTPUT'):
+ find_trex = subprocess.Popen(cmd_find_trex,
+ shell=True,
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.PIPE)
+ else:
+ find_trex = subprocess.Popen(cmd_find_trex,
+ shell=True,
+ stderr=subprocess.PIPE)
+
output, error = find_trex.communicate()
if find_trex.returncode:
@@ -159,8 +180,12 @@ class Trex(ITrafficGenerator):
% (self._trex_host_ip_addr, self._trex_base_dir))
try:
- self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr,
- verbose_level='info')
+ if settings.getValue('CLEAN_OUTPUT'):
+ self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr,
+ verbose_level='error')
+ else:
+ self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr,
+ verbose_level='info')
self._stlclient.connect()
except STLError:
raise RuntimeError('T-Rex: Cannot connect to T-Rex server. Please check if it is '
@@ -386,7 +411,8 @@ class Trex(ITrafficGenerator):
self._stlclient.set_port_attr(my_ports, promiscuous=True)
packet_1, packet_2 = self.create_packets(traffic, ports_info)
- self.show_packet_info(packet_1, packet_2)
+ if not settings.getValue('CLEAN_OUTPUT'):
+ self.show_packet_info(packet_1, packet_2)
stream_1, stream_2, stream_1_lat, stream_2_lat = Trex.create_streams(packet_1, packet_2, traffic)
self._stlclient.add_streams(stream_1, ports=[0])
self._stlclient.add_streams(stream_2, ports=[1])
@@ -564,6 +590,48 @@ class Trex(ITrafficGenerator):
result[ResultsConstants.CAPTURE_TX] = stats['capture_tx']
if 'capture_rx' in stats:
result[ResultsConstants.CAPTURE_RX] = stats['capture_rx']
+ # Write all per-trial results to a file
+ filec = os.path.join(settings.getValue('RESULTS_PATH'), 'trex_pertrial_results.csv')
+
+ ports = [0, 1]
+ with open(filec, 'a') as fcp:
+ fcp.write("frame_size,port,rx_pkts,tx_pkts,rx_bytes,tx_bytes,"+
+ "rx_pps,tx_pps,rx_bps,tx_bps,"+
+ "drp_pkts_d1,drp_pkts_d2,min1,avg1,max1,"+
+ "min2,avg2,max2\n")
+ for key in self.trial_results:
+ for port in ports:
+ stats = self.trial_results[key][port]
+ far_end_stats = self.trial_results[key][1 - port]
+ tx_pkts = stats['opackets']
+ rx_pkts = stats['ipackets']
+ tx_bytes = stats['obytes']
+ rx_bytes = stats['ibytes']
+ rx_pps = stats['rx_pps']
+ tx_pps = stats['tx_pps']
+ rx_bps = stats['rx_bps']
+ tx_bps = stats['tx_bps']
+ dr_pkts_d1 = (cast_integer(far_end_stats['0packets'])
+ - cast_integer(stats['ipackets']))
+ dr_pkts_d2 = (cast_integer(stats['0packets'])
+ - cast_integer(far_end_stats['ipackets']))
+ try:
+ min1 = float(stats["latency"][0]["latency"]["total_min"])
+ min2 = float(stats["latency"][1]["latency"]["total_min"])
+ max1 = float(stats["latency"][0]["latency"]["total_max"])
+ max2 = float(stats["latency"][1]["latency"]["total_max"])
+ avg1 = float(stats["latency"][0]["latency"]["average"])
+ avg2 = float(stats["latency"][1]["latency"]["average"])
+ except TypeError:
+ min1,min2,max1,max2,avg1,avg2 = -1.0
+
+ fcp.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17}\n".format(
+ key,port,rx_pkts,tx_pkts,rx_bytes,
+ tx_bytes,rx_pps,tx_pps,rx_bps,tx_bps,
+ dr_pkts_d1, dr_pkts_d2, min1, avg1, max1,
+ min2, avg2, max2))
+
+
return result
def learning_packets(self, traffic):
@@ -595,6 +663,7 @@ class Trex(ITrafficGenerator):
"""
threshold = settings.getValue('TRAFFICGEN_TREX_RFC2544_TPUT_THRESHOLD')
max_repeat = settings.getValue('TRAFFICGEN_TREX_RFC2544_MAX_REPEAT')
+ frame_size = traffic['l2']['framesize']
loss_verification = settings.getValue('TRAFFICGEN_TREX_RFC2544_BINARY_SEARCH_LOSS_VERIFICATION')
if loss_verification:
self._logger.info("Running Binary Search with Loss Verification")
@@ -606,8 +675,10 @@ class Trex(ITrafficGenerator):
right = boundaries['right']
center = boundaries['center']
self._logger.info('Starting RFC2544 trials')
+ results = []
while (right - left) > threshold:
stats = self.generate_traffic(new_params, duration)
+ results.append(copy.deepcopy(stats))
test_lossrate = ((stats["total"]["opackets"] - stats[
"total"]["ipackets"]) * 100) / stats["total"]["opackets"]
if stats["total"]["ipackets"] == 0:
@@ -645,6 +716,7 @@ class Trex(ITrafficGenerator):
new_params = copy.deepcopy(traffic)
new_params['frame_rate'] = center
iteration += 1
+ self.trial_results[frame_size] = results
return stats_ok
def send_cont_traffic(self, traffic=None, duration=30):