Skip to content

Commit 9c477c3

Browse files
committed
Retry update in flaky test of CSV w/owned API Service.
1 parent ff94842 commit 9c477c3

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

test/e2e/csv_e2e_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,11 +1029,12 @@ var _ = Describe("CSV", func() {
10291029
require.True(GinkgoT(), ok, "expected olm sha annotation not present on existing pod template")
10301030

10311031
// Induce a cert rotation
1032-
now := metav1.Now()
1033-
fetchedCSV.Status.CertsLastUpdated = &now
1034-
fetchedCSV.Status.CertsRotateAt = &now
1035-
fetchedCSV, err = crc.OperatorsV1alpha1().ClusterServiceVersions(testNamespace).UpdateStatus(context.TODO(), fetchedCSV, metav1.UpdateOptions{})
1036-
require.NoError(GinkgoT(), err)
1032+
Eventually(Apply(fetchedCSV, func(csv *v1alpha1.ClusterServiceVersion) error {
1033+
now := metav1.Now()
1034+
csv.Status.CertsLastUpdated = &now
1035+
csv.Status.CertsRotateAt = &now
1036+
return nil
1037+
})).Should(Succeed())
10371038

10381039
_, err = fetchCSV(crc, csv.Name, testNamespace, func(csv *v1alpha1.ClusterServiceVersion) bool {
10391040
// Should create deployment

test/e2e/subscription_e2e_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
k8serrors "k8s.io/apimachinery/pkg/api/errors"
2323
"k8s.io/apimachinery/pkg/api/resource"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25-
"k8s.io/apimachinery/pkg/runtime/schema"
2625
"k8s.io/apimachinery/pkg/util/wait"
2726
"k8s.io/client-go/discovery"
2827

@@ -962,11 +961,6 @@ var _ = Describe("Subscription", func() {
962961
plan := &v1alpha1.InstallPlan{}
963962
plan.SetNamespace(ref.Namespace)
964963
plan.SetName(ref.Name)
965-
plan.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{
966-
Group: v1alpha1.GroupName,
967-
Version: v1alpha1.GroupVersion,
968-
Kind: v1alpha1.InstallPlanKind,
969-
})
970964

971965
// Set the InstallPlan's approval mode to Manual
972966
Eventually(Apply(plan, func(p *v1alpha1.InstallPlan) error {

test/e2e/util_test.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,34 @@ func toggleFeatureGates(deployment *appsv1.Deployment, toToggle ...featuregate.F
885885
awaitPredicates(deadline, w, deploymentReplicas(2), deploymentAvailable, deploymentReplicas(1))
886886
}
887887

888+
var gvks = map[reflect.Type]schema.GroupVersionKind{
889+
reflect.TypeOf(&v1alpha1.ClusterServiceVersion{}): schema.GroupVersionKind{
890+
Group: v1alpha1.GroupName,
891+
Version: v1alpha1.GroupVersion,
892+
Kind: v1alpha1.ClusterServiceVersionKind,
893+
},
894+
reflect.TypeOf(&v1alpha1.InstallPlan{}): schema.GroupVersionKind{
895+
Group: v1alpha1.GroupName,
896+
Version: v1alpha1.GroupVersion,
897+
Kind: v1alpha1.InstallPlanKind,
898+
},
899+
}
900+
888901
type Object interface {
889902
runtime.Object
890903
metav1.Object
891904
}
892905

906+
func SetDefaultGroupVersionKind(o Object) {
907+
gvk := o.GetObjectKind().GroupVersionKind()
908+
if !gvk.Empty() {
909+
return
910+
}
911+
if gvk, ok := gvks[reflect.TypeOf(o)]; ok {
912+
o.GetObjectKind().SetGroupVersionKind(gvk)
913+
}
914+
}
915+
893916
// Apply returns a function that invokes a change func on an object and performs a server-side apply patch with the result and its status subresource.
894917
// The given resource must be a pointer to a struct that specifies its Name, Namespace, APIVersion, and Kind at minimum.
895918
// The given change function must be aunary, matching the signature: "func(<obj type>) error".
@@ -948,7 +971,7 @@ func Apply(obj Object, changeFunc interface{}) func() error {
948971
if err := client.Get(bg, key, cp); err != nil {
949972
return err
950973
}
951-
cp.GetObjectKind().SetGroupVersionKind(obj.GetObjectKind().GroupVersionKind())
974+
SetDefaultGroupVersionKind(cp)
952975
cp.SetManagedFields(nil)
953976

954977
var (
@@ -970,7 +993,7 @@ func Apply(obj Object, changeFunc interface{}) func() error {
970993
if err := client.Get(bg, key, cp); err != nil {
971994
return err
972995
}
973-
cp.GetObjectKind().SetGroupVersionKind(obj.GetObjectKind().GroupVersionKind())
996+
SetDefaultGroupVersionKind(cp)
974997
cp.SetManagedFields(nil)
975998

976999
if len(out) != 1 {

0 commit comments

Comments
 (0)