Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit 8a5707d

Browse files
author
phansGithub
committed
Added the golang client to our e2e testing
Signed-off-by: phansGithub <[email protected]>
1 parent 93d43de commit 8a5707d

File tree

4 files changed

+102
-27
lines changed

4 files changed

+102
-27
lines changed

.github/workflows/public-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
run: sudo apt-get update && sudo apt install libbpf-dev clang llvm gcc-multilib
5959

6060
- name: Install staticcheck
61-
run: go install honnef.co/go/tools/cmd/staticcheck@latest
61+
run: go install honnef.co/go/tools/cmd/staticcheck@latest && go get github.com/intel/afxdp-plugins-for-kubernetes/pkg/goclient
6262

6363
- name: run static analysis
6464
run: make static-ci

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ e2efull: build
125125
e2edaemon: image
126126
@echo "****** E2E Daemonset ******"
127127
@echo
128-
cd test/e2e/ && ./e2e-test.sh --daemonset
128+
cd test/e2e/ && ./e2e-test.sh --daemonset --uds && ./e2e-test.sh --daemonset --golang
129129
@echo
130130
@echo
131131

test/e2e/e2e-test.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ ciWorkdir="./../../.github/e2e"
2020
run_dp="./../../bin/afxdp-dp"
2121
full_run=false
2222
daemonset=false
23+
daemonsetGo=false
24+
daemonsetUDS=false
2325
soak=false
2426
ci_run=false
2527
pids=( )
@@ -148,9 +150,15 @@ run_local_pods() {
148150
echo
149151
kubectl exec -i afxdp-e2e-test -- env
150152
echo
151-
echo "***** UDS Test *****"
152-
echo
153-
kubectl exec -i afxdp-e2e-test --container afxdp -- udsTest
153+
if [ "$daemonsetUDS" = true ]; then
154+
echo "***** UDS Test *****"
155+
echo
156+
kubectl exec -i afxdp-e2e-test --container afxdp -- udsTest uds
157+
elif [ "$daemonsetGo" = true ]; then
158+
echo "***** GO Library Test *****"
159+
echo
160+
kubectl exec -i afxdp-e2e-test --container afxdp -- udsTest golang
161+
fi
154162
echo "***** Delete Pod *****"
155163
kubectl delete pod --grace-period 0 --ignore-not-found=true afxdp-e2e-test &> /dev/null
156164
if [ "$full_run" = true ]; then
@@ -375,6 +383,12 @@ then
375383
-d|--daemonset)
376384
daemonset=true
377385
;;
386+
-g|--golang)
387+
daemonsetGo=true
388+
;;
389+
-u|--uds)
390+
daemonsetUDS=true
391+
;;
378392
-c|--ci)
379393
ci_run=true
380394
daemonset=true

test/e2e/udsTest.go

Lines changed: 83 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
package main
1717

1818
import (
19-
"github.com/intel/afxdp-plugins-for-kubernetes/constants"
20-
"github.com/intel/afxdp-plugins-for-kubernetes/internal/uds"
19+
"fmt"
2120
"os"
2221
"strconv"
2322
"strings"
2423
"time"
24+
25+
"github.com/intel/afxdp-plugins-for-kubernetes/constants"
26+
"github.com/intel/afxdp-plugins-for-kubernetes/internal/uds"
27+
"github.com/intel/afxdp-plugins-for-kubernetes/pkg/goclient"
2528
)
2629

