Whamcloud - gitweb
LU-16459 tests: fix YAML verification function 84/49584/4
authorLei Feng <flei@whamcloud.com>
Tue, 10 Jan 2023 08:51:27 +0000 (16:51 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 19 Jan 2023 15:31:15 +0000 (15:31 +0000)
YAML verification function is not correct in tests.
Fix it and change test case accordingly.

Fixes: bedb797c5d ("LU-16110 lprocfs: make job_stats and rename_stats valid YAML")
Signed-off-by: Lei Feng <flei@whamcloud.com>
Test-Parameters: trivial
Change-Id: I109e2294aea3d1bffa08e6d2c39a5911fa8ef7df
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49584
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index 7cb7657..7a62f51 100755 (executable)
@@ -19215,29 +19215,26 @@ test_205d() {
                skip "need lustre >= 2.15.51"
        verify_yaml_available || skip_env "YAML verification not installed"
 
-       test_mkdir $DIR/$tdir
-       $LFS setstripe -E 1M -L mdt -E -1 $file || error "setstripe failed"
+       test_mkdir -i 0 $DIR/$tdir
+       $LFS setstripe -E 1M -L mdt -E -1 $file || error "create file failed"
 
        dd if=/dev/zero of=$file bs=1M count=10 conv=sync ||
                error "failed to write data to $file"
        mv $file $file.2
 
        echo -n 'verify rename_stats...'
-       output=$(do_facet mds1 \
-                "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats")
-       verify_yaml "$output" || error "rename_stats is not valid YAML"
+       do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats" |
+               verify_yaml || error "rename_stats is not valid YAML"
        echo " OK"
 
        echo -n 'verify mdt job_stats...'
-       output=$(do_facet mds1 \
-                "$LCTL get_param -n mdt.$FSNAME-MDT0000.job_stats")
-       verify_yaml "$output" || error "job_stats on mds1 is not valid YAML"
+       do_facet mds1 "$LCTL get_param -n mdt.$FSNAME-MDT0000.job_stats" |
+               verify_yaml || error "job_stats on mds1 is not valid YAML"
        echo " OK"
 
        echo -n 'verify ost job_stats...'
-       output=$(do_facet ost1 \
-                "$LCTL get_param -n obdfilter.$FSNAME-OST0000.job_stats")
-       verify_yaml "$output" || error "job_stats on ost1 is not valid YAML"
+       do_facet ost1 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.job_stats" |
+               verify_yaml || error "job_stats on ost1 is not valid YAML"
        echo " OK"
 }
 run_test 205d "verify the format of some stats files"
index 673dfc3..478b6c5 100755 (executable)
@@ -11067,9 +11067,9 @@ exhaust_all_precreations() {
 }
 
 verify_yaml_available() {
-       python3 -c "import yaml; yaml.safe_load_all('''a: b''')"
+       python3 -c "import yaml; yaml.safe_load('''a: b''')"
 }
 
 verify_yaml() {
-       python3 -c "import yaml; yaml.safe_load_all('''$1''')"
+       python3 -c "import sys, yaml; obj = yaml.safe_load(sys.stdin)"
 }