]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
monitoring/grafana: improve grafana unit tests variable substitution
authorPere Diaz Bou <pdiazbou@redhat.com>
Thu, 2 Dec 2021 14:15:53 +0000 (15:15 +0100)
committerPere Diaz Bou <pdiazbou@redhat.com>
Tue, 14 Dec 2021 08:36:23 +0000 (09:36 +0100)
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
monitoring/grafana/dashboards/tests/__init__.py

index 204a5f0d721b2c4b1d6b46c9372331bed675e2dd..d758afabf526a129c0baa15862d4dbb78f3331a3 100644 (file)
@@ -171,7 +171,8 @@ class PromqlTest:
 
         for variable, value in self.variables.items():
             expr = self.promql_expr_test.expr
-            new_expr = re.sub(r'\${0}'.format(variable), str(value), expr)
+            regex = fr'\${variable}(?=\W)'
+            new_expr = re.sub(regex, fr'{str(value)}', expr)
             self.set_expression(new_expr)
 
         test_as_dict = asdict(self.test_file)