-
Notifications
You must be signed in to change notification settings - Fork 129
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
Test editing resources in Managed and Unmanaged console-operator state #117
Test editing resources in Managed and Unmanaged console-operator state #117
Conversation
legitimate test errors i think |
@@ -39,8 +44,8 @@ func DeleteAll(t *testing.T, client *Clientset) { | |||
} | |||
} | |||
|
|||
func getResource(client *Clientset, resource string) (metav1.Object, error) { | |||
var res metav1.Object | |||
func GetResource(client *Clientset, resource string) (runtime.Object, error) { |
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.
runtime.Object
too generic? I think we lose type safety if we use these. Necessary?
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.
yeah its too generic and we dont need all of the interface features. Was speaking with @mfojtik and he advised me to use runtime.Object, since its more generic and there is a smaller chance you get an object that we cant handle
@@ -76,7 +81,7 @@ func deleteResource(client *Clientset, resource string) error { | |||
|
|||
// DeleteCompletely sends a delete request and waits until the resource and | |||
// its dependents are deleted. | |||
func DeleteCompletely(getObject func() (metav1.Object, error), deleteObject func(*metav1.DeleteOptions) error) error { | |||
func DeleteCompletely(getObject func() (runtime.Object, error), deleteObject func(*metav1.DeleteOptions) error) error { |
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.
runtime.Object
same as above, too generic?
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.
As commented above :)
pkg/testframework/framework.go
Outdated
}) | ||
} | ||
|
||
func getUID(obj runtime.Object) types.UID { | ||
configMap, ok := obj.(*corev1.ConfigMap) |
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.
Wondering if passing a runtime.Object
then casting it back is the best approach?
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.
yeah, just found out that the idiomatic way is to pass the runtime.Object into meta.Accessor which will return meta.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.
Using meta.Accessor is also more safe cause we can get error if passed object is not supported.
pkg/testframework/framework.go
Outdated
@@ -134,12 +156,31 @@ func IsResourceAvailable(errChan chan error, client *Clientset, resource string) | |||
errChan <- err | |||
} | |||
|
|||
func IsResourceAvailable_(client *Clientset, resource string) error { |
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.
Another way to do the same thing?
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.
yeah... sorry for that ... forgot to clean this :D
test/e2e/util.go
Outdated
func patchAndCheckConfigMap(t *testing.T, client *testframework.Clientset) bool { | ||
res, err := testframework.GetResource(client, "ConfigMap") | ||
errorCheck(t, err) | ||
configMap, ok := res.(*corev1.ConfigMap) |
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 casting again concerns me a bit, I see it in all of these functions. Wondering if its a signal the generalized GetResource
ought to be a specific function for each resource type w/a specific return type?
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.
yeah was thinking about it and thought it would be better to have an single get function for all the types then multiple get functions for each type that would also cast object directly. Wasnt really sure which one is more idiomatic.
test/e2e/util.go
Outdated
return reflect.DeepEqual(originalData, newData) | ||
} | ||
|
||
func errorCheck(t *testing.T, err error) { |
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 sympathize with the helper to get rid of the if block :)
So I think the recommended path is to always return the error, and handle them only at the top in one place.
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.
Quick review, mostly the casting bits make me pause. Yay progress!
e45fa42
to
5f36d9e
Compare
5f36d9e
to
5ba1055
Compare
@benjaminapetersen updated per our conversation |
/retest |
that one legitimate? |
3628ba4
to
da73385
Compare
da73385
to
6056ee1
Compare
ok! lets give these a spin. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: benjaminapetersen, jhadvig 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 |
/retest Please review the full test history for this PR and help us cut down flakes. |
@benjaminapetersen adding promised tests.
Per our discussion, the tests are editing the resources separately, not bulk, since they have different semantics for the test.
The tests are testing ConfigMap, Service and Route. I've skipped the Deployment since the console operator is not managing changes user makes to it(which is kinda weird?).
Also made the
getResource()
public ->GetResource()
, so it can be used on different places + now it's returning runtime.Object so different fields object field can be accessed.PTAL