From b923c858254fe50f1286d616dc7406af039b899f Mon Sep 17 00:00:00 2001 From: Marcin Erdmann Date: Sat, 28 Dec 2019 20:12:05 +0100 Subject: [PATCH] Fix LambdaTest tunnel configuration, setup execution of tests in LambdaTest on CI. Part of geb/issues#603 --- .circleci/config.yml | 28 +++++++++++++++++++ .../gradle/lambdatest/LambdaTestTunnel.groovy | 2 ++ .../lambdatest/LambdaTestTunnelOps.groovy | 3 +- .../src/main/groovy/GebConfig.groovy | 2 +- module/geb-core/geb-core.gradle | 9 ++---- .../geb/driver/LambdaTestDriverFactory.groovy | 15 ++++++---- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4e5551a48..352ef89b9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -222,6 +244,11 @@ workflows: - integrations - manual - site + - lambdatest: + requires: + - integrations + - manual + - site - non-ie: requires: - integrations @@ -234,6 +261,7 @@ workflows: requires: - local-cross-browser - saucelabs + - lambdatest - ie filters: branches: diff --git a/integration/geb-gradle/src/main/groovy/geb/gradle/lambdatest/LambdaTestTunnel.groovy b/integration/geb-gradle/src/main/groovy/geb/gradle/lambdatest/LambdaTestTunnel.groovy index f59560516..5ca7aa245 100755 --- a/integration/geb-gradle/src/main/groovy/geb/gradle/lambdatest/LambdaTestTunnel.groovy +++ b/integration/geb-gradle/src/main/groovy/geb/gradle/lambdatest/LambdaTestTunnel.groovy @@ -147,6 +147,8 @@ class LambdaTestTunnel extends ExternalTunnel { if (extension.local.version) { commandLine << "-version" << extension.local.version } + + commandLine.addAll(extension.local.additionalOptions) commandLine } diff --git a/integration/geb-gradle/src/main/groovy/geb/gradle/lambdatest/LambdaTestTunnelOps.groovy b/integration/geb-gradle/src/main/groovy/geb/gradle/lambdatest/LambdaTestTunnelOps.groovy index 23bca9510..a32e8b384 100755 --- a/integration/geb-gradle/src/main/groovy/geb/gradle/lambdatest/LambdaTestTunnelOps.groovy +++ b/integration/geb-gradle/src/main/groovy/geb/gradle/lambdatest/LambdaTestTunnelOps.groovy @@ -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 @@ -55,6 +54,6 @@ class LambdaTestTunnelOps implements TestTaskConfigurer { List additionalOptions = [] void configure(Test test) { - test.environment(LOCAL_ID_ENV_VAR, identifier) + test.environment(LOCAL_ID_ENV_VAR, tunnelName) } } diff --git a/internal/test-support/src/main/groovy/GebConfig.groovy b/internal/test-support/src/main/groovy/GebConfig.groovy index 9167852c2..b271a4615 100644 --- a/internal/test-support/src/main/groovy/GebConfig.groovy +++ b/internal/test-support/src/main/groovy/GebConfig.groovy @@ -89,7 +89,7 @@ def lambdaTestBrowser = System.getProperty("geb.lambdatest.browser") if (lambdaTestBrowser) { setPortIndexProperty(getForkIndex(5)) driver = { - new LambdaTestDriverFactory().create(lambdaTestBrowser) + new LambdaTestDriverFactory().create() } } diff --git a/module/geb-core/geb-core.gradle b/module/geb-core/geb-core.gradle index 435e0b048..6d73b24f2 100644 --- a/module/geb-core/geb-core.gradle +++ b/module/geb-core/geb-core.gradle @@ -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" } @@ -117,7 +114,7 @@ lambdaTest { application(*applicationAddresses) browsers { - chrome_windows_70 { + firefox_windows_70 { capabilities platform: "Windows 10" } } @@ -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 { diff --git a/module/geb-core/src/main/groovy/geb/driver/LambdaTestDriverFactory.groovy b/module/geb-core/src/main/groovy/geb/driver/LambdaTestDriverFactory.groovy index 6cbb06a35..e4f585db1 100755 --- a/module/geb-core/src/main/groovy/geb/driver/LambdaTestDriverFactory.groovy +++ b/module/geb-core/src/main/groovy/geb/driver/LambdaTestDriverFactory.groovy @@ -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 additionalCapabilities = [:]) { - create(specification, System.getenv("GEB_LAMBDATEST_USERNAME"), System.getenv("GEB_LAMBDATEST_AUTHKEY"), additionalCapabilities) + WebDriver create(Map 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 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)