Skip to content
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

fix: flakey TestWriteBackToInformer test #2621

Merged
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions rollout/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1948,9 +1948,17 @@ func TestWriteBackToInformer(t *testing.T) {
obj, exists, err := c.rolloutsIndexer.GetByKey(roKey)
assert.NoError(t, err)
assert.True(t, exists)
un, ok := obj.(*unstructured.Unstructured)
assert.True(t, ok)
stableRS, _, _ := unstructured.NestedString(un.Object, "status", "stableRS")

// Want to keep this code for future reference, this commented code would randomly fail to do the type cast
// using json marshalling to convert to a map[string]interface{} fixes the issue. The type returned from
// c.rolloutsIndexer.GetByKey is not always the same type it switches between *unstructured.Unstructured and
// *v1alpha1.Rollout the underlying cause is not fully known.
//un, ok := obj.(*unstructured.Unstructured)
//assert.True(t, ok)
zachaller marked this conversation as resolved.
Show resolved Hide resolved
unObj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj)
assert.NoError(t, err)

stableRS, _, _ := unstructured.NestedString(unObj, "status", "stableRS")
assert.NotEmpty(t, stableRS)
assert.Equal(t, rs1.Labels[v1alpha1.DefaultRolloutUniqueLabelKey], stableRS)
}
Expand Down