[4/4] binutils/testsuite: Check additional server metrics at start-up

Message ID CAJDtP-T355Tofi8g7EOkEi3+z_pe0zTM0avDsyVmxfq6J2a5vQ@mail.gmail.com
State New
Headers show
Series
  • [1/4] binutils/testsuite: Replace set ::env with setenv
Related show

Commit Message

Aaron Merey Jan. 17, 2020, 3:33 a.m.

Patch

binutils/testsuite: Check additional server metrics at start-up.

Check additional server metrics to confirm that it has finished
scanning the directory of debug files.

	* binutils/testsuite/binutils-all/debuginfod.exp:
	Check additional server metrics at start-up.
---
 .../testsuite/binutils-all/debuginfod.exp     | 29 ++++++++++++-------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/binutils/testsuite/binutils-all/debuginfod.exp b/binutils/testsuite/binutils-all/debuginfod.exp
index 42a861d084..7e1c6380a5 100644
--- a/binutils/testsuite/binutils-all/debuginfod.exp
+++ b/binutils/testsuite/binutils-all/debuginfod.exp
@@ -122,23 +122,32 @@  if { !$debuginfod_pid } {
     return
 }
 
-# Wait for debuginfod indicate it's ready.
-set ready 0
-for {set timelim 30} {$timelim != 0} {incr timelim -1} {
-    sleep 1
-    set want ".*ready 1.*"
+set metrics [list "ready 1" \
+             "thread_work_total{role=\"traverse\"} 1" \
+             "thread_work_pending{role=\"scan\"} 0" \
+             "thread_busy{role=\"scan\"} 0" \
+             "groom{statistic=\"buildids\"} 2"]
+
+# Check server metrics to confirm init has completed.
+foreach m $metrics {
+  set timelim 20
+  while { $timelim != 0 } {
+    sleep 0.5
+
     catch {exec curl -s http://127.0.0.1:$port/metrics} got
 
-    if { [regexp $want $got] } {
-      set ready 1
+    if { [regexp $m $got] } {
       break
     }
-}
 
-if { !$ready } {
-    fail "$test (server ready)"
+    incr timelim -1
+  }
+
+  if { $timelim == 0 } {
+    fail "$test (server init timeout)"
     catch {exec kill -INT $debuginfod_pid}
     return
+  }
 }
 
 setenv DEBUGINFOD_URLS http://127.0.0.1:$port
-- 
2.23.0