|
4 | 4 | import sys |
5 | 5 | import time |
6 | 6 |
|
| 7 | +# Mapping of testsuite names whose tests originate from openshift-tests-private |
| 8 | +# and need classname remapped to match the Polarion naming convention used by |
| 9 | +# the main openstack test suites (sig-installer.Suite_openshift_openstack.*). |
| 10 | +PRIVATE_TEST_SUITES = { |
| 11 | + 'egressip_tests': 'sig-installer.Suite_openshift_openstack.egressip', |
| 12 | +} |
| 13 | + |
| 14 | + |
7 | 15 | def format_test_case_name(s): |
8 | 16 | return s.replace(':', '_').replace('/', '_').replace(' ', '_').replace('.', '_').replace('[', '.').replace(']', '.').rstrip('.').replace('..','.').replace('_.','.').replace('._','.')[1::] |
9 | 17 |
|
| 18 | + |
| 19 | +def remap_private_test_name(tc_name, testsuite_name): |
| 20 | + """Remap openshift-tests-private names to Polarion-compatible format. |
| 21 | +
|
| 22 | + Tests from openshift-tests-private use [sig-networking] SDN_OVN_EgressIP_* |
| 23 | + naming which JUMP cannot match. Remap to the sig-installer.Suite_openshift_openstack |
| 24 | + pattern that has registered Polarion test case entries. |
| 25 | + """ |
| 26 | + prefix = PRIVATE_TEST_SUITES.get(testsuite_name) |
| 27 | + if not prefix: |
| 28 | + return None |
| 29 | + short_name = format_test_case_name(tc_name) |
| 30 | + # Strip the sig-networking (or similar) classname prefix from Ginkgo output |
| 31 | + if '.' in short_name: |
| 32 | + _, short_name = short_name.split('.', 1) |
| 33 | + return f"{prefix}.{short_name}" |
| 34 | + |
| 35 | + |
| 36 | +# Self-test mode: verify transform logic without processing XML files. |
| 37 | +if len(sys.argv) == 2 and sys.argv[1] == '--self-test': |
| 38 | + egressip_input = ( |
| 39 | + '[sig-networking] SDN OVN EgressIP Author:huirwang-ConnectedOnly-Medium-47272-' |
| 40 | + '.FdpOvnOvs.Pods will not be affected by the egressIP set on other netnamespace .Serial' |
| 41 | + ) |
| 42 | + result = remap_private_test_name(egressip_input, 'egressip_tests') |
| 43 | + assert result.startswith('sig-installer.Suite_openshift_openstack.egressip.SDN_OVN_EgressIP_'), \ |
| 44 | + f"Unexpected remap result: {result}" |
| 45 | + |
| 46 | + assert remap_private_test_name(egressip_input, 'unknown_suite') is None, \ |
| 47 | + "Unknown suite should return None" |
| 48 | + |
| 49 | + otp_input = '[OTP][sig-installer] Suite openshift openstack lb Serial test' |
| 50 | + otp_result = format_test_case_name(otp_input) |
| 51 | + assert otp_result.startswith('OTP.sig-installer'), \ |
| 52 | + f"OTP prefix not preserved by format_test_case_name: {otp_result}" |
| 53 | + |
| 54 | + print("All self-tests passed.") |
| 55 | + sys.exit(0) |
| 56 | + |
10 | 57 | # This script modify a given xml report so it can be uploaded to ReportPortal and Polarion. |
11 | | -# third argument. Currently it's used for NetworkPolicy and Conformance tests |
12 | 58 | # @arg1: input xml file. |
13 | 59 | # @arg2: output xml file. |
14 | 60 | # @arg3: Tests to include |
@@ -48,9 +94,14 @@ def format_test_case_name(s): |
48 | 94 | print('TestCase removed from input XML:', tc_name) |
49 | 95 | ts.remove(tc) |
50 | 96 | else: |
51 | | - new_tc_name = format_test_case_name(tc_name) |
52 | | - if new_tc_name.startswith('OTP.'): |
53 | | - new_tc_name = new_tc_name[4:] |
| 97 | + remapped = remap_private_test_name(tc_name, testsuite_name) |
| 98 | + if remapped: |
| 99 | + new_tc_name = remapped |
| 100 | + else: |
| 101 | + new_tc_name = format_test_case_name(tc_name) |
| 102 | + if new_tc_name.startswith('OTP.'): |
| 103 | + new_tc_name = new_tc_name[4:] |
| 104 | + |
54 | 105 | if '.' in new_tc_name: |
55 | 106 | tc_classname, tc_name_rest = new_tc_name.split('.', 1) |
56 | 107 | tc.set('classname', tc_classname) |
|
0 commit comments