2730
const (
@@ -33,6 +36,44 @@ const (
3336
var udsHandler uds.Handler
3437

3538
func main() {
39+
if os.Args[1] == "uds" {
40+
udsTest()
41+
} else if os.Args[1] == "golang" {
42+
clientTest()
43+
} else {
44+
println("Unrecognized testing parameters.")
45+
}
46+
}
47+
48+
func timeout() {
49+
println("Test App - Pausing for", timeoutDuration, "seconds to force timeout")
50+
println("Test App - Expecting timeout error to occur")
51+
time.Sleep(timeoutDuration * time.Second)
52+
println("Test App - Exiting")
53+
os.Exit(0)
54+
}
55+
56+
func makeRequest(request string) {
57+
println()
58+
println("Test App - Request: " + request)
59+
60+
if err := udsHandler.Write(request, -1); err != nil {
61+
println("Test App - Write error: ", err)
62+
}
63+
64+
response, fd, err := udsHandler.Read()
65+
if err != nil {
66+
println("Test App - Read error: ", err)
67+
}
68+
69+
println("Test App - Response: " + response)
70+
if fd > 0 {
71+
println("Test App - File Descriptor:", strconv.Itoa(fd))
72+
}
73+
println()
74+
}
75+
76+
func udsTest() {
3677
timeoutAfterConnect := false
3778
timeoutBeforeConnect := false
3879
// Command line argument to set timeout test
@@ -80,7 +121,6 @@ func main() {
80121
cleanup()
81122
os.Exit(1)
82123
}
83-
defer cleanup()
84124

85125
// connect and verify pod hostname
86126
makeRequest("/connect, " + hostname)
@@ -114,32 +154,53 @@ func main() {
114154
// finish
115155
makeRequest("/fin")
116156
time.Sleep(requestDelay)
157+
cleanup()
117158
}
118159

119-
func timeout() {
120-
println("Test App - Pausing for", timeoutDuration, "seconds to force timeout")
121-
println("Test App - Expecting timeout error to occur")
122-
time.Sleep(timeoutDuration * time.Second)
123-
println("Test App - Exiting")
124-
os.Exit(0)
125-
}
160+
func clientTest() {
126161

127-
func makeRequest(request string) {
128-
println()
129-
println("Test App - Request: " + request)
162+
var clean2 uds.CleanupFunc
163+
var fd int
130164

131-
if err := udsHandler.Write(request, -1); err != nil {
132-
println("Test App - Write error: ", err)
165+
//Get environment variable device values
166+
devicesVar, exists := os.LookupEnv(constants.Devices.EnvVarList)
167+
if !exists {
168+
println("Test App Error: Devices env var does not exist")
169+
os.Exit(1)
133170
}
171+
devices := strings.Split(devicesVar, " ")
134172

135-
response, fd, err := udsHandler.Read()
136-
if err != nil {
137-
println("Test App - Read error: ", err)
173+
// Request Client Version
174+
println("GO Library: Requesting client version from GO library")
175+
ver := goclient.GetClientVersion()
176+
fmt.Printf("GO Library: Client Version: %s \n \n", ver)
177+
time.Sleep(requestDelay)
178+
179+
// Request Server Version
180+
println("GO Library: Requesting server version from GO library")
181+
ver, clean1, _ := goclient.GetServerVersion()
182+
fmt.Printf("GO Library: Server Version: %s \n \n", ver)
183+
time.Sleep(requestDelay)
184+
185+
// Request XSK map FD for all devices
186+
println("GO Library: Requesting XSK map FD")
187+
for _, dev := range devices {
188+
fd, clean2, _ = goclient.RequestXSKmapFD(dev)
189+
fmt.Printf("GO Library: XSK map FD request succeded for %s with fd %d \n \n", dev, fd)
190+
// time.Sleep(requestDelay)
138191
}
192+
time.Sleep(requestDelay)
139193

140-
println("Test App - Response: " + response)
141-
if fd > 0 {
142-
println("Test App - File Descriptor:", strconv.Itoa(fd))
194+
// Request XSK map FD for an unknown device
195+
println("GO Library: Request XSk map FD for an unknown device")
196+
fd, clean3, err := goclient.RequestXSKmapFD("bad-device")
197+
if err != nil {
198+
fmt.Printf("GO Library: Returned value from unknown device: %d \n \n", fd)
143199
}
144-
println()
200+
time.Sleep(requestDelay)
201+
202+
println("Cleaning up... \n")
203+
clean1()
204+
clean2()
205+
clean3()
145206
}

0 commit comments

Comments
 (0)