Skip to content

Commit 3433bdc

Browse files
author
Mikhail Podtserkovskiy
committed
fix linters warnings
1 parent 7c200e5 commit 3433bdc

File tree

19 files changed

+72
-30
lines changed

19 files changed

+72
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ~~jsonwire-grid~~WebDriverGrid [![Build Status](https://travis-ci.org/qa-dev/jsonwire-grid.svg?branch=master)](https://travis-ci.org/qa-dev/jsonwire-grid)
1+
# ~~jsonwire-grid~~WebDriverGrid [![Build Status](https://travis-ci.org/qa-dev/jsonwire-grid.svg?branch=master)](https://travis-ci.org/qa-dev/jsonwire-grid) [![Go Report Card](https://goreportcard.com/badge/github.com/qa-dev/jsonwire-grid)](https://goreportcard.com/report/github.com/qa-dev/jsonwire-grid)
22
This is high-performance scalable implementation of Selenium Grid (hub),
33
###### What is Selenium-Grid?
44
>Selenium-Grid allows you run your tests on different machines against different browsers in parallel. That is, running multiple tests at the same time against different machines running different browsers and operating systems. Essentially, Selenium-Grid support distributed test execution. It allows for running your tests in a distributed test execution environment.

config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import (
77
"os"
88
)
99

10+
// Config - settings of application.
1011
type Config struct {
1112
Logger Logger `json:"logger"`
1213
DB DB `json:"db"`
1314
Grid Grid `json:"grid"`
1415
Statsd Statsd `json:"statsd"`
1516
}
1617

18+
// Grid general settings
1719
type Grid struct {
1820
ClientType string `json:"client_type"`
1921
Port int `json:"port"`
@@ -23,27 +25,32 @@ type Grid struct {
2325
ReservedDuration string `json:"reserved_node_duration"` // duration string format ex. 12m, see time.ParseDuration()
2426
}
2527

28+
// Strategy - Describes the algorithm of node selection.
2629
type Strategy struct {
2730
Params json.RawMessage `json:"params"` // ex. docker config, kubernetes config, etc.
2831
Type string `json:"type"`
2932
Limit int `json:"limit"`
3033
NodeList []Node `json:"node_list"`
3134
}
3235

36+
// Node - Describes node properties and capabilities. Applicable only for on-demand strategies.
3337
type Node struct {
3438
Params json.RawMessage `json:"params"` // ex. image_name, etc.
3539
CapabilitiesList []map[string]interface{} `json:"capabilities_list"`
3640
}
3741

42+
// Logger - Configuration of logger.
3843
type Logger struct {
3944
Level string `json:"level"`
4045
}
4146

47+
// DB - Configuration of storage.
4248
type DB struct {
4349
Implementation string `json:"implementation"`
4450
Connection string `json:"connection"`
4551
}
4652

53+
// Statsd - Settings of metrics sender.
4754
type Statsd struct {
4855
Host string `json:"host"`
4956
Port int `json:"port"`
@@ -52,10 +59,12 @@ type Statsd struct {
5259
Enable bool `json:"enable"`
5360
}
5461

62+
// New - Constructor of config.
5563
func New() *Config {
5664
return &Config{}
5765
}
5866

67+
// LoadFromFile - config loader from json file.
5968
func (c *Config) LoadFromFile(path string) error {
6069
log.Printf(path)
6170
if path == "" {

handlers/apiProxy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/qa-dev/jsonwire-grid/pool"
99
)
1010

11+
// APIProxy - responds with information about whether the node is registered.
1112
type APIProxy struct {
1213
Pool *pool.Pool
1314
}

handlers/createSession.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"net/url"
1717
)
1818

19+
// CreateSession - Receives requests to create session.
1920
type CreateSession struct {
2021
Pool *pool.Pool
2122
ClientFactory jsonwire.ClientFactoryInterface

handlers/registerNode.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/qa-dev/jsonwire-grid/pool/capabilities"
1313
)
1414

15+
// RegisterNode - Receives requests to register nodes for persistent strategy.
1516
type RegisterNode struct {
1617
Pool *pool.Pool
1718
}

handlers/useSession.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/qa-dev/jsonwire-grid/pool"
1111
)
1212

13+
// UseSession - Receives requests to use session.
1314
type UseSession struct {
1415
Pool *pool.Pool
1516
Cache *pool.Cache

jsonwire/interfaces.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package jsonwire
22

3+
// ClientFactoryInterface - is an abstract http-client factory for node implementations.
34
type ClientFactoryInterface interface {
45
Create(address string) ClientInterface
56
}
67

8+
// ClientInterface - is an abstract http-client for node implementations.
79
type ClientInterface interface {
810
Health() (*Message, error)
911
Sessions() (*Sessions, error)
1012
CloseSession(sessionID string) (*Message, error)
1113
Address() string
1214
}
13-
14-
type NodeInterface interface {
15-
RemoveAllSessions() (int, error)
16-
}

jsonwire/jsonwire.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ import (
44
"encoding/json"
55
)
66

7+
// Message - common protocol message structure.
78
type Message struct {
89
SessionID string `json:"sessionId"`
910
Status int `json:"status"`
1011
Value interface{} `json:"value"`
1112
}
1213

14+
// NewSession - message structure for the creation of a new session
1315
type NewSession struct {
1416
Message
1517
Value struct {
1618
SessionID string `json:"sessionId"`
1719
} `json:"value"`
1820
}
1921

22+
// Sessions - message structure for sessions list.
2023
type Sessions struct {
2124
Message
2225
Value []struct {
@@ -25,31 +28,35 @@ type Sessions struct {
2528
} `json:"value"`
2629
}
2730

31+
// Register - message structure for registration new node.
2832
type Register struct {
2933
Class string `json:"class,omitempty"`
3034
Configuration *Configuration `json:"configuration,omitempty"`
3135
CapabilitiesList []Capabilities `json:"capabilities,omitempty"` // selenium 3
3236
}
3337

38+
// Capabilities - structure of supported capabilities.
3439
type Capabilities map[string]interface{}
3540

41+
// Configuration - structure of node configuration.
3642
type Configuration struct {
37-
Id string `json:"id,omitempty"`
38-
Proxy string `json:"proxy,omitempty"`
39-
Role string `json:"role,omitempty"`
40-
Hub string `json:"hub,omitempty"`
41-
Port int `json:"port,omitempty"`
42-
RemoteHost string `json:"remoteHost,omitempty"`
43-
Host string `json:"host,omitempty"`
44-
MaxSession int `json:"maxSession,omitempty"`
45-
HubHost string `json:"hubHost,omitempty"`
43+
ID string `json:"id,omitempty"`
44+
Proxy string `json:"proxy,omitempty"`
45+
Role string `json:"role,omitempty"`
46+
Hub string `json:"hub,omitempty"`
47+
Port int `json:"port,omitempty"`
48+
RemoteHost string `json:"remoteHost,omitempty"`
49+
Host string `json:"host,omitempty"`
50+
MaxSession int `json:"maxSession,omitempty"`
51+
HubHost string `json:"hubHost,omitempty"`
4652
RegisterCycle int `json:"registerCycle,omitempty"`
4753
HubPort int `json:"hubPort,omitempty"`
4854
URL string `json:"url,omitempty"`
4955
Register bool `json:"register,omitempty"`
5056
CapabilitiesList []Capabilities `json:"capabilities,omitempty"` // selenium 2
5157
}
5258

59+
// APIProxy - message structure for node check.
5360
type APIProxy struct {
5461
ID string `json:"id"`
5562
Request interface{} `json:"request"` //todo: пока не ясно зачем он нужен

jsonwire/mocks.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,41 @@ import (
44
"github.com/stretchr/testify/mock"
55
)
66

7+
// ClientFactoryMock - mock of factory of client.
78
type ClientFactoryMock struct {
89
mock.Mock
910
}
1011

12+
// Create - mock of create session.
1113
func (cf *ClientFactoryMock) Create(address string) ClientInterface {
1214
args := cf.Called(address)
1315
return args.Get(0).(ClientInterface)
1416
}
1517

18+
// ClientMock - mock of client.
1619
type ClientMock struct {
1720
mock.Mock
1821
}
1922

23+
// Health - mock of healthcheck.
2024
func (c *ClientMock) Health() (*Message, error) {
2125
args := c.Called()
2226
return args.Get(0).(*Message), args.Error(1)
2327
}
2428

29+
// Sessions - mock of sessions list.
2530
func (c *ClientMock) Sessions() (*Sessions, error) {
2631
args := c.Called()
2732
return args.Get(0).(*Sessions), args.Error(1)
2833
}
2934

35+
// CloseSession - mock of close session.
3036
func (c *ClientMock) CloseSession(sessionID string) (*Message, error) {
3137
args := c.Called(sessionID)
3238
return args.Get(0).(*Message), args.Error(1)
3339
}
3440

41+
// Address - mock of get node address.
3542
func (c *ClientMock) Address() string {
3643
args := c.Called()
3744
return args.String(0)

logger/logger.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/qa-dev/jsonwire-grid/config"
88
)
99

10+
// Init - initialisation of logger.
1011
func Init(logger config.Logger) error {
1112
level, err := logrus.ParseLevel(logger.Level)
1213
if err != nil {

0 commit comments

Comments
 (0)