zinserjan / wdio-visual-regression-service

Visual regression service for WebdriverIO.
MIT License
102 stars 39 forks source link

process image operations in parallel #76

Closed zinserjan closed 6 years ago

zinserjan commented 6 years ago

This PR introduces a new hook processScreenshot as a replacement of the afterScreenshot hook. This hook runs in parallel, so the browser does not need to wait until the image comparision is complete, before taking the next screenshot.

All non-blocking methods will benefit, for example Spectre.

before:

> wdio wdio.conf.js

  wdio-visual-regression-service:Spectre Api-Url: http://XXX:3000, Project: test-project, Suite: test-suite - Creating testrun +0ms
  wdio-visual-regression-service:Spectre Api-Url: http://XXX:3000, Project: test-project, Suite: test-suite - Testrun created - Run-Id: #132 +156ms
  wdio-visual-regression-service:Spectre Api-Url: http://XXX:3000, Project: test-project, Suite: test-suite - Saved Run-Id #132 to XXX/run_id.json +3ms
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 320, Fuzz-Level: 30% - Starting upload +0ms
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 320, Fuzz-Level: 30% - Upload successful +13s
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 320, Fuzz-Level: 30% - Image is within tolerance or the same +0ms
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 480, Fuzz-Level: 30% - Starting upload +9s
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 480, Fuzz-Level: 30% - Upload successful +14s
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 480, Fuzz-Level: 30% - Image is within tolerance or the same +0ms
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1024, Fuzz-Level: 30% - Starting upload +9s
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1024, Fuzz-Level: 30% - Upload successful +17s
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1024, Fuzz-Level: 30% - Image is within tolerance or the same +1ms
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1500, Fuzz-Level: 30% - Starting upload +7s
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1500, Fuzz-Level: 30% - Upload successful +19s
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1500, Fuzz-Level: 30% - Image is within tolerance or the same +0ms
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1600, Fuzz-Level: 30% - Starting upload +7s
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1600, Fuzz-Level: 30% - Upload successful +19s
  wdio-visual-regression-service:Spectre Run-Id: #132, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1600, Fuzz-Level: 30% - Image is within tolerance or the same +0ms
․

1 passing (134.50s)

=> everything runs in series

after:

> wdio wdio.conf.js

  wdio-visual-regression-service:Spectre Api-Url: http://XXX:3000, Project: test-project, Suite: test-suite - Creating testrun +0ms
  wdio-visual-regression-service:Spectre Api-Url: http://XXX:3000, Project: test-project, Suite: test-suite - Testrun created - Run-Id: #131 +151ms
  wdio-visual-regression-service:Spectre Api-Url: http://XXX:3000, Project: test-project, Suite: test-suite - Saved Run-Id #131 to XXX/run_id.json +2ms
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 320, Fuzz-Level: 30% - Starting upload +0ms
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 480, Fuzz-Level: 30% - Starting upload +9s
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 320, Fuzz-Level: 30% - Upload successful +4s
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 320, Fuzz-Level: 30% - Image is within tolerance or the same +0ms
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1024, Fuzz-Level: 30% - Starting upload +5s
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1500, Fuzz-Level: 30% - Starting upload +7s
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 480, Fuzz-Level: 30% - Upload successful +2s
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 480, Fuzz-Level: 30% - Image is within tolerance or the same +0ms
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1600, Fuzz-Level: 30% - Starting upload +5s
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1500, Fuzz-Level: 30% - Upload successful +26s
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1500, Fuzz-Level: 30% - Image is within tolerance or the same +0ms
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1024, Fuzz-Level: 30% - Upload successful +7s
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1024, Fuzz-Level: 30% - Image is within tolerance or the same +0ms
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1600, Fuzz-Level: 30% - Upload successful +8s
  wdio-visual-regression-service:Spectre Run-Id: #131, Test: test 1, Url: https://github.com/, Browser: Chrome, Size: 1600, Fuzz-Level: 30% - Image is within tolerance or the same +0ms
․

1 passing (97.70s)

=> processing runs in parallel