SDK test resource random name potential collision
I think there may be a logic error in how the test SDK generates random names for resources.
As an example, consider: test_mgmt_compute_test_containerdb8c0d41, which is the name of the resource group in this recording.
The problem, as I see it, is illustrated by the following, which is how get_resource_name creates the "random" name for the resource:
In [9]: hex(zlib.adler32(b'test_mgmt_compute.test_container') & 0xffffffff)
Out[9]: '0xdb8c0d41'
Note that the suffix appended to the fully qualified test name is just the checksum derived from the fully qualified test name itself! This means that there is no point in using both the fully qualified test name and the checksum: any resources created for that test and named using get_resource_name will have the same name.
This doesn't seem to cause any huge issues so I think it makes sense to resolve it piecemeal, by handling it better in azure-devtools. As I understand it, the intent here is that it should be possible to use the same name for resources in different tests but differentiate them based on the fully qualified test names as above to avoid collisions. If our resource name generator takes a prefix and then augments it with either the fully qualified test name OR the checksum, that should be enough as long as we don't use the same prefix more than once in a test.
@huguesv you were the original designer of this. @v-iam seems right to me, or I miss something?
The implementation of get_resource_name looks correct to me:
https://github.com/Azure/azure-sdk-for-python/blob/69da9801a7abb98b322df60ce4fcc0410863eccf/azure-common/testutils/common_recordingtestcase.py#L98
The name becomes redundant if you pass in the qualified test name as the name parameter, which is what is done here:
https://github.com/Azure/azure-sdk-for-python/blob/94ed6ed3858e00420b95e244860c87e692d4a6b4/azure-mgmt/tests/mgmt_testcase.py#L70
It probably doesn't need to pass in the fully qualified name there, it could pass in a shorter "prefix" instead.
Note that there is some value (at least there was back then) to having a name that can be traced back to a particular test/test class. When you use the Azure portal and see a ton of resources or resource groups that didn't clean up properly, it's nice to be able to tell where they came from. If the full name is just a checksum, it's more difficult.
To clarify, I would probably change mgmt_testcase.py to do this instead:
self.group_name = self.qualified_test_name.replace('.', '_')
Closing, since we didn't get any issues so far, assuming this is correct :)