Skip to content

Commit 01dff73

Browse files
author
Mikhail Podtserkovskiy
committed
fix
1 parent 928ad7a commit 01dff73

File tree

10 files changed

+33
-22
lines changed

10 files changed

+33
-22
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ language: go
33
go:
44
- 1.8.x
55

6-
7-
before_install:
8-
- mysql -e 'CREATE DATABASE grid;'
96
install: make get-deps prepare
107
script:
118
- make test
12-
- make concurrency-test
139
services:
1410
- mysql
1511

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ ENV CONFIG_PATH ./config.json
77

88
RUN make
99

10-
CMD ["service-entrypoint"]
10+
CMD ["jsonwire-grid"]
1111

1212
EXPOSE 4444

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export CONFIG_PATH=./config.json
2-
32
TEST_CONFIG_PATH=./config-test.json
43
all: get-deps build
54

@@ -13,7 +12,8 @@ help:
1312
@echo "run - start application"
1413

1514
build: prepare
16-
go build -o ${GOPATH}/bin/service-entrypoint
15+
@echo "Install jsonwire-grid"
16+
go install github.com/qa-dev/jsonwire-grid
1717

1818
fmt:
1919
go fmt
@@ -27,18 +27,27 @@ get-deps:
2727
prepare: fmt gen
2828

2929
run: build
30-
${GOPATH}/bin/service-entrypoint
30+
@echo "Start jsonwire-grid"
31+
jsonwire-grid
3132

3233
test:
3334
go test ./...
3435

3536
concurrency-test-prepare: build
37+
@echo "Install jsonwire-grid"
3638
go install github.com/qa-dev/jsonwire-grid/testing/webdriver-node-mock
39+
@echo "Install webdriver-node-mock"
3740
go install github.com/qa-dev/jsonwire-grid/testing/webdriver-mock-creator
41+
@echo "Install webdriver-mock-creator"
3842
go install github.com/qa-dev/jsonwire-grid/testing/webdriver-concurrency-test
39-
nohupkillall -9 service-entrypoint >/dev/null 2>&1 &
40-
CONFIG_PATH=$(TEST_CONFIG_PATH) ${GOPATH}/bin/service-entrypoint &
43+
@echo "Kill all running jsonwire-grid"
44+
killall -9 jsonwire-grid &
45+
@echo "Wait 1s"
46+
sleep 1
47+
@echo "Start jsonwire-grid"
48+
CONFIG_PATH=$(TEST_CONFIG_PATH) jsonwire-grid &
4149

4250
concurrency-test: concurrency-test-prepare
51+
@echo "Start webdriver-concurrency-test"
4352
webdriver-concurrency-test
4453

config-sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
},
55
"db": {
66
"implementation": "mysql",
7-
"connection": "root:@(localhost:3306)/grid?tx_isolation=SERIALIZABLE&parseTime=true"
7+
"connection": "root:@(localhost:3306)/grid?tx_isolation=SERIALIZABLE&parseTime=true&interpolateParams=true"
88
},
99
"grid": {
1010
"port": 4444,

config-test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
},
55
"db": {
66
"implementation": "mysql",
7-
"connection": "root:@(127.0.0.1:3306)/grid?tx_isolation=SERIALIZABLE&parseTime=true"
7+
"connection": "root:@(127.0.0.1:3306)/grid?tx_isolation=SERIALIZABLE&parseTime=true&interpolateParams=true"
88
},
99
"grid": {
1010
"port": 4444,

main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,20 @@ func main() {
7979
http.Handle("/", m.Log(&handlers.UseSession{Pool: poolInstance}))
8080

8181
server := &http.Server{Addr: fmt.Sprintf(":%v", cfg.Grid.Port)}
82+
serverError := make(chan error)
8283
go func() {
8384
err = server.ListenAndServe()
8485
if err != nil {
85-
// todo: норма ли что при закрытии всегда возвращается еррор???
86-
log.Errorf("Listen serve error, %s", err)
86+
// todo: норма ли что при вызове server.Shutdown всегда возвращается еррор???
87+
serverError <- err
8788
}
8889
}()
8990

90-
<-stop
91+
select {
92+
case err = <-serverError:
93+
log.Fatalf("Server error, %s", err)
94+
case <-stop:
95+
}
9196

9297
log.Info("Shutting down the server...")
9398

storage/mysql/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (f *Factory) Create(config config.Config) (pool.StorageInterface, error) {
2121
return nil, err
2222
}
2323

24-
db.SetMaxIdleConns(0) // this is the root problem! set it to 0 to remove all idle connections
24+
db.SetMaxIdleConns(0) // this is the root problem! set it to 0 to remove all idle connections
2525
db.SetMaxOpenConns(50) // or whatever is appropriate for your setup.
2626

2727
storage := NewMysqlStorage(db)

storage/mysql/storage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package mysql
22

33
import (
44
"errors"
5+
"fmt"
56
"github.com/jmoiron/sqlx"
67
"github.com/qa-dev/jsonwire-grid/pool"
78
"sort"
89
"strconv"
9-
"time"
10-
"fmt"
1110
"strings"
11+
"time"
1212
)
1313

1414
type MysqlNodeModel struct {

testing/webdriver-concurrency-test/webdriver-concurrency-test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ var (
2525
durationStr *string
2626
)
2727

28+
// todo: prototype
2829
func main() {
2930
hubUrl = flag.String("hub", "http://127.0.0.1:4444", "address of hub, default http://127.0.0.1:4444")
30-
level = flag.Int("level", 100, "count parallell conections")
31+
level = flag.Int("level", 50, "count parallell conections")
3132
durationStr = flag.String("duration", "30s", "duration of test, string format ex. 12m, see time.ParseDuration()")
32-
mockMaxDuration := flag.Int("mockMaxDuration", 100, "request duration [0 <=duration], default 0")
33+
mockMaxDuration := flag.Int("mockMaxDuration", 500, "request duration [0 <=duration], default 0")
3334
mockStartPort := flag.Int("mockStartPort", 5000, "mockStartPort")
3435
flag.Parse()
3536

@@ -62,7 +63,7 @@ func main() {
6263

6364
go func() {
6465
for i := 1; i <= *level && isAlive; i++ {
65-
time.Sleep(time.Millisecond * 50)
66+
time.Sleep(time.Millisecond * 100)
6667
go func() {
6768
wg.Add(1)
6869
defer wg.Done()

testing/webdriver-mock-creator/webdriver-mock-creator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func main() {
3333
}()
3434

3535
for port := *startPort; port < *startPort+*countNodes && isAlive; port++ {
36-
time.Sleep(time.Millisecond)
36+
time.Sleep(time.Millisecond * 5)
3737
cmd := exec.Command(
3838
"webdriver-node-mock",
3939
fmt.Sprintf("-hub=%v", *hubUrl),

0 commit comments

Comments
 (0)