Skip to content

Commit 8ebb801

Browse files
committed
Add content file validation
1 parent 73ef552 commit 8ebb801

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

tests/gold_tests/logging/qlog_quiche.test.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def _configure_traffic_server(self, tr: 'TestRun'):
7171
self._ts.addDefaultSSLFiles()
7272
self._ts.Disk.records_config.update(
7373
'''
74+
diags:
75+
debug:
76+
enabled: 1
77+
tags: vv_quic|v_quic
7478
quic:
7579
no_activity_timeout_in: 3000
7680
''')
@@ -104,12 +108,22 @@ def test(self):
104108
quiche_qlog_Test.client_counter += 1
105109
tr.Processes.Default.ReturnCode = 0
106110

107-
# Check for the qlog file. If requested then the file should be present.
108-
# If not, then we expect the `ls` to return an error.
111+
# If requested we will copy the file to a known name as the runtime name is not know
112+
# by the test. So we will rename them all and grab the first one for validation.
109113
test_run = Test.AddTestRun(f"{self._name} : check qlog files")
110-
qlog_file = f'{os.path.join(self._ts.Variables.LOGDIR, "test_qlog")}-*.sqlog'
111-
test_run.Processes.Default.Command = f"sleep 5; ls -la {qlog_file}"
112-
test_run.Processes.Default.ReturnCode = 0 if self._generate_qlog else 2
114+
qlog_base_name = "test_qlog"
115+
rename_script = os.path.join(Test.TestDirectory, 'rename_qlog.sh')
116+
test_run.Processes.Default.Command = f'sleep 5; bash {rename_script} {self._ts.Variables.LOGDIR} {qlog_base_name}'
117+
test_run.Processes.Default.ReturnCode = 0 if self._generate_qlog else 2 # exit 2 is what we want if no qlog was generated.
118+
119+
# Basic valdation
120+
if self._generate_qlog:
121+
tr = Test.AddTestRun("Check qlog content")
122+
file = os.path.join(self._ts.Variables.LOGDIR, "1.sqlog")
123+
f = tr.Disk.File(file)
124+
tr.Processes.Default.Command = "echo 0"
125+
tr.Processes.Default.ReturnCode = 0
126+
f.Content = Testers.IncludesExpression('"title":"Apache Traffic Server"', 'Should include this basic text')
113127

114128

115129
quiche_qlog_Test("Generate qlog test").with_qlogs().test()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
x=0
3+
4+
for i in `find $1 -name $2*`; do
5+
((x+=1))
6+
mv -- "$i" "$1/$x.sqlog"
7+
echo "renamed $i with $1/$x.sqlog"
8+
done
9+
10+
if [ $x -gt 0 ]; then
11+
echo "exit with 0"
12+
exit 0
13+
else
14+
echo "exit with 2"
15+
exit 2
16+
fi

0 commit comments

Comments
 (0)