Cluster-api: Audit KCP test coverage

Created on 8 Jul 2020  路  19Comments  路  Source: kubernetes-sigs/cluster-api

[originally this was proposed as https://github.com/kubernetes-sigs/cluster-api/issues/3287, but the discussion took a different direction there 馃槣]

As already done at the beginning of v0.3.x series, we should re-audit test coverage for KCP and ensure that it is adequate for the complexity of this critical component

@wfernandes If I'm not wrong you make last analysis. Could you kindly link the results to this issue?

help wanted lifecyclactive

All 19 comments

We should probably audit tests throughout the codebase, including infrastructure providers. That's a much larger effort though.

Hmm...I don't remember if I did the KCP audit. @gab-satchi were you involved with this?
I remember we had a github issue and a public spreadsheet that tracked all of the tests required. I'll link them if I can find them.

We might be talking about #2753

This is a gist with the current test coverage results; We should take a look at it and derive some action items.
Also https://github.com/kubernetes-sigs/cluster-api/pull/3310 will make this easier to repeat in future

/milestone v0.3.x

Some actions for KCP (this can be address in multiple PRs as well)

/help

@fabriziopandini:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

Some actions for KCP (this can be address in multiple PRs as well)

/help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

I was looking into writing a test for cloneConfigsAndGenerateMachine. The errors to be returned are primarily from fakeClient.Create which is hard to setup. Is there some way to let fakeClient return an error?

I'll work on tests for UpdateCoreDNS.
/assign

Moving on to machine filters - MatchesKubernetesVersion, MatchesTemplateClonedFrom

Moving on to GetWorkloadCluster

So writing a unit test for GetWorkloadCluster for KCP is not as simple since the code for connecting and creating a client is within the GetWorkloadCluster method.
https://github.com/kubernetes-sigs/cluster-api/blob/dfe7022e94b8f61eb27a9606e270e09c84d29767/controlplane/kubeadm/internal/cluster.go#L94-L103

There are a couple of options:

  1. We use envtest to create an environment and use it's restConfig for client.New. But I'm not sure if envtest would be appropriate for "unit" tests.
  2. We refactor the Management struct and inject behavior to get the workload client using an options pattern; something like WithWorkloadClient. But that could mean a substantial refactor/changes throughout.

I'm leaning towards the second one. Any thoughts?

UPDATE: So I noticed https://github.com/kubernetes-sigs/cluster-api/pull/3349 discussing standardizing our tests towards envtest. I'll try and use it and see how it goes.

/lifecycle active

Note to self.
Started work on testing ReconcileEtcdMembers. I created a branch wfernandes:add-test-reconcile-etcd-members from the wfernandes:add-get-workload-cluster-test branch since I want to build upon the envtest work.

/milestone v0.3.9

Can we close this in favor of more specific issues? I'm not sure if all the PRs will make it in v0.3.9

I'm fine with closing this issue in favor of more specific issues.

Regarding the PRs that might not make it in v0.3.9, are you referring to PRs #3408 and #3350?

/close

Thanks @wfernandes! Yes, I was referring to those PRs, let's open more specific ones and avoid having umbrella-like issues

@vincepri: Closing this issue.

In response to this:

/close

Thanks @wfernandes! Yes, I was referring to those PRs, let's open more specific ones and avoid having umbrella-like issues

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Was this page helpful?
0 / 5 - 0 ratings