Currents Documentation
Currents.devGitHubChangelog
  • Getting Started
    • What is Currents?
    • Playwright
      • Playwright: Quick Start
      • Troubleshooting Playwright
    • Cypress
      • Your First Cypress Run
      • Integrating with Cypress
        • Compatibility
        • Alternative Cypress Binaries
      • Troubleshooting Cypress
    • Jest
      • Your First Jest Run
      • Detox + Jest
      • Troubleshooting Jest
    • Others
    • CI Setup
      • GitHub Actions
        • Cypress - GitHub Actions
        • Playwright - GitHub Actions
        • Jest - GitHub Actions
        • Node.js - GitHub Actions
        • Commit data for GitHub Actions
        • Custom Docker runners
        • Named Runners
      • GitLab
        • Cypress - GitLab CI/CD
        • Playwright - GitLab CI/CD
        • Custom Docker runners
      • Jenkins
        • Cypress - Jenkins
        • Playwright - Jenkins
      • CircleCI
        • Cypress - CircleCI
        • Playwright - CircleCI
      • Bitbucket
        • Cypress - Bitbucket Pipelines
      • Azure DevOps
        • Cypress - Azure DevOps
        • Playwright - Azure DevOps
      • AWS Code Build
        • Cypress - AWS Code Build
        • Playwright - AWS Code Build
      • NX
        • Playwright - NX
        • Cypress - NX
  • Guides
    • Record Key
    • CI Build ID
    • Reporting
      • Reporting Strategy
      • Reporting in CI
      • Step-Level Reporting
    • CI Optimization
      • Playwright Parallelization
      • Orchestration Setup
      • Fully Parallel Mode
      • Re-run Only Failed Tests
      • Cloud Spot Instances
      • Failing Fast
      • Load Balancing
    • Code Coverage
      • Code Coverage for Playwright
      • Code Coverage for Cypress
    • Currents Actions
      • Setup Currents Actions
      • Using Currents Actions
      • Reference
        • Conditions
        • Actions
    • Playwright Component Testing
    • Playwright Visual Testing
    • Playwright Annotations
    • Playwright Tags
    • MCP Server
  • Dashboard
    • Projects
      • Projects Summary view
      • Project Settings
      • Archive and Unarchive Projects
    • Runs
      • Run Status
      • Run Details
      • Commit Information
      • Tags
      • Run Timeouts
      • Canceling Runs
      • Deleting Runs
      • Run Progress
    • Tests
      • Spec File Status
      • Test Status
      • Flaky Tests
      • Test History
    • Test Suite Explorer
      • Test Explorer
        • Tests Performance
      • Spec Files Explorer
        • Spec Files Performance
      • Errors Explorer
  • Automated Reports
  • Insights and Analytics
  • Administration
    • Email Domain Based Access
    • SSO SAML2.0
      • SAML2.0 Configuration
      • SCIM User Provisioning
      • IdP-initiated Sessions
      • JumpCloud
        • JumpCloud User provisioning
      • Okta
        • Okta User provisioning
      • Troubleshooting SSO
    • Billing & Usage
  • Billing and Pricing
  • Resources
    • Reporters
      • cypress-cloud
        • Batched Orchestration
        • Migration to Cypress@13
      • @currents/cli
      • @currents/playwright
        • Configuration
        • pwc
        • pwc-p (orchestration)
        • Playwright Fixtures
      • @currents/jest
      • @currents/node-test-reporter
      • @currents/cmd
        • currents api
        • currents upload
        • currents cache
        • currents convert
      • Data Format Reference
    • Integrations
      • GitHub
        • GitHub App
        • GitHub OAuth
      • GitLab
      • Slack
      • Microsoft Teams
      • HTTP Webhooks
      • Bitbucket
    • API
      • Introduction
      • Authentication
      • API Keys
      • Errors
      • Pagination
      • API Resources
        • Instances
        • Runs
        • Projects
        • Spec Files
        • Test Signature
        • Test Results
    • Data Privacy
      • Access to Customer Data
      • Data Retention
      • Cloud Endpoints
    • Support
Powered by GitBook
On this page
  • Cost Efficiency of Spot Instances
  • How it works
  • Setup and Configuration

Was this helpful?

  1. Guides
  2. CI Optimization

Cloud Spot Instances

Running Playwright E2E tests on CI Spot Instances and using Currents Orchestration to automatically rerouting tests before an eviction.

PreviousRe-run Only Failed TestsNextFailing Fast

Last updated 2 days ago

Was this helpful?

An additional benefit of using Currents for balancing tests is the ability to automatically redrive tests from one machine to another.

  • Get familiar with Orchestration Setup

  • Requires @currents/playwright@1.3.0+

Cost Efficiency of Spot Instances

Many cloud providers have an option to use for running workloads. Using Spot Instances can cost up to 90% lower, compared to the traditionally allocated resources.

However, spot instances can be terminated at any time, which can cause the loss of the test results.

Currents Orchestration can automatically reassign the tests from to-be-terminated instance to another machine. This way, the execution can continue without manual intervention.

How it works

Imagine a scenario when you have two machines running a testing suite consisting of two spec files.

  • Machine A - running specA

  • Machine B - running specB

When a spot instance is just about to be terminated (let's say Machine A), Currents will identify the affected spec files and reassign them a different machine.

Setup and Configuration

Only tests orchestrated with pwc-p can be dynamically reassigned. Read more about Orchestration Setup.

Starting from version 1.3.0 of @currents/playwright set --pwc-reset-signal CLI parameter:

pwc-p .... --pwc-reset-signal SIGUSR1|SIGUSR2

When specified, pwc-p starts listening to POSIX signal (SIGUSR1 or SIGUSR2). After receiving the signal, it send a request to Currents servers to reassign the affected tests to healthy machines. Currents updates the run status accordingly.

An example output you're expected to see upon termination:

$ npx pwc-p --key XXX --project-id YYY --ci-build-id reset-001 --pwc-reset-signal SIGUSR1

🚥 Will reset tests on SIGUSR1. PID: 66640
🚀 Starting orchestration session...
📦 Currents reporter: 1.3.0 recording CI build reset-001 for project YYY
🎭 Playwright: 1.44.0 1 test in 1 project [chromium] 

🌐 Executing orchestrated task: [chromium] test.spec.ts 
🌐 Run URL: https://app.currents.dev/run/c11610c6e1644913

================================================================

2024-05-15T23:31:57.336Z starting test attempt #1: [chromium] › test.spec.ts:15:5 › A

# in another terminal: kill -SIGUSR1 66640

🚥 Received SIGUSR1
🚥 Resetting tests: machineId: 3SN5zz9Mhl2ALzzB, runId: c11610c6e1644913
🚥 Success resetting tests: machineId: 3SN5zz9Mhl2ALzzB, runId: c11610c6e1644913

It is your responsibility to capture the eviction notice, detect the PID and send the signal to pwc-p process before an eviction.

  • usr1 normally activates the Node.js debugger, but this ability is disabled when we listen on usr1

  • usr2 normally treated as a exit in Node.js, so if you pass it WITHOUT turning on our listener, you will immediately kill the process

  • You must send the signal to pwc-p process - not the npx or wrapper process. The parent process will behave as noted above and not pass the signal down to our process.

Refer to the following documentation for capturing the eviction notice for various cloud providers:

AWS - Spot Instance interruption notice
Azure - Simulate Spot Virtual Machine eviction
GCP - Spot VM preemption process
Spot Instances
Cost optimization with Spot Instances. Source: https://aws.amazon.com/blogs/containers/cost-optimization-for-kubernetes-on-aws/
Reassigning tests in case of spot instance termination