Skip to content

Instantly share code, notes, and snippets.

@ramr
Created February 8, 2017 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramr/38423bad348846b743fcd8afba7533dd to your computer and use it in GitHub Desktop.
Save ramr/38423bad348846b743fcd8afba7533dd to your computer and use it in GitHub Desktop.
eventqueue error
$ cat pkg/client/cache/ramr_eq_test.go
package cache
import (
"testing"
"k8s.io/kubernetes/pkg/watch"
)
type qEntry struct {
key string
value interface{}
}
func TestEventQueue_addDeleteAdd(t *testing.T) {
keyFunc := func(obj interface{}) (string, error) {
return obj.(qEntry).key, nil
}
q := NewEventQueue(keyFunc)
addError := q.Add(qEntry{"os3", 3.4})
if addError != nil {
t.Errorf("event-queue add #1 failed: %s", addError)
}
deleteError := q.Delete(qEntry{key: "os3"})
if deleteError != nil {
t.Errorf("event-queue delete #1 failed: %s", deleteError)
}
updateError := q.Update(qEntry{key: "os3", value: 3.41})
if updateError != nil {
t.Errorf("event-queue update #1 failed: %s", updateError)
}
updateError = q.Update(qEntry{key: "os3", value: 3.42})
if updateError != nil {
t.Errorf("event-queue update #2 failed: %s", updateError)
}
deleteError = q.Delete(qEntry{key: "os3"})
if deleteError != nil {
t.Errorf("event-queue delete #2 failed: %s", deleteError)
}
addError = q.Add(qEntry{key: "os3", value: 3.5})
if addError != nil {
t.Errorf("event-queue add #2 failed: %s", addError)
}
/*
*/
event, thing, _ := q.Pop()
value := thing.(qEntry).value
if value != 3.5 {
t.Fatalf("expected %v, got %v", 3.5, value)
}
if event != watch.Added {
t.Fatalf("expected %s, got %s", watch.Added, event)
}
}
$ make test-unit WHAT=pkg/client/cache
TEST_KUBE=true GOTEST_FLAGS="" hack/test-go.sh pkg/client/cache
--- FAIL: TestEventQueue_addDeleteAdd (0.00s)
panic: Invalid state transition: DELETED -> ADDED [recovered]
panic: Invalid state transition: DELETED -> ADDED
goroutine 72 [running]:
panic(0x182f420, 0xc420298620)
/usr/local/go/src/runtime/panic.go:500 +0x1ae
testing.tRunner.func1(0xc4202a0b40)
/usr/local/go/src/testing/testing.go:579 +0x474
panic(0x182f420, 0xc420298620)
/usr/local/go/src/runtime/panic.go:458 +0x271
github.com/openshift/origin/pkg/client/cache.(*EventQueue).handleEvent(0xc4202a24d0, 0x190ddc0, 0xc4201afc40, 0x1a63488, 0x5, 0x0, 0x0)
github.com/openshift/origin/pkg/client/cache/_test/_obj_test/eventqueue.go:141 +0xe75
github.com/openshift/origin/pkg/client/cache.(*EventQueue).Add(0xc4202a24d0, 0x190ddc0, 0xc4201afc40, 0x190ddc0, 0xc4201afc40)
github.com/openshift/origin/pkg/client/cache/_test/_obj_test/eventqueue.go:227 +0x7e
github.com/openshift/origin/pkg/client/cache.TestEventQueue_addDeleteAdd(0xc4202a0b40)
/home/ramr/work/redhat/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/pkg/client/cache/ramr_eq_test.go:46 +0x598
testing.tRunner(0xc4202a0b40, 0x1bdac48)
/usr/local/go/src/testing/testing.go:610 +0xca
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:646 +0x530
FAIL github.com/openshift/origin/pkg/client/cache 0.636s
[ERROR] PID 15899: hack/test-go.sh:285: `go test ${gotest_flags} ${test_packages}` exited with status 1.
[INFO] Stack Trace:
[INFO] 1: hack/test-go.sh:285: `go test ${gotest_flags} ${test_packages}`
[INFO] Exiting with code 1.
hack/test-go.sh failed after 5 seconds
Makefile:144: recipe for target 'test-unit' failed
make: *** [test-unit] Error 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment