Skip to content

Commit

Permalink
Merge pull request #390 from vania-pooh/master
Browse files Browse the repository at this point in the history
Dependencies update
  • Loading branch information
vania-pooh authored Dec 31, 2023
2 parents d2fc6aa + 85f53c6 commit 5fe0f6f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 28 deletions.
13 changes: 8 additions & 5 deletions docs/cli-flags.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
== Ggr CLI Flags

The following flags are supported by ```ggr``` command:
```
[source,bash]
----
-graceful-period duration
graceful shutdown period in time.Duration format, e.g. 300s or 500ms (default 5m0s)
-guests-allowed
Expand All @@ -20,13 +21,15 @@ The following flags are supported by ```ggr``` command:
enable verbose mode
-version
show version and exit
```
----
For example:
```
[source,bash]
----
$ ./ggr -quotaDir /my/custom/quota/dir
```
When using Ggr inside Docker container these flags are passed like the following:
----
When using Ggr inside Docker container these flags are passed like the following:
[source,bash,subs="attributes+"]
----
Expand Down
8 changes: 4 additions & 4 deletions docs/multiple-instances.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ $ curl -s http://example.com:4444/ping
----

.Result
[source,javascript]
[source,json]
----
{"uptime":"2m46.854829503s","lastReloadTime":"2017-05-12 12:33:06.322038542 +0300 MSK","numRequests":42, "numSessions":19, "version": "1.6.3"}
----

It returns `200 OK` when Ggr operates normally. Additionally server uptime, last quota reload time and overall number of session requests from service startup are returned in JSON format.
It returns `200 OK` when Ggr operates normally. Additionally, server uptime, last quota reload time and overall number of session requests from service startup are returned in JSON format.

=== Why Ggr is Stateless
Selenium uses an HTTP-based protocol. That means every action in Selenium, e.g. launching browser or taking screenshot is a separate HTTP request. When multiple instances of Ggr are handling requests behind load balancer every request can be routed to any of these instances. Here's how it works.
Expand All @@ -25,7 +25,7 @@ On the picture above there is one SLB, two instances of Ggr and one Selenium hub

For example let's assume that new session request is routed to `Ggr 1` (black arrows). This Ggr randomly chooses a hub `hub1.example.com` and creates a new session on it. This hub returns some session identifier marked as `ID` on the picture. `Ggr 1` in its turn knows that session was created on `hub1.example.com` and extends the session ID by adding an MD5 sum `S` of hub hostname. This is why it returns to user new longer session with identifier `S+ID` just by concatenating two strings. Every Ggr instance during startup creates an in-memory map - storing host names and their MD5 sums. When consequent request for the same session `S+ID` arrives e.g. to `Ggr 2` (red arrows) it extracts `S` from extended session ID and finds hub hostname in its map. Then it removes `S` from request session identifier and simply proxies this request to hub corresponding to `S`.

IMPORTANT: Because of stateless Ggr architecture you can use an unlimited number of Ggr instances behind load balancer. In order to work properly it is very important to have exactly the same XML quota files on every Ggr instance. Otherwise some Ggr instances will return `404` error when a request with unknown host `S` arrives.
IMPORTANT: Because of stateless Ggr architecture you can use an unlimited number of Ggr instances behind load balancer. In order to work properly it is very important to have exactly the same XML quota files on every Ggr instance. Otherwise, some Ggr instances will return `404` error when a request with unknown host `S` arrives.

=== Getting Host by Session ID
Sometimes you may want to get real hostname behind Ggr that is executing browser session. This can be done using session ID:
Expand All @@ -37,7 +37,7 @@ $ curl -s http://test:test-password@ggr.example.com:4444/host/4355afe3f54e61eb32
----

.Result
[source,javascript]
[source,json]
----
{"Name":"my-host.example.com","Port":4444,"Count":5,"Username":"","Password":""}
----
2 changes: 1 addition & 1 deletion docs/quick-start-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $ cat /etc/grid-router/quota/test.xml
</qa:browsers>
----
+
NOTE: File name should correspond to user name you added to `htpasswd` file.
NOTE: File name should correspond to username you added to `htpasswd` file.
For user `test` we added on previous steps you should create `test.xml`.
. Start Ggr container:
+
Expand Down
8 changes: 4 additions & 4 deletions docs/quota-files.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ NOTE: A frequent question being asked is the meaning of `count` attribute becaus

