Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop a unit test suite for Kubernetes provider #2767

Closed
Tracked by #2774
EronWright opened this issue Jan 23, 2024 · 1 comment · Fixed by #2768
Closed
Tracked by #2774

Develop a unit test suite for Kubernetes provider #2767

EronWright opened this issue Jan 23, 2024 · 1 comment · Fixed by #2768
Assignees
Labels
kind/task Work that's part of an ongoing epic resolution/fixed This issue was fixed

Comments

@EronWright
Copy link
Contributor

EronWright commented Jan 23, 2024

Develop a unit test suite for the Kubernetes provider, based on the following principles:

  • directly stimulate the kubeProvider implementation code, not via the Pulumi CLI.
  • use a mock Kubernetes client, not an actual Kubernetes API server. This will improve coverage by facilitating fault injection.

For scoping, focus on building up a framework and on basic coverage that would benefit other upcoming issues.

@EronWright EronWright self-assigned this Jan 23, 2024
EronWright added a commit that referenced this issue Jan 26, 2024
<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md)
    for Pulumi's contribution guidelines.

    Help us merge your changes more quickly by adding more details such
    as labels, milestones, and reviewers.-->

### Proposed changes

This PR implements a suite of unit tests for the provider implementation
code in `provider/pkg/provider/provider.go`. Unlike the test suites in
`tests/`, this suite uses a mock Kubernetes client and executes the
provider code directly.

This PR focuses on the provider lifecycle (e.g. plugin info and provider
configuration):
- [x] Suite
- [x] RPC:CheckConfig
  - [x] Strict Mode
  - [x] Yaml Rendering Mode
- [x] RPC:DiffConfig
  - [x] Kubeconfig Parsing
  - [x] Cluster Change Detection 
- [x] RPC:Configure
  - [x] Secrets Support
  - [x] Connectivity
- [x] RPC:GetPluginInfo
- [x] RPC:GetSchema
- [x] RPC:GetMapping
- [x] RPC:Cancel

In follow-up PR(s), tests will be developed for the resource lifecycle
(eg. `Check`, `Diff`, `Read`, `Create`, `Update`, `Delete`), and for
invokes (`Invoke`, `StreamInvoke`).

### Changes to Implementation Code
Some minor refactoring was necessary to make it possible to substitute
fake Kubernetes clients.
- the type of the `RESTMapper` field of `DynamicClientSet` was changed
to an interface.
- the type of the `client` field of `LogClient` was changed to an
interface.
- the low-level logic for making a Kubernetes client from a kubeconfig
was moved into a function called `makeClient`.
- add a `makeClient` field to `kubeProvider` as an indirection for test
purposes.

Closes #2767
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Jan 26, 2024
@pulumi-bot pulumi-bot reopened this Jan 26, 2024
@pulumi-bot
Copy link
Contributor

Cannot close issue:

  • does not have required labels: kind/

Please fix these problems and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Work that's part of an ongoing epic resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants