saucelabs / saucectl-espresso-example

A showcase of saucectl running espresso.
Other
10 stars 17 forks source link

Test Sharding? #11

Closed ianrhamilton closed 3 years ago

ianrhamilton commented 3 years ago

I am trying to shard my espresso tests using the config.yml, however, it is still being executed in a single thread on the same emulator.

My config.yml looks as follows:

apiVersion: v1alpha
kind: espresso
sauce:
  region: eu-central-1
  concurrency: 10
  metadata:
    build: Release $CI_COMMIT_SHORT_SHA
espresso:
  app: ./my-debug.apk
  testApp: ./my-debug-androidTest.apk
suites:
  - name: "saucy barista - combined"
    testOptions:
    numShards: 10
    clearPackageData: true
    emulators:
      - name: "Android GoogleApi Emulator"
        clearPackageData: true
        orientation: portrait
        platformVersions:
          - "10.0"

artifacts:
  download:
    when: always
    match:
      - output.xml
    directory: ./reports/

Do you plan to upload any examples of sharding?

Thanks in advance, Ian

alexplischke commented 3 years ago

Sharding is very obtuse at the moment. What you'd actually have to do is this (see https://docs.saucelabs.com/testrunner-toolkit/configuration/espresso#shardindex):

  - name: "saucy barista - combined 1/2"
    testOptions:
    numShards: 2
    shardIndex: 0
    clearPackageData: true
    emulators:
      - name: "Android GoogleApi Emulator"
        clearPackageData: true
        orientation: portrait
        platformVersions:
          - "10.0"
  - name: "saucy barista - combined 2/2"
    testOptions:
    numShards: 2
    shardIndex: 1
    clearPackageData: true
    emulators:
      - name: "Android GoogleApi Emulator"
        clearPackageData: true
        orientation: portrait
        platformVersions:
          - "10.0"

Effectively multiplying the suite based on the number shards you want to use, while incrementing the shardIndex. It works this way because sharding is performed by espresso and the user in a weird manual way.

However, there's some good news in this! We are actively working on sharding automatically, so that all you have to do is specify numShards, for which you may want to follow this PR --> https://github.com/saucelabs/saucectl/pull/343

ianrhamilton commented 3 years ago

hey @alexplischke - ah I had a feeling I may have to do that. Thanks for the reply! I'll watch the PR - that definitely seems like the best approach - would be very helpful!

Thanks :)