add more debug functionality to the test suite
@@ -57,6 +57,7 @@ type fixture struct {
apiserverLister []*osev1.APIServer
actions []core.Action
+ skipActionsValidation bool
objects []runtime.Object
oseobjects []runtime.Object
@@ -78,7 +79,23 @@ func newFixture(t *testing.T) *fixture {
}
func (f *fixture) validateActions() {
+ if f.skipActionsValidation {
+ f.t.Log("Skipping actions validation")
+ return
+ }
actions := filterInformerActions(f.client.Actions())
+ if len(f.actions) != len(actions) {
+ f.t.Log("Expected Actions:")
+ for i := range f.actions {
+ f.t.Logf("\t%v %#v", f.actions[i].GetVerb(), f.actions[i])
+ }
+ f.t.Log("Seen Actions:")
+ for i := range actions {
+ f.t.Logf("\t%v %#v", actions[i].GetVerb(), actions[i])
+ }
+ f.t.Errorf("number of seen actions do not match expected actions count")
+ return
+ }
for i, action := range actions {
glog.Infof(" Action: %v", action)
@@ -88,7 +105,7 @@ func (f *fixture) validateActions() {
}
expectedAction := f.actions[i]
- checkAction(expectedAction, action, f.t)
+ checkAction(expectedAction, action, f.t, i)
}
if len(f.actions) > len(actions) {
@@ -287,9 +304,14 @@ func filterOSEActions(actions []core.Action) []core.Action {
// checkAction verifies that expected and actual actions are equal and both have
// same attached resources
-func checkAction(expected, actual core.Action, t *testing.T) {
+func checkAction(expected, actual core.Action, t *testing.T, index int) {
if !(expected.Matches(actual.GetVerb(), actual.GetResource().Resource) && actual.GetSubresource() == expected.GetSubresource()) {
- t.Errorf("Expected\n\t%#v\ngot\n\t%#v", expected, actual)
+ if actual.GetVerb() == "patch" {
+ actual := actual.(core.PatchAction)
+ t.Errorf("Expected(index=%v)\n\t%#v\ngot\n\t%#v\npatch\t%#v", index, expected, actual, string(actual.GetPatch()))
+ } else {
+ t.Errorf("Expected(index=%v)\n\t%#v\ngot\n\t%#v", index, expected, actual)
+ }
return
}
@@ -350,6 +372,15 @@ func (f *fixture) expectUpdateKubeletConfig(config *mcfgv1.KubeletConfig) {
f.actions = append(f.actions, core.NewRootUpdateSubresourceAction(schema.GroupVersionResource{Version: "v1", Group: "machineconfiguration.openshift.io", Resource: "kubeletconfigs"}, "status", config))
}
+func (f *fixture) expectUpdateKubeletConfigRoot(config *mcfgv1.KubeletConfig) {
+ f.actions = append(f.actions, core.NewRootUpdateAction(schema.GroupVersionResource{Version: "v1", Group: "machineconfiguration.openshift.io", Resource: "kubeletconfigs"}, config))
+}
+
+func (f *fixture) resetActions() {
+ f.actions = []core.Action{}
+ f.client.ClearActions()
+}
+
func TestKubeletConfigCreate(t *testing.T) {
for _, platform := range []osev1.PlatformType{osev1.AWSPlatformType, osev1.NonePlatformType, "unrecognized"} {
t.Run(string(platform), func(t *testing.T) {
