Add unit test cases for gpuagent #15
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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