add jsonwire-grid

This commit is contained in:
kev 2019-11-03 16:19:43 +08:00
parent 8fa3f30613
commit eba2b7ed78
6 changed files with 173 additions and 0 deletions

26
jsonwire-grid/Dockerfile Normal file
View File

@ -0,0 +1,26 @@
#
# Dockerfile for jsonwire-grid
#
FROM alpine:1.9-alpine
MAINTAINER EasyPi Software Foundation
ENV VERSION=0.5.0
ENV REPOSITORY=https://github.com/qa-dev/jsonwire-grid
ENV CONFIG_PATH=config.json
WORKDIR /etc/jsonwire-grid
RUN set -xe \
&& apk add --no-cache curl \
&& curl -sSL ${REPOSITORY}/releases/download/v${VERSION}/jsonwire-grid_${VERSION}_linux_amd64.tar.gz \
| tar xz -C /usr/local/bin jsonwire-grid \
&& curl -sSLO ${REPOSITORY}/raw/master/config-local-sample.json \
&& curl -sSLO ${REPOSITORY}/raw/master/config-sample.json \
&& curl -sSLO ${REPOSITORY}/raw/master/config-test.json \
&& ln -s config-local-sample.json ${CONFIG_PATH} \
&& apk del curl
EXPOSE 4444
ENTRYPOINT ["jsonwire-grid"]

View File

@ -0,0 +1,31 @@
#
# Dockerfile for jsonwire-grid
#
FROM golang:alpine AS build
RUN apk add --no-cache git file
RUN go get github.com/qa-dev/jsonwire-grid
RUN file /go/bin/jsonwire-grid
FROM alpine
MAINTAINER EasyPi Software Foundation
ENV REPOSITORY=https://github.com/qa-dev/jsonwire-grid
ENV CONFIG_PATH=config.json
WORKDIR /etc/jsonwire-grid
RUN set -xe \
&& apk add --no-cache curl \
&& curl -sSLO ${REPOSITORY}/raw/master/config-local-sample.json \
&& curl -sSLO ${REPOSITORY}/raw/master/config-sample.json \
&& curl -sSLO ${REPOSITORY}/raw/master/config-test.json \
&& ln -s config-local-sample.json ${CONFIG_PATH} \
&& apk del curl
COPY --from=build /go/bin/jsonwire-grid /usr/local/bin/
EXPOSE 4444
ENTRYPOINT ["jsonwire-grid"]

41
jsonwire-grid/README.md Normal file
View File

@ -0,0 +1,41 @@
jsonwire-grid
=============
This is high-performance scalable implementation of Selenium Grid (hub).
## up and running
```
# every registed node accepts only one session (`maxInstances` does not work)
$ docker-compose up -d
# there are three common status for every registed node
$ curl http://127.0.0.1:4444/grid/status | jq -r .node_list[].status
available
reserved
busy
```
## quick start
```python
#!/usr/bin/env python
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
capabilities = DesiredCapabilities.FIREFOX # it does not work :-1:
capabilities = {'browserName': 'firefox'} # it works :+1:
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=capabilities
)
driver.get('https://www.google.com/')
driver.save_screenshot('google.png')
driver.quit()
```
https://github.com/qa-dev/jsonwire-grid

View File

@ -0,0 +1,19 @@
{
"logger": {
"level": "debug"
},
"db": {
"implementation": "local"
},
"grid": {
"client_type": "selenium",
"port": 4444,
"strategy_list": [
{
"type": "persistent"
}
],
"busy_node_duration": "15m",
"reserved_node_duration": "5m"
}
}

View File

@ -0,0 +1,23 @@
version: "3.7"
services:
hub:
image: vimagick/jsonwire-grid
ports:
- "4444:4444"
volumes:
- ./data:/etc/jsonwire-grid
restart: unless-stopped
firefox:
image: selenium/node-firefox:3.141.59-xenon
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME -port 5555" /opt/bin/entry_point.sh'
volumes:
- /dev/shm:/dev/shm
environment:
- HUB_HOST=hub
- HUB_PORT=4444
depends_on:
- hub
restart: unless-stopped

View File

@ -0,0 +1,33 @@
version: "3.7"
services:
hub:
image: vimagick/jsonwire-grid
ports:
- "4444:4444"
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
firefox:
image: selenium/node-firefox:3.141.59-xenon
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME -port 5555" /opt/bin/entry_point.sh'
volumes:
- /dev/shm:/dev/shm
environment:
- HUB_HOST=hub
- HUB_PORT=4444
depends_on:
- hub
deploy:
replicas: 10
placement:
constraints:
- node.role == worker
restart_policy:
condition: on-failure