Browse Source

Merge pull request #78 from tendermint/feature/new-logging

New logging
pull/1780/head
Ethan Buchman 8 years ago
committed by GitHub
parent
commit
bd2b87dd3d
24 changed files with 185 additions and 119 deletions
  1. +15
    -0
      .editorconfig
  2. +1
    -3
      .gitignore
  3. +2
    -2
      Makefile
  4. +2
    -2
      client/grpc_client.go
  5. +1
    -1
      client/local_client.go
  6. +0
    -7
      client/log.go
  7. +6
    -5
      client/socket_client.go
  8. +12
    -4
      cmd/abci-cli/abci-cli.go
  9. +7
    -2
      cmd/counter/main.go
  10. +8
    -2
      cmd/dummy/main.go
  11. +7
    -2
      example/block_aware/block_aware_app.go
  12. +5
    -5
      example/block_aware/block_aware_test.go
  13. +9
    -1
      example/dummy/dummy_test.go
  14. +0
    -7
      example/dummy/log.go
  15. +20
    -10
      example/dummy/persistent_dummy.go
  16. +9
    -8
      example/example_test.go
  17. +43
    -30
      glide.lock
  18. +3
    -2
      glide.yaml
  19. +0
    -7
      server/log.go
  20. +9
    -7
      server/socket_server.go
  21. +0
    -0
      tests/test.sh
  22. +4
    -1
      tests/test_app/app.go
  23. +9
    -4
      tests/test_app/test.sh
  24. +13
    -7
      tests/test_cli/test.sh

+ 15
- 0
.editorconfig View File

@ -0,0 +1,15 @@
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[Makefile]
indent_style = tab
[*.sh]
indent_style = tab

+ 1
- 3
.gitignore View File

@ -1,4 +1,2 @@
*.swp
*.swo
*.pyc
vendor
.glide

+ 2
- 2
Makefile View File

@ -19,7 +19,7 @@ build:
# test.sh requires that we run the installed cmds, must not be out of date
test: install
find . -name test.sock -exec rm {} \;
find . -path ./vendor -prune -o -name *.sock -exec rm {} \;
@ go test -p 1 `${NOVENDOR}`
@ bash tests/test.sh
@ -30,7 +30,7 @@ lint:
@ go get -u github.com/golang/lint/golint
@ for file in $$(find "." -name '*.go' | grep -v '/vendor/' | grep -v '\.pb\.go'); do \
golint -set_exit_status $${file}; \
done;
done;
test_integrations: get_vendor_deps install test


+ 2
- 2
client/grpc_client.go View File

