Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pkg/cclient/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright(c) 2022 Intel Corporation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Copyright(c) 2022 Intel Corporation.
# Copyright(c) 2024 Intel Corporation.

# 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.

FROM ubuntu:22.04
RUN apt-get update \
&& apt-get install -y iproute2
COPY ./cTest /bin
COPY ./lib_udsclient.so /lib

9 changes: 9 additions & 0 deletions pkg/cclient/cTest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "lib_udsclient.h"
#include <stdio.h>

int main() {
printf("C Library: Client Version: %s \n", GetUdsClientVersion());
printf("C Library: Server Version: %s \n", GetUdsServerVersion());
printf("C Library: Xsk Map FD request: %d \n", RequestXskMapFd("enp94s0f0"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printf("C Library: Xsk Map FD request: %d \n", RequestXskMapFd("enp94s0f0"));
printf("C Library: xskmap FD request: %d \n", RequestXskMapFd("enp94s0f0"));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about hardcoding this to a physical interface... might be better to create a veth in the context of the pod for testing?

CleanUpConnection();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a blank line please at the end of file

10 changes: 10 additions & 0 deletions pkg/cclient/e2e-c-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Build binary, .h, .a and .so files
go build -o lib_udsclient.so -buildmode=c-shared ./cclient.go
gcc -c cTest.c -o cTest.o
cp lib_udsclient.so /lib
gcc -pthread -o cTest cTest.o -L. /lib/lib_udsclient.so
# Build and push image
docker build -t localhost:5000/afxdp-c-test:latest .
docker push localhost:5000/afxdp-c-test
45 changes: 44 additions & 1 deletion test/e2e/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ workdir="."
ciWorkdir="./../../.github/e2e"
run_dp="./../../bin/afxdp-dp"
full_run=false
c_run=false
daemonset=false
soak=false
ci_run=false
Expand Down Expand Up @@ -46,6 +47,7 @@ cleanup() {
echo "*****************************************************"
echo "Delete Pod"
kubectl delete pod --grace-period=0 --ignore-not-found=true afxdp-e2e-test &> /dev/null
kubectl delete pod --grace-period=0 --ignore-not-found=true afxdp-c-test &> /dev/null
kubectl delete pods -l app=afxdp-e2e -n default --grace-period=0 --ignore-not-found=true &> /dev/null
echo "Delete Test App"
rm -f ./udsTest &> /dev/null
Expand Down Expand Up @@ -80,6 +82,13 @@ build() {
go build -tags netgo -o udsTest ./udsTest.go
echo "***** Docker Image *****"
$container_tool build -t afxdp-e2e-test -f Dockerfile .
if [ "$c_run" = true ]; then
echo "*****************************************************"
echo "* Build C Image and Library *"
echo "*****************************************************"
echo
# ../../pkg/cclient/e2e-c-test.sh
fi
}

run() {
Expand Down Expand Up @@ -132,7 +141,7 @@ run_local_pods() {
echo "* Run Pod: 1 container, 1 device *"
echo "*****************************************************"
kubectl create -f $workdir/pod-1c1d.yaml
sleep 10
sleep 30
echo
echo "***** Netdevs attached to pod (ip a) *****"
echo
Expand Down Expand Up @@ -249,6 +258,37 @@ run_local_pods() {
echo "***** Delete Pod *****"
kubectl delete pod --grace-period 0 --ignore-not-found=true afxdp-e2e-test &> /dev/null
fi

if [ "$c_run" = true ]
then
echo
echo "******************************************************************"
echo "* Run Pod: C-E2E (after connect) *"
echo "******************************************************************"
echo
echo "***** C Library Test *****"
echo
kubectl create -f $workdir/pod-c-e2e.yaml
sleep 30
echo "***** Netdevs attached to pod (ip a) *****"
echo
kubectl exec -i afxdp-c-test -- ip a
sleep 2
echo
echo "***** Netdevs attached to pod (ip l) *****"
echo
kubectl exec -i afxdp-c-test -- ip l
sleep 2
echo
echo "***** Pod Env Vars *****"
echo
kubectl exec -i afxdp-c-test -- env
echo
kubectl exec -i afxdp-c-test --container afxdp-c -- /bin/cTest
echo
echo "***** Delete Pod *****"
kubectl delete pod --grace-period 0 --ignore-not-found=true afxdp-c-test &> /dev/null
fi
}

run_ci_pods() {
Expand Down Expand Up @@ -375,6 +415,9 @@ then
-d|--daemonset)
daemonset=true
;;
-ce|--ce2e)
c_run=true
;;
-c|--ci)
ci_run=true
daemonset=true
Expand Down
20 changes: 20 additions & 0 deletions test/e2e/pod-c-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Pod
metadata:
name: afxdp-c-test
annotations:
k8s.v1.cni.cncf.io/networks: afxdp-e2e-test
spec:
containers:
- name: afxdp-c
image: localhost:5000/afxdp-c-test:latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
image: localhost:5000/afxdp-c-test:latest
image: afxdp-c-test:latest

securityContext:
privileged: true
imagePullPolicy: Always
command: ["tail", "-f", "/dev/null"]
resources:
requests:
afxdp/e2e: '1'
limits:
afxdp/e2e: '1'
restartPolicy: Never