Skip to content

Commit d3042a3

Browse files
committed
Initial
0 parents  commit d3042a3

32 files changed

+1476
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.gradle
2+
build
3+
.idea
4+
out
5+
*.iml
6+
*.ipr
7+
*.iws
8+
classes/

AUTHORS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The following authors have created the source code of "Selenoud"
2+
published and distributed by YANDEX LLC as the owner:
3+
4+
* Ilya Sadykov <smecsia@yandex-team.ru>
5+
* Alexander Andryashin <aandryashin@yandex-team.ru>
6+
* Roman Orlov <fote@yandex-team.ru>
7+
* Ivan Krutov <vania-pooh@yandex-team.ru>
8+
* Mikhail Levin <levsha@yandex-team.ru>

LICENSE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(C) YANDEX LLC, 2016
2+
3+
The Source Code called "Selenoud" available at https://github.com/seleniumkit/selenoud is subject
4+
to the terms of the Apache License 2.0 (hereinafter referred to as the "License").
5+
The text of the License is the following:
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.

README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Selenoud
2+
Microservice acting like Selenium Hub, but launching Selenium nodes within Docker containers per session request.
3+
4+
5+
## Quick Start Guide
6+
1. Install [Docker](https://www.docker.com/).
7+
2. Create ```/etc/selenoud/images.json``` file. This file maps browser versions to Docker containers. The file must have the following structure:
8+
```json
9+
{
10+
"images": {
11+
"chrome": { "image": "selenium/node-chrome:latest", "path": "/wd/hub/"},
12+
"chrome:50.0.2661.86": { "image": "selenium/node-chrome:latest" },
13+
"chrome:50.0": {"image": "selenium/node-chrome:latest" },
14+
"chrome:50": { "image": "selenium/node-chrome:latest" },
15+
"firefox": { "image": "selenium/node-firefox:latest" },
16+
"firefox:45.0.2": { "image": "selenium/node-firefox:latest" },
17+
"firefox:45": { "image": "selenium/node-firefox:latest" }
18+
},
19+
"environment": [
20+
"HUB_PORT_4444_TCP_ADDR=$hubHost",
21+
"HUB_PORT_4444_TCP_PORT=$hubPort",
22+
"REMOTE_HOST=$name",
23+
"SE_OPTS=-port $port -Djava.security.egd=file:/dev/random",
24+
"DISPLAY=:$port"
25+
]
26+
}
27+
```
28+
In this file:
29+
* `images` section specifies the list of used Docker images (every image will be pulled from repo upon start). An optional ```path``` parameter allows you to specify base URL used to create Selenium sessions (e.g. ```/wd/hub/``` for standard Selenium server).
30+
* `environment` section represents the array of environment variables, that will be passed to the launching docker container.
31+
You can use the following variables here: `$hubHost`, `$hubPort`, `$name`, `$port`, that represent host of this service,
32+
port of this service, name of a launching container and port of a launching container.
33+
34+
3. Create ```/etc/selenoud/log4j.properties``` file. This is the logging configuration:
35+
```
36+
# suppress inspection "UnusedProperty" for whole file
37+
log4j.rootLogger=INFO, logger, selenoud
38+
39+
# Enable lines below for debug purposes
40+
#log4j.logger.ru.qatools.selenoud=TRACE
41+
#log4j.selenoud.ru.qatools.selenoud=TRACE
42+
43+
# CONSOLE appender not used by default
44+
log4j.appender.logger=org.apache.log4j.ConsoleAppender
45+
log4j.appender.logger.layout=org.apache.log4j.PatternLayout
46+
log4j.appender.logger.layout.ConversionPattern=%d [%-10.10t] %-5p %c{1} - %m%n
47+
48+
log4j.appender.selenoud=org.apache.log4j.DailyRollingFileAppender
49+
log4j.appender.selenoud.MaxFileSize=2GB
50+
log4j.appender.selenoud.File=/var/log/selenoud/selenoud.log
51+
log4j.appender.selenoud.bufferSize=5242880
52+
log4j.appender.selenoud.MaxBackupIndex=7
53+
log4j.appender.selenoud.layout=org.apache.log4j.PatternLayout
54+
log4j.appender.selenoud.layout.ConversionPattern=%d [%-30.30t] %-5p %-30.30c{1} - %m%n
55+
```
56+
57+
4. Start Selenoud container:
58+
```
59+
$ docker run \
60+
-v /etc/selenoud/:/etc/selenoud:ro \
61+
-v /var/log/selenoud/:/var/log/selenoud \
62+
-v /var/run/docker.sock:/var/run/docker.sock \
63+
--name selenoud \
64+
--privileged \
65+
--restart=always \
66+
--net host \
67+
--log-opt max-size=1g \
68+
--log-opt max-file=2 \
69+
-e JAVA_OPTS="-Dlog4j.configuration=file:/etc/selenoud/log4j.properties
70+
-DimagesFile=/etc/selenoud/images.json
71+
-Dlogs.dir=/var/log/selenoud/logs" \
72+
-d seleniumkit/selenoud:latest
73+
```
74+
75+
5. Run your tests using the following Selenium URL:
76+
```
77+
http://localhost:4444/wd/hub
78+
```
79+
6. See log files for each session in ```/var/log/selenoud/logs```.
80+
81+
## Configuration
82+
83+
Selenoud supports the following System properties:
84+
```properties
85+
host=localhost # host to listen on (for node to connect to)
86+
port=4444 # port to listen on
87+
limit.threads=200 # how many threads will be used
88+
limit.bodyLength=10485760 # maximum request body size (bytes)
89+
limit.count=0 # max containers (0 - unlimited)
90+
limit.startupSec=60 # max node startup (sec)
91+
limit.inactivitySec=120 # max node inactivity (sec)
92+
limit.readTimeoutSec=60 # timeout to read from node (sec)
93+
limit.connectTimeoutSec=10 # timeout to connect to node (sec)
94+
limit.watcherIntervalMs=5000 # interval(ms) of freezed containers watcher
95+
cloud.host=172.17.0.1 # host to connect
96+
container.port=4455 # port to use inside container (when network is bridge)
97+
docker.network=bridge # docker network driver (default: bridge)
98+
docker.endpoint=unix:///var/run/docker.sock # default docker endpoint
99+
docker.pull.enabled=false # should we pull image per request?
100+
log4j.configuration=file:/etc/selenoud/log4j.properties # config for log4j
101+
imagesFile=/etc/selenoud/images.json # images config file
102+
logsCollector=ru.qatools.selenoud.docker.ToFileDockerLogCollector # containers logs collector
103+
logs.dir=/tmp/selenoud/logs # where to put all the containers logs
104+
```
105+
106+
## Development
107+
### Building code
108+
109+
```
110+
$ ./gradlew clean build
111+
```
112+
113+
Then you can find the distribution under `build/distributions` directory.
114+
115+
### Running
116+
To start the basic app type:
117+
```
118+
$ ./gradlew run
119+
```
120+
To run Selenoud in production mode:
121+
122+
```$ JAVA_OPTS="-Dport=4444 -Dthreads=1000" ./bin/selenoud```
123+
124+
### Building Docker image
125+
126+
```
127+
$ ./gradlew clean build docker
128+
```

build.gradle

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
group GROUP
2+
version VERSION_NAME
3+
4+
apply plugin: 'groovy'
5+
apply plugin: 'java'
6+
apply plugin: 'idea'
7+
apply plugin: 'io.ratpack.ratpack-groovy'
8+
apply plugin: 'com.github.johnrengelman.shadow'
9+
apply plugin: 'docker'
10+
11+
12+
sourceCompatibility = 1.8
13+
14+
repositories {
15+
mavenLocal()
16+
mavenCentral()
17+
}
18+
19+
buildscript {
20+
repositories {
21+
jcenter()
22+
mavenLocal()
23+
mavenCentral()
24+
}
25+
dependencies {
26+
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
27+
classpath 'io.ratpack:ratpack-gradle:1.4.1'
28+
classpath 'se.transmode.gradle:gradle-docker:1.2'
29+
}
30+
}
31+
32+
33+
dependencies {
34+
compile 'org.codehaus.groovy:groovy-all:2.4.6'
35+
compile 'org.slf4j:slf4j-api:1.7.15'
36+
compile 'org.slf4j:slf4j-log4j12:1.7.15'
37+
compile 'com.google.code.gson:gson:2.7'
38+
compile 'com.spotify:docker-client:3.5.12'
39+
compile 'org.apache.commons:commons-io:1.3.2'
40+
testCompile 'junit:junit:4.12'
41+
}
42+
43+
docker {
44+
baseImage 'java:openjdk-8-jre'
45+
maintainer 'Ilya Sadykov "smecsia@gmail.com"'
46+
}
47+
48+
49+
//tasks.withType(JavaExec) {
50+
// systemProperties System.properties
51+
//}
52+
53+
task docker(type: Docker) {
54+
applicationName = 'selenoud'
55+
defaultCommand = ["/opt/selenoud/bin/selenoud"]
56+
tag = 'seleniumkit/selenoud'
57+
exposePort 4444
58+
volume '/var/log/selenoud'
59+
addFile "build/distributions/selenoud-${VERSION_NAME}.zip", '/opt/selenoud.zip'
60+
workingDir '/opt'
61+
runCommand 'mkdir -p /opt'
62+
runCommand 'cd /opt'
63+
runCommand 'unzip /opt/selenoud.zip'
64+
runCommand 'rm /opt/selenoud.zip'
65+
runCommand "mv /opt/selenoud-${VERSION_NAME} /opt/selenoud"
66+
}
67+
68+
apply from: rootDir.path + '/release.gradle'

gradle.properties

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
VERSION_NAME=1.0
2+
VERSION_CODE=1
3+
GROUP=ru.qatools.seleniumkit
4+
5+
POM_NAME=Selenoud
6+
POM_ARTIFACT_ID=selenoud
7+
POM_PACKAGING=jar
8+
9+
RELEASE_REPOSITORY_URL=
10+
SNAPSHOT_REPOSITORY_URL=

gradle/wrapper/gradle-wrapper.jar

52.4 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Mon May 30 15:28:37 MSK 2016
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip

0 commit comments

Comments
 (0)