discovery: fix a flaky test failure in mojo
* Fix the global discovery scan to not return LOST event when the
context is done
* Avoid blocking when stopping by using a buffer channel in mojo
discovery test
Fix https://github.com/vanadium/build/issues/63
MultiPart: 2/2
Change-Id: I2142518772d5a0c12296d2204ffe3ae4c6903be6
diff --git a/go/src/v.io/mojo/discovery/apptest/apptest_util.go b/go/src/v.io/mojo/discovery/apptest/apptest_util.go
index 5f0cfa1..f7667d2 100644
--- a/go/src/v.io/mojo/discovery/apptest/apptest_util.go
+++ b/go/src/v.io/mojo/discovery/apptest/apptest_util.go
@@ -36,7 +36,7 @@
}
func scan(d mojom.Discovery, query string) (<-chan mojom.Update_Pointer, func(), error) {
- ch := make(chan mojom.Update_Pointer)
+ ch := make(chan mojom.Update_Pointer, 10)
handler := &mockScanHandler{ch}
req, ptr := mojom.CreateMessagePipeForScanHandler()
stub := mojom.NewScanHandlerStub(req, handler, bindings.GetAsyncWaiter())
@@ -101,9 +101,11 @@
return nil, err
}
defer func() {
+ go func() {
+ for range scanCh {
+ }
+ }()
stop()
- for range scanCh {
- }
}()
updatePtrs := make([]mojom.Update_Pointer, 0, expectedUpdates)
diff --git a/mojoapptests b/mojoapptests
index 3d39823..c5351c1 100644
--- a/mojoapptests
+++ b/mojoapptests
@@ -6,15 +6,13 @@
"test": "https://test.v.io/discovery_apptests.mojo",
"test-args": [],
"shell-args": ["--args-for=https://mojo.v.io/discovery.mojo --test-mode"],
- "timeout": 300,
+ "timeout": 120,
},
- # Testing dart apptests timeout failure with a large timeout value.
- # See https://github.com/vanadium/issues/issues/1278
{
"test": "https://dart.test.mojo.v.io/discovery_apptests.dart",
"type": "dart",
"dart_strict_mode": True,
"shell-args": ["--args-for=https://mojo.v.io/discovery.mojo --test-mode"],
- "timeout": 300,
+ "timeout": 120,
}
]