Skip to content

Commit

Permalink
common-instancetypes: Add watched cluster CRDs to cleanup func test
Browse files Browse the repository at this point in the history
A quick follow up to kubevirt#467 to provide functional test coverage of the
behaviour through some existing but previously missed cleanup tests.

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
  • Loading branch information
lyarwood committed Dec 14, 2022
1 parent 6601cb7 commit 47d1f43
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/operands/common-instancetypes/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@ func (c *commonInstancetypes) Name() string {
return operandName
}

func (c *commonInstancetypes) WatchClusterTypes() []operands.WatchType {
func WatchClusterTypes() []operands.WatchType {
return []operands.WatchType{
{Object: &instancetypev1alpha2.VirtualMachineClusterInstancetype{}, Crd: instancetypeapi.ClusterPluralResourceName, WatchFullObject: true},
{Object: &instancetypev1alpha2.VirtualMachineClusterPreference{}, Crd: instancetypeapi.ClusterPluralPreferenceResourceName, WatchFullObject: true},
}
}

func (c *commonInstancetypes) WatchClusterTypes() []operands.WatchType {
return WatchClusterTypes()
}

func (c *commonInstancetypes) WatchTypes() []operands.WatchType {
return nil
}
Expand Down
4 changes: 3 additions & 1 deletion tests/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package tests
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
data_sources "kubevirt.io/ssp-operator/internal/operands/data-sources"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -12,7 +11,9 @@ import (
sspv1beta1 "kubevirt.io/ssp-operator/api/v1beta1"
"kubevirt.io/ssp-operator/internal/common"
"kubevirt.io/ssp-operator/internal/operands"
common_instancetypes "kubevirt.io/ssp-operator/internal/operands/common-instancetypes"
common_templates "kubevirt.io/ssp-operator/internal/operands/common-templates"
data_sources "kubevirt.io/ssp-operator/internal/operands/data-sources"
"kubevirt.io/ssp-operator/internal/operands/metrics"
nodelabeller "kubevirt.io/ssp-operator/internal/operands/node-labeller"
template_validator "kubevirt.io/ssp-operator/internal/operands/template-validator"
Expand All @@ -31,6 +32,7 @@ var _ = Describe("Cleanup", func() {
var allWatchTypes []operands.WatchType
for _, f := range []func() []operands.WatchType{
common_templates.WatchClusterTypes,
common_instancetypes.WatchClusterTypes,
data_sources.WatchClusterTypes,
metrics.WatchTypes,
metrics.WatchClusterTypes,
Expand Down
2 changes: 2 additions & 0 deletions tests/tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"k8s.io/utils/pointer"
kubevirtv1 "kubevirt.io/api/core/v1"
instancetypev1alpha2 "kubevirt.io/api/instancetype/v1alpha2"
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
lifecycleapi "kubevirt.io/controller-lifecycle-operator-sdk/api"
qe_reporters "kubevirt.io/qe-tools/pkg/ginkgo-reporters"
Expand Down Expand Up @@ -408,6 +409,7 @@ func setupApiClient() {
Expect(clientgoscheme.AddToScheme(testScheme)).ToNot(HaveOccurred())
Expect(os.Setenv(kubevirtv1.KubeVirtClientGoSchemeRegistrationVersionEnvVar, "v1")).ToNot(HaveOccurred())
Expect(kubevirtv1.AddToScheme(testScheme)).ToNot(HaveOccurred())
Expect(instancetypev1alpha2.AddToScheme(testScheme)).ToNot(HaveOccurred())

cfg, err := config.GetConfig()
Expect(err).ToNot(HaveOccurred())
Expand Down

0 comments on commit 47d1f43

Please sign in to comment.