Skip to content

Conversation

@mithun-pensando
Copy link

@mithun-pensando mithun-pensando commented May 10, 2025

the test cases can be run by running make from the tests folder, it builds a test container and builds the go grpc client code and runs go test from inside the container. user needs to pass the IP of the server where gpuagent is running.
Sample test run output:

$GRPC_BASE_URL="134.199.131.74" make
docker build -t gpuagent-go-test-env .
[+] Building 0.3s (10/10) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.49kB 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:22.04 0.3s
=> [1/6] FROM docker.io/library/ubuntu:22.04@sha256:67cadaff1dca187079fce41360d5a7eb6f7dcd3745e53c79ad5efd8563118240 0.0s
=> CACHED [2/6] RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y wget git make unzip build-essential && echo 'Install golang' && wget https://dl.google. 0.0s
=> CACHED [3/6] WORKDIR /gpu-agent 0.0s
=> CACHED [4/6] RUN go mod init temp 0.0s
=> CACHED [5/6] RUN go get github.com/gogo/protobuf/protoc-gen-gogofast 0.0s
=> CACHED [6/6] RUN go install github.com/gogo/protobuf/protoc-gen-gogofast 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:255ad47988c8e92ecd8f7c07b6ec9b4d72fb258d08d2f54bbf1cb58937272a07 0.0s
=> => naming to docker.io/library/gpuagent-go-test-env 0.0s
docker run --rm
-e GRPC_BASE_URL=134.199.131.74
-v /home/mithun/workspace/src/github.com/ROCm/gpu-agent/sw/nic/gpuagent/tests/../../../..:/gpu-agent gpuagent-go-test-env
sh -c "make -C /gpu-agent/sw/nic/gpuagent/protos && go test -v /gpu-agent/sw/nic/gpuagent/tests/"
make: Entering directory '/gpu-agent/sw/nic/gpuagent/protos'
debug.proto events.proto gpu.proto gpu_watch.proto topo.proto
mkdir -p ../../../nic/gpuagent/gen/go
rm -f ../../../nic/gpuagent/gen/go/*.go
LC_ALL=C protoc --proto_path=/gpu-agent/sw/nic/gpuagent/protos -I/gpu-agent/sw/nic/gpuagent/protos
-I../../.. -I../../../vendor/github.com/gogo/protobuf/gogoproto
--gogofast_out=Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,Mgogo.proto=github.com/gogo/protobuf/gogoproto,plugins=grpc:../../../nic/gpuagent/gen/go types.proto debug.proto events.proto gpu.proto gpu_watch.proto topo.proto
make: Leaving directory '/gpu-agent/sw/nic/gpuagent/protos'
go: downloading google.golang.org/grpc v1.72.1
go: downloading google.golang.org/protobuf v1.36.6
go: downloading github.com/satori/go.uuid v1.2.0
go: downloading golang.org/x/net v0.35.0
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a
go: downloading golang.org/x/sys v0.30.0
go: downloading golang.org/x/text v0.22.0
grpcbaseurl: 134.199.131.74
Running Unit test cases for gpuagent
=== RUN TestGetGpu
TestGetGpusAll: No of GPUs returned: 8
--- PASS: TestGetGpu (0.86s)
=== RUN TestGpuAdminStUpdate
--- PASS: TestGpuAdminStUpdate (0.94s)
=== RUN TestGpuPerfLevelUpdate
--- PASS: TestGpuPerfLevelUpdate (0.94s)
=== RUN TestGpuOverdriveLevelUpdate
--- PASS: TestGpuOverdriveLevelUpdate (0.94s)
=== RUN TestGpuDeviceTopology
--- PASS: TestGpuDeviceTopology (0.08s)
=== RUN TestGpuReset
--- PASS: TestGpuReset (0.78s)
PASS
ok github.com/ROCm/gpu-agent/sw/nic/gpuagent/tests 4.618s
docker rmi -f gpuagent-go-test-env
Untagged: gpuagent-go-test-env:latest
Deleted: sha256:255ad47988c8e92ecd8f7c07b6ec9b4d72fb258d08d2f54bbf1cb58937272a07

@mithun-pensando mithun-pensando force-pushed the gpuagentmh branch 3 times, most recently from e6cca97 to fa44b98 Compare May 16, 2025 01:04
@mithun-pensando mithun-pensando changed the title Add unit test cases for gpuagent The test binary can be compiled by … Add unit test cases for gpuagent May 16, 2025
@@ -0,0 +1,21 @@
module github.com/ROCm/gpu-agent
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess these new go.mod & .sum files are needed for the go tests?

Copy link
Author

Choose a reason for hiding this comment

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

Yes

…running 'make' in

sw/nic/gpuagent/test/ which generates gpuAgentTest binary which can be
run against gpuagent running on a server

Added changes to generate go grpc client code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants