Skip to content

Commit

Permalink
Fix hanging accounts test
Browse files Browse the repository at this point in the history
  • Loading branch information
anbsky committed Jul 17, 2019
1 parent 1e4d938 commit 88d069f
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 27 deletions.
15 changes: 7 additions & 8 deletions api/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (
"net/http"
"net/http/httptest"
"os"
"sync"
"testing"
"time"
"sync"

"github.com/lbryio/lbrytv/config"
"github.com/lbryio/lbrytv/internal/lbrynet"
"github.com/lbryio/lbrytv/internal/monitor"
"github.com/lbryio/lbrytv/internal/storage"

ljsonrpc "github.com/lbryio/lbry.go/extras/jsonrpc"
Expand Down Expand Up @@ -48,8 +47,8 @@ func TestMain(m *testing.M) {
}

func testFuncSetup() {
time.Sleep(testSetupWait)
lbrynet.RemoveAccount(dummyUserID)
time.Sleep(testSetupWait)
}

func testFuncTeardown() {
Expand Down Expand Up @@ -129,16 +128,17 @@ func TestWithValidAuthToken(t *testing.T) {
}

func TestWithValidAuthTokenConcurrent(t *testing.T) {
testFuncSetup()
defer testFuncTeardown()
// This test requires its own dummy account ID
lbrynet.RemoveAccount(123123)
defer lbrynet.RemoveAccount(123123)

var wg sync.WaitGroup

ts := launchDummyAPIServerDelayed([]byte(`{
"success": true,
"error": null,
"data": {
"id": 751365,
"id": 123123,
"language": "en",
"given_name": null,
"family_name": null,
Expand All @@ -162,7 +162,7 @@ func TestWithValidAuthTokenConcurrent(t *testing.T) {
config.Override("InternalAPIHost", ts.URL)
defer config.RestoreOverridden()

for w := range [20]int{} {
for w := range [10]int{} {
wg.Add(1)
go func(w int, wg *sync.WaitGroup) {
var response jsonrpc.RPCResponse
Expand All @@ -177,7 +177,6 @@ func TestWithValidAuthTokenConcurrent(t *testing.T) {
require.Equal(t, http.StatusOK, rr.Code)
json.Unmarshal(rr.Body.Bytes(), &response)
require.Nil(t, response.Error)
monitor.Logger.Debugf("request %v done", w)
wg.Done()
}(w, &wg)
}
Expand Down
43 changes: 24 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
module github.com/lbryio/lbrytv

require (
cloud.google.com/go v0.40.0 // indirect
cloud.google.com/go v0.41.0 // indirect
github.com/btcsuite/btcd v0.0.0-20190614013741-962a206e94e9 // indirect
github.com/coreos/bbolt v1.3.3 // indirect
github.com/coreos/etcd v3.3.13+incompatible // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a // indirect
github.com/cosiner/argv v0.0.1 // indirect
github.com/getsentry/sentry-go v0.1.0
github.com/go-delve/delve v1.2.0 // indirect
github.com/go-kit/kit v0.9.0 // indirect
github.com/gobuffalo/packr v1.30.1 // indirect
github.com/gobuffalo/packr/v2 v2.5.1
github.com/gofrs/uuid v3.2.0+incompatible // indirect
github.com/golang/mock v1.3.1 // indirect
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
github.com/gorilla/mux v1.7.2
github.com/grpc-ecosystem/grpc-gateway v1.9.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.9.4 // indirect
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6 // indirect
github.com/jinzhu/gorm v1.9.9
github.com/jmoiron/sqlx v1.2.0
github.com/kat-co/vala v0.0.0-20170210184112-42e1d8b61f12
github.com/kisielk/errcheck v1.2.0 // indirect
github.com/kr/pty v1.1.5 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/lbryio/lbry.go v1.0.15-0.20190624042915-7e445e0cf875
github.com/lbryio/lbryschema.go v0.0.0-20190602173230-6d2f69a36f46 // indirect

Expand All @@ -31,14 +32,20 @@ require (
github.com/magiconair/properties v1.8.1 // indirect
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2 // indirect
github.com/markbates/safe v1.0.1 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pelletier/go-toml v1.4.0 // indirect
github.com/peterh/liner v1.1.0 // indirect
github.com/pingcap/errors v0.11.4 // indirect
github.com/pkg/errors v0.8.1
github.com/pkg/profile v1.3.0 // indirect
github.com/prometheus/common v0.6.0 // indirect
github.com/rogpeppe/fastuuid v1.1.0 // indirect
github.com/prometheus/procfs v0.0.3 // indirect
github.com/rogpeppe/fastuuid v1.2.0 // indirect
github.com/rubenv/sql-migrate v0.0.0-20190618074426-f4d34eae5a5c
github.com/russross/blackfriday v2.0.0+incompatible // indirect
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 // indirect
Expand All @@ -49,24 +56,22 @@ require (
github.com/spf13/viper v1.4.0
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.3.0
github.com/ugorji/go v1.1.5-pre // indirect
github.com/ugorji/go v1.1.7 // indirect
github.com/volatiletech/inflect v0.0.0-20170731032912-e7201282ae8d // indirect
github.com/volatiletech/null v8.0.0+incompatible
github.com/volatiletech/sqlboiler v3.4.0+incompatible
github.com/ybbus/jsonrpc v2.1.2+incompatible
github.com/ziutek/mymysql v1.5.4 // indirect
go.etcd.io/bbolt v1.3.3 // indirect
go.opencensus.io v0.22.0 // indirect
golang.org/x/arch v0.0.0-20190312162104-788fe5ffcd8c // indirect
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522 // indirect
golang.org/x/image v0.0.0-20190622003408-7e034cad6442 // indirect
golang.org/x/mobile v0.0.0-20190607214518-6fa95d984e88 // indirect
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 // indirect
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 // indirect
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4 // indirect
google.golang.org/api v0.7.0 // indirect
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/genproto v0.0.0-20190620144150-6af8c5fc6601 // indirect
google.golang.org/grpc v1.21.1 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/exp v0.0.0-20190627132806-fd42eb6b336f // indirect
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9 // indirect
golang.org/x/mobile v0.0.0-20190711165009-e47acb2ca7f9 // indirect
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 // indirect
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 // indirect
golang.org/x/tools v0.0.0-20190716221150-e98af2309876 // indirect
google.golang.org/genproto v0.0.0-20190716160619-c506a9f90610 // indirect
google.golang.org/grpc v1.22.0 // indirect
gopkg.in/gorp.v1 v1.7.2 // indirect
)

0 comments on commit 88d069f

Please sign in to comment.