From eba2b7ed78bd89c0321353378a7743b42d24c926 Mon Sep 17 00:00:00 2001 From: kev Date: Sun, 3 Nov 2019 16:19:43 +0800 Subject: [PATCH] add jsonwire-grid --- jsonwire-grid/Dockerfile | 26 ++++++++++++++++++++ jsonwire-grid/Dockerfile.latest | 31 ++++++++++++++++++++++++ jsonwire-grid/README.md | 41 ++++++++++++++++++++++++++++++++ jsonwire-grid/data/config.json | 19 +++++++++++++++ jsonwire-grid/docker-compose.yml | 23 ++++++++++++++++++ jsonwire-grid/docker-stack.yml | 33 +++++++++++++++++++++++++ 6 files changed, 173 insertions(+) create mode 100644 jsonwire-grid/Dockerfile create mode 100644 jsonwire-grid/Dockerfile.latest create mode 100644 jsonwire-grid/README.md create mode 100644 jsonwire-grid/data/config.json create mode 100644 jsonwire-grid/docker-compose.yml create mode 100644 jsonwire-grid/docker-stack.yml diff --git a/jsonwire-grid/Dockerfile b/jsonwire-grid/Dockerfile new file mode 100644 index 0000000..265cdfc --- /dev/null +++ b/jsonwire-grid/Dockerfile @@ -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"] diff --git a/jsonwire-grid/Dockerfile.latest b/jsonwire-grid/Dockerfile.latest new file mode 100644 index 0000000..26162c4 --- /dev/null +++ b/jsonwire-grid/Dockerfile.latest @@ -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"] diff --git a/jsonwire-grid/README.md b/jsonwire-grid/README.md new file mode 100644 index 0000000..be5b106 --- /dev/null +++ b/jsonwire-grid/README.md @@ -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 diff --git a/jsonwire-grid/data/config.json b/jsonwire-grid/data/config.json new file mode 100644 index 0000000..1927683 --- /dev/null +++ b/jsonwire-grid/data/config.json @@ -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" + } +} diff --git a/jsonwire-grid/docker-compose.yml b/jsonwire-grid/docker-compose.yml new file mode 100644 index 0000000..ba2cf09 --- /dev/null +++ b/jsonwire-grid/docker-compose.yml @@ -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 diff --git a/jsonwire-grid/docker-stack.yml b/jsonwire-grid/docker-stack.yml new file mode 100644 index 0000000..d9a9ef2 --- /dev/null +++ b/jsonwire-grid/docker-stack.yml @@ -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