Skip to content

Commit

Permalink
Fix LambdaTest tunnel configuration, setup execution of tests in Lamb…
Browse files Browse the repository at this point in the history
…daTest on CI.

Part of geb/issues#603
  • Loading branch information
erdi committed Jan 2, 2020
1 parent 82bde98 commit b923c85
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
28 changes: 28 additions & 0 deletions .circleci/config.yml
Expand Up @@ -110,6 +110,28 @@ jobs:
key: gradle-home-saucelabs
paths:
- .gradle-home
lambdatest:
docker:
- image: gebish/ci:v7
environment:
GRADLE_OPTS: -Xmx1024m -XX:MaxMetaspaceSize=256m
GRADLE_USER_HOME: .gradle-home
steps:
- checkout
- restore_cache:
keys:
- gradle-home-lambdatest
- run:
command: |
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
./gradlew --no-daemon -Pci allLambdaTestTests
fi
- store_artifacts:
path: build/reports
- save_cache:
key: gradle-home-lambdatest
paths:
- .gradle-home
non-ie:
docker:
- image: gebish/ci:v7
Expand Down Expand Up @@ -222,6 +244,11 @@ workflows:
- integrations
- manual
- site
- lambdatest:
requires:
- integrations
- manual
- site
- non-ie:
requires:
- integrations
Expand All @@ -234,6 +261,7 @@ workflows:
requires:
- local-cross-browser
- saucelabs
- lambdatest
- ie
filters:
branches:
Expand Down
Expand Up @@ -147,6 +147,8 @@ class LambdaTestTunnel extends ExternalTunnel {
if (extension.local.version) {
commandLine << "-version" << extension.local.version
}

commandLine.addAll(extension.local.additionalOptions)
commandLine
}

Expand Down
Expand Up @@ -22,7 +22,6 @@ class LambdaTestTunnelOps implements TestTaskConfigurer {

public static final String LOCAL_ID_ENV_VAR = "GEB_LAMBDATEST_TUNNELID"

String identifier
String tunnelName
String config
String controller
Expand Down Expand Up @@ -55,6 +54,6 @@ class LambdaTestTunnelOps implements TestTaskConfigurer {
List<String> additionalOptions = []

void configure(Test test) {
test.environment(LOCAL_ID_ENV_VAR, identifier)
test.environment(LOCAL_ID_ENV_VAR, tunnelName)
}
}
2 changes: 1 addition & 1 deletion internal/test-support/src/main/groovy/GebConfig.groovy
Expand Up @@ -89,7 +89,7 @@ def lambdaTestBrowser = System.getProperty("geb.lambdatest.browser")
if (lambdaTestBrowser) {
setPortIndexProperty(getForkIndex(5))
driver = {
new LambdaTestDriverFactory().create(lambdaTestBrowser)
new LambdaTestDriverFactory().create()
}
}

Expand Down
9 changes: 3 additions & 6 deletions module/geb-core/geb-core.gradle
Expand Up @@ -84,9 +84,6 @@ browserStack {
firefox_mac_47 {
capabilities os: "OS X", os_version: "High Sierra"
}
firefox_windows_70 {
capabilities os: "Windows", os_version: "10"
}
create("internet explorer_windows_10") {
capabilities os: "Windows", os_version: "8"
}
Expand Down Expand Up @@ -117,7 +114,7 @@ lambdaTest {
application(*applicationAddresses)

browsers {
chrome_windows_70 {
firefox_windows_70 {
capabilities platform: "Windows 10"
}
}
Expand All @@ -132,13 +129,13 @@ lambdaTest {
accessKey = System.getenv(LambdaTestAccount.ACCESS_KEY_ENV_VAR)
}
tunnelOps {
identifier = UUID.randomUUID().toString()
tunnelName = UUID.randomUUID().toString()
}
}


task nonIeBrowserStackTests {
dependsOn 'androidTest', 'chromeMac78Test', 'chromeWindows78Test', 'firefoxWindows70Test', 'firefoxMac47Test'
dependsOn 'androidTest', 'chromeMac78Test', 'chromeWindows78Test', 'firefoxMac47Test'
}

task ieBrowserStackTests {
Expand Down
Expand Up @@ -21,23 +21,28 @@ import org.openqa.selenium.remote.DesiredCapabilities

class LambdaTestDriverFactory extends CloudDriverFactory {

public static final String LOCAL_IDENTIFIER_CAPABILITY = "lambdatest.localIdentifier"
public static final String LOCAL_IDENTIFIER_CAPABILITY = "tunnelName"

@Override
String assembleProviderUrl(String username, String password) {
"https://$username:$password@hub.lambdatest.com/wd/hub"
}

WebDriver create(String specification, Map<String, Object> additionalCapabilities = [:]) {
create(specification, System.getenv("GEB_LAMBDATEST_USERNAME"), System.getenv("GEB_LAMBDATEST_AUTHKEY"), additionalCapabilities)
WebDriver create(Map<String, Object> additionalCapabilities = [:]) {
def specification = System.getProperty("geb.lambdatest.browser")
def user = System.getenv("GEB_LAMBDATEST_USERNAME")
def key = System.getenv("GEB_LAMBDATEST_AUTHKEY")
create(specification, user, key, additionalCapabilities)
}

WebDriver create(String specification, String username, String password, String localId, Map<String, Object> capabilities = [:]) {
def mergedCapabilities = ImmutableMap.builder().putAll(capabilities).put(LOCAL_IDENTIFIER_CAPABILITY, localId).build()
create(specification, username, password, mergedCapabilities)
}
protected void configureCapabilities(DesiredCapabilities desiredCapabilities) {
desiredCapabilities.setCapability("tunnel", "false")

@Override
protected void configureCapabilities(String username, String key, DesiredCapabilities desiredCapabilities) {
desiredCapabilities.setCapability("tunnel", "true")
def tunnelId = System.getenv("GEB_LAMBDATEST_TUNNELID")
if (tunnelId) {
desiredCapabilities.setCapability(LOCAL_IDENTIFIER_CAPABILITY, tunnelId)
Expand Down

0 comments on commit b923c85

Please sign in to comment.