@ -51,7 +51,7 @@ RETRY_LOOP:
if cli.mustConnect {
return err
}
log.Warn(fmt.Sprintf("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr))
cli.Logger.Error(fmt.Sprintf("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr))
time.Sleep(time.Second * 3)
continue RETRY_LOOP
}
@ -93,7 +93,7 @@ func (cli *grpcClient) StopForError(err error) {
}
cli.mtx.Unlock()
log.Warn(fmt.Sprintf("Stopping abci.grpcClient for error: %v", err.Error()))
cli.Logger.Error(fmt.Sprintf("Stopping abci.grpcClient for error: %v", err.Error()))
cli.Stop()
}


+ 1
- 1
client/local_client.go View File

@ -22,7 +22,7 @@ func NewLocalClient(mtx *sync.Mutex, app types.Application) *localClient {
mtx: mtx,
Application: app,
}
cli.BaseService = *cmn.NewBaseService(log, "localClient", cli)
cli.BaseService = *cmn.NewBaseService(nil, "localClient", cli)
return cli
}


+ 0
- 7
client/log.go View File

@ -1,7 +0,0 @@
package abcicli
import (
"github.com/tendermint/tmlibs/logger"
)
var log = logger.New("module", "abcicli")

+ 6
- 5
client/socket_client.go View File

@ -53,7 +53,8 @@ func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) {
resCb: nil,
}
cli.BaseService = *cmn.NewBaseService(nil, "socketClient", cli)
// FIXME we are loosing "Starting socketClient" message here
// add logger to params?
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
return cli, err
}
@ -70,7 +71,7 @@ RETRY_LOOP:
if cli.mustConnect {
return err
}
log.Warn(fmt.Sprintf("abci.socketClient failed to connect to %v. Retrying...", cli.addr))
cli.Logger.Error(fmt.Sprintf("abci.socketClient failed to connect to %v. Retrying...", cli.addr))
time.Sleep(time.Second * 3)
continue RETRY_LOOP
}
@ -107,7 +108,7 @@ func (cli *socketClient) StopForError(err error) {
}
cli.mtx.Unlock()
log.Warn(fmt.Sprintf("Stopping abci.socketClient for error: %v", err.Error()))
cli.Logger.Error(fmt.Sprintf("Stopping abci.socketClient for error: %v", err.Error()))
cli.Stop()
}
@ -147,7 +148,7 @@ func (cli *socketClient) sendRequestsRoutine(conn net.Conn) {
cli.StopForError(fmt.Errorf("Error writing msg: %v", err))
return
}
// log.Debug("Sent request", "requestType", reflect.TypeOf(reqres.Request), "request", reqres.Request)
// cli.Logger.Debug("Sent request", "requestType", reflect.TypeOf(reqres.Request), "request", reqres.Request)
if _, ok := reqres.Request.Value.(*types.Request_Flush); ok {
err = w.Flush()
if err != nil {
@ -175,7 +176,7 @@ func (cli *socketClient) recvResponseRoutine(conn net.Conn) {
cli.StopForError(errors.New(r.Exception.Error))
return
default:
// log.Debug("Received response", "responseType", reflect.TypeOf(res), "response", res)
// cli.Logger.Debug("Received response", "responseType", reflect.TypeOf(res), "response", res)
err := cli.didRecvResponse(res)
if err != nil {
cli.StopForError(err)


+ 12
- 4
cmd/abci-cli/abci-cli.go View File

@ -6,13 +6,13 @@ import (
"errors"
"fmt"
"io"
"log"
"os"
"strings"
"github.com/tendermint/abci/client"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/types"
"github.com/tendermint/abci/version"
"github.com/tendermint/tmlibs/log"
"github.com/urfave/cli"
)
@ -36,6 +36,8 @@ type queryResponse struct {
// client is a global variable so it can be reused by the console
var client abcicli.Client
var logger log.Logger
func main() {
//workaround for the cli library (https://github.com/urfave/cli/issues/565)
@ -129,18 +131,24 @@ func main() {
app.Before = before
err := app.Run(os.Args)
if err != nil {
log.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
}
func before(c *cli.Context) error {
if logger == nil {
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
}
if client == nil {
var err error
client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false)
if err != nil {
log.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
client.SetLogger(logger.With("module", "abci-client"))
}
return nil
}


+ 7
- 2
cmd/counter/main.go View File

@ -2,11 +2,12 @@ package main
import (
"flag"
"log"
"os"
"github.com/tendermint/abci/example/counter"
"github.com/tendermint/abci/server"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func main() {
@ -17,11 +18,15 @@ func main() {
flag.Parse()
app := counter.NewCounterApplication(*serialPtr)
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
if err != nil {
log.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
srv.SetLogger(logger.With("module", "abci-server"))
// Wait forever
cmn.TrapSignal(func() {


+ 8
- 2
cmd/dummy/main.go View File

@ -2,12 +2,13 @@ package main
import (
"flag"
"log"
"os"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func main() {
@ -17,19 +18,24 @@ func main() {
persistencePtr := flag.String("persist", "", "directory to use for a database")
flag.Parse()
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Create the application - in memory or persisted to disk
var app types.Application
if *persistencePtr == "" {
app = dummy.NewDummyApplication()
} else {
app = dummy.NewPersistentDummyApplication(*persistencePtr)
app.(*dummy.PersistentDummyApplication).SetLogger(logger.With("module", "dummy"))
}
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
if err != nil {
log.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
srv.SetLogger(logger.With("module", "abci-server"))
// Wait forever
cmn.TrapSignal(func() {


+ 7
- 2
example/block_aware/block_aware_app.go View File

@ -2,11 +2,12 @@ package main
import (
"flag"
"log"
"os"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func main() {
@ -15,11 +16,15 @@ func main() {
abciPtr := flag.String("abci", "socket", "socket | grpc")
flag.Parse()
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
if err != nil {
log.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
srv.SetLogger(logger.With("module", "abci-server"))
// Wait forever
cmn.TrapSignal(func() {


+ 5
- 5
example/block_aware/block_aware_test.go View File

@ -1,19 +1,17 @@
package main
import (
"fmt"
"log"
"strconv"
"strings"
"testing"
"github.com/tendermint/abci/client"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
"github.com/tendermint/tmlibs/log"
)
func TestChainAware(t *testing.T) {
app := NewChainAwareApplication()
// Start the listener
@ -21,13 +19,15 @@ func TestChainAware(t *testing.T) {
if err != nil {
t.Fatal(err)
}
srv.SetLogger(log.TestingLogger().With("module", "abci-server"))
defer srv.Stop()
// Connect to the socket
client, err := abcicli.NewSocketClient("unix://test.sock", false)
if err != nil {
log.Fatal(fmt.Sprintf("Error starting socket client: %v", err.Error()))
t.Fatalf("Error starting socket client: %v", err.Error())
}
client.SetLogger(log.TestingLogger().With("module", "abci-client"))
client.Start()
defer client.Stop()


+ 9
- 1
example/dummy/dummy_test.go View File

@ -10,9 +10,10 @@ import (
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
"github.com/tendermint/go-crypto"
crypto "github.com/tendermint/go-crypto"
"github.com/tendermint/merkleeyes/iavl"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func testDummy(t *testing.T, app types.Application, tx []byte, key, value string) {
@ -211,10 +212,13 @@ func valsEqual(t *testing.T, vals1, vals2 []*types.Validator) {
func makeSocketClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
// Start the listener
socket := cmn.Fmt("unix://%s.sock", name)
logger := log.TestingLogger()
server, err := server.NewSocketServer(socket, app)
if err != nil {
return nil, nil, err
}
server.SetLogger(logger.With("module", "abci-server"))
// Connect to the socket
client, err := abcicli.NewSocketClient(socket, false)
@ -222,6 +226,7 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client,
server.Stop()
return nil, nil, err
}
client.SetLogger(logger.With("module", "abci-client"))
client.Start()
return client, server, err
@ -230,18 +235,21 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client,
func makeGRPCClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
// Start the listener
socket := cmn.Fmt("unix://%s.sock", name)
logger := log.TestingLogger()
gapp := types.NewGRPCApplication(app)
server, err := server.NewGRPCServer(socket, gapp)
if err != nil {
return nil, nil, err
}
server.SetLogger(logger.With("module", "abci-server"))
client, err := abcicli.NewGRPCClient(socket, true)
if err != nil {
server.Stop()
return nil, nil, err
}
client.SetLogger(logger.With("module", "abci-client"))
return client, server, err
}


+ 0
- 7
example/dummy/log.go View File

@ -1,7 +0,0 @@
package dummy
import (
"github.com/tendermint/tmlibs/logger"
)
var log = logger.New("module", "dummy")

+ 20
- 10
example/dummy/persistent_dummy.go View File

@ -6,11 +6,13 @@ import (
"strconv"
"strings"
"github.com/pkg/errors"
"github.com/tendermint/abci/types"
"github.com/tendermint/go-wire"
wire "github.com/tendermint/go-wire"
"github.com/tendermint/merkleeyes/iavl"
cmn "github.com/tendermint/tmlibs/common"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
)
const (
@ -29,6 +31,8 @@ type PersistentDummyApplication struct {
// validator set
changes []*types.Validator
logger log.Logger
}
func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication {
@ -38,14 +42,19 @@ func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication {
stateTree := iavl.NewIAVLTree(0, db)
stateTree.Load(lastBlock.AppHash)
log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash())
// log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash())
return &PersistentDummyApplication{
app: &DummyApplication{state: stateTree},
db: db,
app: &DummyApplication{state: stateTree},
db: db,
logger: log.NewNopLogger(),
}
}
func (app *PersistentDummyApplication) SetLogger(l log.Logger) {
app.logger = l
}
func (app *PersistentDummyApplication) Info() (resInfo types.ResponseInfo) {
resInfo = app.app.Info()
lastBlock := LoadLastBlock(app.db)
@ -79,13 +88,16 @@ func (app *PersistentDummyApplication) CheckTx(tx []byte) types.Result {
func (app *PersistentDummyApplication) Commit() types.Result {
// Save
appHash := app.app.state.Save()
log.Info("Saved state", "root", appHash)
app.logger.Info("Saved state", "root", appHash)
lastBlock := LastBlockInfo{
Height: app.blockHeader.Height,
AppHash: appHash, // this hash will be in the next block header
}
app.logger.Info("Saving block", "height", lastBlock.Height, "root", lastBlock.AppHash)
SaveLastBlock(app.db, lastBlock)
return types.NewResultOK(appHash, "")
}
@ -98,7 +110,7 @@ func (app *PersistentDummyApplication) InitChain(validators []*types.Validator)
for _, v := range validators {
r := app.updateValidator(v)
if r.IsErr() {
log.Error("Error updating validators", "r", r)
app.logger.Error("Error updating validators", "r", r)
}
}
}
@ -134,8 +146,7 @@ func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) {
r, n, err := bytes.NewReader(buf), new(int), new(error)
wire.ReadBinaryPtr(&lastBlock, r, 0, n, err)
if *err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
log.Crit(cmn.Fmt("Data has been corrupted or its spec has changed: %v\n", *err))
cmn.PanicCrisis(errors.Wrap(*err, "cannot load last block (data has been corrupted or its spec has changed)"))
}
// TODO: ensure that buf is completely read.
}
@ -144,12 +155,11 @@ func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) {
}
func SaveLastBlock(db dbm.DB, lastBlock LastBlockInfo) {
log.Notice("Saving block", "height", lastBlock.Height, "root", lastBlock.AppHash)
buf, n, err := new(bytes.Buffer), new(int), new(error)
wire.WriteBinary(lastBlock, buf, n, err)
if *err != nil {
// TODO
cmn.PanicCrisis(*err)
cmn.PanicCrisis(errors.Wrap(*err, "cannot save last block"))
}
db.Set(lastBlockKey, buf.Bytes())
}


+ 9
- 8
example/example_test.go View File

@ -2,7 +2,6 @@ package example
import (
"fmt"
"log"
"net"
"reflect"
"testing"
@ -12,11 +11,12 @@ import (
"golang.org/x/net/context"
"github.com/tendermint/abci/client"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func TestDummy(t *testing.T) {
@ -35,21 +35,22 @@ func TestGRPC(t *testing.T) {
}
func testStream(t *testing.T, app types.Application) {
numDeliverTxs := 200000
// Start the listener
server, err := server.NewSocketServer("unix://test.sock", app)
if err != nil {
log.Fatal(cmn.Fmt("Error starting socket server: %v", err.Error()))
t.Fatalf("Error starting socket server: %v", err.Error())
}
server.SetLogger(log.TestingLogger().With("module", "abci-server"))
defer server.Stop()
// Connect to the socket
client, err := abcicli.NewSocketClient("unix://test.sock", false)
if err != nil {
log.Fatal(cmn.Fmt("Error starting socket client: %v", err.Error()))
t.Fatalf("Error starting socket client: %v", err.Error())
}
client.SetLogger(log.TestingLogger().With("module", "abci-client"))
client.Start()
defer client.Stop()
@ -108,20 +109,20 @@ func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
}
func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
numDeliverTxs := 2000
// Start the listener
server, err := server.NewGRPCServer("unix://test.sock", app)
if err != nil {
log.Fatal(cmn.Fmt("Error starting GRPC server: %v", err.Error()))
t.Fatalf("Error starting GRPC server: %v", err.Error())
}
server.SetLogger(log.TestingLogger().With("module", "abci-server"))
defer server.Stop()
// Connect to the socket
conn, err := grpc.Dial("unix://test.sock", grpc.WithInsecure(), grpc.WithDialer(dialerFunc))
if err != nil {
log.Fatal(cmn.Fmt("Error dialing GRPC server: %v", err.Error()))
t.Fatalf("Error dialing GRPC server: %v", err.Error())
}
defer conn.Close()


+ 43
- 30
glide.lock View File

@ -1,28 +1,35 @@
hash: 13c7dac029851e5177bf78ff26ce6ccd047360111795a9a65af4ba6a0b87f4b3
updated: 2017-04-21T18:38:50.4243289-04:00
hash: 8038c78e65a8b5ad4bc6ff8e74c40bd02be23e2c3c4245aff8b354e3dbdec1e2
updated: 2017-05-05T12:30:23.699400925Z
imports:
- name: github.com/btcsuite/btcd
version: 583684b21bfbde9b5fc4403916fd7c807feb0289
version: 4b348c1d33373d672edd83fc576892d0e46686d2
subpackages:
- btcec
- name: github.com/go-kit/kit
version: 0873e56b0faeae3a1d661b10d629135508ea5504
subpackages:
- log
- log/level
- log/term
- name: github.com/go-logfmt/logfmt
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
- name: github.com/go-stack/stack
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
version: 7a2f19628aabfe68f0766b59e74d6315f8347d22
- name: github.com/golang/protobuf
version: 8ee79997227bf9b34611aee7946ae64735e6fd93
version: 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8
subpackages:
- proto
- ptypes/any
- name: github.com/golang/snappy
version: d9eb7a3d35ec988b8585d4a0068e462c27d28380
version: 553a641470496b2327abcac10b36396bd98e45c9
- name: github.com/jmhodges/levigo
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
- name: github.com/mattn/go-colorable
version: d228849504861217f796da67fae4f6e347643f15
- name: github.com/mattn/go-isatty
version: 30a891c33c7cde7b02a981314b4228ec99380cca
- name: github.com/kr/logfmt
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
- name: github.com/pkg/errors
version: 645ef00459ed84a119197bfb8d8205042c6df63d
version: c605e284fe17294bda444b34710735b29d1a9d90
- name: github.com/syndtr/goleveldb
version: 23851d93a2292dcc56e71a18ec9e0624d84a0f65
version: 8c81ea47d4c41a385645e133e15510fc6a2a74b4
subpackages:
- leveldb
- leveldb/cache
@ -42,31 +49,27 @@ imports:
- edwards25519
- extra25519
- name: github.com/tendermint/go-crypto
version: 9b95da8fa4187f6799558d89b271dc8ab6485615
version: 524ba917a3a1636f21ab2c0bf76b6526903ab879
- name: github.com/tendermint/go-wire
version: 334005c236d19c632fb5f073f9de3b0fab6a522b
version: b53add0b622662731985485f3a19be7f684660b8
subpackages:
- data
- name: github.com/tendermint/log15
version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6
subpackages:
- term
- name: github.com/tendermint/merkleeyes
version: 6fd69aa0871a4e685a5570aa7ab3d12e4068a722
version: d0aa363fd4e015e509038c3a0ec493bc62ee0b8a
subpackages:
- iavl
- name: github.com/tendermint/tmlibs
version: df250b69416a35a943a6e2a92118667e9ef031d4
version: a9a96064a0a494ef6a13c38b4395c20abee64996
subpackages:
- common
- db
- logger
- log
- merkle
- process
- name: github.com/urfave/cli
version: 0bdeddeeb0f650497d603c4ad7b20cfe685682f6
version: ab403a54a148f2d857920810291539e1f817ee7b
- name: golang.org/x/crypto
version: 7c6cc321c680f03b9ef0764448e780704f486b51
version: 5a033cc77e57eca05bdb50522851d29e03569cbe
subpackages:
- nacl/secretbox
- openpgp/armor
@ -75,7 +78,7 @@ imports:
- ripemd160
- salsa20/salsa
- name: golang.org/x/net
version: 61557ac0112b576429a0df080e1c2cef5dfbb642
version: feeb485667d1fdabe727840fe00adc22431bc86e
subpackages:
- context
- http2
@ -84,26 +87,36 @@ imports:
- internal/timeseries
- lex/httplex
- trace
- name: golang.org/x/sys
version: d75a52659825e75fff6158388dddc6a5b04f9ba5
- name: golang.org/x/text
version: 470f45bf29f4147d6fbd7dfd0a02a848e49f5bf4
subpackages:
- secure/bidirule
- transform
- unicode/bidi
- unicode/norm
- name: google.golang.org/genproto
version: 411e09b969b1170a9f0c467558eb4c4c110d9c77
subpackages:
- unix
- googleapis/rpc/status
- name: google.golang.org/grpc
version: cbcceb2942a489498cf22b2f918536e819d33f0a
version: 844f573616520565fdc6fb4db242321b5456fd6d
subpackages:
- codes
- credentials
- grpclb/grpc_lb_v1
- grpclog
- internal
- keepalive
- metadata
- naming
- peer
- stats
- status
- tap
- transport
testImports:
- name: github.com/davecgh/go-spew
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9
subpackages:
- spew
- name: github.com/pmezard/go-difflib
@ -111,7 +124,7 @@ testImports:
subpackages:
- difflib
- name: github.com/stretchr/testify
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
version: 4d4bfba8f1d1027c4fdbe371823030df51419987
subpackages:
- assert
- require

+ 3
- 2
glide.yaml View File

@ -3,6 +3,7 @@ import:
- package: github.com/golang/protobuf
subpackages:
- proto
- package: github.com/pkg/errors
- package: github.com/tendermint/go-crypto
version: develop
- package: github.com/tendermint/go-wire
@ -12,11 +13,11 @@ import:
subpackages:
- iavl
- package: github.com/tendermint/tmlibs
version: develop
version: log
subpackages:
- common
- db
- logger
- log
- merkle
- process
- package: github.com/urfave/cli


+ 0
- 7
server/log.go View File

@ -1,7 +0,0 @@
package server
import (
"github.com/tendermint/tmlibs/logger"
)
var log = logger.New("module", "abci-server")

+ 9
- 7
server/socket_server.go View File

@ -40,6 +40,8 @@ func NewSocketServer(protoAddr string, app types.Application) (cmn.Service, erro
conns: make(map[int]net.Conn),
}
s.BaseService = *cmn.NewBaseService(nil, "ABCIServer", s)
// FIXME we are loosing "Starting ABCIServer" message here
// add logger to params?
_, err := s.Start() // Just start it
return s, err
}
@ -94,15 +96,15 @@ func (s *SocketServer) acceptConnectionsRoutine() {
// semaphore <- struct{}{}
// Accept a connection
log.Notice("Waiting for new connection...")
s.Logger.Info("Waiting for new connection...")
conn, err := s.listener.Accept()
if err != nil {
if !s.IsRunning() {
return // Ignore error from listener closing.
}
log.Crit("Failed to accept connection: " + err.Error())
s.Logger.Error("Failed to accept connection: " + err.Error())
} else {
log.Notice("Accepted a new connection")
s.Logger.Info("Accepted a new connection")
}
connID := s.addConn(conn)
@ -119,18 +121,18 @@ func (s *SocketServer) acceptConnectionsRoutine() {
// Wait until signal to close connection
errClose := <-closeConn
if err == io.EOF {
log.Warn("Connection was closed by client")
s.Logger.Error("Connection was closed by client")
} else if errClose != nil {
log.Warn("Connection error", "error", errClose)
s.Logger.Error("Connection error", "error", errClose)
} else {
// never happens
log.Warn("Connection was closed.")
s.Logger.Error("Connection was closed.")
}
// Close the connection
err := s.rmConn(connID, conn)
if err != nil {
log.Warn("Error in closing connection", "error", err)
s.Logger.Error("Error in closing connection", "error", err)
}
// <-semaphore


+ 0
- 0
tests/test.sh View File


+ 4
- 1
tests/test_app/app.go View File

@ -6,8 +6,9 @@ import (
"os"
"time"
"github.com/tendermint/abci/client"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/types"
"github.com/tendermint/tmlibs/log"
"github.com/tendermint/tmlibs/process"
)
@ -37,6 +38,8 @@ func startClient(abciType string) abcicli.Client {
if err != nil {
panic("connecting to abci_app: " + err.Error())
}
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
client.SetLogger(logger.With("module", "abcicli"))
return client
}


+ 9
- 4
tests/test_app/test.sh View File

@ -3,14 +3,19 @@ set -e
# These tests spawn the counter app and server by execing the ABCI_APP command and run some simple client tests against it
ROOT=$GOPATH/src/github.com/tendermint/abci/tests/test_app
cd $ROOT
# Get the directory of where this script is.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# Change into that dir because we expect that.
cd "$DIR"
# test golang counter
ABCI_APP="counter" go run *.go
ABCI_APP="counter" go run ./*.go
# test golang counter via grpc
ABCI_APP="counter -abci=grpc" ABCI="grpc" go run *.go
ABCI_APP="counter -abci=grpc" ABCI="grpc" go run ./*.go
# test nodejs counter
# TODO: fix node app


+ 13
- 7
tests/test_cli/test.sh View File

@ -1,6 +1,12 @@
#! /bin/bash
cd $GOPATH/src/github.com/tendermint/abci
# Get the root directory.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )/../.." && pwd )"
# Change into that dir because we expect that.
cd "$DIR" || exit
function testExample() {
N=$1
@ -10,17 +16,17 @@ function testExample() {
echo "Example $N"
$APP &> /dev/null &
sleep 2
abci-cli --verbose batch < $INPUT > "${INPUT}.out.new"
killall "$APP"
abci-cli --verbose batch < "$INPUT" > "${INPUT}.out.new"
killall "$APP"
pre=`shasum < "${INPUT}.out"`
post=`shasum < "${INPUT}.out.new"`
pre=$(shasum < "${INPUT}.out")
post=$(shasum < "${INPUT}.out.new")
if [[ "$pre" != "$post" ]]; then
echo "You broke the tutorial"
echo "Got:"
echo "Got:"
cat "${INPUT}.out.new"
echo "Expected:"
echo "Expected:"
cat "${INPUT}.out"
exit 1
fi


Loading…
Cancel
Save