. Browser name is matched against `browserName` capability. Values are compared as strings and should be exactly equal. When testing mobile applications (e.g. with http://github.com/appium/appium[Appium]) `browserName` capability makes no sense and can be replaced by `deviceName` or `appium:deviceName` capability. Ggr will try to match both against browser name specified in XML.
. Version `number` is matched against `version` or `browserVersion` capability by prefix. For example both `61` and `61.0` in version capability (i.e. in your code) will match version number `61.0`.
. Similarly version `platform` attribute is matched against `platform` or `platformName` capability by prefix. When platform from capabilities equals to `ANY` - default platform will be chosen.
. Similarly, version `platform` attribute is matched against `platform` or `platformName` capability by prefix. When platform from capabilities equals to `ANY` - default platform will be chosen.
. Sometimes you may need to have the same browser name and version on different platforms, e.g. Firefox on both Linux and Windows. To achieve this you need to add `defaultPlatform` and `platform` attributes to quota file as follows:
+
.Adding platform information to quota file
Expand All @@ -63,7 +63,7 @@ Sometimes for debugging purposes you need to see the screen of the browser where
----
ws://ggr-host.example.com:4444/vnc/<session-id>
----
Browser VNC clients like https://github.com/novnc/noVNC[noVNC] work with such URLs out of the box. By default having an XML host entry like this...
Browser VNC clients like https://github.com/novnc/noVNC[noVNC] work with such URLs out of the box. By default, having an XML host entry like this...
[source,xml]
----
<host name="host1.example.com" port="4444" count="1"/>
Expand Down Expand Up @@ -94,7 +94,7 @@ Having this URL Ggr will append session ID and proxy VNC traffic from:

Although Ggr is mainly used for creating your own Selenium cluster you can also configure it to obtain some browsers in external Selenium services such as http://saucelabs.com/[Saucelabs], http://browserstack.com/[BrowserStack] or https://testingbot.com/[TestingBot]. These services always require username and password to be specified. Credentials should be set for each browser version in respective quota file:

.Providing user name and password for external Selenium service
.Providing username and password for external Selenium service
[source,xml]
----
<qa:browsers xmlns:qa="urn:config.gridrouter.qatools.ru">
Expand All @@ -110,7 +110,7 @@ Although Ggr is mainly used for creating your own Selenium cluster you can also

=== Guest Quota

By default every quota file corresponds to a user. In some cases you may need to give anonymous (guest) access to some users. This is very useful to maintain a sandbox where users can debug their tests without disturbing other tests. Guest quota is enabled using Ggr flags:
By default, every quota file corresponds to a user. In some cases you may need to give anonymous (guest) access to some users. This is very useful to maintain a sandbox where users can debug their tests without disturbing other tests. Guest quota is enabled using Ggr flags:

$ ./ggr -guests-allowed -guests-quota test <the-rest-of-the-flags...>

Expand Down
11 changes: 6 additions & 5 deletions docs/quota-reload.adoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
== Quota Reloading
* To **reload quota files** just send **SIGHUP** to process or Docker container:
+
```
# kill -HUP <pid>
# docker kill -s HUP <container-id-or-name>
```
[source,bash]
----
$ kill -HUP <pid>
$ docker kill -s HUP <container-id-or-name>
----
+
NOTE: Use only one of these commands depending on whether you have Docker installed.
NOTE: Use only one of these commands depending on whether you have Docker installed.
12 changes: 6 additions & 6 deletions docs/tls.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
== Encrypting Connection to Ggr

Ggr itself does not support any modern encryption technologies such as https://en.wikipedia.org/wiki/Transport_Layer_Security[TLS] or https://en.wikipedia.org/wiki/WebSocket[WebSocket Secure]. In order to use them you are expected to setup a reverse proxy having such capabilities. A typical http://nginx.org/[Nginx] configuration looks like the following:
Ggr itself does not support any modern encryption technologies such as https://en.wikipedia.org/wiki/Transport_Layer_Security[TLS] or https://en.wikipedia.org/wiki/WebSocket[WebSocket Secure]. In order to use them you are expected to set up a reverse proxy having such capabilities. A typical http://nginx.org/[Nginx] configuration looks like the following:

.Nginx configuration for encrypted connection
.Nginx's configuration for encrypted connection
----
map $http_upgrade $connection_upgrade {
default upgrade;
Expand All @@ -17,20 +17,20 @@ upstream ggr {
server {
server_name selenium.example.com;
listen 4444 ssl;
listen [::]:4444 ssl;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers kEECDH+AESGCM+AES128:kEECDH+AES128:kRSA+AESGCM+AES128:kRSA+AES128:DES-CBC3-SHA:!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv2;
ssl_session_cache shared:SSL:64m;
ssl_session_timeout 28h;
# These two files are private key and certificate from SSL certificate provider
ssl_certificate /etc/ssl/selenium.pem;
ssl_certificate_key /etc/ssl/selenium.key;
access_log /var/log/nginx/selenium_access.log;
error_log /var/log/nginx/selenium_error.log;
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module github.com/aerokube/ggr

go 1.20
go 1.21

require (
github.com/aandryashin/matchers v0.0.0-20161126170413-435295ea180e
github.com/aandryashin/reloader v0.0.0-20161127125235-da4f1b43ce40
github.com/abbot/go-http-auth v0.4.1-0.20220112235402-e1cee1c72f2f
golang.org/x/net v0.17.0
golang.org/x/net v0.19.0
)

require (
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ github.com/abbot/go-http-auth v0.4.1-0.20220112235402-e1cee1c72f2f h1:R2ZVGCZzU9
github.com/abbot/go-http-auth v0.4.1-0.20220112235402-e1cee1c72f2f/go.mod h1:l2P3JyHa+fjy5Bxol6y1u2o4DV/mv3QMBdBu2cNR53w=
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down

0 comments on commit 5fe0f6f

Please sign in to comment.