Skip to content

Commit

Permalink
Merge pull request #10 from vania-pooh/master
Browse files Browse the repository at this point in the history
VNC and platform support
  • Loading branch information
vania-pooh authored Dec 3, 2018
2 parents 2c94d6d + d2783e1 commit ac85afb
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 160 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.iml
sctl
vendor
coverage.*
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ sudo: required
language: go

go:
- 1.9.x
- 1.11.x

services:
- docker

script:
- export GO111MODULE="on"
- go test -race -v github.com/seleniumkit/sctl/cmd -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/seleniumkit/sctl/cmd
- 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`"
- 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`"

before_install:
- go get -u github.com/golang/dep/cmd/dep

install:
- go get -u github.com/mitchellh/gox # cross compile
- dep ensure

deploy:
- provider: releases
Expand Down
31 changes: 0 additions & 31 deletions Gopkg.lock

This file was deleted.

29 changes: 0 additions & 29 deletions Gopkg.toml

This file was deleted.

36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
This repository contains source code for simple Selenium quota management binary.

## Building
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:
To build the code:

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

## Running
Expand Down Expand Up @@ -65,15 +65,16 @@ In **quota** section we define quota names, browser names, their versions and us
"test-quota": {
"firefox" : {
"defaultVersion": "33.0",
"defaultPlatform": "LINUX",
"versions": {
"33.0": "cloud",
"42.0": "cloud"
"42.0@LINUX": "cloud"
}
}
}
}
```
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.
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.
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.

Cloud provider attributes `username` and `password` can be included in the input file:
Expand All @@ -91,3 +92,28 @@ Cloud provider attributes `username` and `password` can be included in the input
}
}
```

To specify VNC proxying settings - use `vnc` attribute as follows:
```
"vnc-hosts": {
"some-dc" : {
"selenoid-host.example.com": {
"port": 4444,
"count": 1,
"vnc": "selenoid"
}
}
}
```
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:
```
"vnc-hosts": {
"some-dc" : {
"some-host-[1:5].example.com": {
"port": 4444,
"count": 5,
"vnc": "vnc://$hostName:5900"
}
}
}
```
66 changes: 15 additions & 51 deletions cmd/data.go
Original file line number Diff line number Diff line change
@@ -1,67 +1,31 @@
package cmd

import "encoding/xml"

// Input data

type JsonHost struct {
type Host struct {
Port int `json:"port"`
Count int `json:"count"`
Username string `json:"username"`
Password string `json:"password"`
VNC string `json:"vnc"`
}

type JsonRegion map[string]JsonHost

type JsonRegions map[string]JsonRegion

type JsonHosts map[string]JsonRegions

type JsonVersions map[string]string

type JsonBrowser struct {
DefaultVersion string `json:"defaultVersion"`
Versions JsonVersions `json:"versions"`
}

type JsonQuota map[string]JsonBrowser
type Region map[string]Host

type JsonInput struct {
Hosts JsonHosts `json:"hosts"`
Quota map[string]JsonQuota `json:"quota"`
Aliases map[string][]string `json:"aliases"`
}
type Regions map[string]Region

// Output data
type Hosts map[string]Regions

type XmlBrowsers struct {
XMLName xml.Name `xml:"qa:browsers"`
XmlNS string `xml:"xmlns:qa,attr"`
Browsers []XmlBrowser `xml:"browser"`
}
type Versions map[string]string

type XmlBrowser struct {
Name string `xml:"name,attr"`
DefaultVersion string `xml:"defaultVersion,attr"`
Versions []XmlVersion `xml:"version"`
type Browser struct {
DefaultVersion string `json:"defaultVersion"`
DefaultPlatform string `json:"defaultPlatform"`
Versions Versions `json:"versions"`
}

type XmlVersion struct {
Number string `xml:"number,attr"`
Regions []XmlRegion `xml:"region"`
}

type XmlHosts []XmlHost

type XmlRegion struct {
Name string `xml:"name,attr"`
Hosts XmlHosts `xml:"host"`
}
type Quota map[string]Browser

type XmlHost struct {
Name string `xml:"name,attr"`
Port int `xml:"port,attr"`
Count int `xml:"count,attr"`
Username string `xml:"username,attr,omitempty"`
Password string `xml:"password,attr,omitempty"`
type Input struct {
Hosts Hosts `json:"hosts"`
Quota map[string]Quota `json:"quota"`
Aliases map[string][]string `json:"aliases"`
}
Loading

0 comments on commit ac85afb

Please sign in to comment.