]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: use Remote.run_unit_test when "unit_test_scan" config is used
authorVallari Agrawal <val.agl002@gmail.com>
Thu, 26 Oct 2023 05:28:53 +0000 (10:58 +0530)
committerVallari Agrawal <val.agl002@gmail.com>
Thu, 26 Oct 2023 06:43:37 +0000 (12:13 +0530)
"unit_test_scan" optional config uses Remote.run_unit_test()
to scan xml files generated by unit tests to throw better failure
messages (for s3tests and gtests run by workunit)
It also creates "unit_test_summary.yaml" for more exception details
from xml files.

Signed-off-by: Vallari Agrawal <val.agl002@gmail.com>
qa/suites/rados/monthrash/workloads/rados_api_tests.yaml
qa/suites/smoke/basic/tasks/test/rgw_s3tests.yaml
qa/tasks/s3tests.py
qa/tasks/workunit.py
qa/workunits/rados/test.sh

index f14c2c2a60d73722e2164fe7e888625dbc1e412d..a3fd80843d4b2d6f4b5dfa8a6a185479d3620efa 100644 (file)
@@ -25,4 +25,4 @@ tasks:
 - workunit:
     clients:
       client.0:
-        - rados/test.sh
+        - rados/test.sh unit_test_scan
index e3a1167c6ee85de8a363914105f56f378c11f43d..4d4f4fe51f75010d32b4f5056b1762474d11a240 100644 (file)
@@ -6,6 +6,7 @@ tasks:
 - s3tests:
     client.0:
       force-branch: ceph-master
+      unit_test_scan: True
       rgw_server: client.0
 overrides:
   ceph:
index 70b49c086b6f82679e8902a1d8d1bb37c37c9250..27ca1a03bc53e37455b3fe522b1e96a92ca48074 100644 (file)
@@ -9,6 +9,8 @@ import logging
 import os
 import random
 import string
+import datetime
+import uuid
 
 from teuthology import misc as teuthology
 from teuthology import contextutil
@@ -392,10 +394,22 @@ def run_tests(ctx, config):
             attrs += ['not sse_s3']
        
         attrs += client_config.get('extra_attrs', [])
-        args += ['tox', '--', '-v', '-m', ' and '.join(attrs)]
-        args += client_config.get('extra_args', [])
-
-        toxvenv_sh(ctx, remote, args, label="s3 tests against rgw")
+        if 'unit_test_scan' in client_config and client_config['unit_test_scan']:
+            xmlfile_id = datetime.datetime.now().strftime("%Y-%m-%d-%H:%M:%S--") + str(uuid.uuid4())
+            xmlpath= f'{testdir}/archive/s3test-{xmlfile_id}.xml'
+            args += ['tox', '--', '-v', f'--junitxml={xmlpath}', '-m', ' and '.join(attrs)]
+            args += client_config.get('extra_args', [])
+            activate = get_toxvenv_dir(ctx) + '/bin/activate'
+            remote.run_unit_test(
+                args=['source', activate, run.Raw('&&')] + args,
+                label="s3 tests against rgw",
+                xml_path_regex=f'{testdir}/archive/s3test-*.xml',
+                output_yaml=os.path.join(ctx.archive, 'unit_test_summary.yaml'),
+            )
+        else:
+            args += ['tox', '--', '-v', '-m', ' and '.join(attrs)]
+            args += client_config.get('extra_args', [])
+            toxvenv_sh(ctx, remote, args, label="s3 tests against rgw")
     yield
 
 @contextlib.contextmanager
index 23d436fc0c5c7a58648bfe8b6c4bf71bb2d8d642..1876b7842192143be3128483fc289acaa4248635 100644 (file)
@@ -421,11 +421,21 @@ def _run_tests(ctx, refspec, role, tests, env, basedir,
                         workunit=workunit,
                     ),
                 ])
-                remote.run(
-                    logger=log.getChild(role),
-                    args=args + optional_args,
-                    label="workunit test {workunit}".format(workunit=workunit)
-                )
+                if 'unit_test_scan' in optional_args:
+                    optional_args.remove('unit_test_scan')
+                    remote.run_unit_test(
+                        logger=log.getChild(role),
+                        args=args + optional_args,
+                        label="workunit test {workunit}".format(workunit=workunit),
+                        xml_path_regex=f'{testdir}/archive/gtest_xml_report-*.xml',
+                        output_yaml=os.path.join(ctx.archive, 'unit_test_summary.yaml'),
+                    )
+                else:
+                    remote.run(
+                        logger=log.getChild(role),
+                        args=args + optional_args,
+                        label="workunit test {workunit}".format(workunit=workunit)
+                    )
                 if cleanup:
                     args=['sudo', 'rm', '-rf', '--', scratch_tmp]
                     remote.run(logger=log.getChild(role), args=args, timeout=(60*60))
index daa25fe4dfd8a32f4f1e7b7091020581e357f413..a88826cf619cb2a12dde0dd06d2b40fd6d25f6a5 100755 (executable)
@@ -12,6 +12,8 @@ function cleanup() {
 }
 trap cleanup EXIT ERR HUP INT QUIT
 
+GTEST_OUTPUT="xml:/home/ubuntu/cephtest/archive/gtest_xml_report"
+
 declare -A pids
 
 for f in \
@@ -37,7 +39,7 @@ do
     if [ $parallel -eq 1 ]; then
        r=`printf '%25s' $f`
        ff=`echo $f | awk '{print $1}'`
-       bash -o pipefail -exc "ceph_test_rados_$f $color 2>&1 | tee ceph_test_rados_$ff.log | sed \"s/^/$r: /\"" &
+       bash -o pipefail -exc "ceph_test_rados_$f --gtest_output=$GTEST_OUTPUT-$f.xml $color 2>&1 | tee ceph_test_rados_$ff.log | sed \"s/^/$r: /\"" &
        pid=$!
        echo "test $f on pid $pid"
        pids[$f]=$pid