Skip to content

Commit

Permalink
e2e/apibindings: fix TestAPIBindingPermissionClaimsConditions
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed Jan 27, 2023
1 parent 7b5e5cc commit 1da2755
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewController(
dynamicClusterClient kcpdynamic.ClusterInterface,
dynamicDiscoverySharedInformerFactory *informer.DiscoveringDynamicSharedInformerFactory,
apiBindingInformer apisv1alpha1informers.APIBindingClusterInformer,
apiExportInformer apisv1alpha1informers.APIExportClusterInformer,
apiExportInformer, globalAPIExportInformer apisv1alpha1informers.APIExportClusterInformer,
) (*controller, error) {
logger := logging.WithReconciler(klog.Background(), ControllerName)

Expand All @@ -72,7 +72,13 @@ func NewController(
apiBindingsIndexer: apiBindingInformer.Informer().GetIndexer(),

getAPIExport: func(path logicalcluster.Path, name string) (*apisv1alpha1.APIExport, error) {
return indexers.ByPathAndName[*apisv1alpha1.APIExport](apisv1alpha1.Resource("apiexports"), apiExportInformer.Informer().GetIndexer(), path, name)
obj, err := indexers.ByPathAndName[*apisv1alpha1.APIExport](apisv1alpha1.Resource("apiexports"), apiExportInformer.Informer().GetIndexer(), path, name)
if err != nil && !apierrors.IsNotFound(err) {
return nil, err
} else if apierrors.IsNotFound(err) {
return indexers.ByPathAndName[*apisv1alpha1.APIExport](apisv1alpha1.Resource("apiexports"), globalAPIExportInformer.Informer().GetIndexer(), path, name)
}
return obj, nil
},

commit: committer.NewCommitter[*APIBinding, Patcher, *APIBindingSpec, *APIBindingStatus](kcpClusterClient.ApisV1alpha1().APIBindings()),
Expand Down
1 change: 1 addition & 0 deletions pkg/server/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ func (s *Server) installAPIBindingController(ctx context.Context, config *rest.C
ddsif,
s.KcpSharedInformerFactory.Apis().V1alpha1().APIBindings(),
s.KcpSharedInformerFactory.Apis().V1alpha1().APIExports(),
s.CacheKcpSharedInformerFactory.Apis().V1alpha1().APIExports(),
)
if err != nil {
return err
Expand Down
9 changes: 3 additions & 6 deletions test/e2e/apibinding/apibinding_permissionclaims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,20 @@ func TestAPIBindingPermissionClaimsConditions(t *testing.T) {

// validate the invalid claims condition occurs
t.Logf("validate that the permission claim's conditions are false and invalid claims is the reason")

framework.Eventually(t, func() (bool, string) {
// get the binding
binding, err := kcpClusterClient.Cluster(consumerPath).ApisV1alpha1().APIBindings().Get(ctx, "cowboys", metav1.GetOptions{})
if err != nil {
return false, err.Error()
}
require.NoError(t, err, "failed to get binding")

cond := conditions.Get(binding, apisv1alpha1.PermissionClaimsValid)
if cond == nil {
return false, "not done waiting for permission claims to be invalid, no condition exits"
return false, fmt.Sprintf("not done waiting for permission claims to be invalid, no %q condition exists:\n%s", apisv1alpha1.PermissionClaimsValid, toYAML(t, binding.Status.Conditions))
}

if cond.Status == v1.ConditionFalse && cond.Reason == apisv1alpha1.InvalidPermissionClaimsReason {
return true, ""
}
return false, fmt.Sprintf("not done waiting for condition to be invalid reason: %v - message: %v", cond.Reason, cond.Message)
return false, fmt.Sprintf("not done waiting for condition to be invalid reason:\n%s", toYAML(t, binding.Status.Conditions))
}, wait.ForeverTestTimeout, 100*time.Millisecond, "unable to see invalid identity hash")

t.Logf("update to correct hash")
Expand Down

0 comments on commit 1da2755

Please sign in to comment.