Skip to content

Commit

Permalink
[k8smeta] Add test for k8s metadata controller (#1588)
Browse files Browse the repository at this point in the history
Summary: Add test for k8s_metadata_controller. This should exercise most
of the go struct to metadatapb conversion code also.

Type of change: /kind cleanup

Test Plan: New test passes.

---------

Signed-off-by: James Bartlett <[email protected]>
Signed-off-by: Vihang Mehta <[email protected]>
Co-authored-by: Vihang Mehta <[email protected]>
  • Loading branch information
JamesMBartlett and vihangm authored Jun 28, 2023
1 parent fa5dc97 commit c092058
Show file tree
Hide file tree
Showing 4 changed files with 1,134 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/vizier/services/metadata/controllers/k8smeta/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ go_library(
pl_go_test(
name = "k8smeta_test",
srcs = [
"k8s_metadata_controller_test.go",
"k8s_metadata_handler_test.go",
"k8s_metadata_store_test.go",
"metadata_topic_listener_test.go",
Expand All @@ -74,5 +75,13 @@ pl_go_test(
"@com_github_nats_io_nats_go//:nats_go",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
"@io_k8s_api//apps/v1:apps",
"@io_k8s_api//core/v1:core",
"@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
"@io_k8s_apimachinery//pkg/util/intstr",
"@io_k8s_apimachinery//pkg/watch",
"@io_k8s_client_go//kubernetes",
"@io_k8s_client_go//kubernetes/fake",
"@io_k8s_client_go//testing",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ func NewController(updateCh chan *K8sResourceMessage) (*Controller, error) {
if err != nil {
return nil, err
}
return NewControllerWithClientSet(updateCh, clientset)
}

// NewControllerWithClientSet creates a new Controller using the given Clientset.
func NewControllerWithClientSet(updateCh chan *K8sResourceMessage, clientset kubernetes.Interface) (*Controller, error) {
quitCh := make(chan struct{})

// Create a watcher for each resource.
Expand Down
Loading

0 comments on commit c092058

Please sign in to comment.