kubeslice / kubeslice/kubeslice-controller

service package unit tests do not compile on master

Open Beginner friendly
#413 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
73
Forks
48
Avg merge
2d 21h
Merged PRs (30d)
8

Description

### 📜 Description

The `service` package's tests do not compile on `master`, so any run of them fails before a single test executes. Four references in test files point at symbols that no longer exist after dependency upgrades.

### 👟 Reproduction steps

```
git checkout master
go test -c -o /dev/null ./service/
```

`make unit-test` and `docker build -f unit_tests.dockerfile .` hit the same failure. `go vet ./service/...` reports only the first error, since vet stops at one error per package.

### 👍 Expected behavior

The `service` unit tests compile and run.

### 👎 Actual Behavior

The test binary fails to build. All four errors:

```
service/access_control_service_test.go:1273:61: undefined: util.Client
service/namespace_service_test.go:180:67: undefined: util.Client
service/project_service_test.go:279:65: undefined: util.Client
service/worker_slice_gateway_service_test.go:554:4: unknown field ClusterName in struct literal of type "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta
```

Both look like dependency drift that only touched test files, which is why the non-test build is unaffected:

- `util.Client` no longer exists; `util` uses `client.Client` from controller-runtime.
- `ObjectMeta.ClusterName` was removed from apimachinery in Kubernetes 1.25, and this repo is on the 1.32 client libraries.

CI does exercise this package — `unit_tests.dockerfile` runs `go test` against `/build/service` — but cannot report the failure, for reasons already tracked in #336 (`; exit 0` masks the exit code) and #330 (the image is Go 1.19 while the module requires 1.24). This issue is the underlying compile break those two would surface once fixed.

### 🐚 Relevant log output

```shell
$ go test -c -o /dev/null ./service/
# github.com/kubeslice/kubeslice-controller/service [github.com/kubeslice/kubeslice-controller/service.test]
service/access_control_service_test.go:1273:61: undefined: util.Client
service/namespace_service_test.go:180:67: undefined: util.Client
service/project_service_test.go:279:65: undefined: util.Client
service/worker_slice_gateway_service_test.go:554:4: unknown field ClusterName in struct literal of type "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta
```

### Version

master at 4137061e

### 🖥️ What operating system are you seeing the problem on?

Linux

### ✅ Proposed Solution

Change the three `util.Client` parameters to `client.Client` and drop the `ClusterName` field from the `ObjectMeta` literal. Happy to raise a PR if that approach is agreeable.

Fixing this alongside #336 and #330 would make the failure visible in CI rather than silent.

Contributor guide

Open the contributing guide

Research direction

Start with the four reported test locations: service/access_control_service_test.go, service/namespace_service_test.go, service/project_service_test.go, and service/worker_slice_gateway_service_test.go. Update the three obsolete client references and the ObjectMeta literal as proposed, then run go test -c -o /dev/null ./service/ to verify that the service tests compile.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.