Merge "veyron2/vdl/codegen/java: Make all VDL types implement android.os.Parcelable."
diff --git a/runtimes/google/lib/follow/notify_reader_test.go b/runtimes/google/lib/follow/notify_reader_test.go
index 04f8827..380f6ce 100644
--- a/runtimes/google/lib/follow/notify_reader_test.go
+++ b/runtimes/google/lib/follow/notify_reader_test.go
@@ -3,6 +3,7 @@
package follow
import (
+ "io/ioutil"
"os"
"testing"
"time"
@@ -10,14 +11,13 @@
// TestNotifyReadPartial tests partial reads with the fsnotify-based fsReader
func TestNotifyReadPartial(t *testing.T) {
- testFileName := os.TempDir() + "/follow.reader.notify.partial"
-
// Create the test file.
- testfile, err := os.Create(testFileName)
+ testFile, err := ioutil.TempFile(os.TempDir(), "follow.reader.notify.partial")
if err != nil {
- t.Fatalf("os.Create() failed: %v", err)
+ t.Fatalf("ioutil.TempFile() failed: %v", err)
}
- testfile.Close()
+ testFile.Close()
+ testFileName := testFile.Name()
defer os.Remove(testFileName)
// Create the fsnotify-based fsWatcher.
@@ -34,14 +34,13 @@
// TestNotifyReadFull tests full reads with the fsnotify-based fsReader
func TestNotifyReadFull(t *testing.T) {
- testFileName := os.TempDir() + "/follow.reader.notify.full"
-
// Create the test file.
- testfile, err := os.Create(testFileName)
+ testFile, err := ioutil.TempFile(os.TempDir(), "follow.reader.notify.full")
if err != nil {
- t.Fatalf("os.Create() failed: %v", err)
+ t.Fatalf("ioutil.TempFile() failed: %v", err)
}
- testfile.Close()
+ testFile.Close()
+ testFileName := testFile.Name()
defer os.Remove(testFileName)
// Create the fsnotify-based fsWatcher.
@@ -58,14 +57,13 @@
// TestNotifyClose tests close with the fsnotify-based fsReader
func TestNotifyClose(t *testing.T) {
- testFileName := os.TempDir() + "/follow.reader.notify.close"
-
// Create the test file.
- testfile, err := os.Create(testFileName)
+ testFile, err := ioutil.TempFile(os.TempDir(), "follow.reader.notify.close")
if err != nil {
- t.Fatalf("os.Create() failed: %v", err)
+ t.Fatalf("ioutil.TempFile() failed: %v", err)
}
- testfile.Close()
+ testFile.Close()
+ testFileName := testFile.Name()
defer os.Remove(testFileName)
// Create the fsnotify-based fsWatcher.
diff --git a/runtimes/google/lib/follow/notify_watcher_test.go b/runtimes/google/lib/follow/notify_watcher_test.go
index 058f5a1..8ee84a5 100644
--- a/runtimes/google/lib/follow/notify_watcher_test.go
+++ b/runtimes/google/lib/follow/notify_watcher_test.go
@@ -3,18 +3,20 @@
package follow
import (
+ "io/ioutil"
"os"
"testing"
"time"
)
func TestModificationNotify(t *testing.T) {
- testFileName := os.TempDir() + "/follow.modification.notify"
- testfile, err := os.Create(testFileName)
+ // Create the test file.
+ testFile, err := ioutil.TempFile(os.TempDir(), "follow.modification.notify")
if err != nil {
- t.Fatalf("os.Create() failed: %v", err)
+ t.Fatalf("ioutil.TempFile() failed: %v", err)
}
- defer testfile.Close()
+ defer testFile.Close()
+ testFileName := testFile.Name()
defer os.Remove(testFileName)
watcher, err := newFSNotifyWatcher(testFileName)
@@ -22,7 +24,7 @@
t.Fatalf("newCustomFSWatcer() failed: %v", err)
}
timeout := time.Second
- if err := testModification(testfile, watcher, timeout); err != nil {
+ if err := testModification(testFile, watcher, timeout); err != nil {
t.Fatalf("testModification() failed: %v", err)
}
}
diff --git a/runtimes/google/lib/follow/stat_reader_test.go b/runtimes/google/lib/follow/stat_reader_test.go
index c67e8b7..21adb53 100644
--- a/runtimes/google/lib/follow/stat_reader_test.go
+++ b/runtimes/google/lib/follow/stat_reader_test.go
@@ -1,6 +1,7 @@
package follow
import (
+ "io/ioutil"
"os"
"testing"
"time"
@@ -8,14 +9,13 @@
// TestStatReadPartial tests partial reads with the os.Stat()-based fsReader
func TestStatReadPartial(t *testing.T) {
- testFileName := os.TempDir() + "/follow.reader.stat.partial"
-
// Create the test file.
- testfile, err := os.Create(testFileName)
+ testFile, err := ioutil.TempFile(os.TempDir(), "follow.reader.stat.partial")
if err != nil {
- t.Fatalf("os.Create() failed: %v", err)
+ t.Fatalf("ioutil.TempFile() failed: %v", err)
}
- testfile.Close()
+ testFile.Close()
+ testFileName := testFile.Name()
defer os.Remove(testFileName)
// Create the os.Stat()-based fsWatcher.
@@ -26,7 +26,7 @@
t.Fatalf("newCustomFSWatcher() failed: %v", err)
}
- timeout := 100 * time.Millisecond
+ timeout := time.Second
if err := testReadPartial(testFileName, watcher, timeout); err != nil {
t.Fatalf("testReadPartial() failed: %v", err)
}
@@ -34,14 +34,13 @@
// TestStatReadFull tests full reads with the os.Stat()-based fsReader
func TestStatReadFull(t *testing.T) {
- testFileName := os.TempDir() + "/follow.reader.stat.full"
-
// Create the test file.
- testfile, err := os.Create(testFileName)
+ testFile, err := ioutil.TempFile(os.TempDir(), "follow.reader.stat.full")
if err != nil {
- t.Fatalf("os.Create() failed: %v", err)
+ t.Fatalf("ioutil.TempFile() failed: %v", err)
}
- testfile.Close()
+ testFile.Close()
+ testFileName := testFile.Name()
defer os.Remove(testFileName)
// Create the os.Stat()-based fsWatcher.
@@ -52,7 +51,7 @@
t.Fatalf("newCustomFSWatcher() failed: %v", err)
}
- timeout := 100 * time.Millisecond
+ timeout := time.Second
if err := testReadFull(testFileName, watcher, timeout); err != nil {
t.Fatalf("testReadFull() failed: %v", err)
}
@@ -60,14 +59,13 @@
// TestStatClose tests close with the os.Stat()-based fsReader
func TestStatClose(t *testing.T) {
- testFileName := os.TempDir() + "/follow.reader.stat.close"
-
// Create the test file.
- testfile, err := os.Create(testFileName)
+ testFile, err := ioutil.TempFile(os.TempDir(), "follow.reader.stat.close")
if err != nil {
- t.Fatalf("os.Create() failed: %v", err)
+ t.Fatalf("ioutil.TempFile() failed: %v", err)
}
- testfile.Close()
+ testFile.Close()
+ testFileName := testFile.Name()
defer os.Remove(testFileName)
// Create the os.Stat()-based fsWatcher.
@@ -78,7 +76,7 @@
t.Fatalf("newCustomFSWatcher() failed: %v", err)
}
- timeout := 100 * time.Millisecond
+ timeout := time.Second
if err := testClose(testFileName, watcher, timeout); err != nil {
t.Fatalf("testClose() failed: %v", err)
}
diff --git a/runtimes/google/lib/follow/stat_watcher_test.go b/runtimes/google/lib/follow/stat_watcher_test.go
index 5c12f00..67d14e8 100644
--- a/runtimes/google/lib/follow/stat_watcher_test.go
+++ b/runtimes/google/lib/follow/stat_watcher_test.go
@@ -1,18 +1,20 @@
package follow
import (
+ "io/ioutil"
"os"
"testing"
"time"
)
func TestModificationStat(t *testing.T) {
- testFileName := os.TempDir() + "/follow.modification.stat"
- testfile, err := os.Create(testFileName)
+ // Create the test file.
+ testFile, err := ioutil.TempFile(os.TempDir(), "follow.modification.stat")
if err != nil {
- t.Fatalf("os.Create() failed: %v", err)
+ t.Fatalf("ioutil.TempFile() failed: %v", err)
}
- defer testfile.Close()
+ defer testFile.Close()
+ testFileName := testFile.Name()
defer os.Remove(testFileName)
minSleep := 10 * time.Millisecond
@@ -22,7 +24,7 @@
t.Fatalf("newCustomFSWatcher() failed : %v", err)
}
timeout := 100 * time.Millisecond
- if err := testModification(testfile, watcher, timeout); err != nil {
+ if err := testModification(testFile, watcher, timeout); err != nil {
t.Fatalf("testModification() failed: %v", err)
}
}
diff --git a/security/serialization/verifying_reader.go b/security/serialization/verifying_reader.go
index 89ce5cc..5e2ceb4 100644
--- a/security/serialization/verifying_reader.go
+++ b/security/serialization/verifying_reader.go
@@ -121,3 +121,7 @@
}
return nil
}
+
+func init() {
+ vom.Register([sha256.Size]byte{})
+}
diff --git a/services/store/memstore/testing/util.go b/services/store/memstore/testing/util.go
index 14f0c00..d93a4f4 100644
--- a/services/store/memstore/testing/util.go
+++ b/services/store/memstore/testing/util.go
@@ -3,7 +3,6 @@
import (
"io"
"runtime"
- "sync"
"testing"
"veyron/services/store/raw"
@@ -152,14 +151,11 @@
// watcherServiceWatchStreamSender implements watch.WatcherServiceWatchStreamSender
type watcherServiceWatchStreamSender struct {
- mu *sync.Mutex
ctx ipc.ServerContext
output chan<- types.Change
}
func (s *watcherServiceWatchStreamSender) Send(cb types.Change) error {
- s.mu.Lock()
- defer s.mu.Unlock()
select {
case s.output <- cb:
return nil
@@ -220,29 +216,39 @@
}
func watchImpl(id security.PublicID, watchFn func(ipc.ServerContext, *watcherServiceWatchStream) error) *watcherWatchStream {
- mu := &sync.Mutex{}
ctx := NewFakeServerContext(id)
- c := make(chan types.Change, 1)
+ outputc := make(chan types.Change)
+ inputc := make(chan types.Change)
+ // This goroutine ensures that inputs will eventually stop going through
+ // once the context is done. Send could handle this, but running a separate
+ // goroutine is easier as we do not control invocations of Send.
+ go func() {
+ for {
+ select {
+ case change := <-outputc:
+ inputc <- change
+ case <-ctx.Done():
+ close(inputc)
+ return
+ }
+ }
+ }()
errc := make(chan error, 1)
go func() {
stream := &watcherServiceWatchStream{
watcherServiceWatchStreamSender{
- mu: mu,
ctx: ctx,
- output: c,
+ output: outputc,
},
}
err := watchFn(ctx, stream)
- mu.Lock()
- defer mu.Unlock()
- ctx.Cancel()
- close(c)
errc <- err
close(errc)
+ ctx.Cancel()
}()
return &watcherWatchStream{
ctx: ctx,
- input: c,
+ input: inputc,
err: errc,
}
}
diff --git a/services/store/memstore/watch/watcher.go b/services/store/memstore/watch/watcher.go
index 609c292..5896f5e 100644
--- a/services/store/memstore/watch/watcher.go
+++ b/services/store/memstore/watch/watcher.go
@@ -246,7 +246,7 @@
return &onOrAfterFilter{baseFilter{0, false}}, nil
}
if isNowResumeMarker(resumeMarker) {
- // TODO(tilaks): Get the current resume marker from the log.g
+ // TODO(tilaks): Get the current resume marker from the log.
return &onOrAfterFilter{baseFilter{uint64(time.Now().UnixNano()), false}}, nil
}
if len(resumeMarker) != 8 {
diff --git a/services/store/memstore/watch/watcher_test.go b/services/store/memstore/watch/watcher_test.go
index 2588060..46132a1 100644
--- a/services/store/memstore/watch/watcher_test.go
+++ b/services/store/memstore/watch/watcher_test.go
@@ -44,12 +44,12 @@
// Check that watch detects the changes in the first transaction.
changes := []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change := rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatal("Expected change to be the last in this transaction")
}
watchtesting.ExpectMutationExists(t, changes, id1, raw.NoVersion, post1, true, "val1", watchtesting.EmptyDir)
@@ -65,20 +65,20 @@
// Check that watch detects the changes in the second transaction.
changes = []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if !change.Continued {
- t.Error("Expected change to continue the transaction")
+ t.Fatal("Expected change to continue the transaction")
}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatal("Expected change to be the last in this transaction")
}
watchtesting.ExpectMutationExists(t, changes, id1, pre1, post1, true, "val1", watchtesting.DirOf("a", id2))
watchtesting.ExpectMutationExists(t, changes, id2, raw.NoVersion, post2, false, "val2", watchtesting.EmptyDir)
@@ -110,12 +110,12 @@
// Check that watch detects the changes in the first transaction.
changes := []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change := rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatal("Expected change to be the last in this transaction")
}
watchtesting.ExpectEntryExists(t, changes, "", id1, "val1")
@@ -127,20 +127,20 @@
// Check that watch detects the changes in the second transaction.
changes = []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if !change.Continued {
- t.Error("Expected change to continue the transaction")
+ t.Fatal("Expected change to continue the transaction")
}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatal("Expected change to be the last in this transaction")
}
watchtesting.ExpectEntryExists(t, changes, "", id1, "val1")
watchtesting.ExpectEntryExists(t, changes, "a", id2, "val2")
@@ -169,7 +169,7 @@
// Check that watch processed the first transaction.
rStream := ws.RecvStream()
if !rStream.Advance() {
- t.Error("Expected a change.")
+ t.Fatal("Expected a change.")
}
// Cancel the watch request.
@@ -216,7 +216,7 @@
// Check that watch processed the first transaction.
if !ws.RecvStream().Advance() {
- t.Error("Expected a change.")
+ t.Fatal("Expected a change.")
}
// Close the watcher, check that io.EOF was returned.
@@ -270,7 +270,7 @@
rStream := ws.RecvStream()
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change := rStream.Value()
resumeMarker1 := change.ResumeMarker
@@ -288,32 +288,32 @@
// Check that watch detects the changes in the state and the transaction.
changes := []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatal("Expected change to be the last in this transaction")
}
watchtesting.ExpectMutationExists(t, changes, id1, raw.NoVersion, post11, true, "val1", watchtesting.EmptyDir)
// Check that watch detects the changes in the state and the transaction.
changes = []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if !change.Continued {
- t.Error("Expected change to continue the transaction")
+ t.Fatal("Expected change to continue the transaction")
}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatal("Expected change to be the last in this transaction")
}
watchtesting.ExpectMutationExists(t, changes, id1, pre21, post21, true, "val1", watchtesting.DirOf("a", id2))
watchtesting.ExpectMutationExists(t, changes, id2, raw.NoVersion, post22, false, "val2", watchtesting.EmptyDir)
@@ -353,7 +353,7 @@
// Retrieve the resume marker for the first transaction.
rStream := ws.RecvStream()
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change := rStream.Value()
resumeMarker1 := change.ResumeMarker
@@ -371,32 +371,32 @@
// Check that watch detects the changes in the first transaction.
changes := []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatal("Expected change to be the last in this transaction")
}
watchtesting.ExpectMutationExists(t, changes, id1, raw.NoVersion, post11, true, "val1", watchtesting.EmptyDir)
// Check that watch detects the changes in the second transaction.
changes = []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if !change.Continued {
- t.Error("Expected change to continue the transaction")
+ t.Fatal("Expected change to continue the transaction")
}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatal("Expected change to be the last in this transaction")
}
resumeMarker2 := change.ResumeMarker
watchtesting.ExpectMutationExists(t, changes, id1, pre21, post21, true, "val1", watchtesting.DirOf("a", id2))
@@ -415,20 +415,20 @@
// Check that watch detects the changes in the second transaction.
changes = []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if !change.Continued {
- t.Error("Expected change to continue the transaction")
+ t.Fatal("Expected change to continue the transaction")
}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatal("Expected change to be the last in this transaction")
}
watchtesting.ExpectMutationExists(t, changes, id1, pre21, post21, true, "val1", watchtesting.DirOf("a", id2))
watchtesting.ExpectMutationExists(t, changes, id2, raw.NoVersion, post22, false, "val2", watchtesting.EmptyDir)
@@ -457,12 +457,21 @@
post22 := st.Snapshot().Find(id2).Version
+ // Pass some time so that the second transaction happened before "now".
+ time.Sleep(time.Millisecond)
+
// Start a watch request with the "now" resume marker.
req := raw.Request{ResumeMarker: nowResumeMarker}
ws := watchtesting.WatchRaw(rootPublicID, w.WatchRaw, req)
- // Give watch some time to pick "now".
- time.Sleep(time.Second)
+ // Check that watch announces that the initial state was skipped.
+ // This also ensures that the third transaction happens after "now".
+ rStream := ws.RecvStream()
+ if !rStream.Advance() {
+ t.Fatalf("Advance() failed: %v", rStream.Err())
+ }
+ change := rStream.Value()
+ watchtesting.ExpectInitialStateSkipped(t, change)
// Put /a/b
tr = memstore.NewTransaction()
@@ -473,31 +482,23 @@
post32 := st.Snapshot().Find(id2).Version
post33 := st.Snapshot().Find(id3).Version
- // Check that watch announces that the initial state was skipped.
- rStream := ws.RecvStream()
- if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
- }
- change := rStream.Value()
- watchtesting.ExpectInitialStateSkipped(t, change)
-
// Check that watch detects the changes in the third transaction.
changes := []types.Change{}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if !change.Continued {
- t.Error("Expected change to continue the transaction")
+ t.Fatalf("Expected change to continue the transaction")
}
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
changes = append(changes, change)
if change.Continued {
- t.Error("Expected change to be the last in this transaction")
+ t.Fatalf("Expected change to be the last in this transaction")
}
watchtesting.ExpectMutationExists(t, changes, id2, pre32, post32, false, "val2", watchtesting.DirOf("b", id3))
watchtesting.ExpectMutationExists(t, changes, id3, raw.NoVersion, post33, false, "val3", watchtesting.EmptyDir)
@@ -563,7 +564,7 @@
rStream := ws.RecvStream()
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change := rStream.Value()
// Save the ResumeMarker of the change.
@@ -574,11 +575,11 @@
rStream = ws.RecvStream()
if !rStream.Advance() {
- t.Error("Advance() failed: %v", rStream.Err())
+ t.Fatalf("Advance() failed: %v", rStream.Err())
}
change = rStream.Value()
// Expect the same ResumeMarker.
if !bytes.Equal(r, change.ResumeMarker) {
- t.Error("Inconsistent ResumeMarker.")
+ t.Fatal("Inconsistent ResumeMarker.")
}
}