From 58921e381b612fb5f063cf0751ddf8d992958758 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Sun, 4 Dec 2022 22:48:14 -0800 Subject: [PATCH] increase integ test timeout, sometimes tor is slow, its slower restarting a bunch of times; poll on retvals --- .drone.yml | 2 +- testing/cwtch_peer_server_integration_test.go | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 52a0828..fdc3e9f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,7 +39,7 @@ steps: path: /go commands: - export PATH=`pwd`:$PATH - - go test -race -v cwtch.im/cwtch/testing/ + - go test -timeout=30m -race -v cwtch.im/cwtch/testing/ - name: filesharing-integ-test image: golang:1.19.1 volumes: diff --git a/testing/cwtch_peer_server_integration_test.go b/testing/cwtch_peer_server_integration_test.go index 2972723..a6a7c44 100644 --- a/testing/cwtch_peer_server_integration_test.go +++ b/testing/cwtch_peer_server_integration_test.go @@ -1,7 +1,6 @@ package testing import ( - // Import SQL Cipher "crypto/rand" app2 "cwtch.im/cwtch/app" "cwtch.im/cwtch/event" @@ -54,6 +53,16 @@ func waitForConnection(t *testing.T, peer peer.CwtchPeer, addr string, target co } } +func waitForRetVal(peer peer.CwtchPeer, convId int, szp attr.ScopedZonedPath) { + for { + _, err := peer.GetConversationAttribute(convId, szp) + if err == nil { + return + } + time.Sleep(time.Second * 5) + } +} + func checkAndLoadTokens() []*privacypass.Token { var tokens []*privacypass.Token data, err := os.ReadFile("../tokens") @@ -236,23 +245,27 @@ func TestCwtchPeerIntegration(t *testing.T) { // Probably related to latency/throughput problems in the underlying tor network. time.Sleep(30 * time.Second) + waitForRetVal(bob, bob2aliceConversationID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name))) aliceName, err := bob.GetConversationAttribute(bob2aliceConversationID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name))) if err != nil || aliceName != "Alice" { t.Fatalf("Bob: alice GetKeyVal error on alice peer.name %v: %v\n", aliceName, err) } log.Infof("Bob has alice's name as '%v'\n", aliceName) + waitForRetVal(alice, alice2bobConversationID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name))) bobName, err := alice.GetConversationAttribute(alice2bobConversationID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name))) if err != nil || bobName != "Bob" { t.Fatalf("Alice: bob GetKeyVal error on bob peer.name %v: %v \n", bobName, err) } log.Infof("Alice has bob's name as '%v'\n", bobName) + waitForRetVal(carol, carol2aliceConversationID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name))) aliceName, err = carol.GetConversationAttribute(carol2aliceConversationID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name))) if err != nil || aliceName != "Alice" { t.Fatalf("carol GetKeyVal error for alice peer.name %v: %v\n", aliceName, err) } + waitForRetVal(alice, alice2carolConversationID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name))) carolName, err := alice.GetConversationAttribute(alice2carolConversationID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.Name))) if err != nil || carolName != "Carol" { t.Fatalf("alice GetKeyVal error, carol peer.name: %v: %v\n", carolName, err)