Skip to content

Commit e306e7b

Browse files
author
Mikhail Podtserkovskiy
committed
readme and small fixes
1 parent 5fc9033 commit e306e7b

File tree

10 files changed

+119
-29
lines changed

10 files changed

+119
-29
lines changed

README.md

Lines changed: 71 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,75 @@
11
# ~~jsonwire-grid~~WebDriverGrid [![Build Status](https://travis-ci.org/qa-dev/jsonwire-grid.svg?branch=master)](https://travis-ci.org/qa-dev/jsonwire-grid)
2-
This is scalable Golang implementation of Selenium Grid (hub).
2+
This is high-performance scalable implementation of Selenium Grid (hub),
3+
4+
## Features
5+
* One session per one node, no more no less😺
6+
* Scaling grid-instances for fault-tolerance
7+
* Support and effective management over 9000 nodes, for parallel testing👹
8+
* Single entry point for all your test apps
9+
* Send metrics to [statsd](https://github.com/etsy/statsd)
10+
* Support on-demand nodes in Kubernetes cluster (Only if grid running in cluster)
11+
312

413
## HowTo
5-
1. Install MySql
6-
1. Set in config.json your db connesction string `[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]`
7-
1. Run app
8-
#### Run binary file
9-
1. download binary file and
10-
1. `export CONFIG_PATH=./config.json`
11-
1. `./jsonwire-grid`
12-
13-
### Run From Source
14-
#### Requirements
15-
* Go >= 1.8.1
16-
* [go-bindata](https://github.com/jteeuwen/go-bindata)
17-
1. `git clone https://github.com/qa-dev/jsonwire-grid .`
18-
1. `cd jsonwire-grid`
19-
1. `cp config-sample.json config.json`
20-
1. `make run`
21-
22-
## HowToUse
23-
1. Run app
14+
### Run grid
15+
1. [Download last release](https://github.com/qa-dev/jsonwire-grid/releases) and unzip
16+
1. cd to `jsonwire-grid_vXXX`
17+
1. Type `export CONFIG_PATH=./config-local-sample.json`
18+
1. Type `./jsonwire-grid`
19+
1. Grid running!
20+
21+
### Run nodes
22+
1. [Download selenium](http://www.seleniumhq.org/download/)
2423
1. `java -jar selenium-server-standalone-3.4.0.jar -role node -hub http://127.0.0.1:4444/grid/register`
25-
1. try create session `curl -X POST http://127.0.0.1:4444/wd/hub/session -d '{"desiredCapabilities":{"browserName": "firefox"}}'`
24+
1. Repeat!
25+
26+
### Run test
27+
1. Try create session, such as `curl -X POST http://127.0.0.1:4444/wd/hub/session -d '{"desiredCapabilities":{"browserName": "firefox"}}'`
28+
1. If your something similar with `{"state":null,"sessionId":"515be56a...` all right! If not, submit [issue](https://github.com/qa-dev/jsonwire-grid/issues/new)
29+
30+
31+
## Configuration
32+
### Logger - Configuration of logger.
33+
##### `logger.level` - Support `debug`, `info`, `warning` or `error`.
34+
35+
### DB - Configuration of storage.
36+
##### `db.implementation` - Select your favorite db, or local storage.
37+
Now support's: `mysql`, `local`.
38+
>Note: Local (in-memory) storage not support single session storagen between grid-instances.
39+
##### `db.connection` - DSN for your db
40+
* `mysql` - example `db_user:db_pass@(db_host:3306)/db_name?parseTime=true` (parseTime=true - required option)
41+
* `local` - omit this property, because every instance have own in-memory storage
42+
43+
### Statsd - Configuration of metrics.
44+
##### `statsd.host` - Host of statsd server.
45+
##### `statsd.port` - Host of statsd server `int`.
46+
##### `statsd.protocol` - Network protocol.
47+
##### `statsd.prefix` - Prefix of metrics tag.
48+
##### `statsd.enable` - Enable metrics `true/false`.
49+
50+
### Grid - Configuration of app.
51+
##### `grid.client_type` - Type of used nodes.
52+
* `selenium` - [http://www.seleniumhq.org/]()
53+
* `wda` - [agent](https://github.com/qa-dev/WebDriverAgent) for [WDA](https://github.com/qa-dev/WebDriverAgent)
54+
##### `grid.port` - grit will run on this port.
55+
##### `grid.busy_node_duration` - max session lifetime, when timeout was elapsed grid will kill the session.
56+
##### `grid.reserved_node_duration` - max timeout between send request `POST /session` and opening the browser window, if. (Deprecated will renamed)
57+
##### `grid.strategy_list` - list of strategies, if grid not able create session on first strategy it go to next, until list ends. [Read more about strategies.](#strategy-list)
58+
59+
### Strategy list
60+
##### `type` - [type of strategy.](#types-of-strategies)
61+
##### `limit` - max count active nodes of this strategy. Unlimited if equals `0`. Dependent of strategy [type](#types-of-strategies)
62+
##### `params` - object describes available nodes `ex. docker config, kubernetes config, etc.`. Dependent of strategy [type](#types-of-strategies)
63+
##### `node_list` - list of objects describes available nodes.
64+
##### `node_list.[].params` - list of objects describes available nodes `ex. image_name, etc.`. Dependent of strategy [type](#types-of-strategies)
65+
##### `node_list.[].capabilities_list` - array of available capabilities objects. `ex. [{"foo: "bar"}, {"foo: "baz", "ololo": "trololo"}]`
66+
67+
### Types of strategies
68+
##### `persistent` - working with registered nodes, same as original selenium grid.
69+
* `limit` - omit this property, its always equals `0`.
70+
* `node_list` - omit this property.
71+
##### `kubernetes` - on-demand nodes in kubernetes cluster.
72+
* `params` - omit this property.
73+
* `node_list.[].params.image` - docker image with selenium.
74+
* `node_list.[].params.port` - port of selenium.
75+

config-local-sample.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"logger": {
3+
"level": "debug"
4+
},
5+
"db": {
6+
"implementation": "local"
7+
},
8+
"grid": {
9+
"client_type": "selenium",
10+
"port": 4444,
11+
"strategy_list": [
12+
{
13+
"type": "persistent"
14+
}
15+
],
16+
"busy_node_duration": "15m",
17+
"reserved_node_duration": "5m"
18+
}
19+
}

config-sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"logger": {
3-
"level": 6
3+
"level": "debug"
44
},
55
"db": {
66
"implementation": "mysql",

config-test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"logger": {
3-
"level": 3
3+
"level": "warning"
44
},
55
"db": {
66
"implementation": "mysql",

config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package config
33
import (
44
"encoding/json"
55
"errors"
6-
"github.com/Sirupsen/logrus"
76
log "github.com/Sirupsen/logrus"
87
"os"
98
)
@@ -20,6 +19,7 @@ type Grid struct {
2019
Port int `json:"port"`
2120
StrategyList []Strategy `json:"strategy_list"`
2221
BusyNodeDuration string `json:"busy_node_duration"` // duration string format ex. 12m, see time.ParseDuration()
22+
// todo: выпилить и сделать равным дедлайну http запроса
2323
ReservedDuration string `json:"reserved_node_duration"` // duration string format ex. 12m, see time.ParseDuration()
2424
}
2525

@@ -36,7 +36,7 @@ type Node struct {
3636
}
3737

3838
type Logger struct {
39-
Level logrus.Level `json:"level"`
39+
Level string `json:"level"`
4040
}
4141

4242
type DB struct {

goreleaser.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ build:
44
- darwin
55
- linux
66
hooks:
7-
pre: make prepare
7+
pre: make prepare
8+
archive:
9+
files:
10+
- config-local-sample.json
11+
- README.md

logger/logger.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ import (
44
"github.com/Sirupsen/logrus"
55

66
"github.com/qa-dev/jsonwire-grid/config"
7+
"fmt"
78
)
89

9-
func Init(logger config.Logger) {
10-
logrus.SetLevel(logger.Level)
10+
func Init(logger config.Logger) error {
11+
level, err := logrus.ParseLevel(logger.Level)
12+
if err != nil {
13+
return fmt.Errorf("Parse log level, %v", err)
14+
}
15+
logrus.Infof("Set log level to: %v", level)
16+
logrus.SetLevel(level)
17+
return nil
1118
}

main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ func main() {
2727
if err != nil {
2828
log.Fatalf("Problem in loading config from file, %s", err)
2929
}
30-
logger.Init(cfg.Logger)
30+
err = logger.Init(cfg.Logger)
31+
if err != nil {
32+
log.Fatalf("Problem in init logger, %s", err)
33+
}
3134

3235
statsdClient, err := metrics.NewStatsd(
3336
cfg.Statsd.Host,

pool/pool.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
)
1111

1212
const (
13+
// todo: сейчас не используются, совсем удалить или сделать дефолтные параметры для конфига.
1314
defaultBusyNodeDuration = time.Minute * 30
1415
defaultReservedNodeDuration = time.Minute * 5
1516
)

storage/mysql/factory.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ func (f *Factory) Create(config config.Config) (pool.StorageInterface, error) {
2121
return nil, err
2222
}
2323

24+
err = db.Ping()
25+
if err != nil {
26+
err = errors.New("Database connection not establish: " + err.Error())
27+
return nil, err
28+
}
29+
2430
db.SetMaxIdleConns(0) // this is the root problem! set it to 0 to remove all idle connections
2531
db.SetMaxOpenConns(10) // or whatever is appropriate for your setup.
2632

0 commit comments

Comments
 (0)