Merge pull request #80858 from wojtek-t/fix_events_tests

Fix selflinks in events tests
This commit is contained in:
Kubernetes Prow Robot
2019-08-01 11:52:56 -07:00
committed by GitHub
2 changed files with 38 additions and 38 deletions

View File

@@ -68,7 +68,7 @@ func TestEventSeriesf(t *testing.T) {
testPod := &v1.Pod{ testPod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo", SelfLink: "/api/v1/namespaces/baz/pods/foo",
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
@@ -212,7 +212,7 @@ func TestFinishSeries(t *testing.T) {
hostname, _ := os.Hostname() hostname, _ := os.Hostname()
testPod := &v1.Pod{ testPod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo", SelfLink: "/api/v1/namespaces/baz/pods/foo",
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
@@ -284,7 +284,7 @@ func TestRefreshExistingEventSeries(t *testing.T) {
hostname, _ := os.Hostname() hostname, _ := os.Hostname()
testPod := &v1.Pod{ testPod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo", SelfLink: "/api/v1/namespaces/baz/pods/foo",
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",

View File

@@ -104,7 +104,7 @@ func OnPatchFactory(testCache map[string]*v1.Event, patchEvent chan<- *v1.Event)
func TestEventf(t *testing.T) { func TestEventf(t *testing.T) {
testPod := &v1.Pod{ testPod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo", SelfLink: "/api/v1/namespaces/baz/pods/foo",
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
@@ -112,7 +112,7 @@ func TestEventf(t *testing.T) {
} }
testPod2 := &v1.Pod{ testPod2 := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo", SelfLink: "/api/v1/namespaces/baz/pods/foo",
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "differentUid", UID: "differentUid",
@@ -152,7 +152,7 @@ func TestEventf(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[2]", FieldPath: "spec.containers[2]",
}, },
Reason: "Started", Reason: "Started",
@@ -161,7 +161,7 @@ func TestEventf(t *testing.T) {
Count: 1, Count: 1,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false, expectUpdate: false,
}, },
{ {
@@ -180,7 +180,7 @@ func TestEventf(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
APIVersion: "version", APIVersion: "v1",
}, },
Reason: "Killed", Reason: "Killed",
Message: "some other verbose message: 1", Message: "some other verbose message: 1",
@@ -188,7 +188,7 @@ func TestEventf(t *testing.T) {
Count: 1, Count: 1,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
expectUpdate: false, expectUpdate: false,
}, },
{ {
@@ -207,7 +207,7 @@ func TestEventf(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[2]", FieldPath: "spec.containers[2]",
}, },
Reason: "Started", Reason: "Started",
@@ -216,7 +216,7 @@ func TestEventf(t *testing.T) {
Count: 2, Count: 2,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: true, expectUpdate: true,
}, },
{ {
@@ -235,7 +235,7 @@ func TestEventf(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "differentUid", UID: "differentUid",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[3]", FieldPath: "spec.containers[3]",
}, },
Reason: "Started", Reason: "Started",
@@ -244,7 +244,7 @@ func TestEventf(t *testing.T) {
Count: 1, Count: 1,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false, expectUpdate: false,
}, },
{ {
@@ -263,7 +263,7 @@ func TestEventf(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[2]", FieldPath: "spec.containers[2]",
}, },
Reason: "Started", Reason: "Started",
@@ -272,7 +272,7 @@ func TestEventf(t *testing.T) {
Count: 3, Count: 3,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: true, expectUpdate: true,
}, },
{ {
@@ -291,7 +291,7 @@ func TestEventf(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "differentUid", UID: "differentUid",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[3]", FieldPath: "spec.containers[3]",
}, },
Reason: "Stopped", Reason: "Stopped",
@@ -300,7 +300,7 @@ func TestEventf(t *testing.T) {
Count: 1, Count: 1,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectUpdate: false, expectUpdate: false,
}, },
{ {
@@ -319,7 +319,7 @@ func TestEventf(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "differentUid", UID: "differentUid",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[3]", FieldPath: "spec.containers[3]",
}, },
Reason: "Stopped", Reason: "Stopped",
@@ -328,7 +328,7 @@ func TestEventf(t *testing.T) {
Count: 2, Count: 2,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectUpdate: true, expectUpdate: true,
}, },
} }
@@ -529,7 +529,7 @@ func TestLotsOfEvents(t *testing.T) {
func TestEventfNoNamespace(t *testing.T) { func TestEventfNoNamespace(t *testing.T) {
testPod := &v1.Pod{ testPod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo", SelfLink: "/api/v1/namespaces/default/pods/foo",
Name: "foo", Name: "foo",
UID: "bar", UID: "bar",
}, },
@@ -564,7 +564,7 @@ func TestEventfNoNamespace(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "", Namespace: "",
UID: "bar", UID: "bar",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[2]", FieldPath: "spec.containers[2]",
}, },
Reason: "Started", Reason: "Started",
@@ -573,7 +573,7 @@ func TestEventfNoNamespace(t *testing.T) {
Count: 1, Count: 1,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false, expectUpdate: false,
}, },
} }
@@ -626,7 +626,7 @@ func TestEventfNoNamespace(t *testing.T) {
func TestMultiSinkCache(t *testing.T) { func TestMultiSinkCache(t *testing.T) {
testPod := &v1.Pod{ testPod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo", SelfLink: "/api/v1/namespaces/baz/pods/foo",
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
@@ -634,7 +634,7 @@ func TestMultiSinkCache(t *testing.T) {
} }
testPod2 := &v1.Pod{ testPod2 := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo", SelfLink: "/api/v1/namespaces/baz/pods/foo",
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "differentUid", UID: "differentUid",
@@ -674,7 +674,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[2]", FieldPath: "spec.containers[2]",
}, },
Reason: "Started", Reason: "Started",
@@ -683,7 +683,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 1, Count: 1,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false, expectUpdate: false,
}, },
{ {
@@ -702,7 +702,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
APIVersion: "version", APIVersion: "v1",
}, },
Reason: "Killed", Reason: "Killed",
Message: "some other verbose message: 1", Message: "some other verbose message: 1",
@@ -710,7 +710,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 1, Count: 1,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
expectUpdate: false, expectUpdate: false,
}, },
{ {
@@ -729,7 +729,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[2]", FieldPath: "spec.containers[2]",
}, },
Reason: "Started", Reason: "Started",
@@ -738,7 +738,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 2, Count: 2,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: true, expectUpdate: true,
}, },
{ {
@@ -757,7 +757,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "differentUid", UID: "differentUid",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[3]", FieldPath: "spec.containers[3]",
}, },
Reason: "Started", Reason: "Started",
@@ -766,7 +766,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 1, Count: 1,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false, expectUpdate: false,
}, },
{ {
@@ -785,7 +785,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "bar", UID: "bar",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[2]", FieldPath: "spec.containers[2]",
}, },
Reason: "Started", Reason: "Started",
@@ -794,7 +794,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 3, Count: 3,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: true, expectUpdate: true,
}, },
{ {
@@ -813,7 +813,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "differentUid", UID: "differentUid",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[3]", FieldPath: "spec.containers[3]",
}, },
Reason: "Stopped", Reason: "Stopped",
@@ -822,7 +822,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 1, Count: 1,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectUpdate: false, expectUpdate: false,
}, },
{ {
@@ -841,7 +841,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo", Name: "foo",
Namespace: "baz", Namespace: "baz",
UID: "differentUid", UID: "differentUid",
APIVersion: "version", APIVersion: "v1",
FieldPath: "spec.containers[3]", FieldPath: "spec.containers[3]",
}, },
Reason: "Stopped", Reason: "Stopped",
@@ -850,7 +850,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 2, Count: 2,
Type: v1.EventTypeNormal, Type: v1.EventTypeNormal,
}, },
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`, expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectUpdate: true, expectUpdate: true,
}, },
} }