Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to configure pipeline yaml to run in parallel

Vincent Jong May 27, 2023

We have our pipelines to run our webdriverio tests in a docker container. It works when run serially but after configuring our tests in general through the wdio conf to run tests single or multi-threaded, multi-threaded runs only works when running the tests without docker, locally only. Bitbucket pipeline runs look like threads get created but then hang until finally exiting on failure. What do I need to add/modify/remove in the pipeline yaml to run successfully? If there's anything else needed, let me know and thanks for any help and consideration!

Command structure:

STAGE=stg SOURCE_TEST_DIR=$SOURCE_TEST_DIR THREADED=true npm run tests:e2e:docker:ci

envConfig.ts:

export const Threads = process.env.THREADED === "true" ? 5 : 1; // if THREADED, run 5 threads, else default 1.

wdio docker conf:

import {Threads} from "./envConfig";

buildConfig.hostname = 'chromedriver'
buildConfig.port = 4444
// this is not really headless, but required to pass a check on login.
// it would seem that mfa-detect-browser-capabilities detects the hardware requirements
// for multifactor authentication. in docker environment the test runs in a non-headless chrome
// but behaves differently due to biometrics capability on docker container vs your own macbook
buildConfig.headless = true

buildConfig.capabilities = [{

// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instances available you can make sure that not more than
// 5 instances get started at a time.
maxInstances: Threads,
...

 bitbucket-pipelines.yml:

image: tendocicd/pipeline_builder:latest

definitions:
scripts:
- script: &RepoPrivateKey
git config --global url."git@bitbucket.org:tendosystems".insteadOf "https://bitbucket.org/tendosystems" &&
echo "export GOPRIVATE=bitbucket.org/tendosystems/*" >> ~/.bashrc
steps:
- step: &testEndToEndInStg
artifacts:
- node_modules/**
- reports/**
name: End To End Tests in Docker Container - ChromeDriver
services:
- docker
script:
- echo ${AWS_DEFAULT_REGION}
- source docker-setup.sh
- echo SOURCE_TEST_DIR $SOURCE_TEST_DIR
- npm install
- npm run build
- mkdir reports;chmod -R 777 reports
- STAGE=stg SOURCE_TEST_DIR=$SOURCE_TEST_DIR THREADED=true npm run tests:e2e:docker:ci -- --cucumberOpts.tagExpression="@bats and not @skip"
- npm run report:generate

pipelines:
pull-requests:
'**':
- step: *testEndToEndInStg
custom:
e2e-stg:
- step: *testEndToEndInStg

  

1 answer

0 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 7, 2023

Hi @Vincent Jong,

Welcome to the community.

Would you be able to share any failure error message you're getting when the build failed on Bitbucket Cloud Pipelines?

Also, for hanging build, you can add the below monitoring commands to observe which process is consuming more memory. This can help to narrow down the issue.

- while true; do echo "Memory usage in bytes:" && cat /sys/fs/cgroup/memory/memory.memsw.usage_in_bytes; sleep 2; done & 2
- while true; do date && ps aux && echo "" && sleep 2; done &

You can also check this link for more information on troubleshooting Bitbucket Cloud Pipelines.

Regards,
Mark C

Vincent Jong June 15, 2023

Not sure which command it couldn't find...

1 + while true; do echo "Memory usage in bytes:" && cat /sys/fs/cgroup/memory/memory.memsw.usage_in_bytes; sleep 2; done & 2
2 Memory usage in bytes:
3 bash: 2: command not found
4 849416192
5
6

 

- step: &testEndToEndInStg
artifacts:
- node_modules/**
- reports/**
name: End To End Tests in Docker Container - ChromeDriver
services:
- docker
script:
- echo ${AWS_DEFAULT_REGION}
- source docker-setup.sh
- echo SOURCE_TEST_DIR $SOURCE_TEST_DIR
- npm install
- npm run build
- mkdir reports;chmod -R 777 reports
- while true; do echo "Memory usage in bytes:" && cat /sys/fs/cgroup/memory/memory.memsw.usage_in_bytes; sleep 2; done & 2
- while true; do date && ps aux && echo "" && sleep 2; done &
- STAGE=stg SOURCE_TEST_DIR=$SOURCE_TEST_DIR THREADED=true npm run tests:e2e:bats:docker
- npm run report:generate

 

Vincent Jong June 19, 2023

Interesting, now it's been failing fast. It gives me the error below. Special to trying to run multiple threads through docker? The single threaded pipeline using docker doesn't see this...

Couldn't connect to Docker daemon at http://localhost:2375 - is it running?

Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 26, 2023

Hi @[deleted]

It seems failing locally as well.

With regards to running multi-threaded commands, please be informed that Bitbucket Pipelines runs in a shared infrastructure environment which means your step container CPU resources may vary from time to time.

I'd suggest try reducing the number of threads you'd like to run or consider using Bitbucket Cloud Pipelines runners which will allow you to run builds on your self-hosted machine.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events