Skip to content

Commit ac85afb

Browse files
authored
Merge pull request #10 from vania-pooh/master
VNC and platform support
2 parents 2c94d6d + d2783e1 commit ac85afb

13 files changed

+191
-160
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*.iml
33
sctl
44
vendor
5+
coverage.*

.travis.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@ sudo: required
22
language: go
33

44
go:
5-
- 1.9.x
5+
- 1.11.x
66

77
services:
88
- docker
99

1010
script:
11+
- export GO111MODULE="on"
1112
- go test -race -v github.com/seleniumkit/sctl/cmd -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/seleniumkit/sctl/cmd
1213
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/seleniumkit/sctl/cmd.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X github.com/seleniumkit/sctl/cmd.gitRevision=`git describe --tags || git rev-parse HEAD`"
1314
- gox -os "linux darwin" -arch "amd64" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X main.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X main.gitRevision=`git describe --tags || git rev-parse HEAD`"
1415

15-
before_install:
16-
- go get -u github.com/golang/dep/cmd/dep
17-
1816
install:
1917
- go get -u github.com/mitchellh/gox # cross compile
20-
- dep ensure
2118

2219
deploy:
2320
- provider: releases

Gopkg.lock

-31
This file was deleted.

Gopkg.toml

-29
This file was deleted.

README.md

+31-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
This repository contains source code for simple Selenium quota management binary.
33

44
## Building
5-
We use [dep](https://github.com/golang/dep) for dependencies management so ensure it's installed before proceeding with next steps. To build the code:
5+
To build the code:
66

7-
1. Checkout this source tree: ```$ git clone https://github.com/seleniumkit/sctl.git```
8-
2. Download dependencies: ```$ dep ensure```
7+
1. Ensure you have [Golang](http://golang.org/) 1.11 and above.
8+
2. Checkout this source tree: ```$ git clone https://github.com/seleniumkit/sctl.git```
99
3. Build as usually: ```$ go build```
1010

1111
## Running
@@ -65,15 +65,16 @@ In **quota** section we define quota names, browser names, their versions and us
6565
"test-quota": {
6666
"firefox" : {
6767
"defaultVersion": "33.0",
68+
"defaultPlatform": "LINUX",
6869
"versions": {
6970
"33.0": "cloud",
70-
"42.0": "cloud"
71+
"42.0@LINUX": "cloud"
7172
}
7273
}
7374
}
7475
}
7576
```
76-
Here **test-quota** is free-form name of the quota, **firefox** is the browser name. Finally **versions** section contains a mapping of browser version to host group name, e.g. **firefox 33.0** will correspond to all hosts defined in **cloud** hosts group.
77+
To specify a platform use `@`-notation, e.g. `42.0@LINUX`. Here **test-quota** is free-form name of the quota, **firefox** is the browser name. Finally **versions** section contains a mapping of browser version to host group name, e.g. **firefox 33.0** will correspond to all hosts defined in **cloud** hosts group.
7778
In **aliases** section we define aliases for quota blocks from **quota** section. For each defined alias quota contents will be copied to a separate file with new name.
7879

7980
Cloud provider attributes `username` and `password` can be included in the input file:
@@ -91,3 +92,28 @@ Cloud provider attributes `username` and `password` can be included in the input
9192
}
9293
}
9394
```
95+
96+
To specify VNC proxying settings - use `vnc` attribute as follows:
97+
```
98+
"vnc-hosts": {
99+
"some-dc" : {
100+
"selenoid-host.example.com": {
101+
"port": 4444,
102+
"count": 1,
103+
"vnc": "selenoid"
104+
}
105+
}
106+
}
107+
```
108+
When `vnc` equals to `selenoid` then VNC will be set to `ws://host:port/vnc`, otherwise it will be set to specified value with `$hostName` placeholder is replaced by respective host name:
109+
```
110+
"vnc-hosts": {
111+
"some-dc" : {
112+
"some-host-[1:5].example.com": {
113+
"port": 4444,
114+
"count": 5,
115+
"vnc": "vnc://$hostName:5900"
116+
}
117+
}
118+
}
119+
```

cmd/data.go

+15-51
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,31 @@
11
package cmd
22

3-
import "encoding/xml"
4-
5-
// Input data
6-
7-
type JsonHost struct {
3+
type Host struct {
84
Port int `json:"port"`
95
Count int `json:"count"`
106
Username string `json:"username"`
117
Password string `json:"password"`
8+
VNC string `json:"vnc"`
129
}
1310

14-
type JsonRegion map[string]JsonHost
15-
16-
type JsonRegions map[string]JsonRegion
17-
18-
type JsonHosts map[string]JsonRegions
19-
20-
type JsonVersions map[string]string
21-
22-
type JsonBrowser struct {
23-
DefaultVersion string `json:"defaultVersion"`
24-
Versions JsonVersions `json:"versions"`
25-
}
26-
27-
type JsonQuota map[string]JsonBrowser
11+
type Region map[string]Host
2812

29-
type JsonInput struct {
30-
Hosts JsonHosts `json:"hosts"`
31-
Quota map[string]JsonQuota `json:"quota"`
32-
Aliases map[string][]string `json:"aliases"`
33-
}
13+
type Regions map[string]Region
3414

35-
// Output data
15+
type Hosts map[string]Regions
3616

37-
type XmlBrowsers struct {
38-
XMLName xml.Name `xml:"qa:browsers"`
39-
XmlNS string `xml:"xmlns:qa,attr"`
40-
Browsers []XmlBrowser `xml:"browser"`
41-
}
17+
type Versions map[string]string
4218

43-
type XmlBrowser struct {
44-
Name string `xml:"name,attr"`
45-
DefaultVersion string `xml:"defaultVersion,attr"`
46-
Versions []XmlVersion `xml:"version"`
19+
type Browser struct {
20+
DefaultVersion string `json:"defaultVersion"`
21+
DefaultPlatform string `json:"defaultPlatform"`
22+
Versions Versions `json:"versions"`
4723
}
4824

49-
type XmlVersion struct {
50-
Number string `xml:"number,attr"`
51-
Regions []XmlRegion `xml:"region"`
52-
}
53-
54-
type XmlHosts []XmlHost
55-
56-
type XmlRegion struct {
57-
Name string `xml:"name,attr"`
58-
Hosts XmlHosts `xml:"host"`
59-
}
25+
type Quota map[string]Browser
6026

61-
type XmlHost struct {
62-
Name string `xml:"name,attr"`
63-
Port int `xml:"port,attr"`
64-
Count int `xml:"count,attr"`
65-
Username string `xml:"username,attr,omitempty"`
66-
Password string `xml:"password,attr,omitempty"`
27+
type Input struct {
28+
Hosts Hosts `json:"hosts"`
29+
Quota map[string]Quota `json:"quota"`
30+
Aliases map[string][]string `json:"aliases"`
6731
}

0 commit comments

Comments
 (0)