1
0
Fork 0

Don't call t.Fatal() from goroutine

It wouldn't abort the test anyway, so just log.
master
Philip O'Toole 2 years ago
parent 37687c1ff2
commit 0071867e34

@ -23,7 +23,7 @@ jobs:
- run: go version
- run: go get -v -t -d ./...
- run: bash gofmt.sh
- run: go vet -testinggoroutine=false ./...
- run: go vet ./...
- run: go test ./...
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large

@ -237,10 +237,10 @@ func Test_MarshalCompressedConcurrent(t *testing.T) {
defer wg.Done()
_, comp, err := rm.Marshal(r)
if err != nil {
t.Fatalf("failed to marshal QueryRequest: %s", err)
t.Logf("failed to marshal QueryRequest: %s", err)
}
if !comp {
t.Fatal("Marshaled QueryRequest wasn't compressed")
t.Logf("Marshaled QueryRequest wasn't compressed")
}
}()
}

@ -823,10 +823,10 @@ func Test_ConcurrentQueriesInMemory(t *testing.T) {
defer wg.Done()
ro, err := db.QueryStringStmt(`SELECT COUNT(*) FROM foo`)
if err != nil {
t.Fatalf("failed to query table: %s", err.Error())
t.Logf("failed to query table: %s", err.Error())
}
if exp, got := `[{"columns":["COUNT(*)"],"types":[""],"values":[[5000]]}]`, asJSON(ro); exp != got {
t.Fatalf("unexpected results for query\nexp: %s\ngot: %s", exp, got)
t.Logf("unexpected results for query\nexp: %s\ngot: %s", exp, got)
}
}()
}
@ -1726,7 +1726,7 @@ func Test_ParallelOperationsInMemory(t *testing.T) {
defer exWg.Done()
for range foo {
if _, err := db.ExecuteStringStmt(`INSERT INTO foo(id, name) VALUES(1, "fiona")`); err != nil {
t.Fatalf("failed to insert records into foo: %s", err.Error())
t.Logf("failed to insert records into foo: %s", err.Error())
}
}
}()
@ -1734,7 +1734,7 @@ func Test_ParallelOperationsInMemory(t *testing.T) {
defer exWg.Done()
for range bar {
if _, err := db.ExecuteStringStmt(`INSERT INTO bar(id, name) VALUES(1, "fiona")`); err != nil {
t.Fatalf("failed to insert records into bar: %s", err.Error())
t.Logf("failed to insert records into bar: %s", err.Error())
}
}
}()
@ -1742,7 +1742,7 @@ func Test_ParallelOperationsInMemory(t *testing.T) {
defer exWg.Done()
for range qux {
if _, err := db.ExecuteStringStmt(`INSERT INTO qux(id, name) VALUES(1, "fiona")`); err != nil {
t.Fatalf("failed to insert records into qux: %s", err.Error())
t.Logf("failed to insert records into qux: %s", err.Error())
}
}
}()
@ -1755,11 +1755,11 @@ func Test_ParallelOperationsInMemory(t *testing.T) {
var n int
for {
if rows, err := db.QueryStringStmt(`SELECT sql FROM sqlite_master`); err != nil {
t.Fatalf("failed to query for schema during goroutine %d execution: %s", j, err.Error())
t.Logf("failed to query for schema during goroutine %d execution: %s", j, err.Error())
} else {
n++
if exp, got := `[{"columns":["sql"],"types":["text"],"values":[["CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT)"],["CREATE TABLE bar (id INTEGER NOT NULL PRIMARY KEY, name TEXT)"],["CREATE TABLE qux (id INTEGER NOT NULL PRIMARY KEY, name TEXT)"]]}]`, asJSON(rows); exp != got {
t.Fatalf("schema not as expected during goroutine execution, exp %s, got %s, after %d queries", exp, got, n)
t.Logf("schema not as expected during goroutine execution, exp %s, got %s, after %d queries", exp, got, n)
}
}
if n == 500000 {

@ -772,7 +772,7 @@ func Test_MultiNodeClusterQueuedWrites(t *testing.T) {
defer wg.Done()
for i := 0; i < writesPerLoop; i++ {
if _, err := node1.Execute(`INSERT INTO foo(name) VALUES("fiona")`); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}
}()
@ -780,7 +780,7 @@ func Test_MultiNodeClusterQueuedWrites(t *testing.T) {
defer wg.Done()
for i := 0; i < writesPerLoop; i++ {
if _, err := node2.Execute(`INSERT INTO foo(name) VALUES("fiona")`); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}
}()
@ -788,33 +788,33 @@ func Test_MultiNodeClusterQueuedWrites(t *testing.T) {
defer wg.Done()
for i := 0; i < writesPerLoop-1; i++ {
if _, err := node2.ExecuteQueued(`INSERT INTO foo(name) VALUES("fiona")`, false); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}
if _, err := node2.ExecuteQueued(`INSERT INTO foo(name) VALUES("fiona")`, true); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}()
go func() {
defer wg.Done()
for i := 0; i < writesPerLoop-1; i++ {
if _, err := node3.ExecuteQueued(`INSERT INTO foo(name) VALUES("fiona")`, false); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}
if _, err := node3.ExecuteQueued(`INSERT INTO foo(name) VALUES("fiona")`, true); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}()
go func() {
defer wg.Done()
for i := 0; i < writesPerLoop-1; i++ {
if _, err := node3.ExecuteQueued(`INSERT INTO foo(name) VALUES("fiona")`, false); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}
if _, err := node3.ExecuteQueued(`INSERT INTO foo(name) VALUES("fiona")`, true); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}()
wg.Wait()
@ -870,11 +870,11 @@ func Test_MultiNodeClusterLargeQueuedWrites(t *testing.T) {
defer wg.Done()
for i := 0; i < writesPerNode-1; i++ {
if _, err := nt.ExecuteQueued(`INSERT INTO foo(name) VALUES("fiona")`, false); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}
if _, err := nt.ExecuteQueued(`INSERT INTO foo(name) VALUES("fiona")`, true); err != nil {
t.Fatalf("failed to insert records: %s", err.Error())
t.Logf("failed to insert records: %s", err.Error())
}
}(n)
}

@ -219,7 +219,7 @@ func Test_SingleNodeConcurrentRequests(t *testing.T) {
defer wg.Done()
resp, err := PostExecuteStmt(node.APIAddr, `INSERT INTO foo(name) VALUES("fiona")`)
if err != nil {
t.Fatalf("failed to insert record: %s %s", err.Error(), resp)
t.Logf("failed to insert record: %s %s", err.Error(), resp)
}
}()
}
@ -252,7 +252,7 @@ func Test_SingleNodeConcurrentRequestsCompressed(t *testing.T) {
defer wg.Done()
resp, err := PostExecuteStmt(node.APIAddr, `INSERT INTO foo(name) VALUES("fiona")`)
if err != nil {
t.Fatalf("failed to insert record: %s %s", err.Error(), resp)
t.Logf("failed to insert record: %s %s", err.Error(), resp)
}
}()
}

