Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Add support for lambdatest
Browse files Browse the repository at this point in the history
  • Loading branch information
kanhaiya authored and diemol committed Jul 19, 2019
1 parent f5f4243 commit fff0573
Show file tree
Hide file tree
Showing 30 changed files with 722 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ jobs:
- docker pull elgalu/selenium
- travis_retry ./run_integration_tests.sh testingBot

- env: step=lambdaTest
if: type = pull_request
script:
- docker pull elgalu/selenium
- travis_retry ./run_integration_tests.sh lambdaTest

- env: step=dockerCompose
if: type = pull_request
script:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
This is a Selenium Grid extension to scale your local grid dynamically with docker containers. It uses
[docker-selenium](https://github.com/elgalu/docker-selenium) to run your tests in Firefox and Chrome locally, if you
need a different browser, your tests can get redirected to a cloud testing provider ([Sauce Labs](https://saucelabs.com/),
[BrowserStack](https://www.browserstack.com/), [TestingBot](https://testingbot.com/), [CrossBrowserTesting](https://crossbrowsertesting.com/)). Zalenium also works out of the box
[BrowserStack](https://www.browserstack.com/), [TestingBot](https://testingbot.com/), [CrossBrowserTesting](https://crossbrowsertesting.com/), [LambdaTest](https://www.lambdatest.com/)). Zalenium also works out of the box
in [Kubernetes](https://zalando.github.io/zalenium/#kubernetes).

Zalenium's maintainers add new features regularly. We invite you to test it, report bugs, suggest any ideas you may
Expand All @@ -38,7 +38,7 @@ on a node created from scratch and disposed after the test completes.

If you need a capability that cannot be fulfilled by [docker-selenium](https://github.com/elgalu/docker-selenium),
the test gets redirected to a cloud testing provider ([Sauce Labs](https://saucelabs.com/),
[BrowserStack](https://www.browserstack.com/), [TestingBot](https://testingbot.com/), [CrossBrowserTesting](https://crossbrowsertesting.com/)).
[BrowserStack](https://www.browserstack.com/), [TestingBot](https://testingbot.com/), [CrossBrowserTesting](https://crossbrowsertesting.com/), [LambdaTest](https://www.lambdatest.com/)).

Zalenium's main goal is: to allow anyone to have a disposable and flexible Selenium Grid infrastructure.

Expand Down
3 changes: 3 additions & 0 deletions charts/zalenium/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ See Zalenium's [usage examples](https://github.com/zalando/zalenium/blob/master/
| `hub.sauceLabsEnabled` | Enable SauceLabs | false |
| `hub.browserStackEnabled` | Enable BrowserStack | false |
| `hub.testingBotEnabled` | Enable TestingBot | false |
| `hub.lambdaTestEnabled` | Enable LambdaTest | false |
| `hub.videoRecordingEnabled` | Enable video recording | true |
| `hub.cpuRequest` | CPU requested for browser pods. The hub passes this value to the k8s API | 500m |
| `hub.cpuLimit` | CPU limit for browser pods. The hub passes this value to the k8s API | 1000m |
Expand All @@ -111,6 +112,8 @@ See Zalenium's [usage examples](https://github.com/zalando/zalenium/blob/master/
| `hub.browserStackKey` | Credentials for browserstack | blank |
| `hub.testingBotKey` | Credentials for testingbot | blank |
| `hub.testingBotSecret` | Credentials for testingbot | blank |
| `hub.lambdaUsername` | Username for lambdatest | blank |
| `hub.lambdaAccessKey` | Access key for lambdatest | blank |
| `hub.basicAuth.enabled` | Enables basic authentication | false |
| `hub.basicAuth.username` | Username for basic authentication | zalenium |
| `hub.basicAuth.password` | Password for basic authentication | password |
Expand Down
8 changes: 8 additions & 0 deletions charts/zalenium/templates/_pod-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ spec:
- name: TESTINGBOT_SECRET
value: {{ .Values.hub.testingBotSecret | quote }}
{{- end }}
{{- if .Values.hub.lambdaTestEnabled }}
- name: LT_ENABLED
value: {{ .Values.hub.lambdaTestEnabled | quote }}
- name: LT_USERNAME
value: {{ .Values.hub.lambdaUsername | quote }}
- name: LT_ACCESS_KEY
value: {{ .Values.hub.lambdaAccessKey | quote }}
{{- end }}
{{- range $key, $val := .Values.hub.env }}
- name: {{ $key | quote }}
value: {{ $val | quote }}
Expand Down
3 changes: 3 additions & 0 deletions charts/zalenium/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ hub:
testingBotEnabled: false
testingBotKey: blank
testingBotSecret: blank
lambdaTestEnabled: false
lambdaUsername: blank
lambdaAccessKey: blank

## Arbitrary environment variables
env:
Expand Down
Binary file added dashboard/img/lambdatest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,21 @@ RUN cd /tmp \
&& mv cbt_tunnels-linux-x64 /usr/local/bin \
&& which cbt_tunnels-linux-x64

# -----------------------#
# LambdaTest Tunneling #
# -----------------------#
# https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/
# Layer size: medium: ~16 MB
ENV LT_TUNNEL_URL="https://s3.amazonaws.com/lambda-tunnel" \
LT_TUNNEL_ZIP="LT_Linux.zip"
RUN cd /tmp \
&& wget -nv "${LT_TUNNEL_URL}/${LT_TUNNEL_ZIP}" \
&& unzip "${LT_TUNNEL_ZIP}" \
&& chmod 755 LT \
&& rm "${LT_TUNNEL_ZIP}" \
&& mv LT /usr/local/bin \
&& which LT


#===================================================
# Run the following commands as non-privileged user
Expand Down Expand Up @@ -342,6 +357,8 @@ ENV ZAL_VER="${project.build.finalName}" \
TESTINGBOT_WAIT_TIMEOUT="2m" \
CBT_TUNNEL_ID="zalenium" \
CBT_TUNNEL="false" \
LT_TUNNEL_ID="zalenium" \
LT_TUNNEL="false" \
SELENIUM_HUB_PARAMS="" \
SELENIUM_NODE_PARAMS="" \
SELENIUM_CONTAINER_LABELS="" \
Expand All @@ -363,6 +380,8 @@ COPY zalenium.sh \
wait-testingbot.sh \
start-cbt.sh \
wait-cbt.sh \
start-lambdatest.sh \
wait-lambdatest.sh \
dashboard_template.html \
zalando.ico \
logging_info.properties \
Expand All @@ -383,6 +402,8 @@ RUN sudo chmod +x /home/seluser/zalenium.sh \
&& sudo chmod +x /home/seluser/wait-testingbot.sh \
&& sudo chmod +x /home/seluser/start-cbt.sh \
&& sudo chmod +x /home/seluser/wait-cbt.sh \
&& sudo chmod +x /home/seluser/start-lambdatest.sh \
&& sudo chmod +x /home/seluser/wait-lambdatest.sh \
&& sudo chmod +x /usr/bin/log \
&& sudo chmod +x /usr/bin/warn \
&& sudo chmod +x /usr/bin/error \
Expand Down
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ highlighter: rouge

### content configuration ###
title: "Zalenium - A flexible and scalable Selenium Grid."
keywords: "docker, selenium, selenium, grid, kubernetes, saucelabs, browserstack, testingbot"
keywords: "docker, selenium, selenium, grid, kubernetes, saucelabs, browserstack, testingbot, lambdatest"
description: "Allows anyone to have a disposable, flexible, container based Selenium Grid infrastructure featuring video recording, live preview, basic auth & online/offline dashboards"
source_link: "https://github.com/zalando/zalenium"
favicon: "zalando.ico"
Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2000-01-01-home.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ style: center
Start a Selenium Grid in seconds, a grid that scales up and down dynamically with this solution based on [docker-selenium](https://github.com/elgalu/docker-selenium)
to run your tests in Firefox and Chrome. If you need a different browser, Zalenium can redirect your tests to a cloud
testing provider ([Sauce Labs](https://saucelabs.com/){:target="_blank"},
[BrowserStack](https://www.browserstack.com/){:target="_blank"}, [TestingBot](https://testingbot.com/){:target="_blank"}, [CrossBrowserTesting](https://crossbrowsertesting.com){:target="_blank"}).
[BrowserStack](https://www.browserstack.com/){:target="_blank"}, [TestingBot](https://testingbot.com/){:target="_blank"}, [CrossBrowserTesting](https://crossbrowsertesting.com){:target="_blank"}, [LambdaTest](https://www.lambdatest.com/){:target="_blank"}).

Zalenium works out of the box in [Docker](#docker) and [Kubernetes](#kubernetes).

Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2000-01-02-why.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on a node created from scratch and disposed after the test completes.

If you need a capability that cannot be fulfilled by [docker-selenium](https://github.com/elgalu/docker-selenium){:target="_blank"},
the test gets redirected to a cloud testing provider ([Sauce Labs](https://saucelabs.com/){:target="_blank"},
[BrowserStack](https://www.browserstack.com/){:target="_blank"}, [TestingBot](https://testingbot.com/){:target="_blank"}, [CrossBrowserTesting](https://crossbrowsertesting.com/){:target="_blank"}).
[BrowserStack](https://www.browserstack.com/){:target="_blank"}, [TestingBot](https://testingbot.com/){:target="_blank"}, [CrossBrowserTesting](https://crossbrowsertesting.com/){:target="_blank"}, [LambdaTest](https://www.lambdatest.com/){:target="_blank"}).

**Zalenium's main goal is: to allow anyone to have a disposable and flexible Selenium Grid infrastructure.**

Expand Down
34 changes: 33 additions & 1 deletion docs/_posts/2000-01-05-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ you can explicitly tell Zalenium which version you are using via `-e DOCKER=17.0

</details>

<details>
<summary>Enabling LambdaTest (you'll need an account with them)</summary>

{% highlight shell %}
export LT_USERNAME=<your username>
export LT_ACCESS_KEY=<your accessKey>
export LT_URL=<your LT url : port number> # default value is "https://hub.lambdatest.com"
docker run --rm -ti --name zalenium -p 4444:4444 \
-e LT_USERNAME -e LT_ACCESS_KEY -e LT_URL \
-v /tmp/videos:/home/seluser/videos \
-v /var/run/docker.sock:/var/run/docker.sock \
--privileged dosel/zalenium start --lambdaTestEnabled true
{% endhighlight %}

</details>

<details>
<summary>Customising screen width and height, and time zone</summary>

Expand Down Expand Up @@ -311,6 +327,7 @@ you can explicitly tell Zalenium which version you are using via `-e DOCKER=17.0
--testingBotEnabled false
--cbtEnabled false
--startTunnel false
--lambdaTestEnabled false
extra_hosts:
- "google.co.jp:127.0.0.1"
{% endhighlight %}
Expand Down Expand Up @@ -527,6 +544,11 @@ echo "Selenium Hub started!"
<td>false</td>
<td>Start CrossBrowserTesting node or not.</td>
</tr>
<tr>
<td><code>--lambdaTestEnabled</code></td>
<td>false</td>
<td>Start LambdaTest node or not.</td>
</tr>
<tr>
<td><code>--startTunnel</code></td>
<td>false</td>
Expand All @@ -537,6 +559,7 @@ echo "Selenium Hub started!"
<li><a target="_blank" href="https://wiki.saucelabs.com/display/DOCS/Using+Multiple+Sauce+Connect+Tunnels">Sauce Labs</a></li>
<li><a target="_blank" href="https://www.browserstack.com/local-testing">BrowserStack</a></li>
<li><a target="_blank" href="https://testingbot.com/support/other/tunnel">TestingBot</a></li>
<li><a target="_blank" href="https://www.lambdatest.com/support/docs/lambda-tunnel-modifiers/">LambdaTest</a></li>
</ul>
</p>
The local identifier used when creating the tunnel is <code>zalenium</code>.
Expand Down Expand Up @@ -659,6 +682,11 @@ Any of these environment variables can be passed to Zalenium like this:
<td>http://hub.crossbrowsertesting.com:80</td>
<td>Url that will be used to connect to the CrossBrowserTesting cloud service.</td>
</tr>
<tr>
<td><code>LT_URL</code></td>
<td>https://hub.lambdatest.com</td>
<td>Url that will be used to connect to the LamdaTest cloud service.</td>
</tr>
<tr>
<td><code>NEW_SESSION_WAIT_TIMEOUT</code></td>
<td>600000</td>
Expand Down Expand Up @@ -784,6 +812,7 @@ Any of these environment variables can be passed to Zalenium like this:
--browserStackEnabled false
--testingBotEnabled false
--cbtEnabled false
--lambdaTestEnabled false
--startTunnel false
environment:
- HOST_UID
Expand All @@ -796,7 +825,10 @@ Any of these environment variables can be passed to Zalenium like this:
- TESTINGBOT_SECRET
- CBT_USERNAME
- CBT_AUTHKEY

- LT_USERNAME
- LT_ACCESS_KEY


mock:
image: elgalu/google_adwords_mock
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2000-01-08-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ See more details at `build name`.
Adding a <code>testFileNameTemplate</code> capability will save logs and video recording with file name format you prefer.
Resulting file name can have invariable and variable text. You can find the list of variable text below:<br/><br/>

{proxyName} - Zalenium|SauceLabs|BrowserStack<br/>
{proxyName} - Zalenium|SauceLabs|BrowserStack|LambdaTest<br/>
{testName} - The one added as "name" on capabilities, otherwise a session key<br/>
{browser} - The browser name<br/>
{platform} - OS where test runs<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2000-01-09-how.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Zalenium works conceptually in a simple way:
2. One custom node for [docker-selenium](https://github.com/elgalu/docker-selenium){:target="_blank"}
3. If a cloud testing integration is enabled, a cloud proxy node to support a cloud provider
([Sauce Labs](https://saucelabs.com/){:target="_blank"}, [BrowserStack](https://www.browserstack.com/){:target="_blank"},
[TestingBot](https://testingbot.com/){:target="_blank"}) will register to the grid.
[TestingBot](https://testingbot.com/){:target="_blank"}, [LambdaTest](https://www.lambdatest.com/){:target="_blank"}) will register to the grid.
4. A test request is received by the hub and the requested capabilities are verified against each one of the nodes.
5. If [docker-selenium](https://github.com/elgalu/docker-selenium){:target="_blank"} can fulfill the
requested capabilities, a docker container is created on the run, and the test request is sent back to the hub while
Expand Down
4 changes: 2 additions & 2 deletions docs/_posts/2000-01-10-contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ running):
{% endhighlight %}


* Running the integration tests with Sauce Labs or BrowserStack or TestingBot or CrossBrowserTesting. You will need an account on any of those providers
* Running the integration tests with Sauce Labs or BrowserStack or TestingBot or CrossBrowserTesting or LambdaTest. You will need an account on any of those providers
to run them (they have free plans).
{% highlight shell %}
./run_integration_tests.sh sauceLabs|browserStack|testingBot|crossBrowserTesting
./run_integration_tests.sh sauceLabs|browserStack|testingBot|crossBrowserTesting|lambdaTest
{% endhighlight %}
1 change: 1 addition & 0 deletions docs/_posts/2000-01-12-links.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Thanks to the open source accounts we got, we have integrated so far:
<a target="_blank" href="https://saucelabs.com/"><img alt="Sauce Labs" src="img/saucelabs_logo.png" width="300"></a>
<a target="_blank" href="https://testingbot.com/"><img alt="TestingBot" src="img/testingbot_logo.png" width="260"></a>
<a target="_blank" href="https://crossbrowsertesting.com/"><img alt="CBT" src="img/cbt.png" width="300"></a>
<a target="_blank" href="https://www.lambdatest.com/"><img alt="LambdaTest" src="img/lambdatest_logo.png" width="300"></a>
</div>

***
Expand Down
3 changes: 3 additions & 0 deletions docs/docker/docker-compose-drone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
--browserStackEnabled false
--testingBotEnabled false
--cbtEnabled false
--lambdaTestEnabled false
--startTunnel false
environment:
- BUILD_URL
Expand All @@ -48,6 +49,8 @@ services:
- TESTINGBOT_SECRET
- CBT_USERNAME
- CBT_AUTHKEY
- LT_USERNAME
- LT_ACCESS_KEY
# For OSX remember to include the docker version
# allowed values are: 1.11 or 1.12 or 1.13
# - DOCKER=1.11
Expand Down
1 change: 1 addition & 0 deletions docs/docker/docker-compose-extra-hosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
--browserStackEnabled false
--testingBotEnabled false
--cbtEnabled false
--lambdaTestEnabled false
--startTunnel false
extra_hosts:
- "google.co.jp:127.0.0.1"
3 changes: 3 additions & 0 deletions docs/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
--browserStackEnabled false
--testingBotEnabled false
--cbtEnabled false
--lambdaTestEnabled false
--startTunnel false
environment:
- HOST_UID
Expand All @@ -37,6 +38,8 @@ services:
- TESTINGBOT_SECRET
- CBT_USERNAME
- CBT_AUTHKEY
- LT_USERNAME
- LT_ACCESS_KEY

mock:
image: elgalu/google_adwords_mock
Expand Down
9 changes: 9 additions & 0 deletions run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ else
ls -la ${VIDEOS_FOLDER}/zalenium*.mp4 || (echo "No Zalenium videos were generated." && exit 2)
fi
fi
if [ "${INTEGRATION_TO_TEST}" = lambdaTest ]; then
if [ -n "${LT_USERNAME}" ]; then
env "PATH=$PATH" mvn clean
mvn clean verify -Pintegration-test -DthreadCountProperty=2 -Dskip.surefire.tests=true -DintegrationToTest=${INTEGRATION_TO_TEST}
# Check for generated videos
ls -la ${VIDEOS_FOLDER}/lambdatest*.mp4 || (echo "No LambdaTest videos were downloaded." && exit 2)
ls -la ${VIDEOS_FOLDER}/zalenium*.mp4 || (echo "No Zalenium videos were generated." && exit 2)
fi
fi
if [ "${INTEGRATION_TO_TEST}" = dockerCompose ]; then
if [ -n "${SAUCE_USERNAME}" ]; then
env "PATH=$PATH" mvn clean
Expand Down
44 changes: 44 additions & 0 deletions scripts/start-lambdatest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

# set -e: exit asap if a command exits with a non-zero status
set -e

echoerr() { printf "%s\n" "$*" >&2; }

# print error and exit
die () {
echoerr "ERROR: $1"
# if $2 is defined AND NOT EMPTY, use $2; otherwise, set to "160"
errnum=${2-160}
exit $errnum
}

# Required params
[ -z "${LT_USERNAME}" ] && die "Required env var LT_USERNAME"
[ -z "${LT_ACCESS_KEY}" ] && die "Required env var LT_ACCESS_KEY"
[ -z "${LT_TUNNEL_ID}" ] && die "Required env var LT_TUNNEL_ID"


# Start tunnel
LT \
--user ${LT_USERNAME} \
--key ${LT_ACCESS_KEY} \
--tunnelName ${LT_TUNNEL_ID} > ${LT_LOG_FILE} &
LT_TUNNEL_PID=$!



#kills the tunnel through the process id
function shutdown {
echo "Trapped SIGTERM/SIGINT so shutting down LambdaTest gracefully..."
kill -SIGTERM ${LT_TUNNEL_PID}
wait ${LT_TUNNEL_PID}
echo "LambdaTest tunnel shutdown complete."
exit 0
}

# Run function shutdown() when this process receives a killing signal
trap shutdown SIGTERM SIGINT SIGKILL

# tells bash to wait until child processes have exited
wait
Loading

0 comments on commit fff0573

Please sign in to comment.