Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,342
Community Members
 
Community Events
168
Community Groups

Quarantined tests for two build plans?

Is their a way to have quarantined tests for one build plan auto populated to another? We have essentially two Main build plans. One is used for offshore work that gets merged back to the primary daily.  At any given time we have 10-20 quarantined tests coming and going that we would like to be mimicked in the secondary project build plan without having to manually keep them in sync.

1 answer

0 votes

Hi @tdzarnes

Is their a way to have quarantined tests for one build plan auto populated to another?

Bamboo does not have an out-of-the-box feature for this.


We have essentially two Main build plans. One is used for offshore work that gets merged back to the primary daily. At any given time we have 10-20 quarantined tests coming and going that we would like to be mimicked in the secondary project build plan without having to manually keep them in sync.

I totally get your scenario, thank you for explaining it. I'll share what I have and hope that this allows you to move forward.
Bamboo has a rest API to add tests to quarantine, this is the one:

curl -u <USER>:<PASSWORD> \
-H 'Content-Type: application/json' -d{} \
-X POST http://<BAMBOO-URL>/rest/api/latest/plan/COM-TO/test/<TEST-CASE-ID>/quarantine

You will notice that you will need to get the <TEST-CASE-ID> for each one of the tests that you want to put in quarantine. There are two problems here:

  1. There is no REST endpoint to provide you with the <TEST-CASE-ID> at the moment due to this bug: https://jira.atlassian.com/browse/BAM-19816
  2. The test can be exactly the same in both plans but you will have different ids for them.

In order to workaround this I was able to build a query that will show the equivalence of each test considering the test class and test name in both plans.
This is the one:
⚠️It was designed for Postgres DB. In case your DB is different, please update it accordingly.

WITH 
        plan1_tests AS
        (SELECT *        
         FROM build b
         JOIN test_class tcl ON tcl.plan_id=b.build_id
         JOIN test_case tc   ON tc.test_class_id=tcl.test_class_id
         WHERE b.full_key like 'PROJ-PLAN1%'),

        plan2_tests AS
        (SELECT *
         FROM build b
         JOIN test_class tcl ON tcl.plan_id=b.build_id
         JOIN test_case tc   ON tc.test_class_id=tcl.test_class_id
         WHERE b.full_key like 'PROJ-PLAN2%')

SELECT p1.test_class_name,
       p1.test_case_name,
       p1.full_key AS p1_full_key,
       p1.test_case_id AS p1_test_case_id,
       CASE WHEN p1.quarantine_date IS NOT NULL THEN '---YES---' ELSE '---NO---' END AS p1_quarantined,
       p2.full_key AS p2_full_key,
       p2.test_case_id AS p2_test_case_id,
       CASE WHEN p2.quarantine_date IS NOT NULL THEN '---YES---' ELSE '---NO---' END AS p2_quarantined
FROM   plan1_tests p1
JOIN   plan2_tests p2 ON (p1.test_class_name=p2.test_class_name AND p1.test_case_name=p2.test_case_name)
WHERE  p1.quarantine_date IS NOT NULL OR p2.quarantine_date IS NOT NULL

The query should show you only the tests that are quarantined in any of those plans. It could be in the first one, the second one or both. With some programming skills, you should be able to make a script to get these details from the Bamboo DB and run a couple of REST APIs to adjust one plan based on the other one.

I hope it helps.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 9.0 is now available

Hey there, Data Center community! I'm Martyna Wojtas and I am the Product Manager for Bamboo Data Center. I’m excited to share that Bamboo 9.0 is now available. We purpose-built this platform to help...

313 views 0 7
Read article

Atlassian Community Events