mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-02 06:08:23 +08:00
Moves and duplicates Kubernetes test helpers to keep testing code
out of production binaries. Two of the most extensive init operations
in v17 stem from `lib/kube/testing/kube_server`.
```
$ GODEBUG='inittrace=1' ./releases/17.4.1/teleport version 2>&1 | rg '^init' | awk '{print $5 " ms " $2}' | sort -nr | head -5
0.93 ms github.com/gravitational/teleport/lib/kube/proxy
0.69 ms github.com/gravitational/teleport/lib/kube/proxy/testing/kube_server
0.24 ms github.com/gravitational/teleport/gen/go/eventschema
0.20 ms github.com/gravitational/teleport/lib/config
0.18 ms github.com/gravitational/teleport/api/types/externalauditstorage
$ GODEBUG='inittrace=1' ./releases/17.4.1/teleport version 2>&1 | rg '^init' | awk '{print $8 " bytes " $2}' | sort -nr | head -5
623960 bytes github.com/gravitational/teleport/lib/kube/proxy
555896 bytes github.com/gravitational/teleport/lib/kube/proxy/testing/kube_server
404008 bytes github.com/gravitational/teleport/gen/go/eventschema
402208 bytes github.com/gravitational/teleport/api/types/externalauditstorage
348112 bytes github.com/gravitational/teleport/api/utils/aws
```
To remove this package from the teleport dependency tree, testing
utilities were moved into _test.go files, and some test harness
code was duplicated between lib/kube/grpc and lib/kube/proxy.
Resulting in a difference of
```
$ GODEBUG='inittrace=1' ./build/teleport version 2>&1 | rg '^init' | awk '{print $5 " ms " $2}' | sort -nr | head -5
0.94 ms github.com/gravitational/teleport/lib/kube/proxy
0.25 ms github.com/gravitational/teleport/lib/config
0.21 ms github.com/gravitational/teleport/api/types/externalauditstorage
0.20 ms github.com/gravitational/teleport/api/utils/aws
0.15 ms github.com/gravitational/teleport/api/types/events
$ GODEBUG='inittrace=1' ./build/teleport version 2>&1 | rg '^init' | awk '{print $8 " bytes " $2}' | sort -nr | head -5
558944 bytes github.com/gravitational/teleport/lib/kube/proxy
402208 bytes github.com/gravitational/teleport/api/types/externalauditstorage
357184 bytes github.com/gravitational/teleport/api/gen/proto/go/teleport/integration/v1
348112 bytes github.com/gravitational/teleport/api/utils/aws
344896 bytes github.com/gravitational/teleport/api/types/events
```