Skip to content

[quality] service_catalog/shared/kube.py has no unit tests #181

@kubestellar-hive

Description

@kubestellar-hive

Finding

tests/service_catalog/shared/kube.py is a shared Kubernetes utility module used by service catalog tests. It contains functions for kubectl operations, pod introspection, HTTP probing, and artifact writing — but has no unit tests.

Untested functions:

  • run_kubectl(*args) — subprocess wrapper for kubectl
  • require_kubectl(*args) — asserting kubectl wrapper (raises on failure)
  • get_pods_json() — pod JSON fetcher
  • restart_workload() — deployment restart + rollout wait
  • first_pod_name() — pod name extractor
  • http_get() — HTTP probe via urllib
  • write_artifact(name, content) — result file writer

Note: The module reads environment variables at import time (NAMESPACE, APP_LABEL, etc.), which complicates testing. This import-time side effect should be mocked/patched.

Recommendation

  1. Add tests/service_catalog/test_kube_helpers.py with unittest.mock.patch for subprocess.run and urllib.request.urlopen
  2. Set required env vars in conftest.py or use monkeypatch.setenv
  3. Test error paths: failed kubectl, empty pod list, HTTP timeout

Priority

  • Impact: medium — kube helpers are used in cluster integration tests; bugs are hard to debug remotely
  • Effort: medium — env var side effects require careful mocking

Filed by quality agent (hold-gated mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions