-
Notifications
You must be signed in to change notification settings - Fork 365
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
🌱 cache: add replication tests for WorkspaceType resource #2578
🌱 cache: add replication tests for WorkspaceType resource #2578
Conversation
"replicate-workspace-type", | ||
"WorkspaceType", | ||
tenancyv1alpha1.SchemeGroupVersion.WithResource("workspacetypes"), | ||
&tenancyv1alpha1.WorkspaceType{ObjectMeta: metav1.ObjectMeta{Name: "replicate-workspace-type"}, Spec: tenancyv1alpha1.WorkspaceTypeSpec{}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on the next iteration, we could change the scenarios to only provide a resource and some type information.
// The test exercises creation, modification and removal of the Shard object. | ||
func replicateWorkspaceTypeScenario(ctx context.Context, t *testing.T, server framework.RunningServer, kcpShardClusterDynamicClient kcpdynamic.ClusterInterface, cacheKcpClusterDynamicClient kcpdynamic.ClusterInterface) { | ||
t.Helper() | ||
replicateResource(ctx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the bottom line is that now a new scenario requires calling replicateResource
// The test exercises creation, modification and removal of the resource. | ||
func replicateResource(ctx context.Context, t *testing.T, | ||
server framework.RunningServer, kcpShardClusterDynamicClient kcpdynamic.ClusterInterface, cacheKcpClusterDynamicClient kcpdynamic.ClusterInterface, | ||
clusterName logicalcluster.Name, resourceName string, kind string, gvr schema.GroupVersionResource, res runtime.Object, resWithModifiedSpec runtime.Object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a lot of parameters for a function, some of them are not specific, e.g: server, kcpShardClusterDynamicClient, cacheKcpClusterDynamicClient.
Others are specific to a testScenario, e.g.: t, gvr
It feels like it would be possible to reduce the number of parameters that need to be provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, an alternative would be to provide a struct but filling all required fields would at the calling line look the same (almost) as providing params. I will try to think about how it could be changed.
"APIExport", | ||
apisv1alpha1.SchemeGroupVersion.WithResource("apiexports"), | ||
&apisv1alpha1.APIExport{ObjectMeta: metav1.ObjectMeta{Name: "wild.wild.west"}}, | ||
&apisv1alpha1.APIExport{ObjectMeta: metav1.ObjectMeta{Name: "wild.wild.west"}, Spec: apisv1alpha1.APIExportSpec{LatestResourceSchemas: []string{"foo.bar"}}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like having the resource definitions outside of the call to replicateResource may improve the readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, maybe we could bring them closer to the place where we define scenarios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure exactly how it should look, I will try to think about it and change it on the next iteration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now could you have the fields on a new line like in replicateAPIExportNegativeScenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, ptal
} | ||
|
||
// replicateAPIResourceSchemaScenario tests if an APIResourceSchema is propagated to the cache server. | ||
// The test exercises creation, modification and removal of the APIResourceSchema object. | ||
func replicateAPIResourceSchemaScenario(ctx context.Context, t *testing.T, server framework.RunningServer, kcpShardClusterClient kcpclientset.ClusterInterface, cacheKcpClusterClient kcpclientset.ClusterInterface) { | ||
func replicateAPIResourceSchemaScenario(ctx context.Context, t *testing.T, server framework.RunningServer, kcpShardClusterDynamicClient kcpdynamic.ClusterInterface, cacheKcpClusterDynamicClient kcpdynamic.ClusterInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a few lines of comment to describe what needs to be done to test the replication of a new resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will add it to the generic functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
c18419a
to
7db7403
Compare
/lgtm I think it is a good improvement compared to what we have. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sttts The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
Related issue(s)
replaces #2449