diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index d9f284305..2e05cbe49 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -34,203 +34,128 @@ steps: artifacts#v1.9.0: upload: "bugsnag-cocoa/features/fixtures/ios/output/iOSTestApp_Release.ipa" - - label: ':docker: Build CI image for Ruby 2' + - label: ':docker: Build CI image' timeout_in_minutes: 30 - key: "ci-image-ruby-2" + key: "ci-image" plugins: - docker-compose#v4.14.0: build: - - ci-ruby-2 + - ci image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner cache-from: - - ci-ruby-2:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-2 - - docker-compose#v4.14.0: - push: - - ci-ruby-2:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-2 - env: - RUBY_VERSION: "2" - - - label: ':docker: Build CI image for Ruby 3' - timeout_in_minutes: 30 - key: "ci-image-ruby-3" - plugins: - - docker-compose#v4.14.0: - build: - - ci-ruby-3 - image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner - cache-from: - - ci-ruby-3:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-3 - - docker-compose#v4.14.0: + - ci:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci push: - - ci-ruby-3:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-3 - env: - RUBY_VERSION: "3" + - ci:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci - - label: 'Unit tests with Ruby 2' + - label: 'Unit tests' timeout_in_minutes: 30 - depends_on: 'ci-image-ruby-2' + depends_on: 'ci-image' plugins: docker-compose#v4.14.0: - run: unit-test-ruby-2 + run: unit-test image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner cache-from: - - ci-ruby-2:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-2 + - ci:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci command: 'bundle exec rake' - - label: 'Unit tests with Ruby 3' - timeout_in_minutes: 30 - depends_on: 'ci-image-ruby-3' - plugins: - docker-compose#v4.14.0: - run: unit-test-ruby-3 - image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner - cache-from: - - ci-ruby-3:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-3 - command: 'bundle exec rake' - - - label: ':docker: Push W3C CLI image for branch' + - label: ':docker: Push CLI image for branch' key: push-branch-cli timeout_in_minutes: 30 - depends_on: "ci-image-ruby-2" + depends_on: "ci-image" plugins: - docker-compose#v4.14.0: build: cli image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner cache-from: - cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli - - docker-compose#v4.14.0: push: - cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli - - label: ':docker: Push Legacy CLI image for branch' - key: push-branch-cli-legacy + - label: 'Framework tests' timeout_in_minutes: 30 - depends_on: "ci-image-ruby-2" + depends_on: "ci-image" plugins: - docker-compose#v4.14.0: - build: cli-legacy - image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner - cache-from: - - cli-legacy:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli-legacy - - docker-compose#v4.14.0: - push: - - cli-legacy:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli-legacy + run: framework-tests + command: 'bundle exec maze-runner' - - label: 'No-device tests with Ruby 2 - batch 1' - timeout_in_minutes: 30 - depends_on: "ci-image-ruby-2" + - label: 'Comparison tests' + timeout_in_minutes: 10 + depends_on: "ci-image" plugins: - - docker-compose#v4.14.0: - run: framework-tests - docker-compose#v4.14.0: run: comparison-tests - - docker-compose#v4.14.0: - run: proxy-tests - - docker-compose#v4.14.0: - run: cli-tests - - docker-compose#v4.14.0: - run: http-response-tests - env: - RUBY_VERSION: "2" - USE_LEGACY_DRIVER: "1" command: 'bundle exec maze-runner' - - label: 'No-device tests with Ruby 2 - batch 2' - timeout_in_minutes: 30 - depends_on: "ci-image-ruby-2" + - label: 'Proxy tests' + timeout_in_minutes: 10 + depends_on: "ci-image" plugins: - docker-compose#v4.14.0: - run: payload-helper-tests - - docker-compose#v4.14.0: - run: docker-tests - - docker-compose#v4.14.0: - run: doc-server-tests - - docker-compose#v4.14.0: - run: exit-codes-tests - - docker-compose#v4.14.0: - run: command-workflow-tests - - artifacts#v1.9.0: - upload: - - test/e2e/payload-helpers/maze_output/**/* - - test/e2e/payload-helpers/maze_output/* - env: - RUBY_VERSION: "2" - USE_LEGACY_DRIVER: "1" + run: proxy-tests command: 'bundle exec maze-runner' - - label: 'No-device tests with Ruby 3 - batch 1' - timeout_in_minutes: 30 - depends_on: "ci-image-ruby-3" + - label: 'CLI tests' + timeout_in_minutes: 10 + depends_on: "ci-image" plugins: - - docker-compose#v4.14.0: - run: framework-tests - - docker-compose#v4.14.0: - run: comparison-tests - - docker-compose#v4.14.0: - run: proxy-tests - docker-compose#v4.14.0: run: cli-tests + command: 'bundle exec maze-runner' + + - label: 'HTTP response tests' + timeout_in_minutes: 10 + depends_on: "ci-image" + plugins: - docker-compose#v4.14.0: run: http-response-tests - env: - RUBY_VERSION: "3" command: 'bundle exec maze-runner' - - label: 'No-device tests with Ruby 3 - batch 2' - timeout_in_minutes: 30 - depends_on: "ci-image-ruby-3" + - label: 'Payload helper tests' + timeout_in_minutes: 10 + depends_on: "ci-image" plugins: - docker-compose#v4.14.0: run: payload-helper-tests + command: 'bundle exec maze-runner' + + - label: 'Docker tests' + timeout_in_minutes: 10 + depends_on: "ci-image" + plugins: - docker-compose#v4.14.0: run: docker-tests + command: 'bundle exec maze-runner' + + - label: 'Doc server tests' + timeout_in_minutes: 10 + depends_on: "ci-image" + plugins: - docker-compose#v4.14.0: run: doc-server-tests + command: 'bundle exec maze-runner' + + - label: 'Exit codes tests' + timeout_in_minutes: 10 + depends_on: "ci-image" + plugins: - docker-compose#v4.14.0: run: exit-codes-tests + command: 'bundle exec maze-runner' + + - label: 'Command workflow tests' + timeout_in_minutes: 10 + depends_on: "ci-image" + plugins: - docker-compose#v4.14.0: run: command-workflow-tests - env: - RUBY_VERSION: "3" command: 'bundle exec maze-runner' # # BrowserStack tests # - - label: ':browserstack: Android 8.1 - JWP' - timeout_in_minutes: 20 - depends_on: - - "android-test-fixture" - - "push-branch-cli-legacy" - plugins: - artifacts#v1.9.0: - download: "bugsnag-android-performance/build/test-fixture.apk" - upload: - - "bugsnag-android-performance/maze_output/**/*" - docker-compose#v4.14.0: - pull: appium-test-bs-legacy - run: appium-test-bs-legacy - volumes: - - "./bugsnag-android-performance/build:/app/build" - - "./bugsnag-android-performance/features:/app/features" - - "./bugsnag-android-performance/maze_output:/app/maze_output" - command: - - "--app=build/test-fixture.apk" - - "--farm=bs" - - "--device=ANDROID_8" - - "--fail-fast" - - "features/manual_spans.feature" - image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner - cache-from: - - cli-legacy:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli-legacy - env: - RUBY_VERSION: "2" - concurrency: 5 - concurrency_group: 'browserstack-app' - concurrency_method: eager - - - label: ':browserstack: iOS 16 - W3C' + - label: ':browserstack: iOS 17' timeout_in_minutes: 20 depends_on: - "ios-test-fixture" @@ -249,36 +174,21 @@ steps: command: - "--app=features/fixtures/ios/output/iOSTestApp_Release.ipa" - "--farm=bs" - - "--device=IOS_16" + - "--device=IOS_17" - "--fail-fast" - "features/release/barebone_tests.feature" image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner cache-from: - cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli - env: - RUBY_VERSION: "3" concurrency: 5 concurrency_group: 'browserstack-app' concurrency_method: eager + retry: + automatic: + - exit_status: 103 # Appium client failure + limit: 2 - - label: ':browserstack: Firefox - JWP' - depends_on: "push-branch-cli-legacy" - timeout_in_minutes: 10 - plugins: - docker-compose#v4.14.0: - run: browser-tests-legacy - use-aliases: true - verbose: true - command: - - "--farm=bs" - - "--browser=firefox_latest" - - "--browser=chrome_latest" - - "--fail-fast" - concurrency: 2 - concurrency_group: 'browserstack' - concurrency_method: eager - - - label: ':browserstack: Firefox - W3C' + - label: ':browserstack: Firefox' depends_on: "push-branch-cli" timeout_in_minutes: 10 plugins: @@ -318,8 +228,6 @@ steps: - "--aws-public-ip" - "--fail-fast" - "--no-tunnel" - env: - RUBY_VERSION: "2" concurrency: 25 concurrency_group: 'bitbar' concurrency_method: eager @@ -345,17 +253,19 @@ steps: - "--app=build/test-fixture.apk" - "--appium-version=1.22" - "--farm=bb" - - "--device=ANDROID_10|ANDROID_11|ANDROID_12|ANDROID_13" + - "--device=ANDROID_12|ANDROID_13|ANDROID_14|ANDROID_15" - "--fail-fast" - "--no-tunnel" - "--aws-public-ip" - "features/manual_spans.feature" image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner - env: - RUBY_VERSION: "3" concurrency: 25 concurrency_group: 'bitbar' concurrency_method: eager + retry: + automatic: + - exit_status: 103 # Appium client failure + limit: 2 - label: ':bitbar: Appium API' timeout_in_minutes: 20 @@ -380,16 +290,18 @@ steps: - "--app=build/test-fixture.apk" - "--appium-version=1.22" - "--farm=bb" - - "--device=ANDROID_10|ANDROID_11|ANDROID_12|ANDROID_13" + - "--device=ANDROID_12|ANDROID_13|ANDROID_14|ANDROID_15" - "--fail-fast" - "--no-tunnel" - "--aws-public-ip" image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner - env: - RUBY_VERSION: "3" concurrency: 25 concurrency_group: 'bitbar' concurrency_method: eager + retry: + automatic: + - exit_status: 103 # Appium client failure + limit: 2 - label: ':bitbar: iOS' timeout_in_minutes: 20 @@ -419,11 +331,13 @@ steps: image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner cache-from: - cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli - env: - RUBY_VERSION: "3" concurrency: 25 concurrency_group: 'bitbar' concurrency_method: eager + retry: + automatic: + - exit_status: 103 # Appium client failure + limit: 2 - wait @@ -441,11 +355,8 @@ steps: - docker-compose#v4.14.0: push: - cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:${BUILDKITE_TAG}-cli - - cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-v9-cli + - cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-v10-cli - cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-cli - - cli-legacy:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:${BUILDKITE_TAG}-cli-legacy - - cli-legacy:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-v9-cli-legacy - - cli-legacy:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-cli-legacy - label: 'Push to RubyGems.org' if: build.tag =~ /^v[0-9]{1,2}\.[0-9]+\.[0-9]+\$/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 2943224bb..be3ecb501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# v10.0.0 - 2025/08/26 + +## Enhancements + +- Update to Cucumber 10 [773](https://github.com/bugsnag/maze-runner/pull/773) +- Minimum Ruby version increased to 3.1 [781](https://github.com/bugsnag/maze-runner/pull/781) + +## Removals + +- Remove support for legacy JSON-WP drivers [748](https://github.com/bugsnag/maze-runner/pull/748) +- Remove deprecated Cucumber steps for sending keys to elements [751](https://github.com/bugsnag/maze-runner/pull/751) +- Remove document server on port 9340 [752](https://github.com/bugsnag/maze-runner/pull/752) +- Remove scenario retries for driver errors [782](https://github.com/bugsnag/maze-runner/pull/782) + # 9.36.0 - 2025/08/26 ## Enhancements diff --git a/UPGRADING.md b/UPGRADING.md index 42fef559b..1c8ba2af5 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,5 +1,28 @@ # Upgrading Guide +## v9 to v10 + +### Document server + +The document server that ran on port 9340 by default has been removed. Documents are still server under the `/docs` endpoint on port 9339 by default. + +### Legacy drivers + +The legacy JSON-WP protocol drivers (using Selenium v3 and Appium v11) are no longer supported. + +### Removed steps + +| Removed step | Replacement | +|---|------------------------------------------| +| `I wait for {int} span(s)` | I wait to receive at least {int} span(s) | +| `I clear the element {string}` | None. | +| `I send the keys {string} to the element {string}` | None. | +| `I clear and send the keys {string} to the element {string}` | None. | + +# Minimum Ruby version + +The minimum supported Ruby version is now 3.1 (due to Cucumber being updated to v10). + ## v8 to v9 ### Clearing app data between test scenarios diff --git a/bin/maze-runner b/bin/maze-runner index 1c978fd76..937ada433 100755 --- a/bin/maze-runner +++ b/bin/maze-runner @@ -29,7 +29,6 @@ require_relative '../lib/maze/client/appium/base_client' require_relative '../lib/maze/client/appium/bb_client' require_relative '../lib/maze/client/appium/bb_devices' require_relative '../lib/maze/client/appium/bs_client' -require_relative '../lib/maze/client/appium/bs_legacy_client' require_relative '../lib/maze/client/appium/bs_devices' require_relative '../lib/maze/client/appium/local_client' require_relative '../lib/maze/client/appium/session_metadata' @@ -42,7 +41,6 @@ require_relative '../lib/maze/client/selenium/local_client' require_relative '../lib/maze/aws_public_ip' require_relative '../lib/maze/compare' require_relative '../lib/maze/docker' -require_relative '../lib/maze/document_server' require_relative '../lib/maze/errors' require_relative '../lib/maze/generator' require_relative '../lib/maze/helper' diff --git a/bugsnag-android-performance b/bugsnag-android-performance index 1406683a3..3f6bbc4b9 160000 --- a/bugsnag-android-performance +++ b/bugsnag-android-performance @@ -1 +1 @@ -Subproject commit 1406683a39f6d2de53ae696b7597e3c816231f49 +Subproject commit 3f6bbc4b906f278cce5f0a4b24b13e4e7aa03e9c diff --git a/bugsnag-maze-runner.gemspec b/bugsnag-maze-runner.gemspec index 458e7b83e..0e7dada2c 100644 --- a/bugsnag-maze-runner.gemspec +++ b/bugsnag-maze-runner.gemspec @@ -3,46 +3,31 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require_relative 'lib/maze' Gem::Specification.new do |spec| - ruby_version = Gem::Version.new(RUBY_VERSION.dup) - spec.name = 'bugsnag-maze-runner' spec.version = Maze::VERSION - spec.authors = ['Steve Kirkland'] - spec.email = ['steve@bugsnag.com'] - spec.required_ruby_version = '>= 2.5.0' + spec.authors = ['Steve Kirkland', 'Josh Edney'] + spec.email = ['notifiers@bugsnag.com'] + spec.required_ruby_version = '>= 3.1' spec.description = 'Automation steps and mock server to validate' \ 'request payloads response.' - spec.summary = 'Bugsnag API request validation harness' + spec.summary = 'Bugsnag SDK test harness' spec.license = 'MIT' spec.require_paths = ['lib'] spec.files = Dir.glob('{bin,lib}/**/*').select { |fn| File.file?(fn) } spec.executables = spec.files.grep(%r{^bin/[\w\-]+$}) { |f| File.basename(f) } - if ruby_version < Gem::Version.new('3.0.0') - spec.add_dependency 'ffi', '1.16.3' - end - - spec.add_dependency 'cucumber', '~> 7.1' + spec.add_dependency 'cucumber', '~> 10.0' spec.add_dependency 'os', '~> 1.0.0' spec.add_dependency 'test-unit', '~> 3.5.2' spec.add_dependency 'rack', '~> 2.2' spec.add_dependency 'webrick', '~> 1.7.0' - # Appium 12/Selenium 4 enforce the use of W3C - if ENV['USE_LEGACY_DRIVER'] - puts 'Bundling legacy drivers (Selenium 3/Appium 11)' - spec.add_dependency 'appium_lib', '~> 11.0' - spec.add_dependency 'selenium-webdriver', '~> 3.0' - else - puts 'Bundling W3C drivers (Selenium 4/Appium 12)' - spec.add_dependency 'appium_lib', '~> 12.0.0' - spec.add_dependency 'appium_lib_core', '~> 5.4.0' - spec.add_dependency 'selenium-webdriver', '~> 4.0' - end + spec.add_dependency 'appium_lib', '~> 12.0.0' + spec.add_dependency 'appium_lib_core', '~> 5.4.0' + spec.add_dependency 'selenium-webdriver', '~> 4.0' spec.add_dependency 'bugsnag', '~> 6.24' - spec.add_dependency 'cucumber-expressions', '~> 6.0.0' spec.add_dependency 'curb', '~> 1.0.5' spec.add_dependency 'dogstatsd-ruby', '~> 5.5.0' spec.add_dependency 'datadog_api_client', '2.40.0' diff --git a/docker-compose.yml b/docker-compose.yml index 2b576776a..741ba17e3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.6' - x-common-environment: &common-environment DEBUG: BRANCH_NAME: @@ -29,32 +27,18 @@ services: volumes: - ./:/scan - ci-ruby-3: + ci: build: - dockerfile: dockerfiles/Dockerfile.ci-ruby-3 + dockerfile: dockerfiles/Dockerfile.ci context: . - target: ci-ruby-3 - - ci-ruby-2: - build: - dockerfile: dockerfiles/Dockerfile.ci-ruby-2 - context: . - target: ci-ruby-2 - environment: - USE_LEGACY_DRIVER: 1 + target: ci cli: build: - dockerfile: dockerfiles/Dockerfile.ci-ruby-3 + dockerfile: dockerfiles/Dockerfile.ci context: . target: cli - cli-legacy: - build: - dockerfile: dockerfiles/Dockerfile.ci-ruby-2 - context: . - target: cli-legacy - docs: build: dockerfile: dockerfiles/Dockerfile.docs @@ -68,10 +52,9 @@ services: appium-test-bb: build: context: . - dockerfile: dockerfiles/Dockerfile.w3c + dockerfile: dockerfiles/Dockerfile.cli args: BRANCH_NAME: - RUBY_VERSION: environment: <<: *common-environment BITBAR_USERNAME: @@ -86,32 +69,15 @@ services: appium-test-bs: build: context: . - dockerfile: dockerfiles/Dockerfile.w3c - args: - BRANCH_NAME: - RUBY_VERSION: - environment: - <<: *common-environment - BROWSER_STACK_USERNAME: - BROWSER_STACK_ACCESS_KEY: - BROWSER_STACK_DEVICES_USERNAME: - BROWSER_STACK_DEVICES_ACCESS_KEY: - env_file: $DOCKER_ENV_FILE - - appium-test-bs-legacy: - build: - context: . - dockerfile: dockerfiles/Dockerfile.legacy + dockerfile: dockerfiles/Dockerfile.cli args: BRANCH_NAME: - RUBY_VERSION: environment: <<: *common-environment BROWSER_STACK_USERNAME: BROWSER_STACK_ACCESS_KEY: BROWSER_STACK_DEVICES_USERNAME: BROWSER_STACK_DEVICES_ACCESS_KEY: - USE_LEGACY_DRIVER: 1 env_file: $DOCKER_ENV_FILE cli-tests: @@ -119,60 +85,48 @@ services: context: test/e2e/cli args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: comparison-tests: build: context: test/e2e/comparison args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: doc-server-tests: build: context: test/e2e/doc-server args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: exit-codes-tests: build: context: test/e2e/exit-codes args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: framework-tests: build: context: test/e2e/framework args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: docker-tests: build: context: test/e2e/docker-app args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: volumes: - /var/run/docker.sock:/var/run/docker.sock @@ -181,20 +135,16 @@ services: context: test/e2e/proxy args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: payload-helper-tests: build: context: test/e2e/payload-helpers args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: volumes: - ./test/e2e/payload-helpers/maze_output:/app/maze_output @@ -203,10 +153,8 @@ services: context: test/e2e/command-workflow args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: volumes: - ./test/e2e/command-workflow/maze_output:/app/maze_output @@ -215,32 +163,20 @@ services: context: test/e2e/http-response args: BRANCH_NAME: - RUBY_VERSION: environment: MAZE_BUGSNAG_API_KEY: - USE_LEGACY_DRIVER: - - unit-test-ruby-2: - build: - dockerfile: dockerfiles/Dockerfile.ci-ruby-2 - context: . - target: unit-test-ruby-2 - environment: - USE_LEGACY_DRIVER: 1 - unit-test-ruby-3: + unit-test: build: - dockerfile: dockerfiles/Dockerfile.ci-ruby-3 + dockerfile: dockerfiles/Dockerfile.ci context: . - target: unit-test-ruby-3 + target: unit-test browser-tests: build: context: test/e2e/browser - dockerfile: Dockerfile.w3c args: BRANCH_NAME: - RUBY_VERSION: environment: <<: *common-environment BUILDKITE: @@ -255,31 +191,11 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock - browser-tests-legacy: - build: - context: test/e2e/browser - dockerfile: Dockerfile.legacy - args: - BRANCH_NAME: - RUBY_VERSION: - environment: - <<: *common-environment - BUILDKITE: - BROWSER_STACK_USERNAME: - BROWSER_STACK_ACCESS_KEY: - BROWSER_STACK_BROWSERS_USERNAME: - BROWSER_STACK_BROWSERS_ACCESS_KEY: - USE_LEGACY_DRIVER: 1 - env_file: - - ${DOCKER_ENV_FILE:-test/browser/features/e2e/null_env} - browser-tests-bitbar: build: context: test/e2e/browser - dockerfile: Dockerfile.w3c args: BRANCH_NAME: - RUBY_VERSION: environment: <<: *common-environment BITBAR_USERNAME: diff --git a/dockerfiles/Dockerfile.ci-ruby-3 b/dockerfiles/Dockerfile.ci similarity index 94% rename from dockerfiles/Dockerfile.ci-ruby-3 rename to dockerfiles/Dockerfile.ci index 99c0a3193..23a61b2ba 100644 --- a/dockerfiles/Dockerfile.ci-ruby-3 +++ b/dockerfiles/Dockerfile.ci @@ -1,5 +1,5 @@ # Ruby image are based on Debian -FROM ruby:3.3-bullseye as ci-ruby-3 +FROM ruby:3.4-bullseye as ci RUN apt-get update && DEBIAN_FRONTEND=noninteractive \ apt-get install -y apt-utils wget unzip bash bundler \ @@ -38,9 +38,9 @@ COPY Gemfile* bugsnag-maze-runner.gemspec ./ RUN bundle install -FROM ci-ruby-3 as cli +FROM ci as cli ENTRYPOINT ["bundle", "exec", "maze-runner"] -FROM ci-ruby-3 as unit-test-ruby-3 +FROM ci as unit-test COPY test/ test/ COPY Rakefile . diff --git a/dockerfiles/Dockerfile.ci-ruby-2 b/dockerfiles/Dockerfile.ci-ruby-2 deleted file mode 100644 index f13da1ac6..000000000 --- a/dockerfiles/Dockerfile.ci-ruby-2 +++ /dev/null @@ -1,46 +0,0 @@ -# Ruby image are based on Debian -FROM ruby:2-bullseye as ci-ruby-2 - -RUN apt-get update && apt-get upgrade -y && DEBIAN_FRONTEND=noninteractive \ - apt-get install -y apt-utils wget unzip bash bundler \ - # Needed for symbolication - llvm-11 \ - # Needed to install docker compose - ca-certificates \ - curl \ - gnupg \ - lsb-release - -# https://docs.docker.com/engine/install/ubuntu/#set-up-the-repository -RUN mkdir -p /etc/apt/keyrings -RUN curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -RUN echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ - $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - -# install docker & docker compose -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin - -RUN ruby -v - -RUN wget -q https://storage.googleapis.com/bugsnag-public-test-dependencies/BrowserStackLocal-linux-x64-v8_4.zip \ - && unzip BrowserStackLocal-linux-x64-v8_4.zip \ - && rm BrowserStackLocal-linux-x64-v8_4.zip - -RUN wget -q https://sbsecuretunnel.s3.amazonaws.com/cli/linux/SBSecureTunnel \ - && chmod +x SBSecureTunnel - -WORKDIR /app/ - -COPY bin/ bin/ -COPY lib/ lib/ -COPY Gemfile* bugsnag-maze-runner.gemspec ./ - -RUN rm -f Gemfile.lock && USE_LEGACY_DRIVER=1 bundle install - -FROM ci-ruby-2 as cli-legacy -ENTRYPOINT ["bundle", "exec", "maze-runner"] - -FROM ci-ruby-2 as unit-test-ruby-2 -COPY test/ test/ -COPY Rakefile . diff --git a/dockerfiles/Dockerfile.w3c b/dockerfiles/Dockerfile.cli similarity index 100% rename from dockerfiles/Dockerfile.w3c rename to dockerfiles/Dockerfile.cli diff --git a/dockerfiles/Dockerfile.legacy b/dockerfiles/Dockerfile.legacy deleted file mode 100644 index c2dcb9d02..000000000 --- a/dockerfiles/Dockerfile.legacy +++ /dev/null @@ -1,4 +0,0 @@ -ARG BRANCH_NAME -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli-legacy - -WORKDIR /app diff --git a/docs/Device_Mode.md b/docs/Device_Mode.md index 6353df26a..aeeea775c 100644 --- a/docs/Device_Mode.md +++ b/docs/Device_Mode.md @@ -43,21 +43,6 @@ bundle exec maze-runner features/smoke_tests \ For BitBar, the `--device` option maps directly to the name of either a device, or a device group configured in the BitBar dashboard. Multiple device groups can also be listed, separated by a pipe. Maze Runner will select an available device from them at random. E.g. `--device=ANDROID_10|ANDROID_11`. -## Appium client modes - -By default, Maze Runner will use the latest version of `appium_lib`, the Ruby Appium library. For versions onwards, the library enforces the use of W3C mode, which in turn means that Appium server v1.15 or later must be used. If an earlier version is needed for any reason, this case be achieved by setting the `USE_LEGACY_DRIVER` environment variable when both `bundle install`ing the Gem and when executing it. `appium_lib` v11 will then be installed and JWP protocol employed. - -``` -rm Gemfile.lock -USE_LEGACY_DRIVER=1 bundle update -USE_LEGACY_DRIVER=1 bundle exec maze-runner features/smoke_tests \ - --app=fixture-debug.apk \ - --farm=bs \ - --device=ANDROID_9_0 -``` - -Note that the `Gemfile.lock` must also be removed when taking this approach. - ## Test fixture config files Test fixture apps need to know the netword address of the MAze Runner server in order to configure Bugsnag properly. Rather than having to hard code the address in test fixture code, Maze Runner had the concept of a test fixture configuration file. This is a JSON file written to disk locally under `maze_working/` and pushed onto the device using Appium. A test fixture can then read this file to find the address. Example file: diff --git a/docs/Test_Inputs.md b/docs/Test_Inputs.md index 9788c4cdc..b58a9c53f 100644 --- a/docs/Test_Inputs.md +++ b/docs/Test_Inputs.md @@ -27,7 +27,6 @@ Maze Runner recognises various environment variables, as follows: `MAZE_APPIUM_SERVER` - the Appium server URL (if different to the default). `MAZE_SELENIUM_SERVER` - the Selenium server URL (if different to the default). -`USE_LEGACY_DRIVER` - whether the legacy (JSON-WP) driver should be used. #### BitBar diff --git a/lib/features/steps/app_automator_steps.rb b/lib/features/steps/app_automator_steps.rb index e9fad3f66..010f4a914 100644 --- a/lib/features/steps/app_automator_steps.rb +++ b/lib/features/steps/app_automator_steps.rb @@ -49,38 +49,9 @@ Maze::Api::Appium::AppManager.new.background(timeout) end -# Clears a given element -# Requires a running Appium driver -# -# @step_input element_id [String] The locator id -# @deprecated To be removed in the next major version -When('I clear the element {string}') do |element_id| - Maze.driver.clear_element(element_id) -end - -# Sends keys to a given element -# Requires a running Appium driver -# -# @step_input keys [String] The keys to send to the element -# @step_input element_id [String] The locator id -# @deprecated To be removed in the next major version -When('I send the keys {string} to the element {string}') do |keys, element_id| - Maze.driver.send_keys_to_element(element_id, keys) -end - # Set the device orientation to either portrait or landscape # Requires a running Appium driver When('I set the device orientation to {orientation}') do |orientation| Maze::Api::Appium::DeviceManager.new.set_rotation orientation end -# Sends keys to a given element, clearing it first -# Requires a running Appium driver -# -# @step_input keys [String] The keys to send to the element -# @step_input element_id [String] The locator id -# @deprecated To be removed in the next major version -When('I clear and send the keys {string} to the element {string}') do |keys, element_id| - Maze.driver.clear_and_send_keys_to_element(element_id, keys) -end - diff --git a/lib/features/steps/deprecated_steps.rb b/lib/features/steps/deprecated_steps.rb deleted file mode 100644 index 8c0c5935b..000000000 --- a/lib/features/steps/deprecated_steps.rb +++ /dev/null @@ -1,8 +0,0 @@ -# @!group Deprecated steps - -# Waits for a given number of spans to be received, which may be spread across one or more trace requests. -# -# @step_input span_count [Integer] The number of spans to wait for -When('I wait for {int} span(s)') do |span_count| - assert_received_spans Maze::Server.list_for('traces'), span_count -end diff --git a/lib/features/steps/document_server_steps.rb b/lib/features/steps/document_server_steps.rb deleted file mode 100644 index e04f771f4..000000000 --- a/lib/features/steps/document_server_steps.rb +++ /dev/null @@ -1,7 +0,0 @@ -# @!group Document steps - -# Starts the document server manually. It will be stopped automatically at the end of each scenario -# (if started in this way). -When('I start the document server') do - Maze::DocumentServer.manual_start -end diff --git a/lib/features/steps/error_reporting_steps.rb b/lib/features/steps/error_reporting_steps.rb index 169e934ba..7abcbad58 100644 --- a/lib/features/steps/error_reporting_steps.rb +++ b/lib/features/steps/error_reporting_steps.rb @@ -136,14 +136,6 @@ step "the error payload field \"events.0.#{field}\" equals #{float_value} to #{places} decimal places" end -# Tests whether a value in the first event entry equals an integer. -# -# @step_input field [String] The relative location of the value to test -# @step_input value [Integer] The integer to test against -Then('the event {string} equals {int}') do |field, value| - step "the error payload field \"events.0.#{field}\" equals #{value}" -end - # Tests whether a value in the first event entry starts with a string. # # @step_input field [String] The relative location of the value to test diff --git a/lib/features/steps/payload_steps.rb b/lib/features/steps/payload_steps.rb index 4ac075c24..843744afb 100644 --- a/lib/features/steps/payload_steps.rb +++ b/lib/features/steps/payload_steps.rb @@ -76,16 +76,6 @@ Maze.check.not_nil(Maze::Helper.read_key_path(list.current[:body], field_path)) end -# Tests that a payload element equals an integer. -# -# @step_input request_type [String] The type of request (error, session, build, etc) -# @step_input field_path [String] Path to the tested element -# @step_input int_value [Integer] The value to test against -Then('the {request_type} payload field {string} equals {int}') do |request_type, field_path, int_value| - Maze.check.equal(int_value, - Maze::Helper.read_key_path(Maze::Server.list_for(request_type).current[:body], field_path)) -end - # Tests that a payload element equals a float. # # @step_input request_type [String] The type of request (error, session, build, etc) diff --git a/lib/features/support/internal_hooks.rb b/lib/features/support/internal_hooks.rb index 6a56b04ab..3d1c016b8 100644 --- a/lib/features/support/internal_hooks.rb +++ b/lib/features/support/internal_hooks.rb @@ -57,20 +57,11 @@ # Call any blocks registered by the client Maze.hooks.call_before_all - # Start document server, if asked for - # This must happen after any client hooks have run, so that they can set the server root - Maze::DocumentServer.start unless Maze.config.document_server_root.nil? - # Determine public IP if enabled if Maze.config.aws_public_ip public_ip = Maze::AwsPublicIp.new Maze.public_address = public_ip.address $logger.info "Public address: #{Maze.public_address}" - - unless Maze.config.document_server_root.nil? - Maze.public_document_server_address = public_ip.document_server_address - $logger.info "Public document server address: #{Maze.public_document_server_address}" - end end # An initial setup for total success status @@ -146,9 +137,6 @@ # Call any blocks registered by the client Maze.hooks.call_after scenario - # Stop document server if started by the Cucumber step - Maze::DocumentServer.manual_stop - # Stop terminating server if started by the Cucumber step Maze::TerminatingServer.stop diff --git a/lib/maze.rb b/lib/maze.rb index 3d87a47db..8df49c3ca 100644 --- a/lib/maze.rb +++ b/lib/maze.rb @@ -8,11 +8,11 @@ # providing an alternative to the proliferation of global variables or singletons. module Maze - VERSION = '9.36.0' + VERSION = '10.0.0' class << self attr_accessor :check, :driver, :internal_hooks, :mode, :start_time, :dynamic_retry, :public_address, - :public_document_server_address, :run_uuid, :scenario + :run_uuid, :scenario def config @config ||= Maze::Configuration.new diff --git a/lib/maze/aws_public_ip.rb b/lib/maze/aws_public_ip.rb index cd6fad135..436bdf50d 100644 --- a/lib/maze/aws_public_ip.rb +++ b/lib/maze/aws_public_ip.rb @@ -5,29 +5,17 @@ module Maze class AwsPublicIp attr_reader :host attr_reader :port - attr_reader :document_server_port def address "#{@ip}:#{@port}" end - def document_server_address - return nil if @document_server_port.nil? - - "#{@ip}:#{@document_server_port}" - end - def initialize # This class is only relevant on Buildkite return unless ENV['BUILDKITE'] @ip = determine_public_ip @port = determine_public_port Maze.config.port - - unless Maze.config.document_server_root.nil? - @document_server_port = determine_public_port Maze.config.document_server_port - end - end # Determines the public IP address of the running AWS instance diff --git a/lib/maze/client/appium.rb b/lib/maze/client/appium.rb index f4dc8743b..0ce42a026 100644 --- a/lib/maze/client/appium.rb +++ b/lib/maze/client/appium.rb @@ -5,14 +5,7 @@ def self.start client_class = case Maze.config.farm when :bb then BitBarClient - when :bs - if Maze.config.legacy_driver? - $logger.info 'Using the Legacy (JWP) Appium client' - BrowserStackLegacyClient - else - $logger.info 'Using the W3C Appium client' - BrowserStackClient - end + when :bs then BrowserStackClient when :local then LocalClient end diff --git a/lib/maze/client/appium/bb_client.rb b/lib/maze/client/appium/bb_client.rb index 6f477d995..f1aaf7204 100644 --- a/lib/maze/client/appium/bb_client.rb +++ b/lib/maze/client/appium/bb_client.rb @@ -51,12 +51,10 @@ def handle_error(error) end def start_scenario - unless Maze.config.legacy_driver? - # Write Maze's address to file and push to the device - maze_address = Maze.public_address || "local:#{Maze.config.port}" - Maze::Api::Appium::FileManager.new.write_app_file(JSON.generate({ maze_address: maze_address }), - FIXTURE_CONFIG) - end + # Write Maze's address to file and push to the device + maze_address = Maze.public_address || "local:#{Maze.config.port}" + Maze::Api::Appium::FileManager.new.write_app_file(JSON.generate({ maze_address: maze_address }), + FIXTURE_CONFIG) super end diff --git a/lib/maze/client/appium/bs_client.rb b/lib/maze/client/appium/bs_client.rb index c6d9f1374..f280f558f 100644 --- a/lib/maze/client/appium/bs_client.rb +++ b/lib/maze/client/appium/bs_client.rb @@ -31,12 +31,10 @@ def handle_error(error) end def start_scenario - unless Maze.config.legacy_driver? - # Write Maze's address to file and push to the device - maze_address = "bs-local.com:#{Maze.config.port}" - Maze::Api::Appium::FileManager.new.write_app_file(JSON.generate({ maze_address: maze_address }), - FIXTURE_CONFIG) - end + # Write Maze's address to file and push to the device + maze_address = "bs-local.com:#{Maze.config.port}" + Maze::Api::Appium::FileManager.new.write_app_file(JSON.generate({ maze_address: maze_address }), + FIXTURE_CONFIG) super end diff --git a/lib/maze/client/appium/bs_legacy_client.rb b/lib/maze/client/appium/bs_legacy_client.rb deleted file mode 100644 index ca4f57e0f..000000000 --- a/lib/maze/client/appium/bs_legacy_client.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Maze - module Client - module Appium - class BrowserStackLegacyClient < BrowserStackClient - def device_capabilities - config = Maze.config - capabilities = { - 'app' => config.app, - 'browserstack.console' => 'errors', - 'deviceOrientation' => 'portrait', - 'noReset' => 'true' - } - device_caps = Maze::Client::Appium::BrowserStackDevices::DEVICE_HASH[config.device] - capabilities.deep_merge! device_caps - capabilities.deep_merge! JSON.parse(config.capabilities_option) - capabilities.merge! project_name_capabilities - capabilities['browserstack.appium_version'] = config.appium_version unless config.appium_version.nil? - unless device_caps['platformName'] == 'android' && device_caps['platformVersion'].to_i <= 6 - capabilities['disableAnimations'] = 'true' - end - if Maze.config.start_tunnel - capabilities['browserstack.localIdentifier'] = Maze.run_uuid - capabilities['browserstack.local'] = 'true' - end - - capabilities - end - end - end - end -end diff --git a/lib/maze/client/selenium/bs_client.rb b/lib/maze/client/selenium/bs_client.rb index a9647beef..2fe3145c5 100644 --- a/lib/maze/client/selenium/bs_client.rb +++ b/lib/maze/client/selenium/bs_client.rb @@ -23,45 +23,23 @@ def start_session end def create_capabilities(config) - if config.legacy_driver? - capabilities = ::Selenium::WebDriver::Remote::Capabilities.new - capabilities['browserstack.local'] = 'true' - capabilities['browserstack.localIdentifier'] = Maze.run_uuid - capabilities['browserstack.console'] = 'errors' - capabilities['acceptInsecureCerts'] = 'true' - capabilities.merge! JSON.parse(config.capabilities_option) - capabilities.merge! project_name_capabilities - add_browser_capabilities(config, capabilities) - else - raw_capabilities = { - 'acceptInsecureCerts' => true, - 'bstack:options' => { - 'local' => 'true', - 'localIdentifier' => Maze.run_uuid - } + raw_capabilities = { + 'acceptInsecureCerts' => true, + 'bstack:options' => { + 'local' => 'true', + 'localIdentifier' => Maze.run_uuid } - raw_capabilities.deep_merge! JSON.parse(config.capabilities_option) - raw_capabilities.merge! project_name_capabilities - add_browser_capabilities(config, raw_capabilities) - capabilities = ::Selenium::WebDriver::Remote::Capabilities.new raw_capabilities - end + } + raw_capabilities.deep_merge! JSON.parse(config.capabilities_option) + raw_capabilities.merge! project_name_capabilities + add_browser_capabilities(config, raw_capabilities) + capabilities = ::Selenium::WebDriver::Remote::Capabilities.new raw_capabilities config.capabilities = capabilities end def add_browser_capabilities(config, capabilities) browsers = YAML.safe_load(File.read("#{__dir__}/bs_browsers.yml")) - browser = browsers[config.browser] - - if config.legacy_driver? - # Convert W3S capabilities to JSON-WP - capabilities['browser'] = browser['browserName'] - capabilities['browser_version'] = browser['browserVersion'] - capabilities['device'] = browser['device'] - capabilities['os'] = browser['os'] - capabilities['os_version'] = browser['osVersion'] - else - capabilities.deep_merge! browser - end + capabilities.deep_merge! browsers[config.browser] end def stop_session diff --git a/lib/maze/configuration.rb b/lib/maze/configuration.rb index f922921d9..ab1f8425d 100644 --- a/lib/maze/configuration.rb +++ b/lib/maze/configuration.rb @@ -15,7 +15,6 @@ def initialize self.span_timestamp_validation = true self.unmanaged_traces_mode = false self.client_mode_validation = true - @legacy_driver = false end # @@ -41,12 +40,6 @@ def initialize # Document server root attr_accessor :document_server_root - # Document server bind address - attr_accessor :document_server_bind_address - - # Document server port - attr_accessor :document_server_port - # # Common configuration # @@ -194,15 +187,6 @@ def skip_default_validation(endpoint) # URL of the Selenium server attr_accessor :selenium_server_url - # Whether the legacy (JSON-WP) Appium driver should be used - def legacy_driver? - @legacy_driver - end - - def legacy_driver=(value) - @legacy_driver = value - end - # # Local testing specific configuration # diff --git a/lib/maze/document_server.rb b/lib/maze/document_server.rb deleted file mode 100644 index a59a6fdba..000000000 --- a/lib/maze/document_server.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -require 'webrick' - -module Maze - # HTTP server for a given document root - class DocumentServer - class << self - # Start the document server. This is intended to be called only once per test run. - # Use manual_start for finer grained control. - def start - @thread = Thread.new do - options = { - DocumentRoot: Maze.config.document_server_root, - Port: Maze.config.document_server_port, - Logger: $logger, - AccessLog: [] - } - options[:BindAddress] = Maze.config.document_server_bind_address unless Maze.config.document_server_bind_address.nil? - server = WEBrick::HTTPServer.new(options) - server.mount '/reflect', Servlets::ReflectiveServlet - - $logger.info "Starting document server for root: #{Maze.config.document_server_root}" - server.start - end - end - - # Starts the document server "manually" (via a Cucumber step as opposed to command line option) - def manual_start - if !@thread.nil? && @thread.alive? - $logger.warn 'Document Server has already been started on the command line, ignoring manual start' - return - end - @manual_start = true - start - end - - def manual_stop - return unless @manual_start - - @thread.kill - @manual_start = false - end - end - end -end diff --git a/lib/maze/driver/appium.rb b/lib/maze/driver/appium.rb index 91bdd53ad..8dcb0bc64 100644 --- a/lib/maze/driver/appium.rb +++ b/lib/maze/driver/appium.rb @@ -40,8 +40,6 @@ def initialize(server_url, capabilities, locator = :id) # Timers @find_element_timer = Maze.timers.add 'Appium - find element' @click_element_timer = Maze.timers.add 'Appium - click element' - @clear_element_timer = Maze.timers.add 'Appium - clear element' - @send_keys_timer = Maze.timers.add 'Appium - send keys to element' super({ 'caps' => @capabilities, @@ -168,20 +166,6 @@ def click_element_if_present(element_id) raise e end - # Clears a given element - # - # @param element_id [String] the element to clear - def clear_element(element_id) - element = find_element_timed(element_id) - @clear_element_timer.time do - element.clear - end - rescue Selenium::WebDriver::Error::ServerError => e - # Assume the remote appium session has stopped, so crash out of the session - fail_driver(e) - raise e - end - # Gets the application hierarchy XML def page_source @driver.page_source @@ -192,21 +176,6 @@ def unlock @driver.unlock end - # Sends keys to a given element - # - # @param element_id [String] the element to send text to - # @param text [String] the text to send - def send_keys_to_element(element_id, text) - element = find_element_timed(element_id) - @send_keys_timer.time do - element.send_keys(text) - end - rescue Selenium::WebDriver::Error::ServerError => e - # Assume the remote appium session has stopped, so crash out of the session - fail_driver(e) - raise e - end - # Sets the rotation of the device # # @param orientation [Symbol] :portrait or :landscape @@ -218,40 +187,6 @@ def window_size @driver.window_size end - # Send keys to the device without a specific element - # - # @param text [String] the text to send - def send_keys(text) - @driver.send_keys(text) - end - - # Sends keys to a given element, clearing it first - # - # @param element_id [String] the element to clear and send text to - # @param text [String] the text to send - def clear_and_send_keys_to_element(element_id, text) - element = find_element_timed(element_id) - @clear_element_timer.time do - element.clear - end - - @send_keys_timer.time do - element.send_keys(text) - end - rescue Selenium::WebDriver::Error::ServerError => e - # Assume the remote appium session has stopped, so crash out of the session - fail_driver(e) - raise e - end - - # Reset the currently running application after a given timeout - # - # @param timeout [Number] the amount of time in seconds to wait before resetting - def reset_with_timeout(timeout = 0.1) - sleep(timeout) - reset - end - def device_info driver.execute_script('mobile:deviceInfo') end diff --git a/lib/maze/driver/browser.rb b/lib/maze/driver/browser.rb index 297150357..eb0b866e0 100644 --- a/lib/maze/driver/browser.rb +++ b/lib/maze/driver/browser.rb @@ -128,15 +128,9 @@ def create_driver(driver_for, selenium_url=nil) $logger.info "Starting Selenium driver" time = Time.now if driver_for == :remote - if Maze.config.legacy_driver? - driver = ::Selenium::WebDriver.for :remote, - url: selenium_url, - desired_capabilities: @capabilities - else - driver = ::Selenium::WebDriver.for :remote, - url: selenium_url, - capabilities: @capabilities - end + driver = ::Selenium::WebDriver.for :remote, + url: selenium_url, + capabilities: @capabilities else if driver_for == :chrome options = Selenium::WebDriver::Options.chrome diff --git a/lib/maze/option.rb b/lib/maze/option.rb index 0e6c87020..db2caa251 100644 --- a/lib/maze/option.rb +++ b/lib/maze/option.rb @@ -3,10 +3,6 @@ # Provides the set of Maze Runner command line options module Maze module Option - # Document server options - DS_BIND_ADDRESS = 'document-server-bind-address' - DS_PORT = 'document-server-port' - # Server options HTTPS = 'https' BIND_ADDRESS = 'bind-address' diff --git a/lib/maze/option/parser.rb b/lib/maze/option/parser.rb index 58458cd6e..f801561b1 100644 --- a/lib/maze/option/parser.rb +++ b/lib/maze/option/parser.rb @@ -85,14 +85,6 @@ def parse(args) 'Document server root', short: :none, type: :string - opt Option::DS_BIND_ADDRESS, - 'Document server bind address', - short: :none, - type: :string - opt Option::DS_PORT, - 'Document server port', - short: :none, - default: 9340 text '' text 'Appium options:' diff --git a/lib/maze/option/processor.rb b/lib/maze/option/processor.rb index 5d8e17ecd..9dee3ce8c 100644 --- a/lib/maze/option/processor.rb +++ b/lib/maze/option/processor.rb @@ -29,8 +29,6 @@ def populate(config, options) # Document server options config.document_server_root = options[Maze::Option::DS_ROOT] - config.document_server_bind_address = options[Maze::Option::DS_BIND_ADDRESS] - config.document_server_port = options[Maze::Option::DS_PORT] # Logger options config.file_log = options[Maze::Option::FILE_LOG] @@ -52,7 +50,6 @@ def populate(config, options) config.capabilities_option = options[Maze::Option::CAPABILITIES] config.app_activity = options[Maze::Option::APP_ACTIVITY] config.app_package = options[Maze::Option::APP_PACKAGE] - config.legacy_driver = !ENV['USE_LEGACY_DRIVER'].nil? config.start_tunnel = options[Maze::Option::TUNNEL] # Farm specific options @@ -63,11 +60,7 @@ def populate(config, options) if !device_option.empty? config.device = device_option.first config.device_list = device_option.drop(1) - if config.legacy_driver? - config.os_version = Maze::Client::Appium::BrowserStackDevices::DEVICE_HASH[config.device]['os_version'].to_f - else - config.os_version = Maze::Client::Appium::BrowserStackDevices::DEVICE_HASH[config.device]['platformVersion'].to_f - end + config.os_version = Maze::Client::Appium::BrowserStackDevices::DEVICE_HASH[config.device]['platformVersion'].to_f elsif !browser_option.empty? config.browser = browser_option.first config.browser_list = browser_option.drop(1) diff --git a/lib/maze/plugins/global_retry_plugin.rb b/lib/maze/plugins/global_retry_plugin.rb index b2d2efa6c..80e25c91a 100644 --- a/lib/maze/plugins/global_retry_plugin.rb +++ b/lib/maze/plugins/global_retry_plugin.rb @@ -23,7 +23,7 @@ def test_case(test_case) configuration.options[:retry] = 0 # Guard to check if the case should be retried - should_retry = event.result.failed? && Maze::RetryHandler.should_retry?(test_case, event) + should_retry = event.result.failed? && Maze::RetryHandler.should_retry?(test_case) next unless should_retry diff --git a/lib/maze/retry_handler.rb b/lib/maze/retry_handler.rb index 21b81094a..7195fd4cf 100644 --- a/lib/maze/retry_handler.rb +++ b/lib/maze/retry_handler.rb @@ -14,25 +14,11 @@ class << self # Determines whether a failed test_case should be restarted # # @param test_case [Cucumber::RunningTestCase] The current test_case or scenario - # @param event [Cucumber::Core::Event] The triggering event - def should_retry?(test_case, event) + def should_retry?(test_case) # Only retry if the option is set and we haven't already retried return false if !Maze.config.enable_retries || retried_previously?(test_case) - if retry_on_driver_error?(event) - if Maze.mode == :appium - if Maze.config.farm.eql?(:bb) - Maze::Hooks::ErrorCodeHook.exit_code = Maze::Api::ExitCode::APPIUM_SESSION_FAILURE - return false - else - $logger.warn "Retrying #{test_case.name} due to appium driver error: #{event.result.exception}" - Maze.driver.restart - end - elsif Maze.mode == :browser - $logger.warn "Retrying #{test_case.name} due to selenium driver error: #{event.result.exception}" - Maze.driver.refresh - end - elsif retry_on_tag?(test_case) + if retry_on_tag?(test_case) $logger.warn "Retrying #{test_case.name} due to retry tag" elsif Maze.dynamic_retry $logger.warn "Retrying #{test_case.name} due to dynamic retry set" @@ -53,12 +39,6 @@ def increment_retry_count(test_case) global_retried[test_case] += 1 end - def retry_on_driver_error?(event) - error_class = event.result.exception.class - maze_errors = Maze::Error::ERROR_CODES - Maze.driver && maze_errors.include?(error_class) && maze_errors[error_class][:retry] - end - def retry_on_tag?(test_case) test_case.tags.any? do |tag| RETRY_TAGS.include?(tag.name) diff --git a/test/e2e/browser/Dockerfile.w3c b/test/e2e/browser/Dockerfile similarity index 100% rename from test/e2e/browser/Dockerfile.w3c rename to test/e2e/browser/Dockerfile diff --git a/test/e2e/browser/Dockerfile.legacy b/test/e2e/browser/Dockerfile.legacy deleted file mode 100644 index c47137c93..000000000 --- a/test/e2e/browser/Dockerfile.legacy +++ /dev/null @@ -1,5 +0,0 @@ -ARG BRANCH_NAME -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli-legacy AS browserstack-app-automate - -COPY . /app -WORKDIR /app diff --git a/test/e2e/cli/Dockerfile b/test/e2e/cli/Dockerfile index 539ff9540..9dcc52b67 100644 --- a/test/e2e/cli/Dockerfile +++ b/test/e2e/cli/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci RUN curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - RUN sudo apt-get install -y nodejs diff --git a/test/e2e/command-workflow/Dockerfile b/test/e2e/command-workflow/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/command-workflow/Dockerfile +++ b/test/e2e/command-workflow/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/e2e/comparison/Dockerfile b/test/e2e/comparison/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/comparison/Dockerfile +++ b/test/e2e/comparison/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/e2e/doc-server/Dockerfile b/test/e2e/doc-server/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/doc-server/Dockerfile +++ b/test/e2e/doc-server/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/e2e/doc-server/features/doc_server.feature b/test/e2e/doc-server/features/doc_server.feature index cee870608..2c746234f 100644 --- a/test/e2e/doc-server/features/doc_server.feature +++ b/test/e2e/doc-server/features/doc_server.feature @@ -19,20 +19,4 @@ Feature: Using the document server And I start a timer And I make a reflective "POST-WITH-QUERY" request on port "9339" with status "418" and delay of "2000" Then the status code for the last reflective request was "418" - And at least 2000 ms have passed - - Scenario: Reflective requests with the document server - When I start a timer - And I make a reflective "GET" request on port "9340" with status "202" and delay of "2000" - Then the status code for the last reflective request was "202" - And at least 2000 ms have passed - - And I start a timer - And I make a reflective "POST" request on port "9340" with status "567" and delay of "2000" - Then the status code for the last reflective request was "567" - And at least 2000 ms have passed - - And I start a timer - And I make a reflective "POST-WITH-QUERY" request on port "9340" with status "418" and delay of "2000" - Then the status code for the last reflective request was "418" - And at least 2000 ms have passed + And at least 2000 ms have passed \ No newline at end of file diff --git a/test/e2e/doc-server/features/scripts/get_and_post.sh b/test/e2e/doc-server/features/scripts/get_and_post.sh index 6d9286667..e6f3711a4 100755 --- a/test/e2e/doc-server/features/scripts/get_and_post.sh +++ b/test/e2e/doc-server/features/scripts/get_and_post.sh @@ -1,2 +1,2 @@ -curl http://localhost:9340/payload.json -o payload.json +curl http://localhost:9339/docs/payload.json -o payload.json curl -X POST -d @payload.json -H "Content-Type: application/json" http://localhost:9339/notify diff --git a/test/e2e/docker-app/Dockerfile b/test/e2e/docker-app/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/docker-app/Dockerfile +++ b/test/e2e/docker-app/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/e2e/exit-codes/Dockerfile b/test/e2e/exit-codes/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/exit-codes/Dockerfile +++ b/test/e2e/exit-codes/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/e2e/framework/Dockerfile b/test/e2e/framework/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/framework/Dockerfile +++ b/test/e2e/framework/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/e2e/http-response/Dockerfile b/test/e2e/http-response/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/http-response/Dockerfile +++ b/test/e2e/http-response/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/e2e/payload-helpers/Dockerfile b/test/e2e/payload-helpers/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/payload-helpers/Dockerfile +++ b/test/e2e/payload-helpers/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/e2e/payload-helpers/features/support/send_request.rb b/test/e2e/payload-helpers/features/support/send_request.rb index 5475a6119..ceb66344e 100755 --- a/test/e2e/payload-helpers/features/support/send_request.rb +++ b/test/e2e/payload-helpers/features/support/send_request.rb @@ -600,7 +600,7 @@ def send_request(request_type, mock_api_port = 9339) { "key": "browser.page.url", "value": { - "stringValue": "http://localhost:9340/manual-span/?ENDPOINT=http://localhost:9339/traces&LOGS=http://localhost:9339/logs&API_KEY=b3ad5c823d527e720d9beb4767efda18" + "stringValue": "http://localhost:9339/docs/manual-span/?ENDPOINT=http://localhost:9339/traces&LOGS=http://localhost:9339/logs&API_KEY=b3ad5c823d527e720d9beb4767efda18" } } ] diff --git a/test/e2e/proxy/Dockerfile b/test/e2e/proxy/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/proxy/Dockerfile +++ b/test/e2e/proxy/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/e2e/validation/Dockerfile b/test/e2e/validation/Dockerfile index bc116c964..ad7654ddf 100644 --- a/test/e2e/validation/Dockerfile +++ b/test/e2e/validation/Dockerfile @@ -1,6 +1,5 @@ ARG BRANCH_NAME -ARG RUBY_VERSION -FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci-ruby-${RUBY_VERSION} +FROM 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-ci COPY . /app WORKDIR /app diff --git a/test/unit/maze/driver/driver_test.rb b/test/unit/maze/driver/driver_test.rb index f30e23cc6..3d8f7f166 100644 --- a/test/unit/maze/driver/driver_test.rb +++ b/test/unit/maze/driver/driver_test.rb @@ -164,80 +164,6 @@ def test_wait_for_element_stale_error_retry_only_once $logger = nil end - def test_clear_element_defaults - start_logger_mock - driver = Maze::Driver::Appium.new SERVER_URL, @capabilities - - mocked_element = mock('element') - mocked_element.expects(:clear) - - driver.expects(:find_element).with(:id, 'test_text_entry').returns(mocked_element) - - driver.clear_element('test_text_entry') - end - - def test_send_keys_to_element_defaults - start_logger_mock - driver = Maze::Driver::Appium.new SERVER_URL, @capabilities - - mocked_element = mock('element') - mocked_element.expects(:send_keys).with('Test_text') - - driver.expects(:find_element).with(:id, 'test_text_entry').returns(mocked_element) - - driver.send_keys_to_element('test_text_entry', 'Test_text') - end - - def test_clear_and_send_keys_to_element_defaults - start_logger_mock - driver = Maze::Driver::Appium.new SERVER_URL, @capabilities - - mocked_element = mock('element') - mocked_element.expects(:clear) - mocked_element.expects(:send_keys).with('Test_text') - - driver.expects(:find_element).with(:id, 'test_text_entry').returns(mocked_element) - - driver.clear_and_send_keys_to_element('test_text_entry', 'Test_text') - end - - def test_clear_element_locator - start_logger_mock - driver = Maze::Driver::Appium.new SERVER_URL, @capabilities, :accessibility_id - - mocked_element = mock('element') - mocked_element.expects(:clear) - - driver.expects(:find_element).with(:accessibility_id, 'test_text_entry').returns(mocked_element) - - driver.clear_element('test_text_entry') - end - - def test_send_keys_to_element_locator - start_logger_mock - driver = Maze::Driver::Appium.new SERVER_URL, @capabilities, :accessibility_id - - mocked_element = mock('element') - mocked_element.expects(:send_keys).with('Test_text') - - driver.expects(:find_element).with(:accessibility_id, 'test_text_entry').returns(mocked_element) - - driver.send_keys_to_element('test_text_entry', 'Test_text') - end - - def test_clear_and_send_keys_to_element_locator - start_logger_mock - driver = Maze::Driver::Appium.new SERVER_URL, @capabilities, :accessibility_id - - mocked_element = mock('element') - mocked_element.expects(:clear) - mocked_element.expects(:send_keys).with('Test_text') - - driver.expects(:find_element).with(:accessibility_id, 'test_text_entry').returns(mocked_element) - - driver.clear_and_send_keys_to_element('test_text_entry', 'Test_text') - end - def test_start_driver_success logger = start_logger_mock diff --git a/test/unit/maze/option/processor_test.rb b/test/unit/maze/option/processor_test.rb index 6655374e0..88b5bd346 100644 --- a/test/unit/maze/option/processor_test.rb +++ b/test/unit/maze/option/processor_test.rb @@ -37,8 +37,6 @@ def test_populate_local_config assert_equal '1.2.3.4', config.bind_address assert_equal 1234, config.port assert_equal 'root', config.document_server_root - assert_equal '5.6.7.8', config.document_server_bind_address - assert_equal 5678, config.document_server_port assert_false config.start_appium assert_equal '123456789012345678901234567890ab', config.bugsnag_repeater_api_key assert_equal '000006789012345678901234567890ab', config.hub_repeater_api_key @@ -58,8 +56,6 @@ def test_populate_local_config_defaults assert_equal 'ABC', config.apple_team_id assert_equal '123', config.device_id assert_equal 'root', config.document_server_root - assert_equal '5.6.7.8', config.document_server_bind_address - assert_equal 5678, config.document_server_port assert_false config.start_appium assert_nil config.os_version @@ -87,8 +83,6 @@ def test_default_options assert_equal nil, config.bind_address assert_equal 9339, config.port assert_equal nil, config.document_server_root - assert_equal nil, config.document_server_bind_address - assert_equal 9340, config.document_server_port assert_equal :id, config.locator assert_nil config.capabilities @@ -115,8 +109,6 @@ def test_overriden_defaults assert_equal 1234, config.port assert_equal nil, config.document_server_root - assert_equal nil, config.document_server_bind_address - assert_equal 9340, config.document_server_port assert_equal :id, config.locator assert_nil config.capabilities @@ -180,15 +172,4 @@ def test_repeater_key_responses ENV.delete('MAZE_HUB_REPEATER_API_KEY') end - def test_environment_options - ENV['USE_LEGACY_DRIVER'] = '1' - ENV['MAZE_PORT'] = '1234' - - args = [] - options = Maze::Option::Parser.parse args - config = Maze::Configuration.new - Maze::Option::Processor.populate config, options - - assert_true config.legacy_driver? - end end diff --git a/test/unit/maze/retry_handler_test.rb b/test/unit/maze/retry_handler_test.rb index 2c0664f1e..05b5261f8 100644 --- a/test/unit/maze/retry_handler_test.rb +++ b/test/unit/maze/retry_handler_test.rb @@ -87,151 +87,7 @@ def test_retry_on_tag_no_tags assert_false(Maze::RetryHandler.send(:retry_on_tag?, test_case_invalid_tags)) end - def test_retry_on_driver_no_maze_driver - Maze.expects(:driver).returns(nil) - - result_mock = mock('result') - result_mock.expects(:exception).returns(Selenium::WebDriver::Error::UnknownError.new) - - event_mock = mock('event') - event_mock.expects(:result).returns(result_mock) - - assert_nil(Maze::RetryHandler.send(:retry_on_driver_error?, event_mock)) - end - - def test_retry_on_driver_errors - Maze.expects(:driver).times(3).returns(true) - - result_unknown_mock = mock('result') - result_unknown_mock.expects(:exception).returns(Selenium::WebDriver::Error::UnknownError.new) - - event_unknown_error_mock = mock('event') - event_unknown_error_mock.expects(:result).returns(result_unknown_mock) - - assert_true(Maze::RetryHandler.send(:retry_on_driver_error?, event_unknown_error_mock)) - - result_web_driver_mock = mock('result') - result_web_driver_mock.expects(:exception).returns(Selenium::WebDriver::Error::WebDriverError.new) - - event_web_driver_error_mock = mock('event') - event_web_driver_error_mock.expects(:result).returns(result_web_driver_mock) - - assert_true(Maze::RetryHandler.send(:retry_on_driver_error?, event_web_driver_error_mock)) - - result_element_not_found_mock = mock('result') - result_element_not_found_mock.expects(:exception).returns(Maze::Error::AppiumElementNotFoundError.new) - - event_element_not_found_mock = mock('event') - event_element_not_found_mock.expects(:result).returns(result_element_not_found_mock) - - assert_true(Maze::RetryHandler.send(:retry_on_driver_error?, event_element_not_found_mock)) - end - - def test_retry_on_driver_error_wrong_error - Maze.expects(:driver).returns(true) - - result_incorrect_mock = mock('result') - result_incorrect_mock.expects(:exception).returns(RuntimeError.new) - - event_incorrect_error_mock = mock('event') - event_incorrect_error_mock.expects(:result).returns(result_incorrect_mock) - - assert_false(Maze::RetryHandler.send(:retry_on_driver_error?, event_incorrect_error_mock)) - end - - def test_retry_on_driver_error_no_errors - Maze.expects(:driver).returns(true) - - result_no_error_mock = mock('result') - result_no_error_mock.expects(:exception).returns(nil) - - event_no_error_mock = mock('event') - event_no_error_mock.expects(:result).returns(result_no_error_mock) - - assert_false(Maze::RetryHandler.send(:retry_on_driver_error?, event_no_error_mock)) - end - - def test_should_retry_appium_driver_not_bb_error - Maze.mode = :appium - driver_mock = mock('driver') - Maze.expects(:driver).times(2).returns(driver_mock) - driver_mock.expects(:restart) - - test_case_mock = mock('test_case') - test_case_mock.expects(:name).returns('test_case_mock') - - error = Selenium::WebDriver::Error::UnknownError.new - - result_mock = mock('result') - result_mock.expects(:exception).twice.returns(error) - - event_mock = mock('event') - event_mock.expects(:result).twice.returns(result_mock) - - @logger_mock.expects('warn').with("Retrying test_case_mock due to appium driver error: #{error}") - @config_mock.expects('farm').returns(:bs) - - assert_true(Maze::RetryHandler.should_retry?(test_case_mock, event_mock)) - - global_retried = Maze::RetryHandler.send(:global_retried) - assert_equal(global_retried[test_case_mock], 1) - end - - def test_should_not_retry_appium_driver_bb_error - Maze.mode = :appium - - driver_mock = mock('driver') - Maze.expects(:driver).once.returns(driver_mock) - - test_case_mock = mock('test_case') - - error = Selenium::WebDriver::Error::UnknownError.new - - result_mock = mock('result') - result_mock.expects(:exception).once.returns(error) - - event_mock = mock('event') - event_mock.expects(:result).once.returns(result_mock) - - @config_mock.expects('farm').returns(:bb) - - Maze::Hooks::ErrorCodeHook.expects(:exit_code=).with(Maze::Api::ExitCode::APPIUM_SESSION_FAILURE) - - assert_false(Maze::RetryHandler.should_retry?(test_case_mock, event_mock)) - - global_retried = Maze::RetryHandler.send(:global_retried) - assert_equal(global_retried[test_case_mock], 0) - end - - def test_should_retry_browser_driver_error - Maze.mode = :browser - driver_mock = mock('driver') - Maze.expects(:driver).times(2).returns(driver_mock) - driver_mock.expects(:refresh) - - test_case_mock = mock('test_case') - test_case_mock.expects(:name).returns('test_case_mock') - - error = Selenium::WebDriver::Error::UnknownError.new - - result_mock = mock('result') - result_mock.expects(:exception).twice.returns(error) - - event_mock = mock('event') - event_mock.expects(:result).twice.returns(result_mock) - - @logger_mock.expects('warn').with("Retrying test_case_mock due to selenium driver error: #{error}") - - assert_true(Maze::RetryHandler.should_retry?(test_case_mock, event_mock)) - - global_retried = Maze::RetryHandler.send(:global_retried) - assert_equal(global_retried[test_case_mock], 1) - end - def test_should_retry_tag - driver_mock = mock('driver') - Maze.expects(:driver).returns(driver_mock) - retry_tag = mock('retry_tag') retry_tag.expects(:name).returns('@retry') @@ -239,43 +95,25 @@ def test_should_retry_tag test_case_mock.expects(:name).returns('test_case_mock') test_case_mock.expects(:tags).returns([retry_tag]) - result_mock = mock('result') - result_mock.expects(:exception).returns(nil) - - event_mock = mock('event') - event_mock.expects(:result).returns(result_mock) - @logger_mock.expects('warn').with("Retrying test_case_mock due to retry tag") - assert_true(Maze::RetryHandler.should_retry?(test_case_mock, event_mock)) + assert_true(Maze::RetryHandler.should_retry?(test_case_mock)) global_retried = Maze::RetryHandler.send(:global_retried) assert_equal(global_retried[test_case_mock], 1) end def test_should_retry_invalid - driver_mock = mock('driver') - Maze.expects(:driver).returns(driver_mock) - test_case_mock = mock('test_case') test_case_mock.expects(:tags).returns([]) - result_mock = mock('result') - result_mock.expects(:exception).returns(nil) - - event_mock = mock('event') - event_mock.expects(:result).returns(result_mock) - - assert_false(Maze::RetryHandler.should_retry?(test_case_mock, event_mock)) + assert_false(Maze::RetryHandler.should_retry?(test_case_mock)) global_retried = Maze::RetryHandler.send(:global_retried) assert_equal(global_retried[test_case_mock], 0) end def test_should_retry_repeated - driver_mock = mock('driver') - Maze.expects(:driver).returns(driver_mock) - retry_tag = mock('retry_tag') retry_tag.expects(:name).returns('@retry') @@ -283,17 +121,11 @@ def test_should_retry_repeated test_case_mock.expects(:name).returns('test_case_mock') test_case_mock.expects(:tags).returns([retry_tag]) - result_mock = mock('result') - result_mock.expects(:exception).returns(nil) - - event_mock = mock('event') - event_mock.expects(:result).returns(result_mock) - @logger_mock.expects('warn').with("Retrying test_case_mock due to retry tag") - assert_true(Maze::RetryHandler.should_retry?(test_case_mock, event_mock)) + assert_true(Maze::RetryHandler.should_retry?(test_case_mock)) - assert_false(Maze::RetryHandler.should_retry?(test_case_mock, event_mock)) + assert_false(Maze::RetryHandler.should_retry?(test_case_mock)) end def test_should_retry_disabled @@ -301,8 +133,7 @@ def test_should_retry_disabled @config_mock.expects(:enable_retries).returns(false) test_case_mock = mock('test_case') - event_mock = mock('event') - assert_false(Maze::RetryHandler.should_retry?(test_case_mock, event_mock)) + assert_false(Maze::RetryHandler.should_retry?(test_case_mock)) end end diff --git a/test/unit/maze/schemas/trace_validation_test.rb b/test/unit/maze/schemas/trace_validation_test.rb index 2fb3c0730..2533f2d97 100644 --- a/test/unit/maze/schemas/trace_validation_test.rb +++ b/test/unit/maze/schemas/trace_validation_test.rb @@ -177,10 +177,12 @@ def test_contains_key_value_and_options_failure } ] })) - validator.span_element_contains('value', 'correct', 'stringValue', ['good', 'one']) + validator.span_element_contains('value', 'correct', 'stringValue', %w[good one]) assert_false(validator.success) assert_equal(1, validator.errors.size) - assert_equal(validator.errors.first, "Element 'value':'{\"key\"=>\"correct\", \"value\"=>{\"stringValue\"=>\"done\"}}' did not contain a value of 'stringValue' from '[\"good\", \"one\"]'") + + hash = {"key"=>"correct", "value"=>{"stringValue"=>"done"}}.to_s + assert_equal(validator.errors.first, "Element 'value':'#{hash}' did not contain a value of 'stringValue' from '[\"good\", \"one\"]'") end def test_contains_key_value_and_options_value_type_missing_failure @@ -200,10 +202,11 @@ def test_contains_key_value_and_options_value_type_missing_failure } ] })) - validator.span_element_contains('value', 'correct', 'intValue', ['good', 'one']) + validator.span_element_contains('value', 'correct', 'intValue', %w[good one]) assert_false(validator.success) assert_equal(1, validator.errors.size) - assert_equal(validator.errors.first, "Element 'value':'{\"key\"=>\"correct\", \"value\"=>{\"stringValue\"=>\"done\"}}' did not contain a value of 'intValue' from '[\"good\", \"one\"]'") + hash = {"key"=>"correct", "value"=>{"stringValue"=>"done"}}.to_s + assert_equal(validator.errors.first, "Element 'value':'#{hash}' did not contain a value of 'intValue' from '[\"good\", \"one\"]'") end def test_greater_than_success