[ARVADOS] updated: 3fe48e9f9ce4f29ececb07fa8934565992a8d52f

Git user git at public.curoverse.com
Fri Jun 30 13:58:06 EDT 2017


Summary of changes:
 services/ws/session_v0_test.go | 49 +++++++++++++++++++++++++++++-------------
 1 file changed, 34 insertions(+), 15 deletions(-)

       via  3fe48e9f9ce4f29ececb07fa8934565992a8d52f (commit)
       via  21a3b4fb25cc8eef7f38fa8cb699e1f3ded92846 (commit)
       via  23ddb63351e5669d8e9fe7e688751ada55cb3072 (commit)
      from  32c2f3d808e0d4938f6a17b778c38f6d1ecd2f82 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 3fe48e9f9ce4f29ececb07fa8934565992a8d52f
Merge: 32c2f3d 21a3b4f
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Jun 30 13:56:18 2017 -0400

    Merge branch '11910-ws-test-race'
    
    closes #11910
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>


commit 21a3b4fb25cc8eef7f38fa8cb699e1f3ded92846
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Jun 30 09:48:31 2017 -0400

    11910: Ensure test passes despite race between old and new events.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/services/ws/session_v0_test.go b/services/ws/session_v0_test.go
index 4a2da80..1213be5 100644
--- a/services/ws/session_v0_test.go
+++ b/services/ws/session_v0_test.go
@@ -83,7 +83,15 @@ func (s *v0Suite) TestLastLogID(c *check.C) {
 	}), check.IsNil)
 	s.expectStatus(c, r, 200)
 
+	avoidRace := make(chan struct{}, cap(uuidChan))
 	go func() {
+		// When last_log_id is given, although v0session sends
+		// old events in order, and sends new events in order,
+		// it doesn't necessarily finish sending all old
+		// events before sending any new events. To avoid
+		// hitting this bug in the test, we wait for the old
+		// events to arrive before emitting any new events.
+		<-avoidRace
 		s.emitEvents(uuidChan)
 		close(uuidChan)
 	}()
@@ -97,6 +105,7 @@ func (s *v0Suite) TestLastLogID(c *check.C) {
 				}
 				c.Check(lg.EventType, check.Equals, etype)
 			}
+			avoidRace <- struct{}{}
 		}
 	}()
 }

commit 23ddb63351e5669d8e9fe7e688751ada55cb3072
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jun 29 10:56:32 2017 -0400

    11910: Fix racy tests: ignore non-matching logs from previous tests.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/services/ws/session_v0_test.go b/services/ws/session_v0_test.go
index 0ae8ceb..4a2da80 100644
--- a/services/ws/session_v0_test.go
+++ b/services/ws/session_v0_test.go
@@ -88,23 +88,17 @@ func (s *v0Suite) TestLastLogID(c *check.C) {
 		close(uuidChan)
 	}()
 
-	done := make(chan bool)
 	go func() {
 		for uuid := range uuidChan {
 			for _, etype := range []string{"create", "blip", "update"} {
 				lg := s.expectLog(c, r)
-				c.Check(lg.ObjectUUID, check.Equals, uuid)
+				for lg.ObjectUUID != uuid {
+					lg = s.expectLog(c, r)
+				}
 				c.Check(lg.EventType, check.Equals, etype)
 			}
 		}
-		close(done)
 	}()
-
-	select {
-	case <-time.After(10 * time.Second):
-		c.Fatal("timeout")
-	case <-done:
-	}
 }
 
 func (s *v0Suite) TestPermission(c *check.C) {
@@ -117,16 +111,21 @@ func (s *v0Suite) TestPermission(c *check.C) {
 	}), check.IsNil)
 	s.expectStatus(c, r, 200)
 
-	uuidChan := make(chan string, 1)
+	uuidChan := make(chan string, 2)
 	go func() {
 		s.token = arvadostest.AdminToken
-		s.emitEvents(nil)
+		s.emitEvents(uuidChan)
 		s.token = arvadostest.ActiveToken
 		s.emitEvents(uuidChan)
 	}()
 
+	wrongUUID := <-uuidChan
+	rightUUID := <-uuidChan
 	lg := s.expectLog(c, r)
-	c.Check(lg.ObjectUUID, check.Equals, <-uuidChan)
+	for lg.ObjectUUID != rightUUID {
+		c.Check(lg.ObjectUUID, check.Not(check.Equals), wrongUUID)
+		lg = s.expectLog(c, r)
+	}
 }
 
 func (s *v0Suite) TestSendBadJSON(c *check.C) {
@@ -170,7 +169,9 @@ func (s *v0Suite) TestSubscribe(c *check.C) {
 
 	for _, etype := range []string{"create", "blip", "update"} {
 		lg := s.expectLog(c, r)
-		c.Check(lg.ObjectUUID, check.Equals, uuid)
+		for lg.ObjectUUID != uuid {
+			lg = s.expectLog(c, r)
+		}
 		c.Check(lg.EventType, check.Equals, etype)
 	}
 }
@@ -228,8 +229,17 @@ func (s *v0Suite) expectStatus(c *check.C, r *json.Decoder, status int) {
 
 func (s *v0Suite) expectLog(c *check.C, r *json.Decoder) *arvados.Log {
 	lg := &arvados.Log{}
-	c.Check(r.Decode(lg), check.IsNil)
-	return lg
+	ok := make(chan struct{})
+	go func() {
+		c.Check(r.Decode(lg), check.IsNil)
+		close(ok)
+	}()
+	select {
+	case <-time.After(10 * time.Second):
+		panic("timed out")
+	case <-ok:
+		return lg
+	}
 }
 
 func (s *v0Suite) testClient() (*server, *websocket.Conn, *json.Decoder, *json.Encoder) {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list