@ -126,7 +126,7 @@ func (e *echoServer) Start(t *testing.T) {
}
_, err = c.Write(buf)
if err != nil {
t.Fatalf("failed to write byte: %s", err.Error())
t.Logf("failed to write byte: %s", err.Error())
}
c.Close()
}(conn)

@ -60,7 +60,7 @@ func TestMux(t *testing.T) {
// doesn't match then expect close.
if len(msg) == 0 || msg[0] != i {
if err == nil || err.Error() != "network connection closed" {
t.Fatalf("unexpected error: %s", err)
t.Logf("unexpected error: %s", err)
}
return
}
@ -69,14 +69,14 @@ func TestMux(t *testing.T) {
// then expect a connection and read the message.
var buf bytes.Buffer
if _, err := io.CopyN(&buf, conn, int64(len(msg)-1)); err != nil {
t.Fatal(err)
t.Log(err)
} else if !bytes.Equal(msg[1:], buf.Bytes()) {
t.Fatalf("message mismatch:\n\nexp=%x\n\ngot=%x\n\n", msg[1:], buf.Bytes())
t.Logf("message mismatch:\n\nexp=%x\n\ngot=%x\n\n", msg[1:], buf.Bytes())
}
// Write response.
if _, err := conn.Write([]byte("OK")); err != nil {
t.Fatal(err)
t.Log(err)
}
}(i, ln)
}

Loading…
Cancel
Save