Unique key violation during ATF suite test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Context:
Suite was copied from the OOB Problem management suite and modified for our environment. The suite test ran in the DEV environment but not the TEST environment. Each test began with the insertion of a user and a group.
Description of the problem:
While running an ATF suite test in the TEST environment we had all but the first test fail when inserting the new group. Each test failed at the same point giving the error "FAILURE: Unable to insert record into table 'sys_user_group'. Details: Error during insert of sys_user_group (Problem Group)". Checking the logs I found the error, "Unique Key violation detected by database ((conn=143532) Duplicate entry 'Problem Group' for key 'sys_user_group_u')". There was no current group called 'Problem Group' and i could manually create the group without error.
The solution:
On a whim our ATF developer cleared the cache and reran the test without errors. So if you run into funky ATF errors in one environment and not another try clearing the cache and that may solve the problem.
Hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @smcdonaldaz ,
This issue often arises due to duplicate entries or caching inconsistencies.....
>>>> Steps to Resolve:
> Clear Cache: Navigate to System Diagnostics > Cache and click on Clear Cache. This action can resolve issues related to cached data causing conflicts.....
>Verify Unique Constraints: Ensure that the group name you're attempting to insert is unique and doesn't conflict with existing records.
>Check for Existing Records: Before inserting a new group, query the sys_user_group table to confirm that a group with the same name doesn't already exist.
>Review Test Data: Examine the test data and ensure that each test case uses unique values for fields with unique constraints.
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/