Skip to content

Commit

Permalink
This commit fixes tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Avesh Agarwal committed Nov 24, 2015
1 parent a229925 commit 001437a
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 30 deletions.
13 changes: 7 additions & 6 deletions contrib/mesos/pkg/scheduler/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ func NewTestOffer(id string) *mesos.Offer {
// Add assertions to reason about event streams
type Event struct {
Object runtime.Object
Type string
Reason string
Message string
}
Expand All @@ -334,15 +335,15 @@ func NewEventObserver() *EventObserver {
}
}

func (o *EventObserver) Event(object runtime.Object, reason, message string) {
o.fifo <- Event{Object: object, Reason: reason, Message: message}
func (o *EventObserver) Event(object runtime.Object, eventtype, reason, message string) {
o.fifo <- Event{Object: object, Type: eventtype, Reason: reason, Message: message}
}

func (o *EventObserver) Eventf(object runtime.Object, reason, messageFmt string, args ...interface{}) {
o.fifo <- Event{Object: object, Reason: reason, Message: fmt.Sprintf(messageFmt, args...)}
func (o *EventObserver) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{}) {
o.fifo <- Event{Object: object, Type: eventtype, Reason: reason, Message: fmt.Sprintf(messageFmt, args...)}
}
func (o *EventObserver) PastEventf(object runtime.Object, timestamp unversioned.Time, reason, messageFmt string, args ...interface{}) {
o.fifo <- Event{Object: object, Reason: reason, Message: fmt.Sprintf(messageFmt, args...)}
func (o *EventObserver) PastEventf(object runtime.Object, timestamp unversioned.Time, eventtype, reason, messageFmt string, args ...interface{}) {
o.fifo <- Event{Object: object, Type: eventtype, Reason: reason, Message: fmt.Sprintf(messageFmt, args...)}
}

func (a *EventAssertions) Event(observer *EventObserver, pred EventPredicate, msgAndArgs ...interface{}) bool {
Expand Down
77 changes: 55 additions & 22 deletions pkg/client/record/event_test.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/client/record/events_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func makeEvent(reason, message string, involvedObject api.ObjectReference) api.E
Count: 1,
FirstTimestamp: eventTime,
LastTimestamp: eventTime,
Type: api.EventTypeNormal,
}
return event
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/client/unversioned/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestEventCreate(t *testing.T) {
FirstTimestamp: timeStamp,
LastTimestamp: timeStamp,
Count: 1,
Type: api.EventTypeNormal,
}
c := &testClient{
Request: testRequest{
Expand Down Expand Up @@ -113,6 +114,7 @@ func TestEventGet(t *testing.T) {
FirstTimestamp: timeStamp,
LastTimestamp: timeStamp,
Count: 1,
Type: api.EventTypeNormal,
}
c := &testClient{
Request: testRequest{
Expand Down Expand Up @@ -152,6 +154,7 @@ func TestEventList(t *testing.T) {
FirstTimestamp: timeStamp,
LastTimestamp: timeStamp,
Count: 1,
Type: api.EventTypeNormal,
},
},
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/kubectl/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,23 @@ func TestPodDescribeResultsSorted(t *testing.T) {
FirstTimestamp: unversioned.NewTime(time.Date(2014, time.January, 15, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(2014, time.January, 15, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
{
Source: api.EventSource{Component: "scheduler"},
Message: "Item 2",
FirstTimestamp: unversioned.NewTime(time.Date(1987, time.June, 17, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(1987, time.June, 17, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
{
Source: api.EventSource{Component: "kubelet"},
Message: "Item 3",
FirstTimestamp: unversioned.NewTime(time.Date(2002, time.December, 25, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(2002, time.December, 25, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
},
})
Expand Down
4 changes: 4 additions & 0 deletions pkg/kubectl/resource_printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,20 +507,23 @@ func TestPrintEventsResultSorted(t *testing.T) {
FirstTimestamp: unversioned.NewTime(time.Date(2014, time.January, 15, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(2014, time.January, 15, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
{
Source: api.EventSource{Component: "scheduler"},
Message: "Item 2",
FirstTimestamp: unversioned.NewTime(time.Date(1987, time.June, 17, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(1987, time.June, 17, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
{
Source: api.EventSource{Component: "kubelet"},
Message: "Item 3",
FirstTimestamp: unversioned.NewTime(time.Date(2002, time.December, 25, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(2002, time.December, 25, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
},
}
Expand Down Expand Up @@ -902,6 +905,7 @@ func TestPrintHumanReadableWithNamespace(t *testing.T) {
FirstTimestamp: unversioned.NewTime(time.Date(2014, time.January, 15, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(2014, time.January, 15, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
isNamespaced: true,
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/kubectl/sorted_event_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,23 @@ func TestSortableEvents(t *testing.T) {
FirstTimestamp: unversioned.NewTime(time.Date(2014, time.January, 15, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(2014, time.January, 15, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
{
Source: api.EventSource{Component: "scheduler"},
Message: "Item 2",
FirstTimestamp: unversioned.NewTime(time.Date(1987, time.June, 17, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(1987, time.June, 17, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
{
Source: api.EventSource{Component: "kubelet"},
Message: "Item 3",
FirstTimestamp: unversioned.NewTime(time.Date(2002, time.December, 25, 0, 0, 0, 0, time.UTC)),
LastTimestamp: unversioned.NewTime(time.Date(2002, time.December, 25, 0, 0, 0, 0, time.UTC)),
Count: 1,
Type: api.EventTypeNormal,
},
})

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1665,8 +1665,8 @@ func dumpNodeDebugInfo(c *client.Client, nodeNames []string) {

Logf("\nLogging kubelet events for node %v", n)
for _, e := range getNodeEvents(c, n) {
Logf("source %v message %v reason %v first ts %v last ts %v, involved obj %+v",
e.Source, e.Message, e.Reason, e.FirstTimestamp, e.LastTimestamp, e.InvolvedObject)
Logf("source %v type %v message %v reason %v first ts %v last ts %v, involved obj %+v",
e.Source, e.Type, e.Message, e.Reason, e.FirstTimestamp, e.LastTimestamp, e.InvolvedObject)
}
Logf("\nLogging pods the kubelet thinks is on node %v", n)
podList, err := GetKubeletPods(c, n)
Expand Down

0 comments on commit 001437a

Please sign in to comment.