Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Add_plan_entry: possible bug related to a run's entry_index


#1

When I add two Runs to a Plan via the REST API add_plan_entry endpoint, both Runs are visible in the Plan view via web browser. However, if I try to edit the Plan, only one of the Runs is visible on the edit page. And if I then try to save the Plan, the page wants to delete the run that is not being displayed. Here is the data that I POST’d to the add_plan_entry endpoint:

1st POST
{
“suite_id”: 4,
“name”: “blah1”,
“description”: “something useful”
}

2nd POST
{
“suite_id”: 4,
“name”: “blah2”,
“description”: “something useful”
}

One thing I noticed: If I add the two runs via the REST API, both Runs (which are in different entries) have the same entry_index. But if I add the two Runs via the UI, the entry_index’s differ. Also, it seems I cannot set the entry_index myself via the POST. What is this entry_index field being used for?

Is there a defect here? Or am I doing something wrong?

Thanks,
-casey
TestRail v5.2.0.3452

Added via REST:

{
"id": 959,
"name": "Grouper Testing",
"description": null,
"milestone_id": null,
"assignedto_id": null,
"is_completed": false,
"completed_on": null,
"passed_count": 0,
"blocked_count": 0,
"untested_count": 1912,
"retest_count": 0,
"failed_count": 0,
"custom_status1_count": 0,
"custom_status2_count": 0,
"custom_status3_count": 0,
"custom_status4_count": 0,
"custom_status5_count": 0,
"custom_status6_count": 0,
"custom_status7_count": 0,
"project_id": 1,
"created_on": 1475186373,
"created_by": 26,
"url": "https://<removed>/testrail/index.php?/plans/view/959",
"entries": [
    {
        "id": "97beeaf7-8ffc-4c37-ba9d-1f9118cb5795",
        "suite_id": 4,
        "name": "blah2",
        "runs": [
            {
                "id": 1014,
                "suite_id": 4,
                "name": "blah2",
                "description": "Created by autobot, to contain automated test results.",
                "milestone_id": null,
                "assignedto_id": null,
                "include_all": true,
                "is_completed": false,
                "completed_on": null,
                "passed_count": 0,
                "blocked_count": 0,
                "untested_count": 956,
                "retest_count": 0,
                "failed_count": 0,
                "custom_status1_count": 0,
                "custom_status2_count": 0,
                "custom_status3_count": 0,
                "custom_status4_count": 0,
                "custom_status5_count": 0,
                "custom_status6_count": 0,
                "custom_status7_count": 0,
                "project_id": 1,
                "plan_id": 959,
                "entry_index": 1,
                "entry_id": "97beeaf7-8ffc-4c37-ba9d-1f9118cb5795",
                "config": null,
                "config_ids": [],
                "url": "https://<removed>/testrail/index.php?/runs/view/1014"
            }
        ]
    },
    {
        "id": "dbeae3fb-f157-4992-b831-41a9ac67a053",
        "suite_id": 4,
        "name": "blah1",
        "runs": [
            {
                "id": 1013,
                "suite_id": 4,
                "name": "blah1",
                "description": "Created by autobot, to contain automated test results.",
                "milestone_id": null,
                "assignedto_id": null,
                "include_all": true,
                "is_completed": false,
                "completed_on": null,
                "passed_count": 0,
                "blocked_count": 0,
                "untested_count": 956,
                "retest_count": 0,
                "failed_count": 0,
                "custom_status1_count": 0,
                "custom_status2_count": 0,
                "custom_status3_count": 0,
                "custom_status4_count": 0,
                "custom_status5_count": 0,
                "custom_status6_count": 0,
                "custom_status7_count": 0,
                "project_id": 1,
                "plan_id": 959,
                "entry_index": 1,
                "entry_id": "dbeae3fb-f157-4992-b831-41a9ac67a053",
                "config": null,
                "config_ids": [],
                "url": "https://<removed>/testrail/index.php?/runs/view/1013"
            }
        ]
    }
]

}

Added via web browser:

{
"id": 959,
"name": "Grouper Testing",
"description": null,
"milestone_id": null,
"assignedto_id": null,
"is_completed": false,
"completed_on": null,
"passed_count": 0,
"blocked_count": 0,
"untested_count": 1912,
"retest_count": 0,
"failed_count": 0,
"custom_status1_count": 0,
"custom_status2_count": 0,
"custom_status3_count": 0,
"custom_status4_count": 0,
"custom_status5_count": 0,
"custom_status6_count": 0,
"custom_status7_count": 0,
"project_id": 1,
"created_on": 1475186373,
"created_by": 26,
"url": "https://<removed>/testrail/index.php?/plans/view/959",
"entries": [
    {
        "id": "63d5d9e9-fe86-4bd3-b587-decc50c53511",
        "suite_id": 4,
        "name": "blah1",
        "runs": [
            {
                "id": 1011,
                "suite_id": 4,
                "name": "blah1",
                "description": null,
                "milestone_id": null,
                "assignedto_id": null,
                "include_all": true,
                "is_completed": false,
                "completed_on": null,
                "passed_count": 0,
                "blocked_count": 0,
                "untested_count": 956,
                "retest_count": 0,
                "failed_count": 0,
                "custom_status1_count": 0,
                "custom_status2_count": 0,
                "custom_status3_count": 0,
                "custom_status4_count": 0,
                "custom_status5_count": 0,
                "custom_status6_count": 0,
                "custom_status7_count": 0,
                "project_id": 1,
                "plan_id": 959,
                "entry_index": 1,
                "entry_id": "63d5d9e9-fe86-4bd3-b587-decc50c53511",
                "config": null,
                "config_ids": [],
                "url": "https://<removed>/testrail/index.php?/runs/view/1011"
            }
        ]
    },
    {
        "id": "a107fb79-7ebb-42ea-8c28-af024f1152c4",
        "suite_id": 4,
        "name": "blah2",
        "runs": [
            {
                "id": 1012,
                "suite_id": 4,
                "name": "blah2",
                "description": null,
                "milestone_id": null,
                "assignedto_id": null,
                "include_all": true,
                "is_completed": false,
                "completed_on": null,
                "passed_count": 0,
                "blocked_count": 0,
                "untested_count": 956,
                "retest_count": 0,
                "failed_count": 0,
                "custom_status1_count": 0,
                "custom_status2_count": 0,
                "custom_status3_count": 0,
                "custom_status4_count": 0,
                "custom_status5_count": 0,
                "custom_status6_count": 0,
                "custom_status7_count": 0,
                "project_id": 1,
                "plan_id": 959,
                "entry_index": 2,
                "entry_id": "a107fb79-7ebb-42ea-8c28-af024f1152c4",
                "config": null,
                "config_ids": [],
                "url": "https://<removed>/testrail/index.php?/runs/view/1012"
            }
        ]
    }
]

}


#2

I think I was running into this issue because I was making concurrent asynchronous POST’s. I have worked around this by POST’ing in a recursive function, where each POST happens after the previous one has returned.


#3

Hi @caseym,

Thanks for your posting! Yes, add_plan_entry is best called sequentially but good to hear that you got it working already.

Cheers,
Tobias